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
|
2023-01-20 10:41:00 +00:00
|
|
|
, ninja
|
|
|
|
, hip
|
|
|
|
, rocminfo
|
2022-12-17 10:02:37 +00:00
|
|
|
, git
|
|
|
|
, libxml2
|
|
|
|
, libedit
|
2023-01-20 10:41:00 +00:00
|
|
|
, zlib
|
|
|
|
, ncurses
|
2022-11-04 12:27:35 +00:00
|
|
|
, python3
|
2023-01-20 10:41:00 +00:00
|
|
|
, buildRockCompiler ? false
|
2022-11-04 12:27:35 +00:00
|
|
|
}:
|
|
|
|
|
2023-01-20 10:41:00 +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-04 12:27:35 +00:00
|
|
|
pname = "rocmlir";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "5.4.1";
|
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals (!buildRockCompiler) [
|
|
|
|
"external"
|
|
|
|
];
|
2022-11-04 12:27:35 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ROCmSoftwarePlatform";
|
|
|
|
repo = "rocMLIR";
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2022-12-17 10:02:37 +00:00
|
|
|
hash = "sha256-MokE7Ej8mLHTQeLYvKr7PPlsNG6ul91fqfXDlGu5JpI=";
|
2022-11-04 12:27:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
2023-01-20 10:41:00 +00:00
|
|
|
ninja
|
|
|
|
] ++ lib.optionals (!buildRockCompiler) [
|
|
|
|
hip
|
2022-11-04 12:27:35 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2022-12-17 10:02:37 +00:00
|
|
|
git
|
|
|
|
libxml2
|
|
|
|
libedit
|
2022-11-04 12:27:35 +00:00
|
|
|
python3
|
|
|
|
];
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
zlib
|
|
|
|
ncurses
|
|
|
|
];
|
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
cmakeFlags = [
|
2023-01-20 10:41:00 +00:00
|
|
|
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
|
|
|
|
"-DLLVM_ENABLE_ZLIB=ON"
|
|
|
|
"-DLLVM_ENABLE_TERMINFO=ON"
|
|
|
|
] ++ lib.optionals buildRockCompiler [
|
2022-12-17 10:02:37 +00:00
|
|
|
"-DBUILD_FAT_LIBROCKCOMPILER=ON"
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (!buildRockCompiler) [
|
|
|
|
"-DROCM_PATH=${rocminfo}"
|
|
|
|
"-DROCM_TEST_CHIPSET=gfx000"
|
2022-11-04 12:27:35 +00:00
|
|
|
];
|
|
|
|
|
2023-01-20 10:41:00 +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*}
|
|
|
|
'';
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
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-27 09:42:12 +00:00
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "MLIR-based convolution and GEMM kernel generator";
|
|
|
|
homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR";
|
|
|
|
license = with licenses; [ asl20 ];
|
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
|
|
|
})
|