nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 136 lines 3.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 rocmUpdateScript, 7 cmake, 8 rocm-cmake, 9 clr, 10 gfortran, 11 hipblas-common, 12 rocblas, 13 rocsolver, 14 rocsparse, 15 rocprim, 16 gtest, 17 lapack-reference, 18 buildTests ? false, 19 buildBenchmarks ? false, 20 buildSamples ? false, 21}: 22 23# Can also use cuBLAS 24stdenv.mkDerivation (finalAttrs: { 25 pname = "hipblas"; 26 version = "6.3.3"; 27 28 outputs = [ 29 "out" 30 ] 31 ++ lib.optionals buildTests [ 32 "test" 33 ] 34 ++ lib.optionals buildBenchmarks [ 35 "benchmark" 36 ] 37 ++ lib.optionals buildSamples [ 38 "sample" 39 ]; 40 41 src = fetchFromGitHub { 42 owner = "ROCm"; 43 repo = "hipBLAS"; 44 rev = "rocm-${finalAttrs.version}"; 45 hash = "sha256-Rz1KAhBUbvErHTF2PM1AkVhqo4OHldfSNMSpp5Tx9yk="; 46 }; 47 48 patches = [ 49 # https://github.com/ROCm/hipBLAS/pull/952 50 (fetchpatch { 51 name = "transitively-depend-hipblas-common.patch"; 52 url = "https://github.com/ROCm/hipBLAS/commit/54220fdaebf0fb4fd0921ee9e418ace5b143ec8f.patch"; 53 hash = "sha256-MFEhv8Bkrd2zD0FFIDg9oJzO7ztdyMAF+R9oYA0rmwQ="; 54 }) 55 ]; 56 57 postPatch = '' 58 substituteInPlace library/CMakeLists.txt \ 59 --replace-fail "find_package(Git REQUIRED)" "" 60 ''; 61 62 nativeBuildInputs = [ 63 cmake 64 rocm-cmake 65 clr 66 gfortran 67 ]; 68 69 propagatedBuildInputs = [ hipblas-common ]; 70 71 buildInputs = [ 72 rocblas 73 rocprim 74 rocsparse 75 rocsolver 76 ] 77 ++ lib.optionals buildTests [ 78 gtest 79 ] 80 ++ lib.optionals (buildTests || buildBenchmarks) [ 81 lapack-reference 82 ]; 83 84 cmakeFlags = [ 85 "-DCMAKE_BUILD_TYPE=Release" 86 "-DCMAKE_CXX_COMPILER=${lib.getExe' clr "hipcc"}" 87 # Upstream is migrating to amdclang++, it is likely this will be correct in next version bump 88 #"-DCMAKE_CXX_COMPILER=${lib.getBin clr}/bin/amdclang++" 89 # Manually define CMAKE_INSTALL_<DIR> 90 # See: https://github.com/NixOS/nixpkgs/pull/197838 91 "-DCMAKE_INSTALL_BINDIR=bin" 92 "-DCMAKE_INSTALL_LIBDIR=lib" 93 "-DCMAKE_INSTALL_INCLUDEDIR=include" 94 "-DAMDGPU_TARGETS=${rocblas.amdgpu_targets}" 95 ] 96 ++ lib.optionals buildTests [ 97 "-DBUILD_CLIENTS_TESTS=ON" 98 ] 99 ++ lib.optionals buildBenchmarks [ 100 "-DBUILD_CLIENTS_BENCHMARKS=ON" 101 ] 102 ++ lib.optionals buildSamples [ 103 "-DBUILD_CLIENTS_SAMPLES=ON" 104 ]; 105 106 postInstall = 107 lib.optionalString buildTests '' 108 mkdir -p $test/bin 109 mv $out/bin/hipblas-test $test/bin 110 '' 111 + lib.optionalString buildBenchmarks '' 112 mkdir -p $benchmark/bin 113 mv $out/bin/hipblas-bench $benchmark/bin 114 '' 115 + lib.optionalString buildSamples '' 116 mkdir -p $sample/bin 117 mv $out/bin/example-* $sample/bin 118 '' 119 + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' 120 rmdir $out/bin 121 ''; 122 123 passthru.updateScript = rocmUpdateScript { 124 name = finalAttrs.pname; 125 inherit (finalAttrs.src) owner; 126 inherit (finalAttrs.src) repo; 127 }; 128 129 meta = with lib; { 130 description = "ROCm BLAS marshalling library"; 131 homepage = "https://github.com/ROCm/hipBLAS"; 132 license = with licenses; [ mit ]; 133 teams = [ teams.rocm ]; 134 platforms = platforms.linux; 135 }; 136})