2022-11-04 12:27:35 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-12-17 10:02:37 +00:00
|
|
|
, rocmUpdateScript
|
2022-11-04 12:27:35 +00:00
|
|
|
, cmake
|
|
|
|
, rocm-cmake
|
|
|
|
, hip
|
|
|
|
, 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"
|
|
|
|
, tensileCOVersion ? "V3"
|
|
|
|
, tensileSepArch ? true
|
|
|
|
, tensileLazyLib ? true
|
|
|
|
, tensileLibFormat ? "msgpack"
|
|
|
|
, gpuTargets ? [ "all" ]
|
|
|
|
}:
|
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-11-04 12:27:35 +00:00
|
|
|
pname = "rocblas";
|
2023-03-04 12:14:45 +00:00
|
|
|
version = "5.4.3";
|
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 {
|
|
|
|
owner = "ROCmSoftwarePlatform";
|
|
|
|
repo = "rocBLAS";
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2023-03-04 12:14:45 +00:00
|
|
|
hash = "sha256-XhYpzBXviMnUdbF6lZi9g0LARKpzWLtDxJxLI3MuHiM=";
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
rocm-cmake
|
|
|
|
hip
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
python3
|
|
|
|
] ++ lib.optionals buildTensile [
|
|
|
|
msgpack
|
|
|
|
libxml2
|
|
|
|
python3Packages.msgpack
|
|
|
|
] ++ 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"
|
|
|
|
"-DTensile_ROOT=/build/source/tensile/lib/python${python3.pythonVersion}/site-packages/Tensile"
|
|
|
|
"-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
|
|
|
];
|
|
|
|
|
|
|
|
# Tensile REALLY wants to write to the nix directory if we include it normally
|
|
|
|
postPatch = lib.optionalString buildTensile ''
|
|
|
|
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-01-20 10:41:00 +00:00
|
|
|
postInstall = lib.optionalString buildTests ''
|
|
|
|
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
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "BLAS implementation for ROCm platform";
|
|
|
|
homepage = "https://github.com/ROCmSoftwarePlatform/rocBLAS";
|
|
|
|
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;
|
|
|
|
broken = versions.minor finalAttrs.version != versions.minor hip.version;
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|