nixpkgs/pkgs/development/libraries/rocmlir/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
2.6 KiB
Nix
Raw Normal View History

2022-11-03 11:20:02 +00:00
{ lib
, stdenv
, fetchFromGitHub
, rocmUpdateScript
2022-11-03 11:20:02 +00:00
, cmake
, ninja
, hip
, rocminfo
, git
, libxml2
, libedit
, zlib
, ncurses
2022-11-03 11:20:02 +00:00
, python3
, buildRockCompiler ? false
2022-11-03 11:20:02 +00:00
}:
# Theoretically, we could have our MLIR have an output
# with the source and built objects so that we can just
# use it as the external LLVM repo for this
let
llvmNativeTarget =
if stdenv.isx86_64 then "X86"
else if stdenv.isAarch64 then "AArch64"
else throw "Unsupported ROCm LLVM platform";
in stdenv.mkDerivation (finalAttrs: {
2022-11-03 11:20:02 +00:00
pname = "rocmlir";
version = "5.4.1";
2022-11-03 11:20:02 +00:00
outputs = [
"out"
] ++ lib.optionals (!buildRockCompiler) [
"external"
];
2022-11-03 11:20:02 +00:00
src = fetchFromGitHub {
owner = "ROCmSoftwarePlatform";
repo = "rocMLIR";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-MokE7Ej8mLHTQeLYvKr7PPlsNG6ul91fqfXDlGu5JpI=";
2022-11-03 11:20:02 +00:00
};
nativeBuildInputs = [
cmake
ninja
] ++ lib.optionals (!buildRockCompiler) [
hip
2022-11-03 11:20:02 +00:00
];
buildInputs = [
git
libxml2
libedit
2022-11-03 11:20:02 +00:00
python3
];
propagatedBuildInputs = [
zlib
ncurses
];
2022-11-03 11:20:02 +00:00
cmakeFlags = [
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
"-DLLVM_ENABLE_ZLIB=ON"
"-DLLVM_ENABLE_TERMINFO=ON"
] ++ lib.optionals buildRockCompiler [
"-DBUILD_FAT_LIBROCKCOMPILER=ON"
] ++ lib.optionals (!buildRockCompiler) [
"-DROCM_PATH=${rocminfo}"
"-DROCM_TEST_CHIPSET=gfx000"
2022-11-03 11:20:02 +00:00
];
dontBuild = true;
doCheck = true;
# Certain libs aren't being generated, try enabling tests next update
checkTarget = if buildRockCompiler
then "librockCompiler"
else "check-mlir-miopen-build-only";
postInstall = let
libPath = lib.makeLibraryPath [ zlib ncurses hip stdenv.cc.cc ];
in lib.optionals (!buildRockCompiler) ''
mkdir -p $external/lib
cp -a external/llvm-project/llvm/lib/{*.a*,*.so*} $external/lib
patchelf --set-rpath $external/lib:$out/lib:${libPath} $external/lib/*.so*
patchelf --set-rpath $out/lib:$external/lib:${libPath} $out/{bin/*,lib/*.so*}
'';
passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
page = "tags?per_page=2";
filter = ".[1].name | split(\"-\") | .[1]";
};
2022-11-03 11:20:02 +00:00
meta = with lib; {
description = "MLIR-based convolution and GEMM kernel generator";
homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR";
license = with licenses; [ asl20 ];
maintainers = teams.rocm.members;
2023-01-18 08:25:46 +00:00
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
2022-11-03 11:20:02 +00:00
};
})