rocfft: split tests, benchmarks & samples into separate derivations

This commit is contained in:
Kira Bruneau 2023-05-17 10:53:34 -04:00
parent c4a937a9f6
commit 9dc0b2f3b5

View file

@ -14,8 +14,6 @@
, gtest , gtest
, openmp , openmp
, rocrand , rocrand
, buildTests ? false
, buildBenchmarks ? false
# NOTE: Update the default GPU targets on every update # NOTE: Update the default GPU targets on every update
, gpuTargets ? [ , gpuTargets ? [
"gfx803" "gfx803"
@ -54,8 +52,6 @@ let
requiredSystemFeatures = [ "big-parallel" ]; requiredSystemFeatures = [ "big-parallel" ];
})).override { })).override {
buildTests = false;
buildBenchmarks = false;
gpuTargets = [ target ]; gpuTargets = [ target ];
} }
) )
@ -71,7 +67,7 @@ let
# It's not clear why this needs to even be a db in the first place. # It's not clear why this needs to even be a db in the first place.
# It would simplify things A LOT if we could just store these # It would simplify things A LOT if we could just store these
# pre-compiled kernels as files (but that'd need a lot of patching). # pre-compiled kernels as files (but that'd need a lot of patching).
kernelRtcCache = (rocfft.overrideAttrs (_: { kernelRtcCache = rocfft.overrideAttrs (_: {
pname = "rocfft-kernel-cache"; pname = "rocfft-kernel-cache";
buildFlags = [ "rocfft_kernel_cache_target" ]; buildFlags = [ "rocfft_kernel_cache_target" ];
@ -83,23 +79,12 @@ let
''; '';
requiredSystemFeatures = [ "big-parallel" ]; requiredSystemFeatures = [ "big-parallel" ];
})).override { });
buildTests = false;
buildBenchmarks = false;
};
in in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "rocfft"; pname = "rocfft";
version = "5.4.3"; version = "5.4.3";
outputs = [
"out"
] ++ lib.optionals buildTests [
"test"
] ++ lib.optionals buildBenchmarks [
"benchmark"
];
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "ROCmSoftwarePlatform"; owner = "ROCmSoftwarePlatform";
repo = "rocFFT"; repo = "rocFFT";
@ -120,22 +105,9 @@ stdenv.mkDerivation (finalAttrs: {
rocm-cmake rocm-cmake
]; ];
buildInputs = (lib.optionals (finalAttrs.pname == "rocfft") kernelDeviceLibs) ++ [ buildInputs = [
sqlite sqlite
] ++ lib.optionals buildTests [ ] ++ lib.optionals (finalAttrs.pname == "rocfft") kernelDeviceLibs;
gtest
] ++ lib.optionals (buildTests || buildBenchmarks) [
boost
fftw
fftwFloat
openmp
rocrand
];
propagatedBuildInputs = lib.optionals buildTests [
fftw
fftwFloat
];
cmakeFlags = [ cmakeFlags = [
"-DCMAKE_C_COMPILER=hipcc" "-DCMAKE_C_COMPILER=hipcc"
@ -148,36 +120,116 @@ stdenv.mkDerivation (finalAttrs: {
"-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include" "-DCMAKE_INSTALL_INCLUDEDIR=include"
"-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
] ++ lib.optionals buildTests [
"-DBUILD_CLIENTS_TESTS=ON"
] ++ lib.optionals buildBenchmarks [
"-DBUILD_CLIENTS_RIDER=ON"
"-DBUILD_CLIENTS_SAMPLES=ON"
]; ];
postInstall = lib.optionalString (finalAttrs.pname == "rocfft") '' postInstall = lib.optionalString (finalAttrs.pname == "rocfft") ''
ln -s ${kernelRtcCache}/lib/rocfft_kernel_cache.db "$out/lib" ln -s ${kernelRtcCache}/lib/rocfft_kernel_cache.db "$out/lib"
'' + lib.optionalString buildTests ''
mkdir -p $test/{bin,lib/fftw}
cp -a $out/bin/* $test/bin
ln -s ${fftw}/lib/libfftw*.so $test/lib/fftw
ln -s ${fftwFloat}/lib/libfftw*.so $test/lib/fftw
rm -r $out/lib/fftw
rm $test/bin/{rocfft_rtc_helper,*-rider} || true
'' + lib.optionalString buildBenchmarks ''
mkdir -p $benchmark/bin
cp -a $out/bin/* $benchmark/bin
rm $benchmark/bin/{rocfft_rtc_helper,*-test} || true
'' + lib.optionalString (buildTests || buildBenchmarks ) ''
mv $out/bin/rocfft_rtc_helper $out
rm -r $out/bin/*
mv $out/rocfft_rtc_helper $out/bin
''; '';
passthru.updateScript = rocmUpdateScript { passthru = {
name = finalAttrs.pname; test = stdenv.mkDerivation {
owner = finalAttrs.src.owner; pname = "${finalAttrs.pname}-test";
repo = finalAttrs.src.repo; inherit (finalAttrs) version src;
sourceRoot = "source/clients/tests";
nativeBuildInputs = [
cmake
hip
rocm-cmake
];
buildInputs = [
boost
fftw
fftwFloat
finalAttrs.finalPackage
gtest
openmp
rocrand
];
cmakeFlags = [
"-DCMAKE_C_COMPILER=hipcc"
"-DCMAKE_CXX_COMPILER=hipcc"
];
postInstall = ''
rm -r "$out/lib/fftw"
rmdir "$out/lib"
'';
};
benchmark = stdenv.mkDerivation {
pname = "${finalAttrs.pname}-benchmark";
inherit (finalAttrs) version src;
sourceRoot = "source/clients/rider";
nativeBuildInputs = [
cmake
hip
rocm-cmake
];
buildInputs = [
boost
finalAttrs.finalPackage
openmp
(python3.withPackages (ps: with ps; [
pandas
scipy
]))
rocrand
];
cmakeFlags = [
"-DCMAKE_C_COMPILER=hipcc"
"-DCMAKE_CXX_COMPILER=hipcc"
];
postInstall = ''
cp -a ../../../scripts/perf "$out/bin"
'';
};
samples = stdenv.mkDerivation {
pname = "${finalAttrs.pname}-samples";
inherit (finalAttrs) version src;
sourceRoot = "source/clients/samples";
nativeBuildInputs = [
cmake
hip
rocm-cmake
];
buildInputs = [
boost
finalAttrs.finalPackage
openmp
rocrand
];
cmakeFlags = [
"-DCMAKE_C_COMPILER=hipcc"
"-DCMAKE_CXX_COMPILER=hipcc"
];
installPhase = ''
runHook preInstall
mkdir "$out"
cp -a bin "$out"
runHook postInstall
'';
};
updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
}; };
meta = with lib; { meta = with lib; {