Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flushing Proxy Channels at CPU side upon reaching the Inflight Request Limit #415

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions include/mscclpp/proxy_channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace mscclpp {

constexpr int MAX_INFLIGHT_REQUEST = 500;
chhwang marked this conversation as resolved.
Show resolved Hide resolved

struct BaseProxyChannel;
struct ProxyChannel;

Expand Down Expand Up @@ -72,6 +74,7 @@ class ProxyService : public BaseProxyService {
std::vector<RegisteredMemory> memories_;
std::shared_ptr<Proxy> proxy_;
int deviceNumaNode;
int inflightRequests;

void bindThread();

Expand Down
9 changes: 9 additions & 0 deletions src/proxy_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ MSCCLPP_API_CPP ProxyService::ProxyService(size_t fifoSize)
int cudaDevice;
MSCCLPP_CUDATHROW(cudaGetDevice(&cudaDevice));
deviceNumaNode = getDeviceNumaNode(cudaDevice);
inflightRequests = 0;
}

MSCCLPP_API_CPP SemaphoreId ProxyService::buildAndAddSemaphore(Communicator& communicator,
Expand Down Expand Up @@ -71,6 +72,13 @@ ProxyHandlerResult ProxyService::handleTrigger(ProxyTrigger triggerRaw) {

auto result = ProxyHandlerResult::Continue;

inflightRequests++;
if (!(trigger->fields.type & TriggerSync) && inflightRequests > MAX_INFLIGHT_REQUEST) {
semaphore->connection()->flush();
result = ProxyHandlerResult::FlushFifoTailAndContinue;
inflightRequests = 0;
}

if (trigger->fields.type & TriggerData) {
RegisteredMemory& dst = memories_[trigger->fields.dstMemoryId];
RegisteredMemory& src = memories_[trigger->fields.srcMemoryId];
Expand All @@ -85,6 +93,7 @@ ProxyHandlerResult ProxyService::handleTrigger(ProxyTrigger triggerRaw) {
if (trigger->fields.type & TriggerSync) {
chhwang marked this conversation as resolved.
Show resolved Hide resolved
semaphore->connection()->flush();
result = ProxyHandlerResult::FlushFifoTailAndContinue;
inflightRequests = 0;
}

return result;
Expand Down
Loading