bool CPA::exists;
CPA *CPA::_cpa;
-class AnnotateDumpCallback : public Callback
-{
-
- private:
- CPA *cpa;
- public:
- virtual void process();
- AnnotateDumpCallback(CPA *_cpa)
- : cpa(_cpa)
- {}
-};
-
-void
-AnnotateDumpCallback::process()
-{
- cpa->dump(true);
- cpa->dumpKey();
-}
-
-
CPA::CPA(Params *p)
: SimObject(p), numSm(0), numSmt(0), numSys(0), numQs(0), conId(0)
{
ah.key_off = 0;
osbin->write((char*)&ah, sizeof(AnnotateHeader));
- registerExitCallback(new AnnotateDumpCallback(this));
+ registerExitCallback([this]() { dump(true); dumpKey(); });
}
uint64_t
traceStream->write(header_msg);
// get a callback when we exit so we can close the file
- Callback *cb = new MakeCallback<InstPBTrace,
- &InstPBTrace::closeStreams>(this);
- registerExitCallback(cb);
+ registerExitCallback([this]() { closeStreams(); });
}
void
data_rec_header.set_window_size(depWindowSize);
dataTraceStream->write(data_rec_header);
// Register a callback to flush trace records and close the output streams.
- Callback* cb = new MakeCallback<ElasticTrace,
- &ElasticTrace::flushTraces>(this);
- registerExitCallback(cb);
+ registerExitCallback([this]() { flushTraces(); });
}
void
const uint32_t CowDiskImage::VersionMajor = 1;
const uint32_t CowDiskImage::VersionMinor = 0;
-class CowDiskCallback : public Callback
-{
- private:
- CowDiskImage *image;
-
- public:
- CowDiskCallback(CowDiskImage *i) : image(i) {}
- void process() { image->save(); delete this; }
-};
-
CowDiskImage::CowDiskImage(const Params *p)
: DiskImage(p), filename(p->image_file), child(p->child), table(NULL)
{
}
if (!p->read_only)
- registerExitCallback(new CowDiskCallback(this));
+ registerExitCallback([this]() { save(); });
}
}
fd_to_diod(-1), fd_from_diod(-1), diod_pid(-1)
{
// Register an exit callback so we can kill the diod process
- Callback* cb = new MakeCallback<VirtIO9PDiod,
- &VirtIO9PDiod::terminateDiod>(this);
- registerExitCallback(cb);
+ registerExitCallback([this]() { terminateDiod(); });
}
VirtIO9PDiod::~VirtIO9PDiod()
int tlbPort_width = perLaneTLB ? wfSize() : 1;
tlbPort.resize(tlbPort_width);
- cuExitCallback = new CUExitCallback(this);
- registerExitCallback(cuExitCallback);
+ registerExitCallback([this]() { exitCallback(); });
lastExecCycle.resize(numVectorALUs, 0);
lastVaddrSimd[j].clear();
}
lastVaddrCU.clear();
- delete cuExitCallback;
delete ldsPort;
}
}
void
-ComputeUnit::CUExitCallback::process()
+ComputeUnit::exitCallback()
{
- if (computeUnit->countPages) {
- std::ostream *page_stat_file =
- simout.create(computeUnit->name().c_str())->stream();
+ if (countPages) {
+ std::ostream *page_stat_file = simout.create(name().c_str())->stream();
*page_stat_file << "page, wavefront accesses, workitem accesses" <<
std::endl;
- for (auto iter : computeUnit->pageAccesses) {
+ for (auto iter : pageAccesses) {
*page_stat_file << std::hex << iter.first << ",";
*page_stat_file << std::dec << iter.second.first << ",";
*page_stat_file << std::dec << iter.second.second << std::endl;
/*
* for Counting page accesses
- *
- * cuExitCallback inherits from Callback. When you register a callback
- * function as an exit callback, it will get added to an exit callback
- * queue, such that on simulation exit, all callbacks in the callback
- * queue will have their process() function called.
*/
bool countPages;
typedef std::unordered_map<Addr, std::pair<int, int>> pageDataStruct;
pageDataStruct pageAccesses;
- class CUExitCallback : public Callback
- {
- private:
- ComputeUnit *computeUnit;
-
- public:
- virtual ~CUExitCallback() { }
-
- CUExitCallback(ComputeUnit *_cu)
- {
- computeUnit = _cu;
- }
-
- virtual void
- process();
- };
-
- CUExitCallback *cuExitCallback;
+ void exitCallback();
class GMTokenPort : public TokenMasterPort
{
dataBlks(new uint8_t[p->size]), // Allocate data storage in one big chunk
stats(*this)
{
- registerExitCallback(new BaseTagsCallback(this));
+ registerExitCallback([this]() { cleanupRefs(); });
}
ReplaceableEntry*
void computeStatsVisitor(CacheBlk &blk);
};
-class BaseTagsCallback : public Callback
-{
- BaseTags *tags;
- public:
- BaseTagsCallback(BaseTags *t) : tags(t) {}
- virtual void process() { tags->cleanupRefs(); };
-};
-
#endif //__MEM_CACHE_TAGS_BASE_HH__
// Register a callback to compensate for the destructor not
// being called. The callback prints the DRAMSim2 stats.
- Callback* cb = new MakeCallback<DRAMSim2Wrapper,
- &DRAMSim2Wrapper::printStats>(wrapper);
- registerExitCallback(cb);
+ registerExitCallback([&wrapper]() { wrapper->printStats(); });
}
void
// Register a callback to compensate for the destructor not
// being called. The callback forces the stream to flush and
// closes the output file.
- registerExitCallback(
- new MakeCallback<MemTraceProbe, &MemTraceProbe::closeStreams>(this));
+ registerExitCallback([this]() { closeStreams(); });
}
void
/**
* Queue of C++ callbacks to invoke on simulator exit.
*/
-inline CallbackQueue &
+inline CallbackQueue2 &
exitCallbacks()
{
- static CallbackQueue theQueue;
+ static CallbackQueue2 theQueue;
return theQueue;
}
* Register an exit callback.
*/
void
-registerExitCallback(Callback *callback)
+registerExitCallback(const std::function<void()> &callback)
{
- exitCallbacks().add(callback);
+ exitCallbacks().push_back(callback);
}
/**
* information, output directory and exit events
*/
+#include <functional>
#include <string>
#include "base/types.hh"
void setOutputDir(const std::string &dir);
-class Callback;
-void registerExitCallback(Callback *callback);
+void registerExitCallback(const std::function<void()> &callback);
void doExitCleanup();
#endif /* __SIM_CORE_HH__ */
Tick curTick();
-// forward declaration
-class Callback;
-
/// Register a callback to be called when Python exits. Defined in
/// sim/main.cc.
-void registerExitCallback(Callback *);
+void registerExitCallback(const std::function<void()> &);
/// Schedule an event to exit the simulation loop (returning to
/// Python) at the end of the current cycle (curTick()). The message