2023-10-19 13:55:26 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, callPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, rocmUpdateScript
|
|
|
|
, makeWrapper
|
|
|
|
, cmake
|
|
|
|
, perl
|
|
|
|
, clang
|
|
|
|
, hip-common
|
|
|
|
, hipcc
|
|
|
|
, rocm-device-libs
|
|
|
|
, rocm-comgr
|
|
|
|
, rocm-runtime
|
|
|
|
, roctracer
|
|
|
|
, rocminfo
|
|
|
|
, rocm-smi
|
|
|
|
, numactl
|
|
|
|
, libGL
|
|
|
|
, libxml2
|
|
|
|
, libX11
|
|
|
|
, python3Packages
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
wrapperArgs = [
|
|
|
|
"--prefix PATH : $out/bin"
|
|
|
|
"--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
|
|
|
|
"--set HIP_PLATFORM amd"
|
|
|
|
"--set HIP_PATH $out"
|
|
|
|
"--set HIP_CLANG_PATH ${clang}/bin"
|
|
|
|
"--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
|
|
|
|
"--set HSA_PATH ${rocm-runtime}"
|
|
|
|
"--set ROCM_PATH $out"
|
|
|
|
];
|
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "clr";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "5.7.1";
|
2023-10-19 13:55:26 +00:00
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"icd"
|
|
|
|
];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2024-01-02 11:29:13 +00:00
|
|
|
owner = "ROCm";
|
2023-10-19 13:55:26 +00:00
|
|
|
repo = "clr";
|
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-1gZJhvBbUFdKH9p/7SRfzEV/fM+gIN2Qvlxf2VbmAIw=";
|
2023-10-19 13:55:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
cmake
|
|
|
|
perl
|
|
|
|
python3Packages.python
|
|
|
|
python3Packages.cppheaderparser
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
numactl
|
|
|
|
libGL
|
|
|
|
libxml2
|
|
|
|
libX11
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
rocm-device-libs
|
|
|
|
rocm-comgr
|
|
|
|
rocm-runtime
|
|
|
|
rocminfo
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCMAKE_POLICY_DEFAULT_CMP0072=NEW" # Prefer newer OpenGL libraries
|
|
|
|
"-DCLR_BUILD_HIP=ON"
|
|
|
|
"-DCLR_BUILD_OCL=ON"
|
|
|
|
"-DHIP_COMMON_DIR=${hip-common}"
|
|
|
|
"-DHIPCC_BIN_DIR=${hipcc}/bin"
|
|
|
|
"-DHIP_PLATFORM=amd"
|
|
|
|
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
|
|
|
|
"-DROCM_PATH=${rocminfo}"
|
|
|
|
|
|
|
|
# Temporarily set variables to work around upstream CMakeLists issue
|
2024-01-02 11:29:13 +00:00
|
|
|
# Can be removed once https://github.com/ROCm/rocm-cmake/issues/121 is fixed
|
2023-10-19 13:55:26 +00:00
|
|
|
"-DCMAKE_INSTALL_BINDIR=bin"
|
|
|
|
"-DCMAKE_INSTALL_INCLUDEDIR=include"
|
|
|
|
"-DCMAKE_INSTALL_LIBDIR=lib"
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs hipamd/src
|
|
|
|
|
|
|
|
# We're not on Windows so these are never installed to hipcc...
|
|
|
|
substituteInPlace hipamd/CMakeLists.txt \
|
|
|
|
--replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \
|
|
|
|
--replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" ""
|
|
|
|
|
|
|
|
substituteInPlace hipamd/src/hip_embed_pch.sh \
|
|
|
|
--replace "\''$LLVM_DIR/bin/clang" "${clang}/bin/clang"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
patchShebangs $out/bin
|
|
|
|
|
|
|
|
# hipcc.bin and hipconfig.bin is mysteriously never installed
|
|
|
|
cp -a ${hipcc}/bin/{hipcc.bin,hipconfig.bin} $out/bin
|
|
|
|
|
|
|
|
wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
|
|
|
|
# Just link rocminfo, it's easier
|
|
|
|
ln -s ${rocminfo}/bin/* $out/bin
|
|
|
|
|
|
|
|
# Replace rocm-opencl-icd functionality
|
|
|
|
mkdir -p $icd/etc/OpenCL/vendors
|
|
|
|
echo "$out/lib/libamdocl64.so" > $icd/etc/OpenCL/vendors/amdocl64.icd
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
# All known and valid general GPU targets
|
|
|
|
# We cannot use this for each ROCm library, as each defines their own supported targets
|
2024-01-02 11:29:13 +00:00
|
|
|
# See: https://github.com/ROCm/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix
|
2023-10-19 13:55:26 +00:00
|
|
|
gpuTargets = lib.forEach [
|
|
|
|
"803"
|
|
|
|
"900"
|
|
|
|
"906"
|
|
|
|
"908"
|
|
|
|
"90a"
|
|
|
|
"940"
|
|
|
|
"941"
|
|
|
|
"942"
|
|
|
|
"1010"
|
|
|
|
"1012"
|
|
|
|
"1030"
|
|
|
|
"1100"
|
|
|
|
"1101"
|
|
|
|
"1102"
|
|
|
|
] (target: "gfx${target}");
|
|
|
|
|
|
|
|
updateScript = rocmUpdateScript {
|
|
|
|
name = finalAttrs.pname;
|
|
|
|
owner = finalAttrs.src.owner;
|
|
|
|
repo = finalAttrs.src.repo;
|
2023-11-16 04:20:00 +00:00
|
|
|
page = "tags?per_page=1";
|
|
|
|
filter = ".[0].name | split(\"-\") | .[1]";
|
2023-10-19 13:55:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
impureTests = {
|
|
|
|
rocm-smi = callPackage ./test-rocm-smi.nix {
|
|
|
|
inherit rocm-smi;
|
|
|
|
clr = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
opencl-example = callPackage ./test-opencl-example.nix {
|
|
|
|
clr = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "AMD Common Language Runtime for hipamd, opencl, and rocclr";
|
2024-01-02 11:29:13 +00:00
|
|
|
homepage = "https://github.com/ROCm/clr";
|
2023-10-19 13:55:26 +00:00
|
|
|
license = with licenses; [ mit ];
|
|
|
|
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
|
|
|
|
platforms = platforms.linux;
|
2024-01-02 11:29:13 +00:00
|
|
|
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || versionAtLeast finalAttrs.version "6.0.0";
|
2023-10-19 13:55:26 +00:00
|
|
|
};
|
|
|
|
})
|