-
Notifications
You must be signed in to change notification settings - Fork 65
feat(shmem/sdma): implement address-based device putmem_nbi_signal on… #445
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -358,30 +358,54 @@ template <> | |
| inline __device__ void ShmemPutMemNbiSignalBlockKernel<application::TransportType::SDMA, true>( | ||
| const void* dest, const void* source, size_t bytes, const void* signalDest, | ||
| uint64_t signalValue, core::atomicType signalOp, int pe, int qpId) { | ||
|
Comment on lines
358
to
360
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the block-level version is implemented; the thread and warp versions aren't yet. The macro expansion probably expands the thread/warp paths too, so there might be a small issue here. But it's fine to merge for now, we'll add the complete functionality in a follow-up. |
||
| // TODO: add SDMA PutMemNbiSignal (address-based) | ||
| (void)dest; | ||
| (void)source; | ||
| (void)bytes; | ||
| (void)signalDest; | ||
| (void)signalValue; | ||
| (void)signalOp; | ||
| (void)pe; | ||
| (void)qpId; | ||
| // SDMA push + signal: COPY_LINEAR(source -> peer dest) then an ATOMIC on the | ||
| // PEER flag, enqueued on the SAME SDMA queue so the DMA engine executes the | ||
| // flag update strictly after the copy completes (in-order queue) -- a CU-free | ||
| // per-tile signal. NOTE: uses atomic INCREMENT (monotonic-generation | ||
| // semantics); consumers should wait `flag >= gen`. signalValue/signalOp are | ||
| // accepted for API parity but the SDMA path only wraps inc today. | ||
| if (bytes == 0) return; | ||
| if (core::FlatBlockThreadId() == 0) { | ||
| GpuStates* globalGpuStates = GetGlobalGpuStatesPtr(); | ||
| application::SymmMemObj* heapObj = globalGpuStates->heapObj; | ||
| int intraNodePe = pe % 8; | ||
|
|
||
| size_t offset = reinterpret_cast<uintptr_t>(dest) - globalGpuStates->heapBaseAddr; | ||
| size_t sigOffset = reinterpret_cast<uintptr_t>(signalDest) - globalGpuStates->heapBaseAddr; | ||
|
|
||
| uint8_t* srcPtr = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(source)); | ||
| uint8_t* dstPtr = reinterpret_cast<uint8_t*>(heapObj->peerPtrs[pe] + offset); | ||
| HSAuint64* sigPtr = reinterpret_cast<HSAuint64*>(heapObj->peerPtrs[pe] + sigOffset); | ||
|
|
||
| anvil::SdmaQueueDeviceHandle** devicehandles = | ||
| heapObj->deviceHandles_d + intraNodePe * heapObj->sdmaNumQueue; | ||
| HSAuint64* signalAddr = heapObj->signalPtrs + intraNodePe * heapObj->sdmaNumQueue; | ||
| HSAuint64* expectedSignals = heapObj->expectSignalsPtr + intraNodePe * heapObj->sdmaNumQueue; | ||
|
|
||
| // 1) COPY + queue completion atomic (for quiet), thread-scoped. | ||
| core::SdmaPutThread(srcPtr, dstPtr, bytes, devicehandles, signalAddr, expectedSignals, | ||
| heapObj->sdmaNumQueue, qpId); | ||
| // 2) Peer-flag atomic on the SAME queue -> ordered after the copy. | ||
| anvil::SdmaQueueDeviceHandle handle = **(devicehandles + qpId); | ||
| uint64_t off = 0; | ||
| uint64_t base = handle.ReserveQueueSpace(sizeof(SDMA_PKT_ATOMIC), off); | ||
| uint64_t wptr = base; | ||
| auto pkt = anvil::CreateAtomicIncPacket(sigPtr); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the increment semantics are implemented here, signalValue/signalOp are ignored (always atomic += 1). Fine for now; we'll complete the remaining ops in a follow-up. |
||
| handle.template placePacket<SDMA_PKT_ATOMIC>(pkt, wptr, off); | ||
| handle.submitPacket(base, wptr); | ||
| (void)signalValue; | ||
| (void)signalOp; | ||
| } | ||
| __syncthreads(); | ||
| } | ||
|
|
||
| template <> | ||
| inline __device__ void ShmemPutMemNbiSignalBlockKernel<application::TransportType::SDMA, false>( | ||
| const void* dest, const void* source, size_t bytes, const void* signalDest, | ||
| uint64_t signalValue, core::atomicType signalOp, int pe, int qpId) { | ||
| // TODO: add SDMA PutMemNbiSignal (address-based) | ||
| (void)dest; | ||
| (void)source; | ||
| (void)bytes; | ||
| (void)signalDest; | ||
| (void)signalValue; | ||
| (void)signalOp; | ||
| (void)pe; | ||
| (void)qpId; | ||
| // Same as the onlyOneSignal=true SDMA path (see above). | ||
| ShmemPutMemNbiSignalBlockKernel<application::TransportType::SDMA, true>( | ||
| dest, source, bytes, signalDest, signalValue, signalOp, pe, qpId); | ||
| } | ||
|
|
||
| template <> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a bit more device-side runtime overhead to this API. Previously the branch was just between P2P and IBGDA; now there's an extra SDMA branch, which also grows the code size. There's not much we can do about it for now, it's inherent to runtime dispatch. We'll look into addressing this in a follow-up.