Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
53 changes: 53 additions & 0 deletions projects/rccl/test/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,30 @@ function(rccl_define_micro_source_lists)
fakes/transport_p2p_fakes.cc # src/transport/p2p.cc shareable buffers
../common/main_altrsmi.cpp
PARENT_SCOPE)

# src/algorithms/dda/{all_gather,all_reduce,alltoall,reduce_scatter}/dda_*.cu launchers. Own binary:
# rccl-UnitTestsMicro links fakes/dda_fakes.cc, which defines the same DDA entry points.
set(TEST_MICRO_DDA_COLL_SOURCE_FILES
algorithms/dda/all_gather/dda-all-gather-fabric-test.cc
algorithms/dda/all_gather/dda-all-gather-fabric-ll-test.cc
algorithms/dda/all_gather/dda-all-gather-fabric-ll128-test.cc
algorithms/dda/all_gather/dda-all-gather-ipc-test.cc
algorithms/dda/all_reduce/dda-all-reduce-fabric-test.cc
algorithms/dda/all_reduce/dda-all-reduce-fabric-ll-test.cc
algorithms/dda/all_reduce/dda-all-reduce-fabric-ll128-test.cc
algorithms/dda/alltoall/dda-alltoall-fabric-test.cc
algorithms/dda/alltoall/dda-alltoall-fabric-ll-test.cc
algorithms/dda/alltoall/dda-alltoall-fabric-ll128-test.cc
algorithms/dda/alltoall/dda-alltoall-ipc-test.cc
algorithms/dda/reduce_scatter/dda-reduce-scatter-fabric-test.cc
algorithms/dda/reduce_scatter/dda-reduce-scatter-fabric-ll-test.cc
algorithms/dda/reduce_scatter/dda-reduce-scatter-fabric-ll128-test.cc
algorithms/dda/reduce_scatter/dda-reduce-scatter-ipc-test.cc
algorithms/dda/dda-coll-seams.cc
fakes/hip_fakes.cc
fakes/nccl_fakes.cc
../common/main_altrsmi.cpp
PARENT_SCOPE)
endfunction()

