Skip to content

Commit 4ca9b99

Browse files
committed
Merge branch 'release-1.0'
2 parents f4eebc7 + 822f621 commit 4ca9b99

File tree

18 files changed

+223
-83
lines changed

18 files changed

+223
-83
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OBJ=\
3636
src/args/performance_term.o \
3737
src/args/strategy.o \
3838
src/args/testcases.o \
39+
src/args/timeout.o \
3940
src/args/tunit.o \
4041
\
4142
src/cfg/cfg.o \

README.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ where `search.conf` contains:
260260
261261
--testcases popcnt.tc # Path to testcase file
262262
--training_set "{ 0 ... 7 }" # Testcases to use for measuring correctness during search
263-
--test_set "{ 0 ... 1023 }" # Testcases to use as holdout set for checking correctness
263+
--test_set "{ 8 ... 1023 }" # Testcases to use as holdout set for checking correctness
264264
265265
--distance hamming # Metric for measuring error between live-outs
266266
--relax_reg # Allow partial credit for results that appear in wrong locations
@@ -287,17 +287,18 @@ where `search.conf` contains:
287287
288288
--statistics_interval 100000 # Print statistics every 100k proposals
289289
--timeout 1000000 # Propose 1m modifications before giving up
290-
--verification_cycles 16 # Attempt to verify 16 zero cost rewrites before giving up
290+
--timeout_action testcase # Try adding a new testcase from the testset when search times out
291+
--timeout_cycles 16 # Timeout up to 16 times before giving up
291292
292293
--strategy hold_out # Verify results using a larger hold out testcase set
293294
```
294295

295-
STOKE search will produce two types of status messages. Progress update messages will be printed whenever STOKE discovers a new lowest cost verified or unverified rewrite. The code shown on the left is not equivalent to the target code; the code shown on the right is.
296+
STOKE search will produce two types of status messages. Progress update messages will be printed whenever STOKE discovers a new lowest cost verified or unverified rewrite. The code shown on the left is not equivalent to the target code; the code shown on the right is with respect to the current set of testcases.
296297

297298
```
298299
Progress Update:
299300
300-
Best Unverified (9) Best Verified (15)
301+
Lowest Cost Discovered (9) Lowest Known Correct Cost (15)
301302
302303
btrq $0xffffffffffffffc0, %rdi testq %rdi, %rdi
303304
retq je .L_X64ASM_0
@@ -546,20 +547,7 @@ Cost CostFunction::extension_correctness(const Cfg& cfg, Cost max) {
546547
// that compute res iteratively may stop executing and return max once res
547548
// equals or exceeds that value.
548549

549-
// This method should set the testcases_evaluated_ attribute to reflect the
550-
// number of testcases that were examined prior to a possible early exit. The
551-
// final testcase that was used (testcases_evaluted_-1) is returned by a hold_out
552-
// verifier as a counter-example following a failed proof of correctness (a hold-out
553-
// verifier uses a max cost of 0; for non-zero results, the evaluation of this testcase
554-
// is presumably responsible for res exceeding max).
555-
556-
testcases_evaluated_ = 1;
557-
558-
// Invariant 1: 0 < testcases_evaluated_ < sandbox_->size()
559-
assert(testcases_evaluated_ > 0);
560-
assert(testcases_evaluated_ < sandbox_->size());
561-
562-
// Invariant 2: Return value should not exceed max_correctness_cost
550+
// Invariant 1: Return value should not exceed max_correctness_cost
563551
assert(res <= max_correctness_cost);
564552

565553
return res;
@@ -614,11 +602,18 @@ Strategy type is specified using the `--strategy` command line argument. This va
614602

615603
```c++
616604
bool Verifier::extension_verify(const Cfg& target, const Cfg& rewrite) {
617-
// Add user-defined implementation here ...
605+
// Add user-defined implementation here ...
606+
607+
// Invariant 1. If this method returns false and is able to produce a
608+
// counter example explaining why, counter_example_available_ should be
609+
// set to true.
610+
611+
// Invariant 2. If this method returns false, and it is able (see above),
612+
// counter_example_ should be set to a CpuState that will cause target and
613+
// rewrite to produce different values.
618614

619-
// Invariant 1. If this method returns false, counter_example_ should be
620-
// set to a CpuState that will cause target and rewrite to produce different
621-
// values.
615+
// Invariant 3. If this method produces a counter example, it should be
616+
// unique relative to all previously produced counter examples.
622617

623618
return true;
624619
}

examples/bansal/optimization.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
##### Testcase options:
1717

18-
--test_set "{ 0 ... 1023 }"
1918
--testcases ./bansal.tc
2019
--training_set "{ 0 ... 15 }"
20+
--test_set "{ 16 ... 1023 }"
2121

2222
##### Correctness options:
2323

@@ -59,7 +59,8 @@
5959
--max_instrs 32
6060
--statistics_interval 10000000
6161
--timeout 100000000
62-
--verification_cycles 32
62+
--timeout_action testcase
63+
--timeout_cycles 16
6364

6465
##### Verification options:
6566

examples/libimf/log/optimization.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
##### Testcase options:
1515

16-
--test_set "{ 0 ... 1023 }"
1716
--testcases log.tc
1817
--training_set "{ 0 ... 255 }"
18+
--test_set "{ 256 ... 1023 }"
1919

2020
##### Correctness options:
2121

@@ -53,7 +53,8 @@
5353
--max_instrs 80
5454
--statistics_interval 1000000
5555
--timeout 10000000
56-
--verification_cycles 32
56+
--timeout_action testcase
57+
--timeout_cycles 16
5758

5859
##### Verification options:
5960

examples/libimf/sin/optimization.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
##### Testcase options:
1515

16-
--test_set "{ 0 ... 1023 }"
1716
--testcases sin.tc
1817
--training_set "{ 0 ... 255 }"
18+
--test_set "{ 256 ... 1023 }"
1919

2020
##### Correctness options:
2121

@@ -53,7 +53,8 @@
5353
--max_instrs 80
5454
--statistics_interval 1000000
5555
--timeout 10000000
56-
--verification_cycles 32
56+
--timeout_action testcase
57+
--timeout_cycles 16
5758

5859
##### Verification options:
5960

examples/libimf/tan/optimization.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
##### Testcase options:
1515

16-
--test_set "{ 0 ... 1023 }"
1716
--testcases tan.tc
1817
--training_set "{ 0 ... 255 }"
18+
--test_set "{ 256 ... 1023 }"
1919

2020
##### Correctness options:
2121

@@ -53,7 +53,8 @@
5353
--max_instrs 120
5454
--statistics_interval 1000000
5555
--timeout 10000000
56-
--verification_cycles 32
56+
--timeout_action testcase
57+
--timeout_cycles 32
5758

5859
##### Verification options:
5960

examples/mont_mul/optimization.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
##### Testcase options:
1414

15-
--test_set "{ 0 ... 1023 }"
1615
--testcases mont_mul.tc
1716
--training_set "{ 0 ... 31 }"
17+
--test_set "{ 32 ... 1023 }"
1818

1919
##### Correctness options:
2020

@@ -49,7 +49,8 @@
4949
--max_instrs 32
5050
--statistics_interval 10000000
5151
--timeout 100000000
52-
--verification_cycles 32
52+
--timeout_action testcase
53+
--timeout_cycles 16
5354

5455
##### Verification options:
5556

examples/mont_mul/synthesis.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
##### Testcase options:
1212

13-
--test_set "{ 0 ... 1023 }"
1413
--testcases mont_mul.tc
15-
--training_set "{ 0 ... 32 }"
14+
--training_set "{ 0 ... 31 }"
15+
--test_set "{ 32 ... 1023 }"
1616

1717
##### Correctness options:
1818

@@ -47,7 +47,8 @@
4747
--max_instrs 32
4848
--statistics_interval 10000000
4949
--timeout 100000000
50-
--verification_cycles 32
50+
--timeout_action testcase
51+
--timeout_cycles 16
5152

5253
##### Verification options:
5354

examples/tutorial/search.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
--testcases popcnt.tc # Path to testcase file
1212
--training_set "{ 0 ... 7 }" # Testcases to use for measuring correctness during search
13-
--test_set "{ 0 ... 1023 }" # Testcases to use as holdout set for checking correctness
13+
--test_set "{ 8 ... 1023 }" # Testcases to use as holdout set for checking correctness
1414

1515
--distance hamming # Metric for measuring error between live-outs
1616
--relax_reg # Allow partial credit for results that appear in wrong locations
@@ -37,6 +37,7 @@
3737

3838
--statistics_interval 100000 # Print statistics every 100k proposals
3939
--timeout 1000000 # Propose 1m modifications before giving up
40-
--verification_cycles 16 # Attempt to verify 16 zero cost rewrites before giving up
40+
--timeout_action testcase # Try adding a new testcase from the testset when search times out
41+
--timeout_cycles 16 # Timeout up to 16 times before giving up
4142

4243
--strategy hold_out # Verify results using a larger hold out testcase set

src/args/timeout.cc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2014 eric schkufza
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <array>
16+
#include <string>
17+
#include <utility>
18+
19+
#include "src/args/generic.h"
20+
#include "src/args/timeout.h"
21+
22+
using namespace std;
23+
using namespace stoke;
24+
25+
namespace {
26+
27+
array<pair<string, Timeout>, 3> pts {{
28+
{"quit", Timeout::QUIT},
29+
{"restart", Timeout::RESTART},
30+
{"testcase", Timeout::TESTCASE}
31+
}
32+
};
33+
34+
} // namespace
35+
36+
namespace stoke {
37+
38+
void TimeoutReader::operator()(std::istream& is, Timeout& t) {
39+
string s;
40+
is >> s;
41+
if (!generic_read(pts, s, t)) {
42+
is.setstate(ios::failbit);
43+
}
44+
}
45+
46+
void TimeoutWriter::operator()(std::ostream& os, const Timeout t) {
47+
string s;
48+
generic_write(pts, s, t);
49+
os << s;
50+
}
51+
52+
} // namespace stoke

0 commit comments

Comments
 (0)