{ lib, stdenv, fetchFromGitHub, rocmUpdateScript, cmake, rocm-cmake, rocm-smi, rocm-core, clr, mscclpp, perl, hipify, python3, gtest, chrpath, rocprofiler, rocprofiler-register, autoPatchelfHook, buildTests ? false, gpuTargets ? (clr.localGpuTargets or [ ]), }: let useAsan = buildTests; useUbsan = buildTests; san = lib.optionalString (useAsan || useUbsan) ( "-fno-gpu-sanitize -fsanitize=undefined " + (lib.optionalString useAsan "-fsanitize=address -shared-libsan ") ); in # Note: we can't properly test or make use of multi-node collective ops # https://github.com/NixOS/nixpkgs/issues/366242 tracks kernel support # kfd_peerdirect support which is on out-of-tree amdkfd in ROCm/ROCK-Kernel-Driver # infiniband ib_peer_mem support isn't in the mainline kernel but is carried by some distros stdenv.mkDerivation (finalAttrs: { pname = "rccl${clr.gpuArchSuffix}"; version = "6.3.3"; outputs = [ "out" ] ++ lib.optionals buildTests [ "test" ]; patches = [ ./fix-mainline-support-and-ub.diff ./enable-mscclpp-on-all-gfx9.diff ./rccl-test-missing-iomanip.diff ]; src = fetchFromGitHub { owner = "ROCm"; repo = "rccl"; rev = "rocm-${finalAttrs.version}"; hash = "sha256-998tDiC0Qp9hhcXtFpiCWqwdKPVT2vNp0GU/rng03Bw="; }; nativeBuildInputs = [ cmake rocm-cmake clr perl hipify python3 autoPatchelfHook # ASAN doesn't add rpath without this ]; buildInputs = [ rocm-smi gtest rocprofiler rocprofiler-register mscclpp ] ++ lib.optionals buildTests [ chrpath ]; cmakeFlags = [ "-DHIP_CLANG_NUM_PARALLEL_JOBS=4" "-DCMAKE_BUILD_TYPE=Release" "-DROCM_PATH=${clr}" "-DHIP_COMPILER=${clr}/bin/amdclang++" "-DCMAKE_CXX_COMPILER=${clr}/bin/amdclang++" "-DROCM_PATCH_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" "-DROCM_VERSION=${rocm-core.ROCM_LIBPATCH_VERSION}" "-DBUILD_BFD=OFF" # Can't get it to detect bfd.h "-DENABLE_MSCCL_KERNEL=ON" "-DENABLE_MSCCLPP=ON" "-DMSCCLPP_ROOT=${mscclpp}" # Manually define CMAKE_INSTALL_