Skip to content

Commit 1114119

Browse files
committed
Remove estimation mode.
1 parent 8155688 commit 1114119

File tree

8 files changed

+109
-200
lines changed

8 files changed

+109
-200
lines changed

genmc-sys/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ impl Default for GenmcParams {
3131
quiet: true,
3232
log_level_trace: false,
3333
do_symmetry_reduction: false, // TODO GENMC (PERFORMANCE): maybe make this default `true`
34-
estimation_max: 1000,
3534
}
3635
}
3736
}
@@ -47,7 +46,6 @@ mod ffi {
4746
pub quiet: bool, // TODO GENMC: maybe make log-level more fine grained
4847
pub log_level_trace: bool,
4948
pub do_symmetry_reduction: bool,
50-
pub estimation_max: u32,
5149
}
5250

5351
#[derive(Debug)]
@@ -154,11 +152,9 @@ mod ffi {
154152

155153
type GenmcScalar;
156154

157-
// type OperatingMode; // Estimation(budget) or Verification
158-
159155
type MiriGenMCShim;
160156

161-
fn createGenmcHandle(config: &GenmcParams, do_estimation: bool)
157+
fn createGenmcHandle(config: &GenmcParams)
162158
-> UniquePtr<MiriGenMCShim>;
163159
fn getGlobalAllocStaticMask() -> u64;
164160

@@ -235,7 +231,5 @@ mod ffi {
235231
/// Check whether there are more executions to explore.
236232
/// If there are more executions, this method prepares for the next execution and returns `true`.
237233
fn isExplorationDone(self: Pin<&mut MiriGenMCShim>) -> bool;
238-
239-
fn printEstimationResults(self: &MiriGenMCShim, elapsed_time_sec: f64);
240234
}
241235
}

genmc-sys/src_cpp/MiriInterface.cpp

