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

Exchange recvbuff at the beginning of the CUDA kernel call. #464

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions apps/nccl/src/broadcast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,34 @@ __global__ void __launch_bounds__(1024, 1)
const size_t nThread = blockDim.x * gridDim.x;
const size_t nPeer = nRanksPerNode - 1;
const size_t chanOffset = nPeer * blockIdx.x;
const size_t peerRootIdx = (root == rank) ? nPeer : ((root < rank) ? root : (root - 1));

__shared__ mscclpp::DeviceHandle<mscclpp::MemoryChannel> memChans[NRANKS_PER_NODE - 1];
// if (threadIdx.x < nPeer) {
// memChans[threadIdx.x] = memoryChannels[chanOffset + threadIdx.x];
// memChans[threadIdx.x].relaxedSignal();
// memChans[threadIdx.x].wait();
// }

if (threadIdx.x < nPeer) {
// My Id in peer.
const size_t myIdInPeer = (threadIdx.x < rank) ? (rank - 1) : rank;
const size_t offset = myIdInPeer * sizeof(void *);
memChans[threadIdx.x] = memoryChannels[chanOffset + threadIdx.x];
memChans[threadIdx.x].relaxedSignal();
// Write recvbuff (64 bytes).
void **dst = reinterpret_cast<void **>(memChans[threadIdx.x].dst_); // Peer's scratchbuff.
*(dst + offset) = recvbuff;
memChans[threadIdx.x].signal();
//memChans[threadIdx.x].relaxedSignal();
memChans[threadIdx.x].wait();
}
__syncthreads();

const size_t peerRootIdx = (root == rank) ? nPeer : ((root < rank) ? root : (root - 1));
if (threadIdx.x < nPeer) {
void **scratch_ = reinterpret_cast<void **>(scratchbuff); // My scratchbuff.
printf("rank = %ld, recvbuff = %p, recvbuff_[0] = %p, recvbuff_[1] = %p\n", rank, recvbuff,
*scratch_, *(scratch_ + sizeof(void *)));
}

const size_t bytesPerGPU = nelemsPerGPU * sizeof(int);
const size_t bytes = bytesPerGPU;
Expand Down
Loading