Skip to content

Commit 0f56559

Browse files
committed
Remove estimation mode.
1 parent a944944 commit 0f56559

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

221228
[[nodiscard]] auto MiriGenMCShim::handleLoad(ThreadId thread_id, uint64_t address, uint64_t size,
222-
MemOrdering ord, GenmcScalar old_val) -> LoadResult
229+
MemOrdering ord, GenmcScalar old_val) -> LoadResult
223230
{
224231
auto pos = incPos(thread_id);
225232
MIRI_LOG() << "Received Load from Miri at address: " << address << ", size " << size
226-
<< " with ordering " << ord << ", event: " << pos << "\n";
233+
<< " with ordering " << ord << ", event: " << pos << "\n";
227234

228235
auto loc = SAddr(address);
229236
auto aSize = ASize(size);
230237
auto type = AType::Unsigned; // TODO GENMC: get correct type from Miri
231238

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

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

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

249257
auto pos = incPos(thread_id);
250258

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

259-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
267+
auto oldValSetter = [this, old_val](SAddr loc)
268+
{ this->handleOldVal(loc, old_val); };
260269
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
261-
if (const auto *error = result.error.get()) {
270+
if (const auto *error = result.error.get())
271+
{
262272
return ReadModifyWriteResult::fromError(*error);
263273
}
264274

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

268278
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
269-
store_ordering, StoreEventType::ReadModifyWrite);
279+
store_ordering, StoreEventType::ReadModifyWrite);
270280

271281
if (store_result.is_error())
272282
return ReadModifyWriteResult::fromError(*store_result.error.get());
@@ -281,11 +291,11 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
281291
{
282292

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

290300
auto pos = incPos(thread_id);
291301

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

301311
auto newLab = std::make_unique<CasReadLabel>(pos, success_load_ordering, loc, aSize, type,
302-
expectedVal, newVal);
312+
expectedVal, newVal);
303313

304-
auto oldValSetter = [this, old_val](SAddr loc) { this->handleOldVal(loc, old_val); };
314+
auto oldValSetter = [this, old_val](SAddr loc)
315+
{ this->handleOldVal(loc, old_val); };
305316
auto result = GenMCDriver::handleLoad(std::move(newLab), oldValSetter);
306-
if (const auto *error = result.error.get()) {
317+
if (const auto *error = result.error.get())
318+
{
307319
return CompareExchangeResult::fromError(*error);
308320
}
309321

@@ -312,21 +324,21 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
312324
return CompareExchangeResult::failure(oldVal);
313325

314326
auto store_result = handleStore(thread_id, address, size, GenmcScalar(newVal), old_val,
315-
success_store_ordering, StoreEventType::CompareExchange);
327+
success_store_ordering, StoreEventType::CompareExchange);
316328

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

322334
[[nodiscard]] auto MiriGenMCShim::handleStore(ThreadId thread_id, uint64_t address, uint64_t size,
323-
GenmcScalar value, GenmcScalar old_val,
324-
MemOrdering ord, StoreEventType store_event_type)
335+
GenmcScalar value, GenmcScalar old_val,
336+
MemOrdering ord, StoreEventType store_event_type)
325337
-> StoreResult
326338
{
327339
MIRI_LOG() << "Received Store from Miri at address " << address << ", size " << size
328-
<< " with ordering " << ord << ", is part of rmw: ("
329-
<< static_cast<uint64_t>(store_event_type) << ")\n";
340+
<< " with ordering " << ord << ", is part of rmw: ("
341+
<< static_cast<uint64_t>(store_event_type) << ")\n";
330342

331343
auto pos = incPos(thread_id);
332344

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

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

355-
auto oldValSetter = [this, old_val](SAddr loc) {
368+
auto oldValSetter = [this, old_val](SAddr loc)
369+
{
356370
this->handleOldVal(loc,
357-
old_val); // TODO GENMC(HACK): is this the correct way to do it?
371+
old_val); // TODO GENMC(HACK): is this the correct way to do it?
358372
};
359373

360374
return GenMCDriver::handleStore(std::move(wLab), oldValSetter);
@@ -378,7 +392,7 @@ auto MiriGenMCShim::handleMalloc(ThreadId thread_id, uint64_t size, uint64_t ali
378392

379393
auto sd = StorageDuration::SD_Heap; // TODO GENMC: get from Miri
380394
auto stype = StorageType::ST_Durable; // TODO GENMC
381-
auto spc = AddressSpace::AS_User; // TODO GENMC
395+
auto spc = AddressSpace::AS_User; // TODO GENMC
382396

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

0 commit comments

Comments
 (0)