Skip to content

Commit eb88d36

Browse files
committed
Remove estimation mode.
1 parent 13f9305 commit eb88d36

File tree

8 files changed

+110
-201
lines changed

8 files changed

+110
-201
lines changed

genmc-sys/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ impl Default for GenmcParams {
2929
quiet: true,
3030
log_level_trace: false,
3131
do_symmetry_reduction: false, // TODO GENMC (PERFORMANCE): maybe make this default `true`
32-
estimation_max: 1000,
3332
}
3433
}
3534
}
@@ -45,7 +44,6 @@ mod ffi {
4544
pub quiet: bool, // TODO GENMC: maybe make log-level more fine grained
4645
pub log_level_trace: bool,
4746
pub do_symmetry_reduction: bool,
48-
pub estimation_max: u32,
4947
}
5048

5149
#[derive(Debug)]
@@ -188,11 +186,9 @@ mod ffi {
188186

189187
type GenmcScalar;
190188

191-
// type OperatingMode; // Estimation(budget) or Verification
192-
193189
type MiriGenMCShim;
194190

195-
fn createGenmcHandle(config: &GenmcParams, do_estimation: bool)
191+
fn createGenmcHandle(config: &GenmcParams)
196192
-> UniquePtr<MiriGenMCShim>;
197193
fn getGlobalAllocStaticMask() -> u64;
198194

@@ -268,7 +264,5 @@ mod ffi {
268264
/// Check whether there are more executions to explore.
269265
/// If there are more executions, this method prepares for the next execution and returns `true`.
270266
fn isExplorationDone(self: Pin<&mut MiriGenMCShim>) -> bool;
271-
272-
fn printEstimationResults(self: &MiriGenMCShim, elapsed_time_sec: f64);
273267
}
274268
}

