nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 cmake,
7 rocm-cmake,
8 clr,
9 git,
10 rocfft,
11 gtest,
12 boost,
13 fftw,
14 fftwFloat,
15 openmp,
16 buildTests ? false,
17 buildBenchmarks ? false,
18 buildSamples ? false,
19 gpuTargets ? [ ],
20}:
21
22# Can also use cuFFT
23stdenv.mkDerivation (finalAttrs: {
24 pname = "hipfft";
25 version = "6.3.3";
26
27 outputs = [
28 "out"
29 ]
30 ++ lib.optionals buildTests [
31 "test"
32 ]
33 ++ lib.optionals buildBenchmarks [
34 "benchmark"
35 ]
36 ++ lib.optionals buildSamples [
37 "sample"
38 ];
39
40 src = fetchFromGitHub {
41 owner = "ROCm";
42 repo = "hipFFT";
43 rev = "rocm-${finalAttrs.version}";
44 hash = "sha256-Jq/YHEtOo7a0/Ki7gxZATKmSqPU6cyLf5gx3A4MAZNw=";
45 fetchSubmodules = true;
46 };
47
48 nativeBuildInputs = [
49 clr
50 git
51 cmake
52 rocm-cmake
53 ];
54
55 buildInputs = [
56 rocfft
57 ]
58 ++ lib.optionals (buildTests || buildBenchmarks || buildSamples) [
59 gtest
60 boost
61 fftw
62 fftwFloat
63 openmp
64 ];
65
66 cmakeFlags = [
67 "-DCMAKE_C_COMPILER=hipcc"
68 "-DCMAKE_CXX_COMPILER=hipcc"
69 "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
70 "-DHIP_ROOT_DIR=${clr}"
71 "-DHIP_PATH=${clr}"
72 # Manually define CMAKE_INSTALL_<DIR>
73 # See: https://github.com/NixOS/nixpkgs/pull/197838
74 "-DCMAKE_INSTALL_BINDIR=bin"
75 "-DCMAKE_INSTALL_LIBDIR=lib"
76 "-DCMAKE_INSTALL_INCLUDEDIR=include"
77 ]
78 ++ lib.optionals (gpuTargets != [ ]) [
79 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
80 ]
81 ++ lib.optionals buildTests [
82 "-DBUILD_CLIENTS_TESTS=ON"
83 ]
84 ++ lib.optionals buildBenchmarks [
85 "-DBUILD_CLIENTS_RIDER=ON"
86 ]
87 ++ lib.optionals buildSamples [
88 "-DBUILD_CLIENTS_SAMPLES=ON"
89 ];
90
91 postInstall =
92 lib.optionalString buildTests ''
93 mkdir -p $test/bin
94 mv $out/bin/hipfft-test $test/bin
95 ''
96 + lib.optionalString buildBenchmarks ''
97 mkdir -p $benchmark/bin
98 mv $out/bin/hipfft-rider $benchmark/bin
99 ''
100 + lib.optionalString buildSamples ''
101 mkdir -p $sample/bin
102 mv clients/staging/hipfft_* $sample/bin
103 patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
104 ''
105 + lib.optionalString (buildTests || buildBenchmarks) ''
106 rmdir $out/bin
107 '';
108
109 passthru.updateScript = rocmUpdateScript {
110 name = finalAttrs.pname;
111 inherit (finalAttrs.src) owner;
112 inherit (finalAttrs.src) repo;
113 };
114
115 meta = with lib; {
116 description = "FFT marshalling library";
117 homepage = "https://github.com/ROCm/hipFFT";
118 license = with licenses; [ mit ];
119 teams = [ teams.rocm ];
120 platforms = platforms.linux;
121 };
122})