nixpkgs/pkgs/development/libraries/miopengemm/default.nix
Madoura 30a6bef026
rocm-related: deprecate rocmVersion and repoVersion
clang-ocl: deprecate rocmVersion and repoVersion

hipcub: deprecate rocmVersion and repoVersion

hipsparse: deprecate rocmVersion and repoVersion

miopen: deprecate rocmVersion and repoVersion

miopengemm: deprecate rocmVersion and repoVersion

rccl: deprecate rocmVersion and repoVersion

rocblas: deprecate rocmVersion and repoVersion

rocfft: deprecate rocmVersion and repoVersion

rocmlir: deprecate rocmVersion and repoVersion

rocprim: deprecate rocmVersion and repoVersion

rocrand: deprecate rocmVersion and repoVersion

rocsparse: deprecate rocmVersion and repoVersion

rocthrust: deprecate rocmVersion and repoVersion

rocwmma: deprecate rocmVersion and repoVersion

tensile: deprecate rocmVersion and repoVersion
2022-11-28 05:59:50 -06:00

129 lines
3.3 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, writeScript
, cmake
, rocm-cmake
, rocm-opencl-runtime
, clang
, texlive
, doxygen
, sphinx
, openblas
, python3Packages
, buildDocs ? true
, buildTests ? false
, buildBenchmarks ? false
}:
let
latex = lib.optionalAttrs buildDocs texlive.combine {
inherit (texlive) scheme-small
latexmk
tex-gyre
fncychap
wrapfig
capt-of
framed
needspace
tabulary
varwidth
titlesec;
};
in stdenv.mkDerivation (finalAttrs: {
pname = "miopengemm";
version = "5.3.3";
outputs = [
"out"
] ++ lib.optionals buildDocs [
"doc"
] ++ lib.optionals buildTests [
"test"
] ++ lib.optionals buildBenchmarks [
"benchmark"
];
src = fetchFromGitHub {
owner = "ROCmSoftwarePlatform";
repo = "MIOpenGEMM";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-AiRzOMYRA/0nbQomyq4oOEwNZdkPYWRA2W6QFlctvFc=";
};
nativeBuildInputs = [
cmake
rocm-cmake
clang
];
buildInputs = [
rocm-opencl-runtime
] ++ lib.optionals buildDocs [
latex
doxygen
sphinx
python3Packages.sphinx-rtd-theme
python3Packages.breathe
] ++ lib.optionals buildTests [
openblas
];
cmakeFlags = [
"-DCMAKE_C_COMPILER=clang"
"-DCMAKE_CXX_COMPILER=clang++"
# 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 buildTests [
"-DOPENBLAS=ON"
] ++ lib.optionals buildBenchmarks [
"-DAPI_BENCH_MIOGEMM=ON"
# Needs https://github.com/CNugteren/CLBlast
# "-DAPI_BENCH_CLBLAST=ON"
# Needs https://github.com/openai/triton
# "-DAPI_BENCH_ISAAC=ON"
];
# Unfortunately, it seems like we have to call make on these manually
postBuild = lib.optionalString buildDocs ''
export HOME=$(mktemp -d)
make doc
'' + lib.optionalString buildTests ''
make check
'' + lib.optionalString buildBenchmarks ''
make examples
'';
postInstall = lib.optionalString buildDocs ''
mv ../doc/html $out/share/doc/miopengemm
mv ../doc/pdf/miopengemm.pdf $out/share/doc/miopengemm
'' + lib.optionalString buildTests ''
mkdir -p $test/bin
find tests -executable -type f -exec mv {} $test/bin \;
patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $test/bin/*
'' + lib.optionalString buildBenchmarks ''
mkdir -p $benchmark/bin
find examples -executable -type f -exec mv {} $benchmark/bin \;
patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $benchmark/bin/*
'';
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
version="$(curl ''${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
-sL "https://api.github.com/repos/ROCmSoftwarePlatform/MIOpenGEMM/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
update-source-version miopengemm "$version" --ignore-same-hash
'';
meta = with lib; {
description = "OpenCL general matrix multiplication API for ROCm";
homepage = "https://github.com/ROCmSoftwarePlatform/MIOpenGEMM";
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
broken = finalAttrs.version != clang.version;
};
})