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
|
|
|
|
, rocm-opencl-runtime
|
2022-12-02 08:20:57 +00:00
|
|
|
, texlive
|
|
|
|
, doxygen
|
|
|
|
, sphinx
|
|
|
|
, openblas
|
|
|
|
, python3Packages
|
|
|
|
, buildDocs ? true
|
2022-11-04 12:27:35 +00:00
|
|
|
, buildTests ? false
|
|
|
|
, buildBenchmarks ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-12-02 08:20:57 +00:00
|
|
|
latex = lib.optionalAttrs buildDocs texlive.combine {
|
2022-11-04 12:27:35 +00:00
|
|
|
inherit (texlive) scheme-small
|
|
|
|
latexmk
|
|
|
|
tex-gyre
|
|
|
|
fncychap
|
|
|
|
wrapfig
|
|
|
|
capt-of
|
|
|
|
framed
|
|
|
|
needspace
|
|
|
|
tabulary
|
|
|
|
varwidth
|
|
|
|
titlesec;
|
2022-12-02 08:20:57 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2022-11-04 12:27:35 +00:00
|
|
|
pname = "miopengemm";
|
2023-03-08 16:32:21 +00:00
|
|
|
version = "5.4.3";
|
2022-11-04 12:27:35 +00:00
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals buildDocs [
|
2022-12-02 08:20:57 +00:00
|
|
|
"doc"
|
2022-11-04 12:27:35 +00:00
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
"test"
|
|
|
|
] ++ lib.optionals buildBenchmarks [
|
|
|
|
"benchmark"
|
|
|
|
];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ROCmSoftwarePlatform";
|
|
|
|
repo = "MIOpenGEMM";
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2022-11-04 12:27:35 +00:00
|
|
|
hash = "sha256-AiRzOMYRA/0nbQomyq4oOEwNZdkPYWRA2W6QFlctvFc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
rocm-cmake
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
rocm-opencl-runtime
|
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
latex
|
|
|
|
doxygen
|
|
|
|
sphinx
|
2022-12-02 08:20:57 +00:00
|
|
|
python3Packages.sphinx-rtd-theme
|
2022-11-04 12:27:35 +00:00
|
|
|
python3Packages.breathe
|
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
openblas
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2022-12-02 08:20:57 +00:00
|
|
|
postInstall = lib.optionalString buildDocs ''
|
|
|
|
mv ../doc/html $out/share/doc/miopengemm
|
|
|
|
mv ../doc/pdf/miopengemm.pdf $out/share/doc/miopengemm
|
|
|
|
'' + lib.optionalString buildTests ''
|
2022-11-04 12:27:35 +00:00
|
|
|
mkdir -p $test/bin
|
|
|
|
find tests -executable -type f -exec mv {} $test/bin \;
|
2022-11-27 09:42:12 +00:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $test/bin/*
|
2022-11-04 12:27:35 +00:00
|
|
|
'' + lib.optionalString buildBenchmarks ''
|
|
|
|
mkdir -p $benchmark/bin
|
|
|
|
find examples -executable -type f -exec mv {} $benchmark/bin \;
|
2022-11-27 09:42:12 +00:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $benchmark/bin/*
|
2022-11-04 12:27:35 +00:00
|
|
|
'';
|
|
|
|
|
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 = "OpenCL general matrix multiplication API for ROCm";
|
|
|
|
homepage = "https://github.com/ROCmSoftwarePlatform/MIOpenGEMM";
|
|
|
|
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 stdenv.cc.version;
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|