Skip to content

Commit e849f93

Browse files
committed
Remove estimation mode.
1 parent 9e3c850 commit e849f93

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
@@ -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: 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
// 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>();
@@ -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 ****/
@@ -218,32 +225,33 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
218225
/**** Memory access handling ****/
219226

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

227234
auto loc = SAddr(address);
228235
auto aSize = ASize(size);
229236
auto type = AType::Unsigned; // FIXME(genmc): get correct type from Miri(?)
230237

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

233-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
240+
auto oldValSetter = [this, old_val](SAddr loc)
241+
{ this->handleOldVal(loc, old_val); };
234242
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
235243
return result;
236244
}
237245

238246
[[nodiscard]] auto MiriGenMCShim::handleReadModifyWrite(ThreadId thread_id, uint64_t address,
239-
uint64_t size, MemOrdering loadOrd,
240-
MemOrdering store_ordering, RMWBinOp rmw_op,
241-
GenmcScalar rhs_value, GenmcScalar old_val)
247+
uint64_t size, MemOrdering loadOrd,
248+
MemOrdering store_ordering, RMWBinOp rmw_op,
249+
GenmcScalar rhs_value, GenmcScalar old_val)
242250
-> ReadModifyWriteResult
243251
{
244252
MIRI_LOG() << "Received Read-Modify-Write from Miri at address: " << address << ", size "
245-
<< size << " with orderings (" << loadOrd << ", " << store_ordering
246-
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
253+
<< size << " with orderings (" << loadOrd << ", " << store_ordering
254+
<< "), rmw op: " << static_cast<uint64_t>(rmw_op) << "\n";
247255

248256
auto pos = incPos(thread_id);
249257

@@ -255,17 +263,19 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
255263
auto newLab =
256264
std::make_unique<FaiReadLabel>(pos, loadOrd, loc, aSize, type, rmw_op, rhsVal);
257265

258-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
266+
auto oldValSetter = [this, old_val](SAddr loc)
267+
{ this->handleOldVal(loc, old_val); };
259268
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
260-
if (const auto *error = result.error.get()) {
269+
if (const auto *error = result.error.get())
270+
{
261271
return ReadModifyWriteResult::fromError(*error);
262272
}
263273

264274
auto oldVal = result.scalar.toSVal(); // TODO GENMC: u128 handling
265275
auto newVal = executeRMWBinOp(oldVal, rhsVal, size, rmw_op);
266276

267277
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
268-
store_ordering, StoreEventType::ReadModifyWrite);
278+
store_ordering, StoreEventType::ReadModifyWrite);
269279

270280
if (store_result.is_error())
271281
return ReadModifyWriteResult::fromError(*store_result.error.get());
@@ -280,11 +290,11 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
280290
{
281291

282292
MIRI_LOG() << "Received Compare-Exchange from Miri (value: " << expected_value << " --> "
283-
<< new_value << ", old value: " << old_val << ") at address: " << address
284-
<< ", size " << size << " with success orderings (" << success_load_ordering
285-
<< ", " << success_store_ordering
286-
<< "), fail load ordering: " << fail_load_ordering
287-
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
293+
<< new_value << ", old value: " << old_val << ") at address: " << address
294+
<< ", size " << size << " with success orderings (" << success_load_ordering
295+
<< ", " << success_store_ordering
296+
<< "), fail load ordering: " << fail_load_ordering
297+
<< ", is weak (can fail spuriously): " << can_fail_spuriously << "\n";
288298

289299
auto pos = incPos(thread_id);
290300

@@ -298,11 +308,13 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
298308
// FIXME(GenMC): properly handle failure memory ordering.
299309

300310
auto newLab = std::make_unique<CasReadLabel>(pos, success_load_ordering, loc, aSize, type,
301-
expectedVal, newVal);
311+
expectedVal, newVal);
302312

303-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
313+
auto oldValSetter = [this, old_val](SAddr loc)
314+
{ this->handleOldVal(loc, old_val); };
304315
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
305-
if (const auto *error = result.error.get()) {
316+
if (const auto *error = result.error.get())
317+
{
306318
return CompareExchangeResult::fromError(*error);
307319
}
308320

@@ -311,21 +323,21 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
311323
return CompareExchangeResult::failure(oldVal);
312324

313325
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
314-
success_store_ordering, StoreEventType::CompareExchange);
326+
success_store_ordering, StoreEventType::CompareExchange);
315327

316328
if (store_result.is_error())
317329
return CompareExchangeResult::fromError(*store_result.error);
318330
return CompareExchangeResult::success(oldVal, store_result.isCoMaxWrite);
319331
}
320332

321333
[[nodiscard]] auto MiriGenMCShim::handleStore(ThreadId thread_id, uint64_t address, uint64_t size,
322-
GenmcScalar value, GenmcScalar old_val,
323-
MemOrdering ord, StoreEventType store_event_type)
334+
GenmcScalar value, GenmcScalar old_val,
335+
MemOrdering ord, StoreEventType store_event_type)
324336
-> StoreResult
325337
{
326338
MIRI_LOG() << "Received Store from Miri at address " << address << ", size " << size
327-
<< " with ordering " << ord << ", is part of rmw: ("
328-
<< static_cast<uint64_t>(store_event_type) << ")\n";
339+
<< " with ordering " << ord << ", is part of rmw: ("
340+
<< static_cast<uint64_t>(store_event_type) << ")\n";
329341

330342
auto pos = incPos(thread_id);
331343

@@ -337,7 +349,8 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
337349
auto val = value.toSVal();
338350

339351
std::unique_ptr<WriteLabel> wLab;
340-
switch (store_event_type) {
352+
switch (store_event_type)
353+
{
341354
case StoreEventType::Normal:
342355
wLab = std::make_unique<WriteLabel>(pos, ord, loc, aSize, type, val);
343356
break;
@@ -351,9 +364,10 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
351364
ERROR("Unsupported Store Event Type");
352365
}
353366

354-
auto oldValSetter = [this, old_val](SAddr loc) {
367+
auto oldValSetter = [this, old_val](SAddr loc)
368+
{
355369
this->handleOldVal(loc,
356-
old_val); // TODO GENMC(HACK): is this the correct way to do it?
370+
old_val); // TODO GENMC(HACK): is this the correct way to do it?
357371
};
358372

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

0 commit comments

Comments
 (0)