Skip to content

feat(cco): self-contained cco.hpp + compile-time per-NIC GDA dispatch#393

Merged
jhchouuu merged 3 commits into
dev/ccofrom
jiahzhou/dev_cco
Jun 16, 2026
Merged

feat(cco): self-contained cco.hpp + compile-time per-NIC GDA dispatch#393
jhchouuu merged 3 commits into
dev/ccofrom
jiahzhou/dev_cco

Conversation

@jhchouuu

Copy link
Copy Markdown
Collaborator

Summary

  • cco.hpp self-contained & HIP-runtime-free: copy just cco.hpp (+ libmori_cco.so) — no other mori header, no <hip/hip_runtime.h>. External types via forward-decls; ccoProviderType replaces core::ProviderType; device code uses mori::cco::impl AMDGCN-builtin wrappers (mirrors aiter opus/hip_minimal.hpp).
  • Compile-time per-NIC GDA dispatch: was a runtime provider switch, now compile-time like shmem — a build targets one NIC, only that ccoGda<P> is instantiated. cco_scale_out.hpp adds CCO_GDA_BUILD_PROVIDER/CCO_GDA_DISPATCH keyed on MORI_DEVICE_NIC_* (auto-detected by cmake/MoriDetectDevice.cmake); tests wire MORI_DEVICE_NIC_DEFINE. Also fixes the hardcoded-PSD constant that hung test_gda_barrier / failed test_gda_signal_ut on BNXT.
  • GDA provider → informational ccoComm field: device never read it; moved off the by-value ccoDevComm to the host comm, with static_asserts guarding the ccoProviderTypecore::ProviderType 1: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.

jhchouuu and others added 3 commits June 15, 2026 09:53
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>
@jhchouuu jhchouuu merged commit dbf63e7 into dev/cco Jun 16, 2026
@jhchouuu jhchouuu deleted the jiahzhou/dev_cco branch June 16, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant