Skip to content

Commit c88eefa

Browse files
Santosh Narayankhedkarfacebook-github-bot
authored andcommitted
Add registered-source comparison to IBGDA benchmark (meta-pytorch#3413)
Summary: Add an opt-in `--ibgda_sendrecv_enable_registered` mode to the IBGDA send/receive benchmark so registered-source sends can be measured against the existing staged path. Keep staged sends as the default, use the same one-block benchmark geometry for both paths, and explicitly drain registered sends before their source storage can be reused. Reviewed By: rmahidhar Differential Revision: D114552005
1 parent 27e08c8 commit c88eefa

4 files changed

Lines changed: 290 additions & 22 deletions

File tree

comms/prims/benchmarks/IbgdaSendRecv.cu

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ __global__ void __launch_bounds__(512, 1) ibgda_progress_send_kernel(
409409
std::size_t totalBytes,
410410
int numBlocks,
411411
std::size_t maxSignalBytes,
412-
Timeout timeout) {
412+
Timeout timeout,
413+
bool waitForSlotFree) {
413414
auto group = make_block_group();
414415

415416
const std::size_t sectionBytes = section_bytes(transport, totalBytes);
@@ -423,6 +424,50 @@ __global__ void __launch_bounds__(512, 1) ibgda_progress_send_kernel(
423424
IbgdaSendRecvProgressStatus::Done) {
424425
}
425426
}
427+
428+
if (waitForSlotFree) {
429+
auto& channel = transport->local_channel(group.group_id);
430+
transport->wait_signal(
431+
group,
432+
channel.slotFree,
433+
static_cast<uint64_t>(channel.sendProgress.nextStep),
434+
timeout);
435+
}
436+
}
437+
438+
__global__ void __launch_bounds__(512, 1) ibgda_registered_progress_send_kernel(
439+
P2pIbgdaTransportDevice* transport,
440+
IbgdaLocalBuffer src,
441+
std::size_t totalBytes,
442+
int numBlocks,
443+
std::size_t maxSignalBytes,
444+
Timeout timeout) {
445+
auto group = make_block_group();
446+
447+
auto status = IbgdaRegisteredSendProgressStatus::Waiting;
448+
const std::size_t sectionBytes = section_bytes(transport, totalBytes);
449+
const std::size_t totalSections = totalBytes / sectionBytes;
450+
for (std::size_t s = 0; s < totalSections; ++s) {
451+
const auto section = src.subBuffer(s * sectionBytes);
452+
transport->init_registered_send_progress(
453+
group, sectionBytes, maxSignalBytes);
454+
status = IbgdaRegisteredSendProgressStatus::Waiting;
455+
while (status != IbgdaRegisteredSendProgressStatus::Posted &&
456+
status != IbgdaRegisteredSendProgressStatus::Drained) {
457+
status = transport->progress_registered_send_once(
458+
group, section, sectionBytes, maxSignalBytes, timeout);
459+
}
460+
}
461+
while (status != IbgdaRegisteredSendProgressStatus::Drained) {
462+
status = transport->progress_registered_send_drain_once(group, timeout);
463+
}
464+
465+
auto& channel = transport->local_channel(group.group_id);
466+
transport->wait_signal(
467+
group,
468+
channel.slotFree,
469+
static_cast<uint64_t>(channel.sendProgress.nextStep),
470+
timeout);
426471
}
427472

