2022-12-14 08:04:14 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-09-01 19:51:43 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
2022-12-14 08:04:14 +00:00
|
|
|
, rocmUpdateScript
|
|
|
|
, substituteAll
|
2021-09-01 19:51:43 +00:00
|
|
|
, makeWrapper
|
2022-12-14 08:04:14 +00:00
|
|
|
, hip-common
|
|
|
|
, hipcc
|
2021-09-01 19:51:43 +00:00
|
|
|
, rocclr
|
2022-12-14 08:04:14 +00:00
|
|
|
, roctracer
|
|
|
|
, cmake
|
|
|
|
, perl
|
|
|
|
, llvm
|
|
|
|
, rocminfo
|
|
|
|
, rocm-thunk
|
2021-09-01 19:51:43 +00:00
|
|
|
, rocm-comgr
|
|
|
|
, rocm-device-libs
|
|
|
|
, rocm-runtime
|
2022-12-14 08:04:14 +00:00
|
|
|
, rocm-opencl-runtime
|
|
|
|
, cudatoolkit
|
|
|
|
, numactl
|
|
|
|
, libxml2
|
|
|
|
, libX11
|
|
|
|
, libglvnd
|
|
|
|
, doxygen
|
|
|
|
, graphviz
|
|
|
|
, fontconfig
|
|
|
|
, python3Packages
|
|
|
|
, buildDocs ? true
|
|
|
|
, buildTests ? false
|
|
|
|
, useNVIDIA ? false
|
2021-09-01 19:51:43 +00:00
|
|
|
}:
|
|
|
|
|
2021-11-08 10:10:33 +00:00
|
|
|
let
|
2022-12-14 08:04:14 +00:00
|
|
|
hipPlatform = if useNVIDIA then "nvidia" else "amd";
|
|
|
|
|
|
|
|
wrapperArgs = [
|
|
|
|
"--prefix PATH : $out/bin"
|
|
|
|
"--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
|
|
|
|
"--set HIP_PLATFORM ${hipPlatform}"
|
|
|
|
"--set HIP_PATH $out"
|
|
|
|
"--set HIP_CLANG_PATH ${stdenv.cc}/bin"
|
|
|
|
"--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
|
|
|
|
"--set HSA_PATH ${rocm-runtime}"
|
|
|
|
"--set ROCM_PATH $out"
|
|
|
|
] ++ lib.optionals useNVIDIA [
|
|
|
|
"--set CUDA_PATH ${cudatoolkit}"
|
|
|
|
];
|
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "hip-${hipPlatform}";
|
2022-12-16 15:24:05 +00:00
|
|
|
version = "5.4.1";
|
2021-11-08 10:10:33 +00:00
|
|
|
|
2022-12-14 08:04:14 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
"doc"
|
|
|
|
];
|
|
|
|
|
2021-09-01 19:51:43 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ROCm-Developer-Tools";
|
2021-11-08 10:10:33 +00:00
|
|
|
repo = "hipamd";
|
2022-11-24 02:17:04 +00:00
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2022-12-04 00:26:46 +00:00
|
|
|
hash = "sha256-VL0vZVv099pZPX0J2pXPFvrhkVO/b6X+ZZDaD9B1hYI=";
|
2021-09-01 19:51:43 +00:00
|
|
|
};
|
|
|
|
|
2022-09-11 20:51:09 +00:00
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
2022-12-14 08:04:14 +00:00
|
|
|
src = ./0000-fixup-paths.patch;
|
|
|
|
inherit llvm;
|
|
|
|
clang = stdenv.cc;
|
2022-09-11 20:51:09 +00:00
|
|
|
rocm_runtime = rocm-runtime;
|
|
|
|
})
|
2022-12-14 08:04:14 +00:00
|
|
|
|
|
|
|
# https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9.patch";
|
|
|
|
hash = "sha256-eTC4mUIN1FwRce1n38uDOlITFL/vpcOhvnaZTo5R7lo=";
|
|
|
|
})
|
2022-09-11 20:51:09 +00:00
|
|
|
];
|
|
|
|
|
2022-12-14 08:04:14 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
cmake
|
|
|
|
perl
|
|
|
|
python3Packages.python
|
|
|
|
python3Packages.cppheaderparser
|
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
doxygen
|
|
|
|
graphviz
|
|
|
|
fontconfig
|
|
|
|
];
|
2022-10-05 11:52:20 +00:00
|
|
|
|
2022-12-14 08:04:14 +00:00
|
|
|
buildInputs = [
|
|
|
|
numactl
|
|
|
|
libxml2
|
|
|
|
libX11
|
|
|
|
libglvnd
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
stdenv.cc
|
|
|
|
llvm
|
|
|
|
rocminfo
|
|
|
|
rocm-thunk
|
|
|
|
rocm-comgr
|
|
|
|
rocm-device-libs
|
|
|
|
rocm-runtime
|
|
|
|
rocm-opencl-runtime
|
|
|
|
] ++ lib.optionals useNVIDIA [
|
|
|
|
cudatoolkit
|
|
|
|
];
|
2021-09-01 19:51:43 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2022-12-14 08:04:14 +00:00
|
|
|
"-DROCM_PATH=${rocminfo}"
|
|
|
|
"-DHIP_PLATFORM=${hipPlatform}"
|
|
|
|
"-DHIP_COMMON_DIR=${hip-common}"
|
|
|
|
"-DHIPCC_BIN_DIR=${hipcc}/bin"
|
|
|
|
"-DHIP_LLVM_ROOT=${stdenv.cc}"
|
2021-11-08 10:10:33 +00:00
|
|
|
"-DROCCLR_PATH=${rocclr}"
|
2022-12-14 08:04:14 +00:00
|
|
|
"-DAMD_OPENCL_PATH=${rocm-opencl-runtime.src}"
|
|
|
|
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
|
2022-10-26 06:06:24 +00:00
|
|
|
# Temporarily set variables to work around upstream CMakeLists issue
|
|
|
|
# Can be removed once https://github.com/ROCm-Developer-Tools/hipamd/issues/55 is fixed
|
|
|
|
"-DCMAKE_INSTALL_BINDIR=bin"
|
|
|
|
"-DCMAKE_INSTALL_INCLUDEDIR=include"
|
|
|
|
"-DCMAKE_INSTALL_LIBDIR=lib"
|
2022-12-14 08:04:14 +00:00
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
"-DHIP_CATCH_TEST=1"
|
2021-09-01 19:51:43 +00:00
|
|
|
];
|
|
|
|
|
2022-12-14 08:04:14 +00:00
|
|
|
postPatch = ''
|
|
|
|
export HIP_CLANG_PATH=${stdenv.cc}/bin
|
|
|
|
patchShebangs src
|
|
|
|
'' + lib.optionalString buildDocs ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = buildTests;
|
|
|
|
checkTarget = "build_tests";
|
|
|
|
|
|
|
|
preCheck = lib.optionalString buildTests ''
|
|
|
|
export ROCM_PATH=$PWD
|
|
|
|
export DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode
|
|
|
|
patchShebangs bin
|
|
|
|
'';
|
|
|
|
|
2021-09-01 19:51:43 +00:00
|
|
|
postInstall = ''
|
2022-08-16 17:20:55 +00:00
|
|
|
patchShebangs $out/bin
|
2022-12-14 08:04:14 +00:00
|
|
|
cp -a $out/bin/hipcc $out/bin/hipcc-pl
|
|
|
|
cp -a $out/bin/hipconfig $out/bin/hipconfig-pl
|
|
|
|
wrapProgram $out/bin/hipcc --set HIP_USE_PERL_SCRIPTS 0
|
|
|
|
wrapProgram $out/bin/hipconfig --set HIP_USE_PERL_SCRIPTS 0
|
|
|
|
wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipcc-pl --set HIP_USE_PERL_SCRIPTS 1
|
|
|
|
wrapProgram $out/bin/hipconfig-pl --set HIP_USE_PERL_SCRIPTS 1
|
|
|
|
wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
|
|
|
|
wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
|
2021-09-01 19:51:43 +00:00
|
|
|
'';
|
2021-09-09 12:02:40 +00:00
|
|
|
|
2022-12-14 08:04:14 +00:00
|
|
|
passthru.updateScript = rocmUpdateScript {
|
|
|
|
name = finalAttrs.pname;
|
|
|
|
owner = finalAttrs.src.owner;
|
|
|
|
repo = finalAttrs.src.repo;
|
|
|
|
};
|
2021-09-09 12:02:40 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2022-12-14 08:04:14 +00:00
|
|
|
description = "C++ Heterogeneous-Compute Interface for Portability specifically for AMD platform";
|
2021-11-08 10:10:33 +00:00
|
|
|
homepage = "https://github.com/ROCm-Developer-Tools/hipamd";
|
2022-12-14 08:04:14 +00:00
|
|
|
license = with licenses; [ mit ];
|
2022-11-24 01:29:33 +00:00
|
|
|
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
|
2021-09-09 12:02:40 +00:00
|
|
|
platforms = platforms.linux;
|
2022-12-14 08:04:14 +00:00
|
|
|
# Tests require GPU, also include issues
|
|
|
|
broken = finalAttrs.version != hip-common.version || finalAttrs.version != hipcc.version || buildTests;
|
2021-09-09 12:02:40 +00:00
|
|
|
};
|
2022-11-24 02:17:04 +00:00
|
|
|
})
|