Skip to content

Commit

Permalink
rocm-related: fixup for ROCm 5.7.0
Browse files Browse the repository at this point in the history
blender: fixup for ROCm 5.7.0

opensycl: fixup for ROCm 5.7.0

magma: fixup for ROCm 5.7.0

torch: fixup for ROCm 5.7.0
  • Loading branch information
Madouura committed Oct 5, 2023
1 parent d30efcd commit 4072599
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
6 changes: 3 additions & 3 deletions pkgs/applications/misc/blender/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
, zlib, zstd, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath
, jackaudioSupport ? false, libjack2
, cudaSupport ? config.cudaSupport, cudaPackages ? { }
, hipSupport ? false, hip # comes with a significantly larger closure size
, hipSupport ? false, rocmPackages # comes with a significantly larger closure size
, colladaSupport ? true, opencollada
, spaceNavSupport ? stdenv.isLinux, libspnav
, makeWrapper
Expand Down Expand Up @@ -103,8 +103,8 @@ stdenv.mkDerivation (finalAttrs: rec {
substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"'
'') +
(lib.optionalString hipSupport ''
substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${hip}/lib/libamdhip64.so"'
substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${hip}/bin"'
substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${rocmPackages.clr}/lib/libamdhip64.so"'
substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${rocmPackages.clr}/bin"'
'');

cmakeFlags =
Expand Down
10 changes: 4 additions & 6 deletions pkgs/development/compilers/opensycl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
, fetchFromGitHub
, llvmPackages_15
, lld_15
, rocm-device-libs
, python3
, rocm-runtime
, cmake
, boost
, libxml2
, libffi
, makeWrapper
, hip
, rocmPackages
, rocmSupport ? false
}:
let
Expand Down Expand Up @@ -40,8 +38,8 @@ stdenv.mkDerivation rec {
llvmPackages_15.libclang.dev
llvmPackages_15.llvm
] ++ lib.optionals rocmSupport [
hip
rocm-runtime
rocmPackages.clr
rocmPackages.rocm-runtime
];

# opensycl makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually
Expand All @@ -55,7 +53,7 @@ stdenv.mkDerivation rec {
--add-flags "-L${llvmPackages_15.openmp}/lib" \
--add-flags "-I${llvmPackages_15.openmp.dev}/include" \
'' + lib.optionalString rocmSupport ''
--add-flags "--rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
--add-flags "--rocm-device-lib-path=${rocmPackages.rocm-device-libs}/amdgcn/bitcode"
'';

meta = with lib; {
Expand Down
19 changes: 8 additions & 11 deletions pkgs/development/libraries/science/math/magma/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
, gfortran
, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
, gpuTargets ? [ ] # Non-CUDA targets, that is HIP
, hip
, hipblas
, hipsparse
, rocmPackages
, lapack
, lib
, libpthreadstubs
, magmaRelease
, ninja
, openmp
, rocmSupport ? false
, static ? false
, stdenv
Expand All @@ -47,7 +44,7 @@ let
# NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like cudaFlags.realArches.
# For some reason, Magma's CMakeLists.txt file does not handle the "gfx" prefix, so we must
# remove it.
rocmArches = lists.map (x: strings.removePrefix "gfx" x) hip.gpuTargets;
rocmArches = lists.map (x: strings.removePrefix "gfx" x) rocmPackages.clr.gpuTargets;
supportedRocmArches = lists.intersectLists rocmArches supportedGpuTargets;
unsupportedRocmArches = lists.subtractLists supportedRocmArches rocmArches;

Expand Down Expand Up @@ -125,10 +122,10 @@ stdenv.mkDerivation {
] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [
cuda_profiler_api.dev # <cuda_profiler_api.h>
]) ++ lists.optionals rocmSupport [
hip
hipblas
hipsparse
openmp
rocmPackages.clr
rocmPackages.hipblas
rocmPackages.hipsparse
rocmPackages.llvm.openmp
];

cmakeFlags = [
Expand All @@ -142,8 +139,8 @@ stdenv.mkDerivation {
"-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++"
"-DMAGMA_ENABLE_CUDA=ON"
] ++ lists.optionals rocmSupport [
"-DCMAKE_C_COMPILER=${hip}/bin/hipcc"
"-DCMAKE_CXX_COMPILER=${hip}/bin/hipcc"
"-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc"
"-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc"
"-DMAGMA_ENABLE_HIP=ON"
];

Expand Down
12 changes: 6 additions & 6 deletions pkgs/development/python-modules/torch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
# ROCm dependencies
rocmSupport ? false,
gpuTargets ? [ ],
openmp, rocm-core, hip, rccl, miopen, miopengemm, rocrand, rocblas,
openmp, rocm-core, clr, rccl, miopen, miopengemm, rocrand, rocblas,
rocfft, rocsparse, hipsparse, rocthrust, rocprim, hipcub, roctracer,
rocsolver, hipfft, hipsolver, hipblas, rocminfo, rocm-thunk, rocm-comgr,
rocm-device-libs, rocm-runtime, rocm-opencl-runtime, hipify
rocm-device-libs, rocm-runtime, hipify
}:

let
Expand Down Expand Up @@ -89,7 +89,7 @@ let
else if cudaSupport then
gpuArchWarner supportedCudaCapabilities unsupportedCudaCapabilities
else if rocmSupport then
hip.gpuTargets
clr.gpuTargets
else
throw "No GPU targets specified"
);
Expand All @@ -98,11 +98,11 @@ let
name = "rocm-merged";

