Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
74 changes: 74 additions & 0 deletions projects/rccl/test/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ foreach(_func_str_line
rccl_assert_source_line("${CMAKE_CURRENT_LIST_DIR}/client-support-test.cc" "${_func_str_line}"
"the production ncclFuncStr table")
endforeach()
# dda-coll-seams.cc copies these rccl_wrap.cc DDA param defaults; pin both copies.
foreach(_dda_param
"RCCL_PARAM(DdaLL, \"DDA_LL\", 1)"
"RCCL_PARAM(DdaLLOneShotThreshold, \"DDA_LL_ONESHOT_THRESHOLD\", (size_t)(1) * 1024 * 1024)"
"RCCL_PARAM(DdaLL128OneShotThreshold, \"DDA_LL128_ONESHOT_THRESHOLD\", (size_t)(4) * 1024 * 1024)")
rccl_assert_source_line("${_rccl_src_root}/rccl_wrap.cc" "${_dda_param}" "algorithms/dda/dda-coll-seams.cc")
rccl_assert_source_line("${CMAKE_CURRENT_LIST_DIR}/algorithms/dda/dda-coll-seams.cc" "${_dda_param}"
"the rccl_wrap.cc DDA param")
endforeach()
rccl_assert_source_line("${_rccl_src_root}/rccl_wrap.cc"
"RCCL_PARAM(DdaLLTwoShotThreshold, \"DDA_LL_TWOSHOT_THRESHOLD\", (size_t)(2) * 1024 * 1024)"
"dda-coll-seams.cc: DefaultDdaLLTwoShotThreshold()")
rccl_assert_source_line("${CMAKE_CURRENT_LIST_DIR}/algorithms/dda/dda-coll-seams.cc"
"DefaultDdaLLTwoShotThreshold(const ncclComm*) { return (size_t)(2) * 1024 * 1024; }"
"the rccl_wrap.cc DdaLLTwoShotThreshold default")
rccl_assert_source_line("${_rccl_src_root}/rccl_wrap.cc"
"RCCL_PARAM(DdaLL128TwoShotThreshold, \"DDA_LL128_TWOSHOT_THRESHOLD\", (size_t)(64) * 1024 * 1024)"
"dda-coll-seams.cc: DefaultDdaLL128TwoShotThreshold()")
rccl_assert_source_line("${CMAKE_CURRENT_LIST_DIR}/algorithms/dda/dda-coll-seams.cc"
"DefaultDdaLL128TwoShotThreshold(const ncclComm*) { return (size_t)(64) * 1024 * 1024; }"
"the rccl_wrap.cc DdaLL128TwoShotThreshold default")
unset(_func_str_line)
# fakes/topo_stubs.cc copies the AMD arm of topoPathTypeStr; pin both copies to one spelling.
foreach(_path_cc "${_rccl_src_root}/graph/topo.cc" "${CMAKE_CURRENT_LIST_DIR}/fakes/topo_stubs.cc")
Expand Down Expand Up @@ -232,6 +253,30 @@ function(rccl_define_micro_source_lists)
../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)

# rccl-UnitTestsMicroEnqueue(+-devlinker) -- src/enqueue.cc.
set(TEST_MICRO_ENQUEUE_SOURCE_FILES
enqueue-test.cc
Expand Down Expand Up @@ -1046,6 +1091,35 @@ elseif(NOT BUILD_TESTS)
message(WARNING "Skipping sym-kernels-index-test.cc for rccl-UnitTestsMicro: missing ${RCCL_HOST_HIPIFY_DIR}/gensrc/symmetric/sym_kernels_host.cc")
endif()

# ---------------------------------------------------------------------------
# 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-UnitTestsMicroRmaProxy
# ---------------------------------------------------------------------------
Expand Down
16 changes: 9 additions & 7 deletions projects/rccl/test/host/MICROTEST_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ export colliding non-`static` symbols; otherwise a unit needs its own binary:
guard-less positional pair `libc_seam.h` / `libc_seam_undef.h` must bracket
the production source include, after system headers and before test
helpers. CMake pins the copied `ncclFuncStr` table to `src/init.cc`.
- **`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-UnitTestsMicroSymKernels`** — the REAL `src/sym_kernels.cc` (via
`SYM_KERNELS_CC_PATH`, from `sym-kernels-test.cc`), compiled together with the
GENERATED `sym_kernels_host.cc` it calls into; suites `SymKernelMicrotest.*`,
Expand Down Expand Up @@ -869,13 +875,8 @@ make -j $(nproc) rccl-UnitTestsMicro

`test/host/CMakeLists.txt` is dual-mode. Alongside the in-RCCL-build target
above (`./install.sh -t`, wired via `add_subdirectory(host)`), the same file
can be configured **directly** to build every host binary — `rccl-HostUnitTests`,
`rccl-UnitTestsMicro`, `rccl-UnitTestsMicroWarpSpeed`,
`rccl-UnitTestsMicroInit[-uncached|-faultinj]`, `rccl-UnitTestsMicroEnqueue[-devlinker]`,
`rccl-UnitTestsMicroGinHost`, `rccl-UnitTestsMicroDdaIpc`, `rccl-UnitTestsMicroCe`, `rccl-UnitTestsMicroDiagnostics`,
`rccl-UnitTestsMicroGraph`, `rccl-UnitTestsMicroDiagnostics`,
`rccl-UnitTestsMicroSymKernels`, `rccl-UnitTestsMicroTaskPrep` and
`rccl-UnitTestsMicroRmaProxy` — **without configuring/building all of
can be configured **directly** to build every host binary in the run block below
— **without configuring/building all of
librccl**. It compiles just the tests + fakes + the hipified unit-under-test
sources.

Expand Down Expand Up @@ -909,6 +910,7 @@ cmake --build build -j"$(nproc)"
./build/rccl-UnitTestsMicroInit # init.cc tests
./build/rccl-UnitTestsMicroInit-uncached
./build/rccl-UnitTestsMicroInit-faultinj # same, ENABLE_FAULT_INJECTION arm
./build/rccl-UnitTestsMicroDdaColl # src/algorithms/dda/*/dda_*.cu launchers
./build/rccl-UnitTestsMicroEnqueue # enqueue.cc tests
./build/rccl-UnitTestsMicroEnqueue-devlinker # same, RCCL_DEVICE_LINKER arm
./build/rccl-UnitTestsMicroSymKernels # sym_kernels.cc tests
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