Merge pull request #214606 from Madouura/pr/rocfft

This commit is contained in:
Sandro 2023-04-01 16:49:51 +02:00 committed by GitHub
commit 50b19b0bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,11 @@
}: }:
let let
name-zero = "librocfft-device-0.so.0.1";
name-one = "librocfft-device-1.so.0.1";
name-two = "librocfft-device-2.so.0.1";
name-three = "librocfft-device-3.so.0.1";
# This is over 3GB, to allow hydra caching we separate it # This is over 3GB, to allow hydra caching we separate it
rf = stdenv.mkDerivation (finalAttrs: { rf = stdenv.mkDerivation (finalAttrs: {
pname = "rocfft"; pname = "rocfft";
@ -26,6 +31,10 @@ let
outputs = [ outputs = [
"out" "out"
"libzero"
"libone"
"libtwo"
"libthree"
] ++ lib.optionals buildTests [ ] ++ lib.optionals buildTests [
"test" "test"
] ++ lib.optionals buildBenchmarks [ ] ++ lib.optionals buildBenchmarks [
@ -58,7 +67,7 @@ let
openmp openmp
]; ];
propogatedBuildInputs = lib.optionals buildTests [ propagatedBuildInputs = lib.optionals buildTests [
fftw fftw
fftwFloat fftwFloat
]; ];
@ -80,7 +89,16 @@ let
"-DBUILD_CLIENTS_SAMPLES=ON" "-DBUILD_CLIENTS_SAMPLES=ON"
]; ];
postInstall = lib.optionalString buildTests '' postInstall = ''
mv $out/lib/${name-zero} $libzero
mv $out/lib/${name-one} $libone
mv $out/lib/${name-two} $libtwo
mv $out/lib/${name-three} $libthree
ln -s $libzero $out/lib/${name-zero}
ln -s $libone $out/lib/${name-one}
ln -s $libtwo $out/lib/${name-two}
ln -s $libthree $out/lib/${name-three}
'' + lib.optionalString buildTests ''
mkdir -p $test/{bin,lib/fftw} mkdir -p $test/{bin,lib/fftw}
cp -a $out/bin/* $test/bin cp -a $out/bin/* $test/bin
ln -s ${fftw}/lib/libfftw*.so $test/lib/fftw ln -s ${fftw}/lib/libfftw*.so $test/lib/fftw
@ -113,23 +131,31 @@ let
}; };
}); });
rf-zero = runCommand "librocfft-device-0.so.0.1" { preferLocalBuild = true; } '' rf-zero = runCommand name-zero { preferLocalBuild = true; } ''
cp -a ${rf}/lib/$name $out cp -a ${rf.libzero} $out
''; '';
rf-one = runCommand "librocfft-device-1.so.0.1" { preferLocalBuild = true; } '' rf-one = runCommand name-one { preferLocalBuild = true; } ''
cp -a ${rf}/lib/$name $out cp -a ${rf.libone} $out
''; '';
rf-two = runCommand "librocfft-device-2.so.0.1" { preferLocalBuild = true; } '' rf-two = runCommand name-two { preferLocalBuild = true; } ''
cp -a ${rf}/lib/$name $out cp -a ${rf.libtwo} $out
''; '';
rf-three = runCommand "librocfft-device-3.so.0.1" { preferLocalBuild = true; } '' rf-three = runCommand name-three { preferLocalBuild = true; } ''
cp -a ${rf}/lib/$name $out cp -a ${rf.libthree} $out
''; '';
in stdenv.mkDerivation { in stdenv.mkDerivation {
inherit (rf) pname version outputs src passthru meta; inherit (rf) pname version src passthru meta;
outputs = [
"out"
] ++ lib.optionals buildTests [
"test"
] ++ lib.optionals buildBenchmarks [
"benchmark"
];
dontUnpack = true; dontUnpack = true;
dontPatch = true; dontPatch = true;
@ -140,10 +166,10 @@ in stdenv.mkDerivation {
runHook preInstall runHook preInstall
mkdir -p $out/lib mkdir -p $out/lib
cp -as ${rf-zero} $out/lib/${rf-zero.name} ln -sf ${rf-zero} $out/lib/${name-zero}
cp -as ${rf-one} $out/lib/${rf-one.name} ln -sf ${rf-one} $out/lib/${name-one}
cp -as ${rf-two} $out/lib/${rf-two.name} ln -sf ${rf-two} $out/lib/${name-two}
cp -as ${rf-three} $out/lib/${rf-three.name} ln -sf ${rf-three} $out/lib/${name-three}
cp -an ${rf}/* $out cp -an ${rf}/* $out
'' + lib.optionalString buildTests '' '' + lib.optionalString buildTests ''
cp -a ${rf.test} $test cp -a ${rf.test} $test