nixpkgs/pkgs/development/libraries/ucx/default.nix
Yann Hamdaoui 63746cac08
cudaPackages: generalize and refactor setup hook
This PR refactor CUDA setup hooks, and in particular
autoAddOpenGLRunpath and autoAddCudaCompatRunpathHook, that were using a
lot of code in common (in fact, I introduced the latter by copy pasting
most of the bash script of the former). This is not satisfying for
maintenance, as a recent patch showed, because we need to duplicate
changes to both hooks.

This commit abstract the common part in a single shell script that
applies a generic patch action to every elf file in the output. For
autoAddOpenGLRunpath the action is just addOpenGLRunpath (now
addDriverRunpath), and is few line function for
autoAddCudaCompatRunpathHook.

Doing so, we also takes the occasion to use the newer addDriverRunpath
instead of the previous addOpenGLRunpath, and rename the CUDA hook to
reflect that as well.

Co-Authored-By: Connor Baker <connor.baker@tweag.io>
2024-03-15 15:54:21 +01:00

87 lines
1.9 KiB
Nix

{ lib, stdenv, fetchFromGitHub, autoreconfHook, doxygen, numactl
, rdma-core, libbfd, libiberty, perl, zlib, symlinkJoin, pkg-config
, config
, enableCuda ? config.cudaSupport
, cudaPackages
, enableRocm ? config.rocmSupport
, rocmPackages
}:
let
rocmList = with rocmPackages; [ rocm-core rocm-runtime rocm-device-libs clr ];
rocm = symlinkJoin {
name = "rocm";
paths = rocmList;
};
in
stdenv.mkDerivation rec {
pname = "ucx";
version = "1.15.0";
src = fetchFromGitHub {
owner = "openucx";
repo = "ucx";
rev = "v${version}";
sha256 = "sha256-VxIxrk9qKM6Ncfczl4p2EhXiLNgPaYTmjhqi6/w2ZNY=";
};
outputs = [ "out" "doc" "dev" ];
nativeBuildInputs = [
autoreconfHook
doxygen
pkg-config
]
++ lib.optionals enableCuda [
cudaPackages.cuda_nvcc
cudaPackages.autoAddDriverRunpath
];
buildInputs = [
libbfd
libiberty
numactl
perl
rdma-core
zlib
] ++ lib.optionals enableCuda [
cudaPackages.cuda_cudart
cudaPackages.cuda_nvml_dev
] ++ lib.optionals enableRocm rocmList;
LDFLAGS = lib.optionals enableCuda [
# Fake libnvidia-ml.so (the real one is deployed impurely)
"-L${cudaPackages.cuda_nvml_dev}/lib/stubs"
];
configureFlags = [
"--with-rdmacm=${lib.getDev rdma-core}"
"--with-dc"
"--with-rc"
"--with-dm"
"--with-verbs=${lib.getDev rdma-core}"
] ++ lib.optionals enableCuda [ "--with-cuda=${cudaPackages.cuda_cudart}" ]
++ lib.optional enableRocm "--with-rocm=${rocm}";
postInstall = ''
find $out/lib/ -name "*.la" -exec rm -f \{} \;
moveToOutput bin/ucx_info $dev
moveToOutput share/ucx/examples $doc
'';
enableParallelBuilding = true;
meta = with lib; {
description = "Unified Communication X library";
homepage = "https://www.openucx.org";
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = [ maintainers.markuskowa ];
};
}