Skip to content

Commit

Permalink
monitor until not equal
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwu928 committed Jun 13, 2024
1 parent 507a083 commit eaa7a3e
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 54 deletions.
4 changes: 2 additions & 2 deletions include/pando-lib-galois/sync/global_barrier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class GlobalBarrier {
return ready;
});
} else {
DrvAPI::monitor_until(m_count.address, static_cast<std::int64_t>(0));
DrvAPI::monitor_until(m_count.address, static_cast<std::int64_t>(0), true);
}
#else
DrvAPI::monitor_until(m_count.address, static_cast<std::int64_t>(0));
DrvAPI::monitor_until(m_count.address, static_cast<std::int64_t>(0), true);
#endif

#endif
Expand Down
4 changes: 2 additions & 2 deletions include/pando-lib-galois/sync/wait_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ class WaitGroup {
return ready;
});
} else {
DrvAPI::monitor_until<int64_t>(m_count.address, static_cast<std::int64_t>(0));
DrvAPI::monitor_until<int64_t>(m_count.address, static_cast<std::int64_t>(0), true);
}
#else
DrvAPI::monitor_until<int64_t>(m_count.address, static_cast<std::int64_t>(0));
DrvAPI::monitor_until<int64_t>(m_count.address, static_cast<std::int64_t>(0), true);
#endif

#endif
Expand Down
6 changes: 3 additions & 3 deletions pando-drv/api/DrvAPIMemory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ T atomic_cas(DrvAPIAddress address, T compare, T value)
}

/**
* @brief monitor a memory address until it reaches a certain value
* @brief monitor a memory address until it reaches or is no longer a certain value
*/
template <typename T>
void monitor_until(DrvAPIAddress address, T value)
void monitor_until(DrvAPIAddress address, T value, bool equal)
{
DrvAPIThread::current()->setState(std::make_shared<DrvAPIMemMonitorUntil<T>>(address, value));
DrvAPIThread::current()->setState(std::make_shared<DrvAPIMemMonitorUntil<T>>(address, value, equal));
DrvAPIThread::current()->yield();
}

Expand Down
7 changes: 5 additions & 2 deletions pando-drv/api/DrvAPIThreadState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class DrvAPIMemMonitor : public DrvAPIMem {
: DrvAPIMem(address) {}
virtual void getExpected(void *p) = 0;
virtual size_t getSize() const { return 0; }
virtual bool getEqual() { return false; }
};

/**
Expand All @@ -319,16 +320,18 @@ template <typename T>
class DrvAPIMemMonitorUntil : public DrvAPIMemMonitor
{
public:
DrvAPIMemMonitorUntil(DrvAPIAddress address, T value)
: DrvAPIMemMonitor(address), expected_(value) {}
DrvAPIMemMonitorUntil(DrvAPIAddress address, T value, bool equal)
: DrvAPIMemMonitor(address), expected_(value), equal_(equal) {}

void getExpected(void *p) override {
*static_cast<T*>(p) = expected_;
}
size_t getSize() const override { return sizeof(T); }
bool getEqual() override { return equal_; }

private:
T expected_;
bool equal_;
};


Expand Down
4 changes: 2 additions & 2 deletions pando-drv/element/DrvCustomStdMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace MemHierarchy;
DrvCmdMemHandler::DrvCmdMemHandler(SST::ComponentId_t id, SST::Params& params,
std::function<void(Addr,size_t,std::vector<uint8_t>&)> read,
std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> write,
std::function<bool(Addr,size_t,std::vector<uint8_t>&,MemEventBase*)> monitor,
std::function<bool(Addr,size_t,std::vector<uint8_t>&,bool,MemEventBase*)> monitor,
std::function<Addr(MemHierarchy::Addr)> globalToLocal)
: CustomCmdMemHandler(id, params, read, write, monitor, globalToLocal) {
int verbose_level = params.find<int>("verbose_level", 0);
Expand Down Expand Up @@ -117,7 +117,7 @@ DrvCmdMemHandler::finish(MemEventBase *ev, uint32_t flags) {
if (monitor_data) {
output.verbose(CALL_INFO, 1, 0, "Formatting response to monitor memory op\n");
MemHierarchy::Addr localAddr = translateGlobalToLocal(monitor_data->getRoutingAddress());
bool monitor_hit = monitorData(localAddr, monitor_data->getSize(), monitor_data->expected, ev);
bool monitor_hit = monitorData(localAddr, monitor_data->getSize(), monitor_data->expected, monitor_data->equal, ev);
monitor_resp = nullptr;
if (monitor_hit) {
MemEventBase *MEB = ev->makeResponse();
Expand Down
7 changes: 5 additions & 2 deletions pando-drv/element/DrvCustomStdMem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,24 @@ class MonitorReqData : public Interfaces::StandardMem::CustomData {
ss << std::hex;
ss << pAddr << ", size: ";
ss << std::dec;
ss << size << "} ";
ss << size << ", equal: ";
ss << equal << "} ";
return ss.str();
}

/* serialize this data for parallel sims */
void serialize_order(SST::Core::Serialization::serializer &ser) override {
CustomData::serialize_order(ser);
ser & expected;
ser & equal;
ser & size;
ser & pAddr;
}
ImplementSerializable(SST::Drv::MonitorReqData);

