Skip to content

Commit

Permalink
changing fifo poll function
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeed Maleki committed Aug 3, 2023
1 parent e4c097a commit 0808ae7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/mscclpp/fifo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Fifo {

/// Polls the FIFO for a trigger.
///
/// @param trigger A pointer to the trigger to be filled.
void poll(ProxyTrigger* trigger);
/// Returns @ref ProxyTrigger which is the trigger at the head of fifo.
ProxyTrigger poll();

/// Pops a trigger from the FIFO.
void pop();
Expand Down
2 changes: 1 addition & 1 deletion python/fifo_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void register_fifo(nb::module_& m) {

nb::class_<Fifo>(m, "Fifo")
.def(nb::init<>())
.def("poll", &Fifo::poll, nb::arg("trigger"))
.def("poll", &Fifo::poll)
.def("pop", &Fifo::pop)
.def("flush_tail", &Fifo::flushTail, nb::arg("sync") = false)
.def("device_handle", &Fifo::deviceHandle);
Expand Down
6 changes: 4 additions & 2 deletions src/fifo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ struct Fifo::Impl {
MSCCLPP_API_CPP Fifo::Fifo() : pimpl(std::make_unique<Impl>()) {}
MSCCLPP_API_CPP Fifo::~Fifo() = default;

MSCCLPP_API_CPP void Fifo::poll(ProxyTrigger* trigger) {
MSCCLPP_API_CPP ProxyTrigger Fifo::poll() {
ProxyTrigger trigger;
__m128i xmm0 = _mm_load_si128((__m128i*)&pimpl->triggers.get()[pimpl->hostTail % MSCCLPP_PROXY_FIFO_SIZE]);
_mm_store_si128((__m128i*)trigger, xmm0);
_mm_store_si128((__m128i*)&trigger, xmm0);
return trigger;
}

MSCCLPP_API_CPP void Fifo::pop() {
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ MSCCLPP_API_CPP void Proxy::start() {
}
}
// Poll to see if we are ready to send anything
fifo.poll(&trigger);
trigger = fifo.poll();
if (trigger.fst == 0) { // TODO: this check is a potential pitfall for custom triggers
continue; // there is one in progress
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/fifo_tests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TEST(FifoTest, Fifo) {
mscclpp::Timer timer(3);
for (uint64_t i = 0; i < ITER; ++i) {
while (trigger.fst == 0) {
hostFifo.poll(&trigger);
trigger = hostFifo.poll();

if (spin++ > 1000000) {
FAIL() << "Polling is stuck.";
Expand Down

0 comments on commit 0808ae7

Please sign in to comment.