2023-10-19 13:55:26 +00:00
|
|
|
{ rocblas
|
|
|
|
, lib
|
2022-11-04 12:27:35 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-12-17 10:02:37 +00:00
|
|
|
, rocmUpdateScript
|
2023-10-19 13:55:26 +00:00
|
|
|
, runCommand
|
2022-11-04 12:27:35 +00:00
|
|
|
, cmake
|
|
|
|
, rocm-cmake
|
2023-10-19 13:55:26 +00:00
|
|
|
, clr
|
2022-11-04 12:27:35 +00:00
|
|
|
, python3
|
2022-12-02 08:20:57 +00:00
|
|
|
, tensile
|
|
|
|
, msgpack
|
|
|
|
, libxml2
|
|
|
|
, gtest
|
|
|
|
, gfortran
|
2023-01-20 10:41:00 +00:00
|
|
|
, openmp
|
|
|
|
, amd-blis
|
2022-12-02 08:20:57 +00:00
|
|
|
, python3Packages
|
2022-11-04 12:27:35 +00:00
|
|
|
, buildTensile ? true
|
|
|
|
, buildTests ? false
|
|
|
|
, buildBenchmarks ? false
|
|
|
|
, tensileLogic ? "asm_full"
|
2023-10-19 13:55:26 +00:00
|
|
|
, tensileCOVersion ? "default"
|
2022-11-04 12:27:35 +00:00
|
|
|
, tensileSepArch ? true
|
|
|
|
, tensileLazyLib ? true
|
|
|
|
, tensileLibFormat ? "msgpack"
|
|
|
|
, gpuTargets ? [ "all" ]
|
|
|
|
}:
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
let
|
|
|
|
# NOTE: Update the default GPU targets on every update
|
|
|
|
gfx80 = (rocblas.override {
|
|
|
|
gpuTargets = [
|
|
|
|
"gfx803"
|
|
|
|
];
|
|
|
|
}).overrideAttrs { pname = "rocblas-tensile-gfx80"; };
|
|
|
|
|
|
|
|
gfx90 = (rocblas.override {
|
|
|
|
gpuTargets = [
|
|
|
|
"gfx900"
|
|
|
|
"gfx906:xnack-"
|
|
|
|
"gfx908:xnack-"
|
|
|
|
"gfx90a:xnack+"
|
|
|
|
"gfx90a:xnack-"
|
|
|
|
];
|
|
|
|
}).overrideAttrs { pname = "rocblas-tensile-gfx90"; };
|
|
|
|
|
|
|
|
gfx94 = (rocblas.override {
|
|
|
|
gpuTargets = [
|
|
|
|
"gfx940"
|
|
|
|
"gfx941"
|
|
|
|
"gfx942"
|
|
|
|
];
|
|
|
|
}).overrideAttrs { pname = "rocblas-tensile-gfx94"; };
|
|
|
|
|
|
|
|
gfx10 = (rocblas.override {
|
|
|
|
gpuTargets = [
|
|
|
|
"gfx1010"
|
|
|
|
"gfx1012"
|
|
|
|
"gfx1030"
|
|
|
|
];
|
|
|
|
}).overrideAttrs { pname = "rocblas-tensile-gfx10"; };
|
|
|
|
|
|
|
|
gfx11 = (rocblas.override {
|
|
|
|
gpuTargets = [
|
|
|
|
"gfx1100"
|
|
|
|
"gfx1101"
|
|
|
|
"gfx1102"
|
|
|
|
];
|
|
|
|
}).overrideAttrs { pname = "rocblas-tensile-gfx11"; };
|
|
|
|
|
|
|
|
# Unfortunately, we have to do two full builds, otherwise we get overlapping _fallback.dat files
|
|
|
|
fallbacks = rocblas.overrideAttrs { pname = "rocblas-tensile-fallbacks"; };
|
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2022-11-04 12:27:35 +00:00
|
|
|
pname = "rocblas";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "5.7.1";
|
2023-01-20 10:41:00 +00:00
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
"test"
|
|
|
|
] ++ lib.optionals buildBenchmarks [
|
|
|
|
"benchmark"
|
|
|
|
];
|
2022-11-04 12:27:35 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2024-01-02 11:29:13 +00:00
|
|
|
owner = "ROCm";
|
2022-11-04 12:27:35 +00:00
|
|
|
repo = "rocBLAS";
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2023-10-19 13:55:26 +00:00
|
|
|
hash = "sha256-3wKnwvAra8u9xqlC05wUD+gSoBILTVJFU2cIV6xv3Lk=";
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
rocm-cmake
|
2023-10-19 13:55:26 +00:00
|
|
|
clr
|
2022-11-04 12:27:35 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
python3
|
|
|
|
] ++ lib.optionals buildTensile [
|
|
|
|
msgpack
|
|
|
|
libxml2
|
|
|
|
python3Packages.msgpack
|
2023-10-19 13:55:26 +00:00
|
|
|
python3Packages.joblib
|
2022-11-04 12:27:35 +00:00
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
gtest
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (buildTests || buildBenchmarks) [
|
2022-11-04 12:27:35 +00:00
|
|
|
gfortran
|
2023-01-20 10:41:00 +00:00
|
|
|
openmp
|
|
|
|
amd-blis
|
|
|
|
] ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [
|
|
|
|
python3Packages.pyyaml
|
2022-11-04 12:27:35 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCMAKE_C_COMPILER=hipcc"
|
|
|
|
"-DCMAKE_CXX_COMPILER=hipcc"
|
|
|
|
"-Dpython=python3"
|
2022-12-02 08:20:57 +00:00
|
|
|
"-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
|
2022-11-04 12:27:35 +00:00
|
|
|
"-DBUILD_WITH_TENSILE=${if buildTensile then "ON" else "OFF"}"
|
|
|
|
# Manually define CMAKE_INSTALL_<DIR>
|
|
|
|
# See: https://github.com/NixOS/nixpkgs/pull/197838
|
|
|
|
"-DCMAKE_INSTALL_BINDIR=bin"
|
|
|
|
"-DCMAKE_INSTALL_LIBDIR=lib"
|
|
|
|
"-DCMAKE_INSTALL_INCLUDEDIR=include"
|
|
|
|
] ++ lib.optionals buildTensile [
|
|
|
|
"-DVIRTUALENV_HOME_DIR=/build/source/tensile"
|
|
|
|
"-DTensile_TEST_LOCAL_PATH=/build/source/tensile"
|
2023-10-19 13:55:26 +00:00
|
|
|
"-DTensile_ROOT=/build/source/tensile/${python3.sitePackages}/Tensile"
|
2022-11-04 12:27:35 +00:00
|
|
|
"-DTensile_LOGIC=${tensileLogic}"
|
|
|
|
"-DTensile_CODE_OBJECT_VERSION=${tensileCOVersion}"
|
|
|
|
"-DTensile_SEPARATE_ARCHITECTURES=${if tensileSepArch then "ON" else "OFF"}"
|
|
|
|
"-DTensile_LAZY_LIBRARY_LOADING=${if tensileLazyLib then "ON" else "OFF"}"
|
|
|
|
"-DTensile_LIBRARY_FORMAT=${tensileLibFormat}"
|
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
"-DBUILD_CLIENTS_TESTS=ON"
|
|
|
|
] ++ lib.optionals buildBenchmarks [
|
|
|
|
"-DBUILD_CLIENTS_BENCHMARKS=ON"
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (buildTests || buildBenchmarks) [
|
|
|
|
"-DCMAKE_CXX_FLAGS=-I${amd-blis}/include/blis"
|
2022-11-04 12:27:35 +00:00
|
|
|
];
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
postPatch = lib.optionalString (finalAttrs.pname != "rocblas") ''
|
|
|
|
# Return early and install tensile files manually
|
|
|
|
substituteInPlace library/src/CMakeLists.txt \
|
|
|
|
--replace "set_target_properties( TensileHost PROPERTIES OUTPUT_NAME" "return()''\nset_target_properties( TensileHost PROPERTIES OUTPUT_NAME"
|
|
|
|
'' + lib.optionalString (buildTensile && finalAttrs.pname == "rocblas") ''
|
|
|
|
# Link the prebuilt Tensile files
|
|
|
|
mkdir -p build/Tensile/library
|
|
|
|
|
|
|
|
for path in ${gfx80} ${gfx90} ${gfx94} ${gfx10} ${gfx11} ${fallbacks}; do
|
|
|
|
ln -s $path/lib/rocblas/library/* build/Tensile/library
|
|
|
|
done
|
|
|
|
|
|
|
|
unlink build/Tensile/library/TensileManifest.txt
|
|
|
|
'' + lib.optionalString buildTensile ''
|
|
|
|
# Tensile REALLY wants to write to the nix directory if we include it normally
|
2022-11-04 12:27:35 +00:00
|
|
|
cp -a ${tensile} tensile
|
|
|
|
chmod +w -R tensile
|
|
|
|
|
|
|
|
# Rewrap Tensile
|
|
|
|
substituteInPlace tensile/bin/{.t*,.T*,*} \
|
|
|
|
--replace "${tensile}" "/build/source/tensile"
|
|
|
|
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace "include(virtualenv)" "" \
|
|
|
|
--replace "virtualenv_install(\''${Tensile_TEST_LOCAL_PATH})" ""
|
|
|
|
'';
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
postInstall = lib.optionalString (finalAttrs.pname == "rocblas") ''
|
|
|
|
ln -sf ${fallbacks}/lib/rocblas/library/TensileManifest.txt $out/lib/rocblas/library
|
|
|
|
'' + lib.optionalString (finalAttrs.pname != "rocblas") ''
|
|
|
|
mkdir -p $out/lib/rocblas/library
|
|
|
|
rm -rf $out/share
|
|
|
|
'' + lib.optionalString (finalAttrs.pname != "rocblas" && finalAttrs.pname != "rocblas-tensile-fallbacks") ''
|
|
|
|
rm Tensile/library/{TensileManifest.txt,*_fallback.dat}
|
|
|
|
mv Tensile/library/* $out/lib/rocblas/library
|
|
|
|
'' + lib.optionalString (finalAttrs.pname == "rocblas-tensile-fallbacks") ''
|
|
|
|
mv Tensile/library/{TensileManifest.txt,*_fallback.dat} $out/lib/rocblas/library
|
|
|
|
'' + lib.optionalString buildTests ''
|
2023-01-20 10:41:00 +00:00
|
|
|
mkdir -p $test/bin
|
|
|
|
cp -a $out/bin/* $test/bin
|
|
|
|
rm $test/bin/*-bench || true
|
|
|
|
'' + lib.optionalString buildBenchmarks ''
|
|
|
|
mkdir -p $benchmark/bin
|
|
|
|
cp -a $out/bin/* $benchmark/bin
|
|
|
|
rm $benchmark/bin/*-test || true
|
|
|
|
'' + lib.optionalString (buildTests || buildBenchmarks ) ''
|
|
|
|
rm -rf $out/bin
|
|
|
|
'';
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
passthru.updateScript = rocmUpdateScript {
|
|
|
|
name = finalAttrs.pname;
|
|
|
|
owner = finalAttrs.src.owner;
|
|
|
|
repo = finalAttrs.src.repo;
|
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
requiredSystemFeatures = [ "big-parallel" ];
|
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "BLAS implementation for ROCm platform";
|
2024-01-02 11:29:13 +00:00
|
|
|
homepage = "https://github.com/ROCm/rocBLAS";
|
2022-11-04 12:27:35 +00:00
|
|
|
license = with licenses; [ mit ];
|
2022-11-27 09:42:12 +00:00
|
|
|
maintainers = teams.rocm.members;
|
2023-01-20 10:41:00 +00:00
|
|
|
platforms = platforms.linux;
|
2024-01-02 11:29:13 +00:00
|
|
|
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|