nixpkgs/pkgs/development/compilers/hip/default.nix
Madoura 9e0472e206
rocm-related: 5.4.0 → 5.4.1
clang-ocl: 5.4.0 → 5.4.1

hipsparse: 5.4.0 → 5.4.1

composable_kernel: unstable-2022-12-08 → unstable-2022-12-15

llvmPackages_rocm.llvm: 5.4.0 → 5.4.1

miopen: 5.4.0 → 5.4.1

miopengemm: 5.4.0 → 5.4.1

rccl: 5.4.0 → 5.4.1

rocalution: 5.4.0 → 5.4.1

hipcub: 5.4.0 → 5.4.1

rocclr: 5.4.0 → 5.4.1

rocfft: 5.4.0 → 5.4.1

rocm-cmake: 5.4.0 → 5.4.1

rocm-comgr: 5.4.0 → 5.4.1

rocm-device-libs: 5.4.0 → 5.4.1

hip: 5.4.0 → 5.4.1

rocblas: 5.4.0 → 5.4.1

rocm-runtime: 5.4.0 → 5.4.1

rocm-opencl-runtime: 5.4.0 → 5.4.1

rocm-thunk: 5.4.0 → 5.4.1

rocprim: 5.4.0 → 5.4.1

rocm-smi: 5.4.0 → 5.4.1

rocminfo: 5.4.0 → 5.4.1

rocsolver: 5.4.0 → 5.4.1

rocrand: 5.4.0 → 5.4.1

rocthrust: 5.4.0 → 5.4.1

rocprofiler: 5.4.0 → 5.4.1

rocwmma: 5.4.0 → 5.4.1

roctracer: 5.4.0 → 5.4.1

rocsparse: 5.4.0 → 5.4.1

tensile: 5.4.0 → 5.4.1
2022-12-18 12:39:58 -06:00

179 lines
4.6 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, rocmUpdateScript
, substituteAll
, makeWrapper
, hip-common
, hipcc
, rocclr
, roctracer
, cmake
, perl
, llvm
, rocminfo
, rocm-thunk
, rocm-comgr
, rocm-device-libs
, rocm-runtime
, rocm-opencl-runtime
, cudatoolkit
, numactl
, libxml2
, libX11
, libglvnd
, doxygen
, graphviz
, fontconfig
, python3Packages
, buildDocs ? true
, buildTests ? false
, useNVIDIA ? false
}:
let
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}";
version = "5.4.1";
outputs = [
"out"
] ++ lib.optionals buildDocs [
"doc"
];
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "hipamd";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-VL0vZVv099pZPX0J2pXPFvrhkVO/b6X+ZZDaD9B1hYI=";
};
patches = [
(substituteAll {
src = ./0000-fixup-paths.patch;
inherit llvm;
clang = stdenv.cc;
rocm_runtime = rocm-runtime;
})
# 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=";
})
];
nativeBuildInputs = [
makeWrapper
cmake
perl
python3Packages.python
python3Packages.cppheaderparser
] ++ lib.optionals buildDocs [
doxygen
graphviz
fontconfig
];
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
];
cmakeFlags = [
"-DROCM_PATH=${rocminfo}"
"-DHIP_PLATFORM=${hipPlatform}"
"-DHIP_COMMON_DIR=${hip-common}"
"-DHIPCC_BIN_DIR=${hipcc}/bin"
"-DHIP_LLVM_ROOT=${stdenv.cc}"
"-DROCCLR_PATH=${rocclr}"
"-DAMD_OPENCL_PATH=${rocm-opencl-runtime.src}"
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
# 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"
] ++ lib.optionals buildTests [
"-DHIP_CATCH_TEST=1"
];
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
'';
postInstall = ''
patchShebangs $out/bin
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}
'';
passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
meta = with lib; {
description = "C++ Heterogeneous-Compute Interface for Portability specifically for AMD platform";
homepage = "https://github.com/ROCm-Developer-Tools/hipamd";
license = with licenses; [ mit ];
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
platforms = platforms.linux;
# Tests require GPU, also include issues
broken = finalAttrs.version != hip-common.version || finalAttrs.version != hipcc.version || buildTests;
};
})