Lines changed: 59 additions & 45 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
// FIXME(genmc,cxx): could directly return std::optional if CXX ever supports sharing it (see https://github.com/dtolnay/cxx/issues/87).
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>();
@@ -70,14 +71,19 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
7071
// FIXME(genmc): expose this setting to Miri
7172
conf->randomScheduleSeed = "42";
7273
conf->printRandomScheduleSeed = config.print_random_schedule_seed;
73-
if (config.quiet) {
74+
if (config.quiet)
75+
{
7476
// logLevel = VerbosityLevel::Quiet;
7577
// TODO GENMC: error might be better (or new level for `BUG`)
7678
// logLevel = VerbosityLevel::Quiet;
7779
logLevel = VerbosityLevel::Error;
78-
} else if (config.log_level_trace) {
80+
}
81+
else if (config.log_level_trace)
82+
{
7983
logLevel = VerbosityLevel::Trace;
80-
} else {
84+
}
85+
else
86+
{
8187
logLevel = VerbosityLevel::Tip;
8288
}
8389

@@ -96,10 +102,8 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
96102
// FIXME(genmc): expose this setting to Miri (useful for testing Miri-GenMC).
97103
conf->schedulePolicy = SchedulePolicy::WF;
98104

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

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

120124
auto *driverPtr = driver.get();
121-
auto initValGetter = [driverPtr](const AAccess &access) {
125+
auto initValGetter = [driverPtr](const AAccess &access)
126+
{
122127
const auto addr = access.getAddr();
123-
if (!driverPtr->initVals_.contains(addr)) {
128+
if (!driverPtr->initVals_.contains(addr))
129+
{
124130
MIRI_LOG() << "WARNING: TODO GENMC: requested initial value for address "
125-
<< addr << ", but there is none.\n";
131+
<< addr << ", but there is none.\n";
126132
return SVal(0xCC00CC00);
127133
// BUG_ON(!driverPtr->initVals_.contains(addr));
128134
}
129135
auto result = driverPtr->initVals_[addr];
130-
if (!result.is_init) {
136+
if (!result.is_init)
137+
{
131138
MIRI_LOG() << "WARNING: TODO GENMC: requested initial value for address "
132-
<< addr << ", but the memory is uninitialized.\n";
139+
<< addr << ", but the memory is uninitialized.\n";
133140
return SVal(0xFF00FF00);
134141
}
135142
MIRI_LOG() << "MiriGenMCShim: requested initial value for address " << addr
136-
<< " == " << addr.get() << ", returning: " << result << "\n";
143+
<< " == " << addr.get() << ", returning: " << result << "\n";
137144
return result.toSVal();
138145
};
139146
driver->getExec().getGraph().setInitValGetter(initValGetter);
@@ -143,10 +150,10 @@ auto MiriGenMCShim::createHandle(const GenmcParams &config, bool estimation_mode
143150

144151
// This needs to be available to Miri, but clang-tidy wants it static
145152
// NOLINTNEXTLINE(misc-use-internal-linkage)
146-
auto createGenmcHandle(const GenmcParams &config, bool estimation_mode)
153+
auto createGenmcHandle(const GenmcParams &config)
147154
-> std::unique_ptr<MiriGenMCShim>
148155
{
149-
return MiriGenMCShim::createHandle(config, estimation_mode);
156+
return MiriGenMCShim::createHandle(config);
150157
}
151158

152159
/**** Execution start/end handling ****/
@@ -222,11 +229,11 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
222229
/**** Memory access handling ****/
223230

224231
[[nodiscard]] auto MiriGenMCShim::handleLoad(ThreadId thread_id, uint64_t address, uint64_t size,
225-
MemOrdering ord, GenmcScalar old_val) -> LoadResult
232+
MemOrdering ord, GenmcScalar old_val) -> LoadResult
226233
{
227234
auto pos = incPos(thread_id);
228235
MIRI_LOG() << "Received Load from Miri at address: " << address << ", size " << size
229-
<< " with ordering " << ord << ", event: " << pos << "\n";
236+
<< " with ordering " << ord << ", event: " << pos << "\n";
230237

231238
auto loc = SAddr(address);
232239
auto aSize = ASize(size);
@@ -235,20 +242,21 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
235242

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

238-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
245+
auto oldValSetter = [this, old_val](SAddr loc)
246+
{ this->handleOldVal(loc, old_val); };
239247
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
240248
return result;
241249
}
242250

243251
[[nodiscard]] auto MiriGenMCShim::handleReadModifyWrite(ThreadId thread_id, uint64_t address,
244-
uint64_t size, MemOrdering loadOrd,
245-
MemOrdering store_ordering, RMWBinOp rmw_op,
246-
GenmcScalar rhs_value, GenmcScalar old_val)
252+
uint64_t size, MemOrdering loadOrd,
253+
MemOrdering store_ordering, RMWBinOp rmw_op,
254+
GenmcScalar rhs_value, GenmcScalar old_val)
247255
-> ReadModifyWriteResult
248256
{
249257
MIRI_LOG() << "Received Read-Modify-Write from Miri at address: " << address << ", size "
250-
<< size << " with orderings (" << loadOrd << ", " << store_ordering
251-
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
258+
<< size << " with orderings (" << loadOrd << ", " << store_ordering
259+
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
252260

253261
auto pos = incPos(thread_id);
254262

@@ -261,17 +269,19 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
261269
auto newLab =
262270
std::make_unique<FaiReadLabel>(pos, loadOrd, loc, aSize, type, rmw_op, rhsVal);
263271

264-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
272+
auto oldValSetter = [this, old_val](SAddr loc)
273+
{ this->handleOldVal(loc, old_val); };
265274
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
266-
if (const auto *error = result.error.get()) {
275+
if (const auto *error = result.error.get())
276+
{
267277
return ReadModifyWriteResult::fromError(*error);
268278
}
269279

270280
auto oldVal = result.scalar.toSVal(); // TODO GENMC: u128 handling
271281
auto newVal = executeRMWBinOp(oldVal, rhsVal, size, rmw_op);
272282

273283
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
274-
store_ordering, StoreEventType::ReadModifyWrite);
284+
store_ordering, StoreEventType::ReadModifyWrite);
275285

276286
if (store_result.is_error())
277287
return ReadModifyWriteResult::fromError(*store_result.error.get());
@@ -286,11 +296,11 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
286296
{
287297

288298
MIRI_LOG() << "Received Compare-Exchange from Miri (value: " << expected_value << " --> "
289-
<< new_value << ", old value: " << old_val << ") at address: " << address
290-
<< ", size " << size << " with success orderings (" << success_load_ordering
291-
<< ", " << success_store_ordering
292-
<< "), fail load ordering: " << fail_load_ordering
293-
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
299+
<< new_value << ", old value: " << old_val << ") at address: " << address
300+
<< ", size " << size << " with success orderings (" << success_load_ordering
301+
<< ", " << success_store_ordering
302+
<< "), fail load ordering: " << fail_load_ordering
303+
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
294304

295305
auto pos = incPos(thread_id);
296306

@@ -305,11 +315,13 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
305315
// FIXME(GenMC): properly handle failure memory ordering.
306316

307317
auto newLab = std::make_unique<CasReadLabel>(pos, success_load_ordering, loc, aSize, type,
308-
expectedVal, newVal);
318+
expectedVal, newVal);
309319

310-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
320+
auto oldValSetter = [this, old_val](SAddr loc)
321+
{ this->handleOldVal(loc, old_val); };
311322
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
312-
if (const auto *error = result.error.get()) {
323+
if (const auto *error = result.error.get())
324+
{
313325
return CompareExchangeResult::fromError(*error);
314326
}
315327

@@ -318,21 +330,21 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
318330
return CompareExchangeResult::failure(oldVal);
319331

320332
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
321-
success_store_ordering, StoreEventType::CompareExchange);
333+
success_store_ordering, StoreEventType::CompareExchange);
322334

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

328340
[[nodiscard]] auto MiriGenMCShim::handleStore(ThreadId thread_id, uint64_t address, uint64_t size,
329-
GenmcScalar value, GenmcScalar old_val,
330-
MemOrdering ord, StoreEventType store_event_type)
341+
GenmcScalar value, GenmcScalar old_val,
342+
MemOrdering ord, StoreEventType store_event_type)
331343
-> StoreResult
332344
{
333345
MIRI_LOG() << "Received Store from Miri at address " << address << ", size " << size
334-
<< " with ordering " << ord << ", is part of rmw: ("
335-
<< static_cast<uint64_t>(store_event_type) << ")\n";
346+
<< " with ordering " << ord << ", is part of rmw: ("
347+
<< static_cast<uint64_t>(store_event_type) << ")\n";
336348

337349
auto pos = incPos(thread_id);
338350

@@ -344,7 +356,8 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
344356
auto val = value.toSVal();
345357

346358
std::unique_ptr<WriteLabel> wLab;
347-
switch (store_event_type) {
359+
switch (store_event_type)
360+
{
348361
case StoreEventType::Normal:
349362
wLab = std::make_unique<WriteLabel>(pos, ord, loc, aSize, type, val);
350363
break;
@@ -358,9 +371,10 @@ void MiriGenMCShim::handleThreadKill(ThreadId thread_id) {
358371
ERROR("Unsupported Store Event Type");
359372
}
360373

361-
auto oldValSetter = [this, old_val](SAddr loc) {
374+
auto oldValSetter = [this, old_val](SAddr loc)
375+
{
362376
this->handleOldVal(loc,
363-
old_val); // TODO GENMC(HACK): is this the correct way to do it?
377+
old_val); // TODO GENMC(HACK): is this the correct way to do it?
364378
};
365379

366380
return GenMCDriver::handleStore(std::move(wLab), oldValSetter);

0 commit comments

Comments
 (0)