feat(cco): self-contained cco.hpp + compile-time per-NIC GDA dispatch#393
Merged
Conversation
cco.hpp now needs only itself + the host .so — no other mori header, and no
<hip/hip_runtime.h>. Goals:
* Self-contained: a user copies just cco.hpp (+ libmori_cco.so). External
types are referenced solely via forward-declared pointers / unique_ptr
(application::{BootstrapNetwork,Context,HeapVAManager,RdmaEndpointDevice},
anvil::SdmaQueueDeviceHandle); hipMemGenericAllocationHandle_t is replicated
as its opaque-pointer typedef; core::ProviderType is replaced by cco's own
ccoProviderType enum (same values; avoids needing a core header and dodges
an enum-redefinition conflict in the host impl). Only system <stddef/stdint>
and (host) STL are included.
* ccoComm / ccoWindowHost stay defined IN cco.hpp (host-guarded), not split
into a private header. unique_ptr<HeapVAManager> works with an incomplete
type via an out-of-line ccoComm dtor (defined in cco_init.cpp).
* No <hip/hip_runtime.h>: device code goes through tiny mori::cco::impl
wrappers over clang AMDGCN builtins (threadIdxX/blockDimX/warpSize/syncWarp/
syncThreads/threadFenceSystem/clock64), copied verbatim from HIP's
amd_detail. HIP qualifiers get #ifndef-guarded __attribute__ fallbacks
(mirroring aiter's opus/hip_minimal.hpp) so cco.hpp also compiles with no
auto-wrapper (-nogpuinc or -D__HIPCC_RTC__, a DSL/JIT front-end) and still
coexists with the real HIP headers. __hip_atomic_* are clang builtins and
__HIP_MEMORY_SCOPE_* are predefined macros, so they need no header.
cco_init.cpp: include cco.hpp + application/va_manager directly, define the
out-of-line ccoComm dtor, map core::ProviderType -> ccoProviderType.
Tests: CCO_GDA_DISPATCH switches on ccoProviderType; the two white-box tests
that read RdmaEndpointDevice include application_device_types.hpp directly.
Validated on BNXT (in-container): host/modes/put/get/flush + lsa_barrier (11/11)
+ allreduce pass. Device-only cco.hpp compiles under -x hip with zero
hip_runtime.h; syntax-only timings: 712ms (default) / 85ms (-D__HIPCC_RTC__) /
50ms (-nogpuinc) vs 1042ms with the explicit header.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GDA kernel dispatch was a runtime switch on the comm's provider. Make it compile-time instead, matching shmem: a build targets one NIC and only that ccoGda<P> specialization is instantiated — no runtime branch, nothing to read at the launch site. cco_scale_out.hpp gains CCO_GDA_BUILD_PROVIDER (fixed from MORI_DEVICE_NIC_*, the NIC auto-detected by cmake/MoriDetectDevice.cmake; the python/mori/jit path already mirrors it) and a CCO_GDA_DISPATCH(...) wrapper that exposes it as a constexpr P. tests/cpp/cco wires MORI_DEVICE_NIC_DEFINE onto the HIP test targets (without it a BNXT/ionic host would default to mlx5). GDA tests: single-launch ones wrap the launch in CCO_GDA_DISPATCH; multi-launch ones set kPrvdType = CCO_GDA_BUILD_PROVIDER (was a hardcoded PSD constant). The runtime dispatch macro + its stale include leave the test harness. This also fixes the old PSD hardcode that hung test_gda_barrier and failed test_gda_signal_ut on BNXT — the full GDA suite now passes 8/8 on BNXT. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The provider lived in ccoDevComm.ibgda (passed by value into every kernel) but the device never reads it — it only drove host dispatch, which is now compile-time. Move it to the host ccoComm as an informational parameter and drop it from the device POD. ccoComm.providerType is still resolved at the first ccoDevCommCreate from a connected endpoint's vendorId. cco.hpp keeps its own ccoProviderType (so the header stays self-contained); cco_init.cpp guards the value-preserving cast to core::ProviderType with static_asserts so the two enums can't silently drift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cco.hppself-contained & HIP-runtime-free: copy justcco.hpp(+libmori_cco.so) — no other mori header, no<hip/hip_runtime.h>. External types via forward-decls;ccoProviderTypereplacescore::ProviderType; device code usesmori::cco::implAMDGCN-builtin wrappers (mirrors aiteropus/hip_minimal.hpp).ccoGda<P>is instantiated.cco_scale_out.hppaddsCCO_GDA_BUILD_PROVIDER/CCO_GDA_DISPATCHkeyed onMORI_DEVICE_NIC_*(auto-detected bycmake/MoriDetectDevice.cmake); tests wireMORI_DEVICE_NIC_DEFINE. Also fixes the hardcoded-PSD constant that hungtest_gda_barrier/ failedtest_gda_signal_uton BNXT.ccoCommfield: device never read it; moved off the by-valueccoDevCommto the host comm, withstatic_asserts guarding theccoProviderType↔core::ProviderType1:1 cast.Testing
In-container on BNXT (MI300X gfx942), fork 8 ranks: GDA put/get/flush_async/counter/barrier/signal_ut/multi_context 8/8 each, LSA barrier 8/8, full suite builds clean.