428473
__global__ void __launch_bounds__(512, 1) ibgda_progress_recv_kernel(
@@ -467,7 +512,36 @@ void launch_ibgda_progress_send(
467512
printf("[PIPES] progress send benchmark is NVIDIA-only\n");
468513
#else
469514
ibgda_progress_send_kernel<<<numBlocks, 512, 0, stream>>>(
470-
transport, src, nbytes, numBlocks, maxSignalBytes, timeout);
515+
transport, src, nbytes, numBlocks, maxSignalBytes, timeout, false);
516+
cudaError_t err = cudaGetLastError();
517+
if (err != cudaSuccess) {
518+
printf(
519+
"[PIPES] progress send kernel launch failed: %s\n",
520+
cudaGetErrorString(err));
521+
}
522+
#endif
523+
}
524+
525+
void launch_ibgda_progress_send_complete(
526+
P2pIbgdaTransportDevice* transport,
527+
char* src,
528+
std::size_t nbytes,
529+
int numBlocks,
530+
cudaStream_t stream,
531+
std::size_t maxSignalBytes,
532+
Timeout timeout) {
533+
#ifdef __HIP_PLATFORM_AMD__
534+
(void)transport;
535+
(void)src;
536+
(void)nbytes;
537+
(void)numBlocks;
538+
(void)stream;
539+
(void)maxSignalBytes;
540+
(void)timeout;
541+
printf("[PIPES] progress send benchmark is NVIDIA-only\n");
542+
#else
543+
ibgda_progress_send_kernel<<<numBlocks, 512, 0, stream>>>(
544+
transport, src, nbytes, numBlocks, maxSignalBytes, timeout, true);
471545
cudaError_t err = cudaGetLastError();
472546
if (err != cudaSuccess) {
473547
printf(
@@ -477,6 +551,35 @@ void launch_ibgda_progress_send(
477551
#endif
478552
}
479553

554+
void launch_ibgda_registered_progress_send(
555+
P2pIbgdaTransportDevice* transport,
556+
const IbgdaLocalBuffer& src,
557+
std::size_t nbytes,
558+
int numBlocks,
559+
cudaStream_t stream,
560+
std::size_t maxSignalBytes,
561+
Timeout timeout) {
562+
#ifdef __HIP_PLATFORM_AMD__
563+
(void)transport;
564+
(void)src;
565+
(void)nbytes;
566+
(void)numBlocks;
567+
(void)stream;
568+
(void)maxSignalBytes;
569+
(void)timeout;
570+
printf("[PIPES] registered progress send benchmark is NVIDIA-only\n");
571+
#else
572+
ibgda_registered_progress_send_kernel<<<numBlocks, 512, 0, stream>>>(
573+
transport, src, nbytes, numBlocks, maxSignalBytes, timeout);
574+
cudaError_t err = cudaGetLastError();
575+
if (err != cudaSuccess) {
576+
printf(
577+
"[PIPES] registered progress send kernel launch failed: %s\n",
578+
cudaGetErrorString(err));
579+
}
580+
#endif
581+
}
582+
480583
void launch_ibgda_progress_recv(
481584
P2pIbgdaTransportDevice* transport,
482585
char* dst,

comms/prims/benchmarks/IbgdaSendRecv.cuh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ __global__ void ibgda_progress_send_kernel(
8686
std::size_t totalBytes,
8787
int numBlocks,
8888
std::size_t maxSignalBytes,
89+
Timeout timeout,
90+
bool waitForSlotFree);
91+
92+
/**
93+
* Unidirectional registered-source progress send kernel.
94+
* Grid: numBlocks. Block: 512 threads.
95+
*/
96+
__global__ void ibgda_registered_progress_send_kernel(
97+
P2pIbgdaTransportDevice* transport,
98+
IbgdaLocalBuffer src,
99+
std::size_t totalBytes,
100+
int numBlocks,
101+
std::size_t maxSignalBytes,
89102
Timeout timeout);
90103

91104
/**

comms/prims/benchmarks/IbgdaSendRecv.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <cstdint>
88

99
#include "comms/prims/core/Timeout.cuh"
10+
#include "comms/prims/transport/ibgda/IbgdaBuffer.h"
1011

1112
namespace comms::prims {
1213
class P2pIbgdaTransportDevice;
@@ -128,6 +129,33 @@ void launch_ibgda_progress_send(
128129
std::size_t maxSignalBytes = 0,
129130
Timeout timeout = Timeout());
130131

132+
/**
133+
* Launch the staged progress sender and wait for the receiver's final credit.
134+
*/
135+
void launch_ibgda_progress_send_complete(
136+
P2pIbgdaTransportDevice* transport,
137+
char* src,
138+
std::size_t nbytes,
139+
int numBlocks,
140+
cudaStream_t stream,
141+
std::size_t maxSignalBytes = 0,
142+
Timeout timeout = Timeout());
143+
144+
/**
145+
* Launch a unidirectional registered-source progress send kernel.
146+
*
147+
* The source is read directly by the NIC. The kernel drains local NIC reads
148+
* and waits for the receiver's final slot-free credit before returning.
149+
*/
150+
void launch_ibgda_registered_progress_send(
151+
P2pIbgdaTransportDevice* transport,
152+
const IbgdaLocalBuffer& src,
153+
std::size_t nbytes,
154+
int numBlocks,
155+
cudaStream_t stream,
156+
std::size_t maxSignalBytes = 0,
157+
Timeout timeout = Timeout());
158+
131159
/**
132160
* Launch unidirectional progress recv kernel. All blocks receive.
133161
*/

0 commit comments

Comments
 (0)