genmc-sys/src_cpp/MiriInterface.cpp

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ using AnnotT = SExpr<AnnotID>;
3131
// NOTE: this is safe because ThreadId is 32 bit, and we return a 64 bit integer
3232
// TODO GENMC: could directly return std::optional if CXX ever supports this
3333
auto MiriGenMCShim::scheduleNext(const int curr_thread_id,
34-
const ActionKind curr_thread_next_instr_kind) -> int64_t
34+
const ActionKind curr_thread_next_instr_kind) -> int64_t
3535
{
3636
// The current thread is the only one where the `kind` could have changed since we last made
3737
// a scheduling decision.
3838
globalInstructions[curr_thread_id].kind = curr_thread_next_instr_kind;
3939

4040
auto result = GenMCDriver::scheduleNext(globalInstructions);
41-
if (result.has_value()) {
41+
if (result.has_value())
42+
{
4243
return static_cast<int64_t>(result.value());
4344
}
4445
return -1;
@@ -47,7 +48,7 @@ auto MiriGenMCShim::scheduleNext(const int curr_thread_id,
4748
/**** Functions available to Miri ****/
4849

4950
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
50-
auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode)
51+
auto MiriGenMCShim::createHandle(const GenmcParams &config)
5152
-> std::unique_ptr<MiriGenMCShim>
5253
{
5354
auto conf = std::make_shared<Config>();
@@ -71,14 +72,19 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
7172
conf->randomScheduleSeed =
7273
"42"; // TODO GENMC: only for random exploration/scheduling mode in GenMC
7374
conf->printRandomScheduleSeed = config.print_random_schedule_seed;
74-
if (config.quiet) {
75+
if (config.quiet)
76+
{
7577
// logLevel = VerbosityLevel::Quiet;
7678
// TODO GENMC: error might be better (or new level for `BUG`)
7779
// logLevel = VerbosityLevel::Quiet;
7880
logLevel = VerbosityLevel::Error;
79-
} else if (config.log_level_trace) {
81+
}
82+
else if (config.log_level_trace)
83+
{
8084
logLevel = VerbosityLevel::Trace;
81-
} else {
85+
}
86+
else
87+
{
8288
logLevel = VerbosityLevel::Tip;
8389
}
8490

@@ -97,10 +103,8 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
97103
// TODO GENMC: Should there be a way to change this option from Miri?
98104
conf->schedulePolicy = SchedulePolicy::WF;
99105

100-
conf->estimate = estimation_mode;
101-
conf->estimationMax = config.estimation_max;
102-
const auto mode = conf->estimate ? GenMCDriver::Mode(GenMCDriver::EstimationMode{})
103-
: GenMCDriver::Mode(GenMCDriver::VerificationMode{});
106+
conf->estimate = false;
107+
const auto mode = GenMCDriver::Mode(GenMCDriver::VerificationMode{});
104108

105109
// Running Miri-GenMC without race detection is not supported.
106110
// Disabling this option also changes the behavior of the replay scheduler to only schedule
@@ -119,22 +123,25 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
119123
auto driver = std::make_unique<MiriGenMCShim>(std::move(conf), mode);
120124

121125
auto *driverPtr = driver.get();
122-
auto initValGetter = [driverPtr](const AAccess &access) {
126+
auto initValGetter = [driverPtr](const AAccess &access)
127+
{
123128
const auto addr = access.getAddr();
124-
if (!driverPtr->initVals_.contains(addr)) {
129+
if (!driverPtr->initVals_.contains(addr))
130+
{
125131
MIRI_LOG() << "WARNING: TODO GENMC: requested initial value for address "
126-
<< addr << ", but there is none.\n";
132+
<< addr << ", but there is none.\n";
127133
return SVal(0xCC00CC00);
128134
// BUG_ON(!driverPtr->initVals_.contains(addr));
129135
}
130136
auto result = driverPtr->initVals_[addr];
131-
if (!result.is_init) {
137+
if (!result.is_init)
138+
{
132139
MIRI_LOG() << "WARNING: TODO GENMC: requested initial value for address "
133-
<< addr << ", but the memory is uninitialized.\n";
140+
<< addr << ", but the memory is uninitialized.\n";
134141
return SVal(0xFF00FF00);
135142
}
136143
MIRI_LOG() << "MiriGenMCShim: requested initial value for address " << addr
137-
<< " == " << addr.get() << ", returning: " << result << "\n";
144+
<< " == " << addr.get() << ", returning: " << result << "\n";
138145
return result.toSVal();
139146
};
140147
driver->getExec().getGraph().setInitValGetter(initValGetter);
@@ -144,10 +151,10 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
144151

145152
// This needs to be available to Miri, but clang-tidy wants it static
146153
// NOLINTNEXTLINE(misc-use-internal-linkage)
147-
auto createGenmcHandle(const GenmcParams &config, bool estimation_mode)
154+
auto createGenmcHandle(const GenmcParams &config)
148155
-> std::unique_ptr<MiriGenMCShim>
149156
{
150-
return MiriGenMCShim::createHandle(config, estimation_mode);
157+
return MiriGenMCShim::createHandle(config);
151158
}
152159

153160
/**** Execution start/end handling ****/
@@ -227,32 +234,33 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
227234
/**** Memory access handling ****/
228235

229236
[[nodiscard]] auto MiriGenMCShim::handleLoad(ThreadId thread_id, uint64_t address, uint64_t size,
230-
MemOrdering ord, GenmcScalar old_val) -> LoadResult
237+
MemOrdering ord, GenmcScalar old_val) -> LoadResult
231238
{
232239
auto pos = incPos(thread_id);
233240
MIRI_LOG() << "Received Load from Miri at address: " << address << ", size " << size
234-
<< " with ordering " << ord << ", event: " << pos << "\n";
241+
<< " with ordering " << ord << ", event: " << pos << "\n";
235242

236243
auto loc = SAddr(address);
237244
auto aSize = ASize(size);
238245
auto type = AType::Unsigned; // TODO GENMC: get correct type from Miri
239246

240247
auto newLab = std::make_unique<ReadLabel>(pos, ord, loc, aSize, type);
241248

242-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
249+
auto oldValSetter = [this, old_val](SAddr loc)
250+
{ this->handleOldVal(loc, old_val); };
243251
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
244252
return result;
245253
}
246254

247255
[[nodiscard]] auto MiriGenMCShim::handleReadModifyWrite(ThreadId thread_id, uint64_t address,
248-
uint64_t size, MemOrdering loadOrd,
249-
MemOrdering store_ordering, RMWBinOp rmw_op,
250-
GenmcScalar rhs_value, GenmcScalar old_val)
256+
uint64_t size, MemOrdering loadOrd,
257+
MemOrdering store_ordering, RMWBinOp rmw_op,
258+
GenmcScalar rhs_value, GenmcScalar old_val)
251259
-> ReadModifyWriteResult
252260
{
253261
MIRI_LOG() << "Received Read-Modify-Write from Miri at address: " << address << ", size "
254-
<< size << " with orderings (" << loadOrd << ", " << store_ordering
255-
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
262+
<< size << " with orderings (" << loadOrd << ", " << store_ordering
263+
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
256264

257265
auto pos = incPos(thread_id);
258266

@@ -264,17 +272,19 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
264272
auto newLab =
265273
std::make_unique<FaiReadLabel>(pos, loadOrd, loc, aSize, type, rmw_op, rhsVal);
266274

267-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
275+
auto oldValSetter = [this, old_val](SAddr loc)
276+
{ this->handleOldVal(loc, old_val); };
268277
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
269-
if (const auto *error = result.error.get()) {
278+
if (const auto *error = result.error.get())
279+
{
270280
return ReadModifyWriteResult::fromError(*error);
271281
}
272282

273283
auto oldVal = result.scalar.toSVal(); // TODO GENMC: u128 handling
274284
auto newVal = executeRMWBinOp(oldVal, rhsVal, size, rmw_op);
275285

276286
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
277-
store_ordering, StoreEventType::ReadModifyWrite);
287+
store_ordering, StoreEventType::ReadModifyWrite);
278288

279289
if (store_result.is_error())
280290
return ReadModifyWriteResult::fromError(*store_result.error.get());
@@ -289,11 +299,11 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
289299
{
290300

291301
MIRI_LOG() << "Received Compare-Exchange from Miri (value: " << expected_value << " --> "
292-
<< new_value << ", old value: " << old_val << ") at address: " << address
293-
<< ", size " << size << " with success orderings (" << success_load_ordering
294-
<< ", " << success_store_ordering
295-
<< "), fail load ordering: " << fail_load_ordering
296-
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
302+
<< new_value << ", old value: " << old_val << ") at address: " << address
303+
<< ", size " << size << " with success orderings (" << success_load_ordering
304+
<< ", " << success_store_ordering
305+
<< "), fail load ordering: " << fail_load_ordering
306+
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
297307

298308
auto pos = incPos(thread_id);
299309

@@ -307,11 +317,13 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
307317
// FIXME(GenMC): properly handle failure memory ordering.
308318

309319
auto newLab = std::make_unique<CasReadLabel>(pos, success_load_ordering, loc, aSize, type,
310-
expectedVal, newVal);
320+
expectedVal, newVal);
311321

312-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
322+
auto oldValSetter = [this, old_val](SAddr loc)
323+
{ this->handleOldVal(loc, old_val); };
313324
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
314-
if (const auto *error = result.error.get()) {
325+
if (const auto *error = result.error.get())
326+
{
315327
return CompareExchangeResult::fromError(*error);
316328
}
317329

@@ -320,21 +332,21 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
320332
return CompareExchangeResult::failure(oldVal);
321333

322334
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
323-
success_store_ordering, StoreEventType::CompareExchange);
335+
success_store_ordering, StoreEventType::CompareExchange);
324336

325337
if (store_result.is_error())
326338
return CompareExchangeResult::fromError(*store_result.error);
327339
return CompareExchangeResult::success(oldVal, store_result.isCoMaxWrite);
328340
}
329341

330342
[[nodiscard]] auto MiriGenMCShim::handleStore(ThreadId thread_id, uint64_t address, uint64_t size,
331-
GenmcScalar value, GenmcScalar old_val,
332-
MemOrdering ord, StoreEventType store_event_type)
343+
GenmcScalar value, GenmcScalar old_val,
344+
MemOrdering ord, StoreEventType store_event_type)
333345
-> StoreResult
334346
{
335347
MIRI_LOG() << "Received Store from Miri at address " << address << ", size " << size
336-
<< " with ordering " << ord << ", is part of rmw: ("
337-
<< static_cast<uint64_t>(store_event_type) << ")\n";
348+
<< " with ordering " << ord << ", is part of rmw: ("
349+
<< static_cast<uint64_t>(store_event_type) << ")\n";
338350

339351
auto pos = incPos(thread_id);
340352

@@ -346,7 +358,8 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
346358
auto val = value.toSVal();
347359

348360
std::unique_ptr<WriteLabel> wLab;
349-
switch (store_event_type) {
361+
switch (store_event_type)
362+
{
350363
case StoreEventType::Normal:
351364
wLab = std::make_unique<WriteLabel>(pos, ord, loc, aSize, type, val);
352365
break;
@@ -360,9 +373,10 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
360373
ERROR("Unsupported Store Event Type");
361374
}
362375

363-
auto oldValSetter = [this, old_val](SAddr loc) {
376+
auto oldValSetter = [this, old_val](SAddr loc)
377+
{
364378
this->handleOldVal(loc,
365-
old_val); // TODO GENMC(HACK): is this the correct way to do it?
379+
old_val); // TODO GENMC(HACK): is this the correct way to do it?
366380
};
367381

368382
return GenMCDriver::handleStore(std::move(wLab), oldValSetter);
@@ -386,7 +400,7 @@ auto MiriGenMCShim::handleMalloc(ThreadId thread_id, uint64_t size, uint64_t ali
386400

387401
auto sd = StorageDuration::SD_Heap; // TODO GENMC: get from Miri
388402
auto stype = StorageType::ST_Durable; // TODO GENMC
389-
auto spc = AddressSpace::AS_User; // TODO GENMC
403+
auto spc = AddressSpace::AS_User; // TODO GENMC
390404

391405
auto deps = EventDeps(); // TODO GENMC: without this, constructor is ambiguous
392406

0 commit comments

Comments
 (0)