# Create one host-only micro-test binary and apply all the boilerplate that
Expand Down Expand Up @@ -1055,6 +1079,35 @@ rccl_add_micro_binary(rccl-UnitTestsMicroClientSupport
CLIENT_SUPPORT_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/ras/client_support.cc"
CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/../test_categories_micro.yaml")

# ---------------------------------------------------------------------------
# rccl-UnitTestsMicroDdaColl
# ---------------------------------------------------------------------------
rccl_add_micro_binary(rccl-UnitTestsMicroDdaColl
SOURCES ${TEST_MICRO_DDA_COLL_SOURCE_FILES}
EXTRA_DEFS
${_MICRO_MODE_DEFS}
DDA_ALL_GATHER_FABRIC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_gather/dda_all_gather_fabric.cu.cpp"
DDA_ALL_GATHER_FABRIC_LL_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_gather/dda_all_gather_fabric_ll.cu.cpp"
DDA_ALL_GATHER_FABRIC_LL128_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_gather/dda_all_gather_fabric_ll128.cu.cpp"
DDA_ALL_GATHER_IPC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_gather/dda_all_gather_ipc.cu.cpp"
DDA_ALL_REDUCE_FABRIC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_reduce/dda_all_reduce_fabric.cu.cpp"
DDA_ALL_REDUCE_FABRIC_LL_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_reduce/dda_all_reduce_fabric_ll.cu.cpp"
DDA_ALL_REDUCE_FABRIC_LL128_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/all_reduce/dda_all_reduce_fabric_ll128.cu.cpp"
DDA_ALLTOALL_FABRIC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/alltoall/dda_alltoall_fabric.cu.cpp"
DDA_ALLTOALL_FABRIC_LL_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/alltoall/dda_alltoall_fabric_ll.cu.cpp"
DDA_ALLTOALL_FABRIC_LL128_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/alltoall/dda_alltoall_fabric_ll128.cu.cpp"
DDA_ALLTOALL_IPC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/alltoall/dda_alltoall_ipc.cu.cpp"
DDA_REDUCE_SCATTER_FABRIC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/reduce_scatter/dda_reduce_scatter_fabric.cu.cpp"
DDA_REDUCE_SCATTER_FABRIC_LL_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/reduce_scatter/dda_reduce_scatter_fabric_ll.cu.cpp"
DDA_REDUCE_SCATTER_FABRIC_LL128_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/reduce_scatter/dda_reduce_scatter_fabric_ll128.cu.cpp"
DDA_REDUCE_SCATTER_IPC_CC_PATH="${RCCL_HOST_HIPIFY_DIR}/src/algorithms/dda/reduce_scatter/dda_reduce_scatter_ipc.cu.cpp"
CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/../test_categories_micro_dda_coll.yaml")
# The launchers define __global__ kernels; an embedded empty GPU binary keeps clang from referencing an
# undefined __hip_fatbin_<cuid>. Registration is faked in dda-coll-seams.cc.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/empty_gpubinary" "")
target_compile_options(rccl-UnitTestsMicroDdaColl PRIVATE
"SHELL:-Xclang -fcuda-include-gpubinary -Xclang ${CMAKE_CURRENT_BINARY_DIR}/empty_gpubinary")

# ---------------------------------------------------------------------------
# rccl-UnitTestsMicroSymKernels
# ---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions projects/rccl/test/host/MICROTEST_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ export colliding non-`static` symbols; otherwise a unit needs its own binary:
`NCCL_GIN_PROXY_NTHREADS` progress-thread assignment. Its own binary, not
sharing `rccl-UnitTestsMicro`: `gin-plugin-init-test.cc` already defines
`ncclParamGinEnable` there. See `test_categories_micro_gin_host.yaml`.
- **`rccl-UnitTestsMicroDdaColl`**: the DDA launchers
`algorithms/dda/{all_gather,alltoall,reduce_scatter}/dda_*.cu` and the fabric
`all_reduce/dda_all_reduce_fabric*.cu` (each via `DDA_<UNIT>_CC_PATH`, from
`algorithms/dda/<coll>/<unit>-test.cc`); suites `Dda<Unit>Microtest`. Launches are recorded
through `DdaCollSeams.h`, not run. Its own binary: `rccl-UnitTestsMicro` links
`fakes/dda_fakes.cc`, which defines the same DDA entry points.
- **`rccl-UnitTestsMicroDiagnostics`**: `src/diagnostics/p2p.cc` (via
`DIAG_P2P_CC_PATH`, suite `DiagP2pMicrotest.*`) and `src/diagnostics/ib_write_bw.cc`
(via `DIAG_IB_WRITE_BW_CC_PATH`, suite `DiagIbWriteBwMicrotest.*`). Its own binary: it fakes the
Expand Down Expand Up @@ -829,6 +835,7 @@ can be configured **directly** to build every host binary — `rccl-HostUnitTest
`rccl-UnitTestsMicro`, `rccl-UnitTestsMicroWarpSpeed`,
`rccl-UnitTestsMicroInit[-uncached|-faultinj]`, `rccl-UnitTestsMicroEnqueue[-devlinker]`,
`rccl-UnitTestsMicroGinHost`, `rccl-UnitTestsMicroCe`, `rccl-UnitTestsMicroDiagnostics`,
`rccl-UnitTestsMicroDdaColl`,
`rccl-UnitTestsMicroSymKernels` and `rccl-UnitTestsMicroTaskPrep` — **without configuring/building all of
librccl**. It compiles just the tests + fakes + the hipified unit-under-test
sources.
Expand Down Expand Up @@ -869,6 +876,7 @@ cmake --build build -j"$(nproc)"
./build/rccl-UnitTestsMicroTaskPrep # src/enqueue/task_prep/ + task_sched/ tests
./build/rccl-UnitTestsMicroDiagnostics # src/diagnostics/{p2p,ib_write_bw}.cc tests
./build/rccl-UnitTestsMicroGinHost # src/gin/gin_host.cc GIN_PROXY_NTHREADS
./build/rccl-UnitTestsMicroDdaColl # src/algorithms/dda/*/dda_*.cu launchers
./build/rccl-UnitTestsMicroDiagnostics # src/diagnostics/p2p.cc tests
./build/rccl-UnitTestsMicroCe # src/ce_coll.cc tests
./build/rccl-HostUnitTests
Expand Down
99 changes: 99 additions & 0 deletions projects/rccl/test/host/algorithms/dda/DdaCollSeams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*************************************************************************
* Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
*
* See LICENSE.txt for license information
************************************************************************/

// Seams shared by the DDA collective launcher tests. Include before the launcher: it renames
// hipExtLaunchKernelGGL so each launch is recorded, with its typed arguments, instead of started.

#ifndef RCCL_TEST_HOST_ALGORITHMS_DDA_DDACOLLSEAMS_H_
#define RCCL_TEST_HOST_ALGORITHMS_DDA_DDACOLLSEAMS_H_

#include <any>
#include <cstdint>
#include <cstring>
#include <functional>
#include <vector>

#include <hip/hip_ext.h>
#include <hip/hip_runtime.h>

#include "comm.h"
#include "fakes/hip_fakes.h"
#include "fakes/nccl_fakes.h" // g_loadParam, used by param_redirect.h

struct DdaLaunch {
const void* kernel;
dim3 grid;
dim3 block;
uint32_t sharedMemBytes;
hipStream_t stream;
hipEvent_t startEvent;
hipEvent_t stopEvent;
uint32_t flags;
std::vector<std::any> args;
// Throws std::bad_any_cast when the launcher passed a different type.
template <typename T>
T Arg(size_t i) const {
return std::any_cast<T>(args.at(i));
}
};

extern std::vector<DdaLaunch> g_ddaLaunches;

template <typename F, typename... Args>
void RecordDdaLaunch(F kernel, const dim3& grid, const dim3& block, uint32_t sharedMemBytes, hipStream_t stream,
hipEvent_t startEvent, hipEvent_t stopEvent, uint32_t flags, Args... args) {
g_ddaLaunches.push_back({reinterpret_cast<const void*>(kernel), grid, block, sharedMemBytes, stream, startEvent,
stopEvent, flags, {std::any(args)...}});
}

#define hipExtLaunchKernelGGL RecordDdaLaunch

// One hipMemcpyAsync, with how many launches had been recorded before it.
struct DdaCopy {
void* dst;
const void* src;
size_t bytes;
hipMemcpyKind kind;
hipStream_t stream;
size_t launchesBefore;
};

inline void RecordDdaCopies(std::vector<DdaCopy>* copies) {
g_hipMemcpyAsync = [copies](void* dst, const void* src, size_t bytes, hipMemcpyKind kind, hipStream_t stream) {
copies->push_back({dst, src, bytes, kind, stream, g_ddaLaunches.size()});
return hipSuccess;
};
}

template <typename K>
const void* KernelPtr(K kernel) {
return reinterpret_cast<const void*>(kernel);
}

// One per State type, never destroyed: the destructor would pull in barrier resource teardown this binary does
// not link. The barrier bytes are filled so a launch can be checked to carry this exact barrier.
template <typename State>
State* SharedBarrierState(unsigned char fill) {
static State* const state = new State();
std::memset(static_cast<void*>(&state->barrierHost), fill, sizeof(state->barrierHost));
return state;
}

template <typename Barrier>
bool SameBarrier(const Barrier& a, const Barrier& b) {
return std::memcmp(&a, &b, sizeof(Barrier)) == 0;
}

// rccl_wrap.cc DDA thresholds; defaults match rccl_wrap.cc with no arch table and no env.
extern std::function<size_t(const ncclComm*, ncclFunc_t)> g_rcclDdaLLThreshold;
extern std::function<size_t(const ncclComm*, ncclFunc_t)> g_rcclDdaLL128Threshold;
extern std::function<size_t(const ncclComm*)> g_rcclDdaLLTwoShotThreshold;
extern std::function<size_t(const ncclComm*)> g_rcclDdaLL128TwoShotThreshold;
extern std::function<int(const ncclComm*)> g_rcclDdaFabricVmmBlocks;

void ResetDdaCollSeams();

#endif // RCCL_TEST_HOST_ALGORITHMS_DDA_DDACOLLSEAMS_H_
Loading
Loading