public:
std::vector<uint8_t> expected;
bool equal;
int64_t size;
Interfaces::StandardMem::Addr pAddr;

Expand All @@ -149,7 +152,7 @@ class DrvCmdMemHandler : public SST::MemHierarchy::CustomCmdMemHandler {
DrvCmdMemHandler(SST::ComponentId_t id, SST::Params& params,
std::function<void(MemHierarchy::Addr,size_t,std::vector<uint8_t>&)> read, // read backing store
std::function<MemHierarchy::MemEventBase*(MemHierarchy::Addr,std::vector<uint8_t>*)> write, // write backing store
std::function<bool(MemHierarchy::Addr,size_t,std::vector<uint8_t>&,MemHierarchy::MemEventBase*)> monitor, // monitor backing store
std::function<bool(MemHierarchy::Addr,size_t,std::vector<uint8_t>&,bool,MemHierarchy::MemEventBase*)> monitor, // monitor backing store
std::function<MemHierarchy::Addr(MemHierarchy::Addr)> globalToLocal); // translate global to local address

/* destructor */
Expand Down
2 changes: 2 additions & 0 deletions pando-drv/element/DrvStdMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,14 @@ DrvStdMemory::sendRequest(DrvCore *core
/* do monitor */
uint64_t size = monitor_req->getSize();
uint64_t addr = monitor_req->getAddress();
bool equal = monitor_req->getEqual();
output_.verbose(CALL_INFO, 10, DrvMemory::VERBOSE_REQ,
"Sending monitor until request addr=%" PRIx64 " size=%" PRIu64 "\n",
addr, size);
MonitorReqData *data = new MonitorReqData();
data->pAddr = addr;
data->size = size;
data->equal = equal;
data->expected.resize(size);
monitor_req->getExpected(&data->expected[0]);
// set monitor type
Expand Down
12 changes: 6 additions & 6 deletions pando-rt/include/pando-rt/execution/result_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ struct ResultStorage {
});
} else {
GlobalPtr<std::int32_t> readyPtr{&ready};
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
}
#else
GlobalPtr<std::int32_t> readyPtr{&ready};
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
#endif

#endif
Expand Down Expand Up @@ -134,11 +134,11 @@ struct ResultStorage<void> {
});
} else {
GlobalPtr<std::int32_t> readyPtr{&ready};
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
}
#else
GlobalPtr<std::int32_t> readyPtr{&ready};
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
#endif

#endif
Expand Down Expand Up @@ -217,11 +217,11 @@ class AllocatedResultStorage {
});
} else {
auto readyPtr = memberPtrOf<std::int32_t>(m_storage, offsetof(StorageType, ready));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
}
#else
auto readyPtr = memberPtrOf<std::int32_t>(m_storage, offsetof(StorageType, ready));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1));
DrvAPI::monitor_until<std::int32_t>(readyPtr.address, static_cast<std::int32_t>(1), true);
#endif

#endif
Expand Down
16 changes: 16 additions & 0 deletions pando-rt/include/pando-rt/sync/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,25 @@ class Future<GlobalPtr<T>> {
* @return @c true if there was no error and @c false if there was an error.
*/
bool wait() {
#ifdef PANDO_RT_USE_BACKEND_PREP
waitUntil([this] {
return *m_ptr != nullptr;
});
#else

#if defined(PANDO_RT_BYPASS)
if (getBypassFlag()) {
waitUntil([this] {
return *m_ptr != nullptr;
});
} else {
DrvAPI::monitor_until<GlobalPtr<T>>(m_ptr.address, nullptr, false);
}
#else
DrvAPI::monitor_until<GlobalPtr<T>>(m_ptr.address, nullptr, false);
#endif

#endif
return s_errorPtr != *m_ptr;
}
};
Expand Down
12 changes: 6 additions & 6 deletions pando-rt/include/pando-rt/sync/notification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ class Notification {
return this->done();
});
} else {
DrvAPI::monitor_until<bool>(m_flag.address, true);
DrvAPI::monitor_until<bool>(m_flag.address, true, true);
}
#else
DrvAPI::monitor_until<bool>(m_flag.address, true);
DrvAPI::monitor_until<bool>(m_flag.address, true, true);
#endif

#endif
Expand Down Expand Up @@ -382,10 +382,10 @@ class NotificationArray {
return this->done(pos);
});
} else {
DrvAPI::monitor_until<bool>((m_flags+pos).address, true);
DrvAPI::monitor_until<bool>((m_flags+pos).address, true, true);
}
#else
DrvAPI::monitor_until<bool>((m_flags+pos).address, true);
DrvAPI::monitor_until<bool>((m_flags+pos).address, true, true);
#endif