paths = [
rocm-core hip rccl miopen miopengemm rocrand rocblas
rocm-core clr rccl miopen miopengemm rocrand rocblas
rocfft rocsparse hipsparse rocthrust rocprim hipcub
roctracer rocfft rocsolver hipfft hipsolver hipblas
rocminfo rocm-thunk rocm-comgr rocm-device-libs
rocm-runtime rocm-opencl-runtime hipify
rocm-runtime clr.icd hipify
];
};

Expand Down Expand Up @@ -170,7 +170,7 @@ in buildPythonPackage rec {
# Strangely, this is never set in cmake
substituteInPlace cmake/public/LoadHIP.cmake \
--replace "set(ROCM_PATH \$ENV{ROCM_PATH})" \
"set(ROCM_PATH \$ENV{ROCM_PATH})''\nset(ROCM_VERSION ${lib.concatStrings (lib.intersperse "0" (lib.splitString "." hip.version))})"
"set(ROCM_PATH \$ENV{ROCM_PATH})''\nset(ROCM_VERSION ${lib.concatStrings (lib.intersperse "0" (lib.splitString "." clr.version))})"
''
# Detection of NCCL version doesn't work particularly well when using the static binary.
+ lib.optionalString cudaSupport ''
Expand Down
9 changes: 2 additions & 7 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30666,7 +30666,6 @@ with pkgs;
# LLVM 11 crashes when compiling GHOST_SystemCocoa.mm
stdenv = if stdenv.isDarwin then llvmPackages_10.stdenv else stdenv;
inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics ForceFeedback OpenAL OpenGL;
inherit (rocmPackages) hip;
};

blender-with-packages = callPackage ../applications/misc/blender/wrapper.nix { };
Expand Down Expand Up @@ -39222,10 +39221,7 @@ with pkgs;

lie = callPackage ../applications/science/math/LiE { };

inherit (callPackage ../development/libraries/science/math/magma {
inherit (rocmPackages.llvm) openmp;
inherit (rocmPackages) hip hipblas hipsparse;
}) magma magma_2_7_2 magma_2_6_2;
inherit (callPackage ../development/libraries/science/math/magma { }) magma magma_2_7_2 magma_2_6_2;

magma-cuda = magma.override {
cudaSupport = true;
Expand All @@ -39236,8 +39232,7 @@ with pkgs;
static = true;
};

# TODO:AMD won't compile with anything newer than 2.6.2 -- it fails at the linking stage.
magma-hip = magma_2_6_2.override {
magma-hip = magma.override {
cudaSupport = false;
rocmSupport = true;
};
Expand Down

0 comments on commit 4072599

Please sign in to comment.