#endif
Expand Down Expand Up @@ -424,12 +424,12 @@ class NotificationArray {
});
} else {
for (SizeType doneIndex = 0; doneIndex < size(); ++doneIndex) {
DrvAPI::monitor_until<bool>((m_flags+doneIndex).address, true);
DrvAPI::monitor_until<bool>((m_flags+doneIndex).address, true, true);
}
}
#else
for (SizeType doneIndex = 0; doneIndex < size(); ++doneIndex) {
DrvAPI::monitor_until<bool>((m_flags+doneIndex).address, true);
DrvAPI::monitor_until<bool>((m_flags+doneIndex).address, true, true);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CustomCmdMemHandler : public SST::SubComponent {
////////////////////////////////////////////////////////////////////////////////////////////
// Code here is added by UW and subject to the copyright statement at the top of the file //
////////////////////////////////////////////////////////////////////////////////////////////
SST_ELI_REGISTER_SUBCOMPONENT_API(SST::MemHierarchy::CustomCmdMemHandler, std::function<void(Addr,size_t,std::vector<uint8_t>&)>, std::function<SST::MemHierarchy::MemEventBase*(Addr,std::vector<uint8_t>*)>, std::function<bool(Addr,size_t,std::vector<uint8_t>&,SST::MemHierarchy::MemEventBase*)>, std::function<Addr(Addr)>)
SST_ELI_REGISTER_SUBCOMPONENT_API(SST::MemHierarchy::CustomCmdMemHandler, std::function<void(Addr,size_t,std::vector<uint8_t>&)>, std::function<SST::MemHierarchy::MemEventBase*(Addr,std::vector<uint8_t>*)>, std::function<bool(Addr,size_t,std::vector<uint8_t>&,bool,SST::MemHierarchy::MemEventBase*)>, std::function<Addr(Addr)>)

class MemEventInfo {
public:
Expand All @@ -66,7 +66,7 @@ class CustomCmdMemHandler : public SST::SubComponent {
////////////////////////////////////////////////////////////////////////////////////////////
// Code here is added by UW and subject to the copyright statement at the top of the file //
////////////////////////////////////////////////////////////////////////////////////////////
CustomCmdMemHandler(ComponentId_t id, Params &params, std::function<void(Addr,size_t,std::vector<uint8_t>&)> read, std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> write, std::function<bool(Addr,size_t,std::vector<uint8_t>&,MemEventBase*)> monitor, std::function<Addr(Addr)> globalToLocal) : SubComponent(id) {
CustomCmdMemHandler(ComponentId_t id, Params &params, std::function<void(Addr,size_t,std::vector<uint8_t>&)> read, std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> write, std::function<bool(Addr,size_t,std::vector<uint8_t>&,bool,MemEventBase*)> monitor, std::function<Addr(Addr)> globalToLocal) : SubComponent(id) {
/* Create debug output */
int debugLevel = params.find<int>("debug_level", 0);
int debugLoc = params.find<int>("debug", 0);
Expand Down Expand Up @@ -129,7 +129,7 @@ class CustomCmdMemHandler : public SST::SubComponent {

std::function<void(Addr,size_t,std::vector<uint8_t>&)> readData;
std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> writeData;
std::function<bool(Addr,size_t,std::vector<uint8_t>&,MemEventBase*)> monitorData;
std::function<bool(Addr,size_t,std::vector<uint8_t>&,bool,MemEventBase*)> monitorData;
////////////////////////////////////////////////////////////////////////////////////////////
// Code here is added by UW and subject to the copyright statement at the top of the file //
////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DefCustomCmdMemHandler : public CustomCmdMemHandler {
////////////////////////////////////////////////////////////////////////////////////////////
// Code here is added by UW and subject to the copyright statement at the top of the file //
////////////////////////////////////////////////////////////////////////////////////////////
DefCustomCmdMemHandler(ComponentId_t id, Params &params, std::function<void(Addr,size_t,std::vector<uint8_t>&)> read, std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> write, std::function<bool(Addr,size_t,std::vector<uint8_t>&,MemEventBase*)> monitor, std::function<Addr(Addr)> globalToLocal)
DefCustomCmdMemHandler(ComponentId_t id, Params &params, std::function<void(Addr,size_t,std::vector<uint8_t>&)> read, std::function<MemEventBase*(Addr,std::vector<uint8_t>*)> write, std::function<bool(Addr,size_t,std::vector<uint8_t>&,bool,MemEventBase*)> monitor, std::function<Addr(Addr)> globalToLocal)
: CustomCmdMemHandler(id, params, read, write, monitor, globalToLocal) {}

~DefCustomCmdMemHandler() {}
Expand Down
Loading

0 comments on commit eaa7a3e

Please sign in to comment.