diff options
author | Madoura <madouura@gmail.com> | 2023-10-01 20:05:32 -0500 |
---|---|---|
committer | Madoura <madouura@gmail.com> | 2023-10-09 16:38:51 -0500 |
commit | 575ce47fa4051fbb5c234a10eed923d11257749a (patch) | |
tree | d64f1026c35f2cdc227a220b3381fc03f5a4ea00 /pkgs/development/rocm-modules/5 | |
parent | 12e7fc6923688a08152ee937d00e272502d2ed63 (diff) |
rocm-related: move all relevant ROCm derivations to rocmPackages
clr: init at 5.7.0 (hipamd, opencl, rocclr merged)
Diffstat (limited to 'pkgs/development/rocm-modules/5')
50 files changed, 4652 insertions, 3 deletions
diff --git a/pkgs/development/rocm-modules/5/clang-ocl/default.nix b/pkgs/development/rocm-modules/5/clang-ocl/default.nix new file mode 100644 index 0000000000000..96fc4945747f5 --- /dev/null +++ b/pkgs/development/rocm-modules/5/clang-ocl/default.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocm-device-libs +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "clang-ocl"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "clang-ocl"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-uMSvcVJj+me2E+7FsXZ4l4hTcK6uKEegXpkHGcuist0="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + buildInputs = [ rocm-device-libs ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "OpenCL compilation with clang compiler"; + homepage = "https://github.com/RadeonOpenCompute/clang-ocl"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/clr/default.nix b/pkgs/development/rocm-modules/5/clr/default.nix new file mode 100644 index 0000000000000..d3f811dcc4224 --- /dev/null +++ b/pkgs/development/rocm-modules/5/clr/default.nix @@ -0,0 +1,147 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, makeWrapper +, cmake +, perl +, clang +, hip-common +, hipcc +, rocm-device-libs +, rocm-comgr +, rocm-runtime +, roctracer +, rocminfo +, 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"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "clr"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-C+rFW/7kf35rz0sQTI2+iY5RhZZQY07fc5a+e6cB5OQ="; + }; + + 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 + # 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" + ]; + + 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 + ''; + + passthru = { + # All known and valid general GPU targets + # We cannot use this for each ROCm library, as each defines their own supported targets + # See: https://github.com/RadeonOpenCompute/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix + 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; + }; + }; + + meta = with lib; { + description = "AMD Common Language Runtime for hipamd, opencl, and rocclr"; + homepage = "https://github.com/ROCm-Developer-Tools/clr"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/composable_kernel/default.nix b/pkgs/development/rocm-modules/5/composable_kernel/default.nix new file mode 100644 index 0000000000000..54bf1251c3091 --- /dev/null +++ b/pkgs/development/rocm-modules/5/composable_kernel/default.nix @@ -0,0 +1,86 @@ +{ lib +, stdenv +, fetchFromGitHub +, unstableGitUpdater +, cmake +, rocm-cmake +, hip +, openmp +, clang-tools-extra +, gtest +, buildTests ? false +, buildExamples ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900" "gfx1030" ... ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "composable_kernel"; + version = "unstable-2023-01-16"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildExamples [ + "example" + ]; + + # ROCm 5.6 should release composable_kernel as stable with a tag in the future + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "composable_kernel"; + rev = "80e05267417f948e4f7e63c0fe807106d9a0c0ef"; + hash = "sha256-+c0E2UtlG/abweLwCWWjNHDO5ZvSIVKwwwettT9mqR4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + clang-tools-extra + ]; + + buildInputs = [ + openmp + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + ] ++ lib.optionals (gpuTargets != [ ]) [ + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] ++ lib.optionals buildTests [ + "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names + ]; + + # No flags to build selectively it seems... + postPatch = lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + '' + lib.optionalString (!buildExamples) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(example)" "" + ''; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + lib.optionalString buildExamples '' + mkdir -p $example/bin + mv $out/bin/example_* $example/bin + ''; + + passthru.updateScript = unstableGitUpdater { }; + + # Times out otherwise + requiredSystemFeatures = [ "big-parallel" ]; + + meta = with lib; { + description = "Performance portable programming model for machine learning tensor operators"; + homepage = "https://github.com/ROCmSoftwarePlatform/composable_kernel"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/5/default.nix b/pkgs/development/rocm-modules/5/default.nix index 6509f88508583..8bc496f452f17 100644 --- a/pkgs/development/rocm-modules/5/default.nix +++ b/pkgs/development/rocm-modules/5/default.nix @@ -1,9 +1,244 @@ { callPackage , recurseIntoAttrs +, cudaPackages +, python3Packages +, elfutils +, boost179 }: let rocmUpdateScript = callPackage ./update.nix { }; -in { +in rec { + ## RadeonOpenCompute ## llvm = recurseIntoAttrs (callPackage ./llvm/default.nix { inherit rocmUpdateScript; }); + + rocm-core = callPackage ./rocm-core { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + rocm-cmake = callPackage ./rocm-cmake { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + rocm-thunk = callPackage ./rocm-thunk { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + rocm-smi = python3Packages.callPackage ./rocm-smi { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + # Eventually will be in the LLVM repo + rocm-device-libs = callPackage ./rocm-device-libs { + inherit rocmUpdateScript rocm-cmake; + stdenv = llvm.rocmClangStdenv; + }; + + rocm-runtime = callPackage ./rocm-runtime { + inherit rocmUpdateScript rocm-device-libs rocm-thunk; + stdenv = llvm.rocmClangStdenv; + }; + + # Eventually will be in the LLVM repo + rocm-comgr = callPackage ./rocm-comgr { + inherit rocmUpdateScript rocm-cmake rocm-device-libs; + stdenv = llvm.rocmClangStdenv; + }; + + rocminfo = callPackage ./rocminfo { + inherit rocmUpdateScript rocm-cmake rocm-runtime; + stdenv = llvm.rocmClangStdenv; + }; + + clang-ocl = callPackage ./clang-ocl { + inherit rocmUpdateScript rocm-cmake rocm-device-libs; + stdenv = llvm.rocmClangStdenv; + }; + + # Broken, too many errors + rdc = callPackage ./rdc { + inherit rocmUpdateScript rocm-smi rocm-runtime; + # stdenv = llvm.rocmClangStdenv; + }; + + ## ROCm-Developer-Tools ## + hip-common = callPackage ./hip-common { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + # Eventually will be in the LLVM repo + hipcc = callPackage ./hipcc { + inherit rocmUpdateScript; + stdenv = llvm.rocmClangStdenv; + }; + + clr = callPackage ./clr { + inherit rocmUpdateScript hip-common hipcc rocm-device-libs rocm-comgr rocm-runtime roctracer rocminfo; + inherit (llvm) clang; + stdenv = llvm.rocmClangStdenv; + }; + + hipify = callPackage ./hipify { + inherit rocmUpdateScript; + inherit (llvm) clang; + stdenv = llvm.rocmClangStdenv; + }; + + # Needs GCC + rocprofiler = callPackage ./rocprofiler { + inherit (llvm) clang; + inherit rocmUpdateScript clr rocm-thunk roctracer rocm-smi hsa-amd-aqlprofile-bin; + }; + + # Needs GCC + roctracer = callPackage ./roctracer { + inherit rocmUpdateScript rocm-device-libs rocm-runtime rocprofiler clr; + inherit (llvm) clang; + }; + + # Needs GCC + rocgdb = callPackage ./rocgdb { + inherit rocmUpdateScript; + elfutils = elfutils.override { enableDebuginfod = true; }; + }; + + rocdbgapi = callPackage ./rocdbgapi { + inherit rocmUpdateScript rocm-cmake rocm-comgr rocm-runtime; + stdenv = llvm.rocmClangStdenv; + }; + + rocr-debug-agent = callPackage ./rocr-debug-agent { + inherit rocmUpdateScript clr rocdbgapi; + stdenv = llvm.rocmClangStdenv; + }; + + + + + + + + + + + + + + + composable_kernel = callPackage ./composable_kernel { + inherit (llvm) openmp clang-tools-extra; + stdenv = llvm.rocmClangStdenv; + }; + + hipcub = callPackage ./hipcub { + stdenv = llvm.rocmClangStdenv; + }; + + hipsparse = callPackage ./hipsparse { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + hipfort = callPackage ./hipfort { + stdenv = llvm.rocmClangStdenv; + }; + + hipfft = callPackage ./hipfft { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + hipsolver = callPackage ./hipsolver { + stdenv = llvm.rocmClangStdenv; + }; + + hipblas = callPackage ./hipblas { + stdenv = llvm.rocmClangStdenv; + }; + + migraphx = callPackage ./migraphx { + inherit (llvm) clang-tools-extra openmp; + stdenv = llvm.rocmClangStdenv; + rocmlir = rocmlir-rock; + }; + + rccl = callPackage ./rccl { + stdenv = llvm.rocmClangStdenv; + }; + + rocalution = callPackage ./rocalution { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + rocsolver = callPackage ./rocsolver { + stdenv = llvm.rocmClangStdenv; + }; + + rocmlir = callPackage ./rocmlir { + stdenv = llvm.rocmClangStdenv; + }; + + rocmlir-rock = rocmlir.override { + buildRockCompiler = true; + }; + + rocprim = callPackage ./rocprim { + stdenv = llvm.rocmClangStdenv; + }; + + rocsparse = callPackage ./rocsparse { + stdenv = llvm.rocmClangStdenv; + }; + + rocfft = callPackage ./rocfft { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + rocrand = callPackage ./rocrand { + stdenv = llvm.rocmClangStdenv; + }; + + tensile = python3Packages.callPackage ./tensile { + stdenv = llvm.rocmClangStdenv; + }; + + rocwmma = callPackage ./rocwmma { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + rocblas = callPackage ./rocblas { + inherit (llvm) openmp; + stdenv = llvm.rocmClangStdenv; + }; + + miopengemm = callPackage ./miopengemm { + stdenv = llvm.rocmClangStdenv; + }; + + rocthrust = callPackage ./rocthrust { + stdenv = llvm.rocmClangStdenv; + }; + + miopen = callPackage ./miopen { + inherit (llvm) llvm clang-tools-extra; + stdenv = llvm.rocmClangStdenv; + rocmlir = rocmlir-rock; + boost = boost179.override { enableStatic = true; }; + }; + + miopen-hip = miopen.override { + useOpenCL = false; + }; + + miopen-opencl = miopen.override { + useOpenCL = true; + }; } diff --git a/pkgs/development/rocm-modules/5/hip-common/default.nix b/pkgs/development/rocm-modules/5/hip-common/default.nix new file mode 100644 index 0000000000000..9f5f37511ef01 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hip-common/default.nix @@ -0,0 +1,44 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hip-common"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIP"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-1Abit9qZCwrCVcnaFT4uMygFB9G6ovRasLmTsOsJ/Fw="; + }; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + mv * $out + + runHook postInstall + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "C++ Heterogeneous-Compute Interface for Portability"; + homepage = "https://github.com/ROCm-Developer-Tools/HIP"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipblas/default.nix b/pkgs/development/rocm-modules/5/hipblas/default.nix new file mode 100644 index 0000000000000..cb60e5de6633a --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipblas/default.nix @@ -0,0 +1,100 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, gfortran +, rocblas +, rocsolver +, gtest +, lapack-reference +, buildTests ? false +, buildBenchmarks ? false +, buildSamples ? false +}: + +# Can also use cuBLAS +stdenv.mkDerivation (finalAttrs: { + pname = "hipblas"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipBLAS"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-abaEZN82dsoEC5gIF3/6epRDVz5ItUo6CkZsybu/G+g="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + gfortran + ]; + + buildInputs = [ + rocblas + rocsolver + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipblas-test $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipblas-bench $benchmark/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv $out/bin/example-* $sample/bin + '' + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm BLAS marshalling library"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipBLAS"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + # Fixed in develop branch by using C++17 and related refactor + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || buildTests || buildBenchmarks || buildSamples; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipcc/default.nix b/pkgs/development/rocm-modules/5/hipcc/default.nix new file mode 100644 index 0000000000000..e6610e8909f75 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipcc/default.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, lsb-release +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipcc"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIPCC"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-lJX6nF1V4YmK5ai7jivXlRnG3doIOf6X9CWLHVdRuVg="; + }; + + nativeBuildInputs = [ cmake ]; + + postPatch = '' + substituteInPlace src/hipBin_amd.h \ + --replace "/usr/bin/lsb_release" "${lsb-release}/bin/lsb_release" + ''; + + postInstall = '' + rm -r $out/hip/bin + ln -s $out/bin $out/hip/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Compiler driver utility that calls clang or nvcc"; + homepage = "https://github.com/ROCm-Developer-Tools/HIPCC"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipcub/default.nix b/pkgs/development/rocm-modules/5/hipcub/default.nix new file mode 100644 index 0000000000000..b3a23241366f6 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipcub/default.nix @@ -0,0 +1,87 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocprim +, hip +, gtest +, gbenchmark +, buildTests ? false +, buildBenchmarks ? false +}: + +# CUB can also be used as a backend instead of rocPRIM. +stdenv.mkDerivation (finalAttrs: { + pname = "hipcub"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipCUB"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-ygBEA3NuCQ13QrSzGqyWXkx8Dy9WhR3u4syzapRTkFU="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = [ + rocprim + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + "-DHIP_ROOT_DIR=${hip}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Thin wrapper library on top of rocPRIM or CUB"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipCUB"; + license = with licenses; [ bsd3 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipfft/default.nix b/pkgs/development/rocm-modules/5/hipfft/default.nix new file mode 100644 index 0000000000000..1e959f0ad56a7 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipfft/default.nix @@ -0,0 +1,107 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, git +, rocfft +, gtest +, boost +, fftw +, fftwFloat +, openmp +, buildTests ? false +, buildBenchmarks ? false +, buildSamples ? false +}: + +# Can also use cuFFT +stdenv.mkDerivation (finalAttrs: { + pname = "hipfft"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipFFT"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-fuYRKdlTrRMwxr3cgMeT3YniPzs4nuvF8YCzr3LLPFM="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ + hip + git + cmake + rocm-cmake + ]; + + buildInputs = [ + rocfft + ] ++ lib.optionals (buildTests || buildBenchmarks || buildSamples) [ + gtest + boost + fftw + fftwFloat + openmp + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DCMAKE_MODULE_PATH=${hip}/lib/cmake/hip" + "-DHIP_ROOT_DIR=${hip}" + "-DHIP_PATH=${hip}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_RIDER=ON" + ] ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipfft-test $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipfft-rider $benchmark/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/hipfft_* $sample/bin + patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "FFT marshalling library"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipFFT"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipfort/default.nix b/pkgs/development/rocm-modules/5/hipfort/default.nix new file mode 100644 index 0000000000000..4bb2a270271b6 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipfort/default.nix @@ -0,0 +1,66 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, gfortran +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipfort"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipfort"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-DRjUWhdinDKP7CZgq2SmU3lGmmodCuXvco9aEeMLSZ4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + gfortran + ]; + + cmakeFlags = [ + "-DHIPFORT_COMPILER=${gfortran}/bin/gfortran" + "-DHIPFORT_AR=${gfortran.cc}/bin/gcc-ar" + "-DHIPFORT_RANLIB=${gfortran.cc}/bin/gcc-ranlib" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postPatch = '' + patchShebangs bin + + substituteInPlace bin/hipfc bin/mymcpu \ + --replace "/bin/cat" "cat" + + substituteInPlace bin/CMakeLists.txt \ + --replace "/bin/mkdir" "mkdir" \ + --replace "/bin/cp" "cp" \ + --replace "/bin/sed" "sed" \ + --replace "/bin/chmod" "chmod" \ + --replace "/bin/ln" "ln" + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Fortran interfaces for ROCm libraries"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipfort"; + license = with licenses; [ mit ]; # mitx11 + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipify/default.nix b/pkgs/development/rocm-modules/5/hipify/default.nix new file mode 100644 index 0000000000000..893056496c9c0 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipify/default.nix @@ -0,0 +1,50 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, clang +, libxml2 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hipify"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIPIFY"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-lCQ2VTUGmFC90Xu70/tvoeDhFaInGqLT3vC2A1UojNI="; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libxml2 ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${clang}/bin/clang" + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + # Fixup bad symlinks + postInstall = '' + rm -r $out/hip/bin + ln -s $out/bin $out/hip/bin + patchShebangs $out/bin + ''; + + meta = with lib; { + description = "Convert CUDA to Portable C++ Code"; + homepage = "https://github.com/ROCm-Developer-Tools/HIPIFY"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipsolver/default.nix b/pkgs/development/rocm-modules/5/hipsolver/default.nix new file mode 100644 index 0000000000000..238564d631bc9 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipsolver/default.nix @@ -0,0 +1,100 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, gfortran +, rocblas +, rocsolver +, gtest +, lapack-reference +, buildTests ? false +, buildBenchmarks ? false +, buildSamples ? false +}: + +# Can also use cuSOLVER +stdenv.mkDerivation (finalAttrs: { + pname = "hipsolver"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipSOLVER"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-I9Xjkilo+baeM1CRXjLAbj/vrg8r5/E2yEImhHGSyf8="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + gfortran + ]; + + buildInputs = [ + rocblas + rocsolver + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] ++ lib.optionals buildSamples [ + "-DBUILD_CLIENTS_SAMPLES=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipsolver-test $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/hipsolver-bench $benchmark/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/example-* $sample/bin + patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm SOLVER marshalling library"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipSOLVER"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/hipsparse/default.nix b/pkgs/development/rocm-modules/5/hipsparse/default.nix new file mode 100644 index 0000000000000..6e6197209e4b9 --- /dev/null +++ b/pkgs/development/rocm-modules/5/hipsparse/default.nix @@ -0,0 +1,136 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocsparse +, hip +, gfortran +, git +, gtest +, openmp +, buildTests ? false +, buildSamples ? false +}: + +# This can also use cuSPARSE as a backend instead of rocSPARSE +stdenv.mkDerivation (finalAttrs: { + pname = "hipsparse"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "hipSPARSE"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-txigaOoZMI/v+EQLgGlj2O0IHfE7EpgjL0cyv49nKzo="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + gfortran + ]; + + buildInputs = [ + rocsparse + git + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals (buildTests || buildSamples) [ + openmp + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ]; + + # We have to manually generate the matrices + # CMAKE_MATRICES_DIR seems to be reset in clients/tests/CMakeLists.txt + postPatch = '' + substituteInPlace clients/common/utility.cpp \ + --replace "#ifdef __cpp_lib_filesystem" " #if true" + '' + lib.optionalString buildTests '' + mkdir -p matrices + + ln -s ${rocsparse.passthru.matrices.matrix-01}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-02}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-03}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-04}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-05}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-06}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-07}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-08}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-09}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-10}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-11}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-12}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-13}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-14}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-15}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-16}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-17}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-18}/*.mtx matrices + ln -s ${rocsparse.passthru.matrices.matrix-19}/*.mtx matrices + + # Not used by the original cmake, causes an error + rm matrices/*_b.mtx + + echo "deps/convert.cpp -> deps/mtx2csr" + hipcc deps/convert.cpp -O3 -o deps/mtx2csr + + for mat in $(ls -1 matrices | cut -d "." -f 1); do + echo "mtx2csr: $mat.mtx -> $mat.bin" + deps/mtx2csr matrices/$mat.mtx matrices/$mat.bin + unlink matrices/$mat.mtx + done + + substituteInPlace clients/tests/CMakeLists.txt \ + --replace "\''${PROJECT_BINARY_DIR}/matrices" "/build/source/matrices" + ''; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/hipsparse-test $test/bin + mv /build/source/matrices $test + rmdir $out/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/example_* $sample/bin + patchelf --set-rpath $out/lib:${lib.makeLibraryPath ( + finalAttrs.buildInputs ++ [ hip gfortran.cc ])} $sample/bin/example_* + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm SPARSE marshalling library"; + homepage = "https://github.com/ROCmSoftwarePlatform/hipSPARSE"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/migraphx/default.nix b/pkgs/development/rocm-modules/5/migraphx/default.nix new file mode 100644 index 0000000000000..fdc97f45da9d4 --- /dev/null +++ b/pkgs/development/rocm-modules/5/migraphx/default.nix @@ -0,0 +1,160 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, pkg-config +, cmake +, rocm-cmake +, hip +, clang-tools-extra +, openmp +, rocblas +, rocmlir +, miopengemm +, miopen +, protobuf +, half +, nlohmann_json +, msgpack +, sqlite +, oneDNN_2 +, blaze +, texlive +, doxygen +, sphinx +, docutils +, ghostscript +, python3Packages +, buildDocs ? false +, buildTests ? false +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec + epstopdf; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "migraphx"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "AMDMIGraphX"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-7yL7Zn5I8GUPIAgB7tVLZI7OEHLv0E4FcLVx9xMfsNY="; + }; + + nativeBuildInputs = [ + pkg-config + cmake + rocm-cmake + hip + clang-tools-extra + python3Packages.python + ] ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + docutils + ghostscript + python3Packages.sphinx-rtd-theme + python3Packages.breathe + ]; + + buildInputs = [ + openmp + rocblas + rocmlir + miopengemm + miopen + protobuf + half + nlohmann_json + msgpack + sqlite + oneDNN_2 + blaze + python3Packages.pybind11 + python3Packages.onnx + ]; + + cmakeFlags = [ + "-DCMAKE_POLICY_DEFAULT_CMP0079=NEW" + # "-DCMAKE_C_COMPILER=hipcc" + # "-DCMAKE_CXX_COMPILER=hipcc" + "-DMIGRAPHX_ENABLE_GPU=OFF" # GPU compilation is broken, don't know why + "-DMIGRAPHX_ENABLE_CPU=ON" + "-DMIGRAPHX_ENABLE_FPGA=ON" + "-DMIGRAPHX_ENABLE_MLIR=ON" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postPatch = '' + patchShebangs tools + + substituteInPlace src/targets/gpu/CMakeLists.txt \ + --replace "CMAKE_CXX_COMPILER MATCHES \".*clang\\\+\\\+\$\"" "TRUE" + '' + lib.optionalString (!buildDocs) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(doc)" "" + '' + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + ''; + + # Unfortunately, it seems like we have to call make on this manually + preInstall = lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + make -j$NIX_BUILD_CORES doc + cd ../doc/pdf + make -j$NIX_BUILD_CORES + cd - + ''; + + postInstall = lib.optionalString buildDocs '' + mv ../doc/html $out/share/doc/migraphx + mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx + '' + lib.optionalString buildTests '' + mkdir -p $test/bin + mv bin/test_* $test/bin + patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "AMD's graph optimization engine"; + homepage = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/miopen/default.nix b/pkgs/development/rocm-modules/5/miopen/default.nix new file mode 100644 index 0000000000000..dd7661a09756a --- /dev/null +++ b/pkgs/development/rocm-modules/5/miopen/default.nix @@ -0,0 +1,190 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchurl +, rocmUpdateScript +, pkg-config +, cmake +, rocm-cmake +, rocblas +, rocmlir +, hip +, clang-tools-extra +, clang-ocl +, llvm +, miopengemm +, composable_kernel +, half +, boost +, sqlite +, bzip2 +, nlohmann_json +, texlive +, doxygen +, sphinx +, zlib +, gtest +, rocm-comgr +, python3Packages +, buildDocs ? true +, buildTests ? false +, fetchKDBs ? true +, useOpenCL ? false +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec; + }; + + kdbs = lib.optionalAttrs fetchKDBs import ./deps.nix { + inherit fetchurl; + mirror = "https://repo.radeon.com/rocm/miopen-kernel/rel-5.0"; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "miopen"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "MIOpen"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-6Bz4yDbQtV8XlEpwbH0YsJFaaZqH7BOfZDL7F4JTS1Q="; + }; + + nativeBuildInputs = [ + pkg-config + cmake + rocm-cmake + hip + clang-tools-extra + ]; + + buildInputs = [ + llvm + rocblas + rocmlir + clang-ocl + miopengemm + composable_kernel + half + boost + sqlite + bzip2 + nlohmann_json + ] ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + python3Packages.sphinx-rtd-theme + python3Packages.breathe + python3Packages.myst-parser + ] ++ lib.optionals buildTests [ + zlib + ]; + + cmakeFlags = [ + "-DMIOPEN_USE_MIOPENGEMM=ON" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals (!useOpenCL) [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DMIOPEN_BACKEND=HIP" + ] ++ lib.optionals useOpenCL [ + "-DMIOPEN_BACKEND=OpenCL" + ] ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + "-DMIOPEN_TEST_ALL=ON" + "-DMIOPEN_TEST_GFX900=ON" + "-DMIOPEN_TEST_GFX906=ON" + "-DMIOPEN_TEST_GFX908=ON" + "-DMIOPEN_TEST_GFX90A=ON" + "-DMIOPEN_TEST_GFX103X=ON" + "-DGOOGLETEST_DIR=${gtest.src}" # Custom linker names + ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "enable_testing()" "" \ + --replace "MIOPEN_HIP_COMPILER MATCHES \".*clang\\\\+\\\\+$\"" "true" \ + --replace "set(MIOPEN_TIDY_ERRORS ALL)" "" # error: missing required key 'key' + '' + lib.optionalString buildTests '' + substituteInPlace test/gtest/CMakeLists.txt \ + --replace "enable_testing()" "" + '' + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + '' + lib.optionalString fetchKDBs '' + ln -sf ${kdbs.gfx1030_36} src/kernels/gfx1030_36.kdb + ln -sf ${kdbs.gfx900_56} src/kernels/gfx900_56.kdb + ln -sf ${kdbs.gfx900_64} src/kernels/gfx900_64.kdb + ln -sf ${kdbs.gfx906_60} src/kernels/gfx906_60.kdb + ln -sf ${kdbs.gfx906_64} src/kernels/gfx906_64.kdb + ln -sf ${kdbs.gfx90878} src/kernels/gfx90878.kdb + ln -sf ${kdbs.gfx90a68} src/kernels/gfx90a68.kdb + ln -sf ${kdbs.gfx90a6e} src/kernels/gfx90a6e.kdb + ''; + + # Unfortunately, it seems like we have to call make on these manually + postBuild = lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + make -j$NIX_BUILD_CORES doc + '' + lib.optionalString buildTests '' + make -j$NIX_BUILD_CORES check + ''; + + postInstall = '' + rm $out/bin/install_precompiled_kernels.sh + '' + lib.optionalString buildDocs '' + mv ../doc/html $out/share/doc/miopen-${if useOpenCL then "opencl" else "hip"} + mv ../doc/pdf/miopen.pdf $out/share/doc/miopen-${if useOpenCL then "opencl" else "hip"} + '' + lib.optionalString buildTests '' + mkdir -p $test/bin + mv bin/test_* $test/bin + patchelf --set-rpath $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ + [ hip rocm-comgr ])} $test/bin/* + '' + lib.optionalString fetchKDBs '' + # Apparently gfx1030_40 wasn't generated so the developers suggest just renaming gfx1030_36 to it + # Should be fixed in the next miopen kernel generation batch + ln -s ${kdbs.gfx1030_36} $out/share/miopen/db/gfx1030_40.kdb + ''; + + requiredSystemFeatures = [ "big-parallel" ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Machine intelligence library for ROCm"; + homepage = "https://github.com/ROCmSoftwarePlatform/MIOpen"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/miopen/deps.nix b/pkgs/development/rocm-modules/5/miopen/deps.nix new file mode 100644 index 0000000000000..e88b61ad974c1 --- /dev/null +++ b/pkgs/development/rocm-modules/5/miopen/deps.nix @@ -0,0 +1,45 @@ +{ fetchurl +, mirror +}: + +{ + gfx1030_36 = fetchurl { + sha256 = "sha256-zEXDLkRWAHS15LDA5IRyqG5rO7HHPBiVgPlQ8JjSqNc="; + url = "${mirror}/gfx1030_36.kdb"; + }; + + gfx900_56 = fetchurl { + sha256 = "sha256-ZTqUPhVKcQzjO6bxykvZMJk1VZh31dRVs+XqcxEtmeI="; + url = "${mirror}/gfx900_56.kdb"; + }; + + gfx900_64 = fetchurl { + sha256 = "sha256-ZTqUPhVKcQzjO6bxykvZMJk1VZh31dRVs+XqcxEtmeI="; + url = "${mirror}/gfx900_64.kdb"; + }; + + gfx906_60 = fetchurl { + sha256 = "sha256-U6pDo8ICfs6fVIEqRziWeE5/4Vzvu41JkcRVn3ou1e4="; + url = "${mirror}/gfx906_60.kdb"; + }; + + gfx906_64 = fetchurl { + sha256 = "sha256-U6pDo8ICfs6fVIEqRziWeE5/4Vzvu41JkcRVn3ou1e4="; + url = "${mirror}/gfx906_64.kdb"; + }; + + gfx90878 = fetchurl { + sha256 = "sha256-r7DRhNH+jHUXAu64b9vWsZzGD4w5oSHnxH0l2RN0qlQ="; + url = "${mirror}/gfx90878.kdb"; + }; + + gfx90a68 = fetchurl { + sha256 = "sha256-NT//zIPTbzsPJyaVycxwU6BcMTzGc/d+Z4Ab9FImDko="; + url = "${mirror}/gfx90a68.kdb"; + }; + + gfx90a6e = fetchurl { + sha256 = "sha256-ENZHbf+/MGYgSTpALKh2meuZPNhH5bG+WrW/jzvGpBs="; + url = "${mirror}/gfx90a6e.kdb"; + }; +} diff --git a/pkgs/development/rocm-modules/5/miopengemm/default.nix b/pkgs/development/rocm-modules/5/miopengemm/default.nix new file mode 100644 index 0000000000000..92616f79eedcc --- /dev/null +++ b/pkgs/development/rocm-modules/5/miopengemm/default.nix @@ -0,0 +1,123 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocm-opencl-runtime +, texlive +, doxygen +, sphinx +, openblas +, python3Packages +, buildDocs ? true +, buildTests ? false +, buildBenchmarks ? false +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "miopengemm"; + version = "5.5.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "MIOpenGEMM"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-AiRzOMYRA/0nbQomyq4oOEwNZdkPYWRA2W6QFlctvFc="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + buildInputs = [ + rocm-opencl-runtime + ] ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + python3Packages.sphinx-rtd-theme + python3Packages.breathe + ] ++ lib.optionals buildTests [ + openblas + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DOPENBLAS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DAPI_BENCH_MIOGEMM=ON" + # Needs https://github.com/CNugteren/CLBlast + # "-DAPI_BENCH_CLBLAST=ON" + # Needs https://github.com/openai/triton + # "-DAPI_BENCH_ISAAC=ON" + ]; + + # Unfortunately, it seems like we have to call make on these manually + postBuild = lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + make doc + '' + lib.optionalString buildTests '' + make check + '' + lib.optionalString buildBenchmarks '' + make examples + ''; + + postInstall = lib.optionalString buildDocs '' + mv ../doc/html $out/share/doc/miopengemm + mv ../doc/pdf/miopengemm.pdf $out/share/doc/miopengemm + '' + lib.optionalString buildTests '' + mkdir -p $test/bin + find tests -executable -type f -exec mv {} $test/bin \; + patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $test/bin/* + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + find examples -executable -type f -exec mv {} $benchmark/bin \; + patchelf --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs}:$out/lib $benchmark/bin/* + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "OpenCL general matrix multiplication API for ROCm"; + homepage = "https://github.com/ROCmSoftwarePlatform/MIOpenGEMM"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rccl/default.nix b/pkgs/development/rocm-modules/5/rccl/default.nix new file mode 100644 index 0000000000000..68dafc29c1643 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rccl/default.nix @@ -0,0 +1,83 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocm-smi +, hip +, gtest +, chrpath +, buildTests ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rccl"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rccl"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-Abrwmsjnkx9JVTrARP/BM965g+R10lY+XPwthy/SG0k="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = [ + rocm-smi + gtest + ] ++ lib.optionals buildTests [ + chrpath + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + ]; + + # Replace the manually set parallel jobs to NIX_BUILD_CORES + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "8 P" "$NIX_BUILD_CORES P" \ + --replace "8)" "$NIX_BUILD_CORES)" + ''; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/* $test/bin + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm communication collectives library"; + homepage = "https://github.com/ROCmSoftwarePlatform/rccl"; + license = with licenses; [ bsd2 bsd3 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rdc/default.nix b/pkgs/development/rocm-modules/5/rdc/default.nix new file mode 100644 index 0000000000000..134b946c5f7ad --- /dev/null +++ b/pkgs/development/rocm-modules/5/rdc/default.nix @@ -0,0 +1,126 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-smi +, rocm-runtime +, libcap +, grpc +, protobuf +, openssl +, doxygen +, graphviz +, texlive +, gtest +, buildDocs ? true +, buildTests ? false +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + changepage + latexmk + varwidth + multirow + hanging + adjustbox + collectbox + stackengine + enumitem + alphalph + wasysym + sectsty + tocloft + newunicodechar + etoc + helvetic + wasy + courier; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "rdc"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rdc"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-xZD/WI/LfNtKK9j6ZjuU0OTTFZz3G4atyD5mVcSsQ8A="; + }; + + nativeBuildInputs = [ + cmake + protobuf + ] ++ lib.optionals buildDocs [ + doxygen + graphviz + latex + ]; + + buildInputs = [ + rocm-smi + rocm-runtime + libcap + grpc + openssl + ] ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_VERBOSE_MAKEFILE=OFF" + "-DRDC_INSTALL_PREFIX=${placeholder "out"}" + "-DBUILD_ROCRTEST=ON" + "-DRSMI_INC_DIR=${rocm-smi}/include" + "-DRSMI_LIB_DIR=${rocm-smi}/lib" + "-DGRPC_ROOT=${grpc}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_LIBEXECDIR=libexec" + "-DCMAKE_INSTALL_DOCDIR=doc" + ] ++ lib.optionals buildTests [ + "-DBUILD_TESTS=ON" + ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "file(STRINGS /etc/os-release LINUX_DISTRO LIMIT_COUNT 1 REGEX \"NAME=\")" "set(LINUX_DISTRO \"NixOS\")" + ''; + + postInstall = '' + find $out/bin -executable -type f -exec \ + patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \; + '' + lib.optionalString buildTests '' + mkdir -p $test + mv $out/bin/rdctst_tests $test/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Simplifies administration and addresses infrastructure challenges in cluster and datacenter environments"; + homepage = "https://github.com/RadeonOpenCompute/rdc"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + # broken = versions.minor finalAttrs.version != versions.minor rocm-smi.version; + broken = true; # Too many errors, unsure how to fix + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocalution/default.nix b/pkgs/development/rocm-modules/5/rocalution/default.nix new file mode 100644 index 0000000000000..650e9dc7a1caa --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocalution/default.nix @@ -0,0 +1,115 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocblas +, rocsparse +, rocprim +, rocrand +, hip +, git +, openmp +, openmpi +, gtest +, buildTests ? false +, buildBenchmarks ? false +, buildSamples ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900:xnack-" "gfx906:xnack-" ... ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocalution"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocALUTION"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-+UGpFuZsC4+kmo8LWZWC2YoFJSdTukjN47e1YqW5Zu4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + git + ]; + + buildInputs = [ + rocblas + rocsparse + rocprim + rocrand + openmp + openmpi + ] ++ lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + "-DROCM_PATH=${hip}" + "-DHIP_ROOT_DIR=${hip}" + "-DSUPPORT_HIP=ON" + "-DSUPPORT_OMP=ON" + "-DSUPPORT_MPI=ON" + "-DBUILD_CLIENTS_SAMPLES=${if buildSamples then "ON" else "OFF"}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/rocalution-test $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/rocalution-bench $benchmark/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv clients/staging/* $sample/bin + rm $sample/bin/rocalution-test || true + rm $sample/bin/rocalution-bench || true + + patchelf --set-rpath \ + $out/lib:${lib.makeLibraryPath (finalAttrs.buildInputs ++ [ hip ])} \ + $sample/bin/* + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Iterative sparse solvers for ROCm"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocALUTION"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocblas/default.nix b/pkgs/development/rocm-modules/5/rocblas/default.nix new file mode 100644 index 0000000000000..59d23ad121da8 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocblas/default.nix @@ -0,0 +1,139 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, python3 +, tensile +, msgpack +, libxml2 +, gtest +, gfortran +, openmp +, amd-blis +, python3Packages +, buildTensile ? true +, buildTests ? false +, buildBenchmarks ? false +, tensileLogic ? "asm_full" +, tensileCOVersion ? "V3" +, tensileSepArch ? true +, tensileLazyLib ? true +, tensileLibFormat ? "msgpack" +, gpuTargets ? [ "all" ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocblas"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocBLAS"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-3wKnwvAra8u9xqlC05wUD+gSoBILTVJFU2cIV6xv3Lk="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = [ + python3 + ] ++ lib.optionals buildTensile [ + msgpack + libxml2 + python3Packages.msgpack + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gfortran + openmp + amd-blis + ] ++ lib.optionals (buildTensile || buildTests || buildBenchmarks) [ + python3Packages.pyyaml + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-Dpython=python3" + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + "-DBUILD_WITH_TENSILE=${if buildTensile then "ON" else "OFF"}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTensile [ + "-DVIRTUALENV_HOME_DIR=/build/source/tensile" + "-DTensile_TEST_LOCAL_PATH=/build/source/tensile" + "-DTensile_ROOT=/build/source/tensile/lib/python${python3.pythonVersion}/site-packages/Tensile" + "-DTensile_LOGIC=${tensileLogic}" + "-DTensile_CODE_OBJECT_VERSION=${tensileCOVersion}" + "-DTensile_SEPARATE_ARCHITECTURES=${if tensileSepArch then "ON" else "OFF"}" + "-DTensile_LAZY_LIBRARY_LOADING=${if tensileLazyLib then "ON" else "OFF"}" + "-DTensile_LIBRARY_FORMAT=${tensileLibFormat}" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DCMAKE_CXX_FLAGS=-I${amd-blis}/include/blis" + ]; + + # Tensile REALLY wants to write to the nix directory if we include it normally + postPatch = lib.optionalString buildTensile '' + cp -a ${tensile} tensile + chmod +w -R tensile + + # Rewrap Tensile + substituteInPlace tensile/bin/{.t*,.T*,*} \ + --replace "${tensile}" "/build/source/tensile" + + substituteInPlace CMakeLists.txt \ + --replace "include(virtualenv)" "" \ + --replace "virtualenv_install(\''${Tensile_TEST_LOCAL_PATH})" "" + ''; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + cp -a $out/bin/* $test/bin + rm $test/bin/*-bench || true + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + cp -a $out/bin/* $benchmark/bin + rm $benchmark/bin/*-test || true + '' + lib.optionalString (buildTests || buildBenchmarks ) '' + rm -rf $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + requiredSystemFeatures = [ "big-parallel" ]; + + meta = with lib; { + description = "BLAS implementation for ROCm platform"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocBLAS"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocdbgapi/default.nix b/pkgs/development/rocm-modules/5/rocdbgapi/default.nix new file mode 100644 index 0000000000000..41c1178f1089f --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocdbgapi/default.nix @@ -0,0 +1,112 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, git +, rocm-comgr +, rocm-runtime +, hwdata +, texlive +, doxygen +, graphviz +, buildDocs ? true +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + changepage + latexmk + varwidth + multirow + hanging + adjustbox + collectbox + stackengine + enumitem + alphalph + wasysym + sectsty + tocloft + newunicodechar + etoc + helvetic + wasy + courier; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "rocdbgapi"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ]; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "ROCdbgapi"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-qMXvgcS61lgcylz62ErYq8fhpYIR31skQEeKUryuP1w="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + git + ] ++ lib.optionals buildDocs [ + latex + doxygen + graphviz + ]; + + buildInputs = [ + rocm-comgr + rocm-runtime + hwdata + ]; + + cmakeFlags = [ + "-DPCI_IDS_PATH=${hwdata}/share/hwdata" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + # Unfortunately, it seems like we have to call make on this manually + postBuild = lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + make -j$NIX_BUILD_CORES doc + ''; + + postInstall = '' + substituteInPlace $out/lib/cmake/amd-dbgapi/amd-dbgapi-config.cmake \ + --replace "/build/source/build/" "" + + substituteInPlace $out/lib/cmake/amd-dbgapi/amd-dbgapi-targets.cmake \ + --replace "/build/source/build" "$out" + '' + lib.optionalString buildDocs '' + mv $out/share/html/amd-dbgapi $doc/share/doc/amd-dbgapi/html + rmdir $out/share/html + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Debugger support for control of execution and inspection state"; + homepage = "https://github.com/ROCm-Developer-Tools/ROCdbgapi"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocfft/default.nix b/pkgs/development/rocm-modules/5/rocfft/default.nix new file mode 100644 index 0000000000000..ee1078eabb28f --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocfft/default.nix @@ -0,0 +1,243 @@ +{ rocfft +, lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, hip +, python3 +, rocm-cmake +, sqlite +, boost +, fftw +, fftwFloat +, gtest +, openmp +, rocrand +# NOTE: Update the default GPU targets on every update +, gpuTargets ? [ + "gfx803" + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx1030" + "gfx1100" + "gfx1102" +] +}: + +let + # To avoid output limit exceeded errors in hydra, we build kernel + # device libs and the kernel RTC cache database in separate derivations + kernelDeviceLibs = map + (target: + (rocfft.overrideAttrs (prevAttrs: { + pname = "rocfft-device-${target}"; + + patches = prevAttrs.patches ++ [ + # Add back install rule for device library + # This workaround is needed because rocm_install_targets + # doesn't support an EXCLUDE_FROM_ALL option + ./device-install.patch + ]; + + buildFlags = [ "rocfft-device-${target}" ]; + + installPhase = '' + runHook preInstall + cmake --install . --component device + runHook postInstall + ''; + + requiredSystemFeatures = [ "big-parallel" ]; + })).override { + gpuTargets = [ target ]; + } + ) + gpuTargets; + + # TODO: Figure out how to also split this by GPU target + # + # It'll be bit more complicated than what we're doing for the kernel + # device libs, because the kernel cache needs to be compiled into + # one sqlite database (whereas the device libs can be linked into + # rocfft as separate libraries for each GPU target). + # + # It's not clear why this needs to even be a db in the first place. + # It would simplify things A LOT if we could just store these + # pre-compiled kernels as files (but that'd need a lot of patching). + kernelRtcCache = rocfft.overrideAttrs (_: { + pname = "rocfft-kernel-cache"; + + buildFlags = [ "rocfft_kernel_cache_target" ]; + + installPhase = '' + runHook preInstall + cmake --install . --component kernel_cache + runHook postInstall + ''; + + requiredSystemFeatures = [ "big-parallel" ]; + }); +in +stdenv.mkDerivation (finalAttrs: { + pname = "rocfft"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocFFT"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-GZSi03geTT+NUztBWhGYyghLqJGsFjUQzVAKQ7d03uA="; + }; + + patches = [ + # Exclude kernel compilation & installation from "all" target, + # and split device libraries by GPU target + ./split-kernel-compilation.patch + ]; + + nativeBuildInputs = [ + cmake + hip + python3 + rocm-cmake + ]; + + buildInputs = [ + sqlite + ] ++ lib.optionals (finalAttrs.pname == "rocfft") kernelDeviceLibs; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DUSE_HIP_CLANG=ON" + "-DSQLITE_USE_SYSTEM_PACKAGE=ON" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ]; + + postInstall = lib.optionalString (finalAttrs.pname == "rocfft") '' + ln -s ${kernelRtcCache}/lib/rocfft_kernel_cache.db "$out/lib" + ''; + + passthru = { + test = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-test"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/clients/tests"; + + nativeBuildInputs = [ + cmake + hip + rocm-cmake + ]; + + buildInputs = [ + boost + fftw + fftwFloat + finalAttrs.finalPackage + gtest + openmp + rocrand + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + ]; + + postInstall = '' + rm -r "$out/lib/fftw" + rmdir "$out/lib" + ''; + }; + + benchmark = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-benchmark"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/clients/rider"; + + nativeBuildInputs = [ + cmake + hip + rocm-cmake + ]; + + buildInputs = [ + boost + finalAttrs.finalPackage + openmp + (python3.withPackages (ps: with ps; [ + pandas + scipy + ])) + rocrand + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + ]; + + postInstall = '' + cp -a ../../../scripts/perf "$out/bin" + ''; + }; + + samples = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-samples"; + inherit (finalAttrs) version src; + + sourceRoot = "${finalAttrs.src.name}/clients/samples"; + + nativeBuildInputs = [ + cmake + hip + rocm-cmake + ]; + + buildInputs = [ + boost + finalAttrs.finalPackage + openmp + rocrand + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + ]; + + installPhase = '' + runHook preInstall + mkdir "$out" + cp -a bin "$out" + runHook postInstall + ''; + }; + + updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + }; + + meta = with lib; { + description = "FFT implementation for ROCm"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocFFT"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ kira-bruneau ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocfft/device-install.patch b/pkgs/development/rocm-modules/5/rocfft/device-install.patch new file mode 100644 index 0000000000000..355cf30d07ff1 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocfft/device-install.patch @@ -0,0 +1,15 @@ +diff --git a/library/src/device/CMakeLists.txt b/library/src/device/CMakeLists.txt +index 73a8ec9..9bfd4b8 100644 +--- a/library/src/device/CMakeLists.txt ++++ b/library/src/device/CMakeLists.txt +@@ -255,4 +255,10 @@ foreach( sub ${AMDGPU_TARGETS} ) + if( NOT BUILD_SHARED_LIBS ) + set_target_properties( rocfft-device-${sub} PROPERTIES PREFIX "lib" ) + endif( ) ++ ++ rocm_install_targets( ++ TARGETS ++ rocfft-device-${sub} ++ COMPONENT device ++ ) + endforeach() diff --git a/pkgs/development/rocm-modules/5/rocfft/split-kernel-compilation.patch b/pkgs/development/rocm-modules/5/rocfft/split-kernel-compilation.patch new file mode 100644 index 0000000000000..5d71fe399c1a5 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocfft/split-kernel-compilation.patch @@ -0,0 +1,124 @@ +diff --git a/library/src/CMakeLists.txt b/library/src/CMakeLists.txt +index 3a16304..606b711 100644 +--- a/library/src/CMakeLists.txt ++++ b/library/src/CMakeLists.txt +@@ -250,12 +250,12 @@ foreach( target + + endforeach() + +-add_executable( rocfft_aot_helper ++add_executable( rocfft_aot_helper EXCLUDE_FROM_ALL + rocfft_aot_helper.cpp + rocfft_stub.cpp + ) + +-add_executable( rocfft_config_search ++add_executable( rocfft_config_search EXCLUDE_FROM_ALL + rocfft_config_search.cpp + rocfft_stub.cpp + ) +@@ -279,10 +279,10 @@ endif() + + target_link_libraries( rocfft PRIVATE ${ROCFFT_DEVICE_LINK_LIBS} ) + +-target_link_libraries( rocfft PRIVATE rocfft-device-0 ) +-target_link_libraries( rocfft PRIVATE rocfft-device-1 ) +-target_link_libraries( rocfft PRIVATE rocfft-device-2 ) +-target_link_libraries( rocfft PRIVATE rocfft-device-3 ) ++foreach( sub ${AMDGPU_TARGETS} ) ++ target_link_libraries( rocfft PRIVATE -lrocfft-device-${sub} ) ++endforeach() ++ + foreach( target rocfft rocfft_aot_helper rocfft_config_search ) + # RTC uses dladdr to find the RTC helper program + if( NOT WIN32 ) +@@ -347,7 +347,7 @@ add_custom_command( + DEPENDS rocfft_aot_helper rocfft_rtc_helper + COMMENT "Compile kernels into shipped cache file" + ) +-add_custom_target( rocfft_kernel_cache_target ALL ++add_custom_target( rocfft_kernel_cache_target + DEPENDS rocfft_kernel_cache.db + VERBATIM + ) +@@ -392,7 +392,8 @@ else() + endif() + rocm_install(FILES ${ROCFFT_KERNEL_CACHE_PATH} + DESTINATION "${ROCFFT_KERNEL_CACHE_INSTALL_DIR}" +- COMPONENT runtime ++ COMPONENT kernel_cache ++ EXCLUDE_FROM_ALL + ) + + # PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ +diff --git a/library/src/device/CMakeLists.txt b/library/src/device/CMakeLists.txt +index 9f7b85f..73a8ec9 100644 +--- a/library/src/device/CMakeLists.txt ++++ b/library/src/device/CMakeLists.txt +@@ -170,11 +170,11 @@ list( SORT rocfft_device_source ) + # functions callable by rocFFT and depends on amdhip64, and another + # one usable by AOT RTC that contains no device code + list( FILTER rocfft_device_source EXCLUDE REGEX function_pool.cpp ) +-add_library( rocfft-function-pool OBJECT ++add_library( rocfft-function-pool OBJECT EXCLUDE_FROM_ALL + function_pool.cpp + ) + target_compile_definitions( rocfft-function-pool PRIVATE FUNCTION_POOL_STANDALONE_BODY= ) +-add_library( rocfft-function-pool-standalone OBJECT ++add_library( rocfft-function-pool-standalone OBJECT EXCLUDE_FROM_ALL + function_pool.cpp + ) + target_compile_definitions( rocfft-function-pool-standalone PRIVATE FUNCTION_POOL_STANDALONE_BODY={} ) +@@ -193,26 +193,15 @@ foreach( pool rocfft-function-pool rocfft-function-pool-standalone ) + add_dependencies(${pool} gen_headers_target) + endforeach() + +-list( LENGTH rocfft_device_source rocfft_device_source_len ) +-math(EXPR split_len "${rocfft_device_source_len} / 4") +-math(EXPR split_idx_2 "${rocfft_device_source_len} / 4 * 2") +-math(EXPR split_idx_3 "${rocfft_device_source_len} / 4 * 3") +- +-list( SUBLIST rocfft_device_source 0 ${split_len} rocfft_device_source_0 ) +-list( SUBLIST rocfft_device_source ${split_len} ${split_len} rocfft_device_source_1 ) +-list( SUBLIST rocfft_device_source ${split_idx_2} ${split_len} rocfft_device_source_2 ) +-list( SUBLIST rocfft_device_source ${split_idx_3} -1 rocfft_device_source_3 ) +- +-foreach( sub RANGE 3 ) +- set( rocfft_device_source_var rocfft_device_source_${sub} ) ++foreach( sub ${AMDGPU_TARGETS} ) + if(NOT SINGLELIB) +- add_library( rocfft-device-${sub} +- ${${rocfft_device_source_var}} ) ++ add_library( rocfft-device-${sub} EXCLUDE_FROM_ALL ++ ${rocfft_device_source} ) + else() + # Compile the device lib as a static library, which is then linked + # into librocfft.so Useful for testing purposes. +- add_library( rocfft-device-${sub} STATIC +- ${${rocfft_device_source_var}} ) ++ add_library( rocfft-device-${sub} STATIC EXCLUDE_FROM_ALL ++ ${rocfft_device_source} ) + + # if we're building singlelib, we don't want to export any of the + # device library symbols to the main library +@@ -241,9 +230,7 @@ foreach( sub RANGE 3 ) + # Set AMD GPU architecture options + + # Enable compilation of desired architectures +- foreach( target ${AMDGPU_TARGETS} ) +- target_compile_options( rocfft-device-${sub} PRIVATE --offload-arch=${target} ) +- endforeach( ) ++ target_compile_options( rocfft-device-${sub} PRIVATE --offload-arch=${sub} ) + + target_include_directories( rocfft-device-${sub} + PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> +@@ -268,9 +255,4 @@ foreach( sub RANGE 3 ) + if( NOT BUILD_SHARED_LIBS ) + set_target_properties( rocfft-device-${sub} PROPERTIES PREFIX "lib" ) + endif( ) +- +- rocm_install_targets( +- TARGETS +- rocfft-device-${sub} +- ) + endforeach() diff --git a/pkgs/development/rocm-modules/5/rocgdb/default.nix b/pkgs/development/rocm-modules/5/rocgdb/default.nix new file mode 100644 index 0000000000000..a2f4435ee7bcf --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocgdb/default.nix @@ -0,0 +1,58 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, pkg-config +, texinfo +, bison +, flex +, zlib +, elfutils +, gmp +, ncurses +, expat +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocgdb"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "ROCgdb"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-TlT7vvTrVd7P6ilVnWIG5VIrjTleFgDezK/mudBV+xE="; + }; + + nativeBuildInputs = [ + pkg-config + texinfo # For makeinfo + bison + flex + ]; + + buildInputs = [ + zlib + elfutils + gmp + ncurses + expat + ]; + + # `-Wno-format-nonliteral` doesn't work + env.NIX_CFLAGS_COMPILE = "-Wno-error=format-security"; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm source-level debugger for Linux, based on GDB"; + homepage = "https://github.com/ROCm-Developer-Tools/ROCgdb"; + license = with licenses; [ gpl2 gpl3 bsd3 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-cmake/default.nix b/pkgs/development/rocm-modules/5/rocm-cmake/default.nix new file mode 100644 index 0000000000000..04ae947d3a4a8 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-cmake/default.nix @@ -0,0 +1,37 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-cmake"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rocm-cmake"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-aVjzuJ4BiSfwOdjufFc5CznfnL8di5h992zl+pzD0DU="; + }; + + nativeBuildInputs = [ cmake ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + page = "releases?per_page=2"; + filter = ".[1].tag_name | split(\"-\") | .[1]"; + }; + + meta = with lib; { + description = "CMake modules for common build tasks for the ROCm stack"; + homepage = "https://github.com/RadeonOpenCompute/rocm-cmake"; + license = licenses.mit; + maintainers = teams.rocm.members; + platforms = platforms.unix; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-comgr/default.nix b/pkgs/development/rocm-modules/5/rocm-comgr/default.nix new file mode 100644 index 0000000000000..c3c4c5fab3cdf --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-comgr/default.nix @@ -0,0 +1,55 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocm-device-libs +, libxml2 +}: + +let + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation (finalAttrs: { + pname = "rocm-comgr"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "ROCm-CompilerSupport"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-QB3G0V92UTW67hD6+zSuExN1+eMT820iYSlMyZeWSFw="; + }; + + sourceRoot = "${finalAttrs.src.name}/lib/comgr"; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + buildInputs = [ + rocm-device-libs + libxml2 + ]; + + cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86" ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "APIs for compiling and inspecting AMDGPU code objects"; + homepage = "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr"; + license = licenses.ncsa; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-core/default.nix b/pkgs/development/rocm-modules/5/rocm-core/default.nix new file mode 100644 index 0000000000000..aae431be8e620 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-core/default.nix @@ -0,0 +1,36 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-core"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rocm-core"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-jFAHLqf/AR27Nbuq8aypWiKqApNcTgG5LWESVjVCKIg="; + }; + + nativeBuildInputs = [ cmake ]; + cmakeFlags = [ "-DROCM_VERSION=${finalAttrs.version}" ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Utility for getting the ROCm release version"; + homepage = "https://github.com/RadeonOpenCompute/rocm-core"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch b/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch new file mode 100644 index 0000000000000..500ff37a99052 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-device-libs/cmake.patch @@ -0,0 +1,43 @@ +diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake +index 07c60eb..c736b3e 100644 +--- a/cmake/Packages.cmake ++++ b/cmake/Packages.cmake +@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES + IMPORTED_LOCATION \"${target_path}\")") + endforeach() + configure_file(AMDDeviceLibsConfig.cmake.in +- ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake ++ lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake + @ONLY) + + + set(install_path_suffix "amdgcn/bitcode") + + # Generate the install-tree package. +-# We do not know the absolute path to the intall tree until we are installed, +-# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use +-# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. +-set(AMD_DEVICE_LIBS_PREFIX_CODE " ++if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") ++else() ++ # We do not know the absolute path to the install tree until we are installed, ++ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use ++ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. ++ set(AMD_DEVICE_LIBS_PREFIX_CODE " + # Derive absolute install prefix from config file path. + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") +-string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") +-foreach(p ${count}) +- set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} ++ string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") ++ foreach(p ${count}) ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)") +-endforeach() ++ endforeach() ++endif() ++ + set(AMD_DEVICE_LIBS_TARGET_CODE) + foreach(target ${AMDGCN_LIB_LIST}) + get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME) diff --git a/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix b/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix new file mode 100644 index 0000000000000..594e210312843 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-device-libs/default.nix @@ -0,0 +1,50 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, libxml2 +}: + +let + llvmNativeTarget = + if stdenv.isx86_64 then "X86" + else if stdenv.isAarch64 then "AArch64" + else throw "Unsupported ROCm LLVM platform"; +in stdenv.mkDerivation (finalAttrs: { + pname = "rocm-device-libs"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "ROCm-Device-Libs"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-f6/LAhJ2mBDO1/JloHvl7MJyDo3WutbXd4IDknA9nzM="; + }; + + patches = [ ./cmake.patch ]; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + buildInputs = [ libxml2 ]; + cmakeFlags = [ "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Set of AMD-specific device-side language runtime libraries"; + homepage = "https://github.com/RadeonOpenCompute/ROCm-Device-Libs"; + license = licenses.ncsa; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-runtime/default.nix b/pkgs/development/rocm-modules/5/rocm-runtime/default.nix new file mode 100644 index 0000000000000..fd9182c8254de --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-runtime/default.nix @@ -0,0 +1,78 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, pkg-config +, cmake +, xxd +, rocm-device-libs +, rocm-thunk +, libelf +, libdrm +, numactl +, valgrind +, libxml2 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-runtime"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "ROCR-Runtime"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-D7Ahan5cxDhqPtV5iDDNys0A4FlxQ9oVRa2EeMoY5Qk="; + }; + + sourceRoot = "${finalAttrs.src.name}/src"; + + nativeBuildInputs = [ + pkg-config + cmake + xxd + ]; + + buildInputs = [ + rocm-thunk + libelf + libdrm + numactl + valgrind + libxml2 + ]; + + postPatch = '' + patchShebangs image/blit_src/create_hsaco_ascii_file.sh + patchShebangs core/runtime/trap_handler/create_trap_handler_header.sh + + substituteInPlace CMakeLists.txt \ + --replace 'hsa/include/hsa' 'include/hsa' + + # We compile clang before rocm-device-libs, so patch it in afterwards + # Replace object version: https://github.com/RadeonOpenCompute/ROCR-Runtime/issues/166 (TODO: Remove on LLVM update?) + substituteInPlace image/blit_src/CMakeLists.txt \ + --replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode' \ + --replace '-mcode-object-version=4' '-mcode-object-version=5' + ''; + + fixupPhase = '' + rm -rf $out/hsa/* + ln -s $out/{include,lib} $out/hsa + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Platform runtime for ROCm"; + homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime"; + license = with licenses; [ ncsa ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch b/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch new file mode 100644 index 0000000000000..2634ea46a1f82 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-smi/cmake.patch @@ -0,0 +1,89 @@ +diff --git a/rocm_smi-backward-compat.cmake b/rocm_smi-backward-compat.cmake +index aa8fd9c..59afce5 100644 +--- a/rocm_smi-backward-compat.cmake ++++ b/rocm_smi-backward-compat.cmake +@@ -72,7 +72,12 @@ function(generate_wrapper_header) + set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) +- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${ROCM_SMI}/${file_name}\"\n") ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) ++ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}") ++ else() ++ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}") ++ endif() ++ set(include_statements "${include_statements}#include \"${include_dir}/${ROCM_SMI}/${file_name}\"\n") + configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${RSMI_WRAPPER_INC_DIR}/${file_name}) + unset(include_guard) + unset(include_statements) +@@ -90,7 +95,12 @@ function(generate_wrapper_header) + set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) +- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${OAM_TARGET_NAME}/${file_name}\"\n") ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) ++ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}") ++ else() ++ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}") ++ endif() ++ set(include_statements "${include_statements}#include \"${include_dir}/${OAM_TARGET_NAME}/${file_name}\"\n") + configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${OAM_WRAPPER_INC_DIR}/${file_name}) + unset(include_guard) + unset(include_statements) +@@ -123,11 +133,16 @@ function(create_library_symlink) + set(library_files "${LIB_RSMI}") + endif() + ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) ++ set(install_libdir "${CMAKE_INSTALL_LIBDIR}") ++ else() ++ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}") ++ endif() + foreach(file_name ${library_files}) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) ++ ${install_libdir}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) + endforeach() + + file(MAKE_DIRECTORY ${OAM_WRAPPER_LIB_DIR}) +@@ -151,11 +166,16 @@ function(create_library_symlink) + set(library_files "${LIB_OAM}") + endif() + ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) ++ set(install_libdir "${CMAKE_INSTALL_LIBDIR}") ++ else() ++ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}") ++ endif() + foreach(file_name ${library_files}) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) ++ ${install_libdir}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) + endforeach() + + endfunction() +diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt +index c594eeb..d3ed39d 100755 +--- a/rocm_smi/CMakeLists.txt ++++ b/rocm_smi/CMakeLists.txt +@@ -105,10 +105,15 @@ endif () + #file reorganization changes + #rocm_smi.py moved to libexec/rocm_smi. so creating rocm-smi symlink + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) ++if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBEXECDIR}) ++ set(install_libexecdir "${CMAKE_INSTALL_LIBEXECDIR}") ++else() ++ set(install_libexecdir "../${CMAKE_INSTALL_LIBEXECDIR}") ++endif() + add_custom_target(link-rocm-smi ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) ++ ${install_libexecdir}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) + + ## Add the install directives for the runtime library. + install(TARGETS ${ROCM_SMI_TARGET} diff --git a/pkgs/development/rocm-modules/5/rocm-smi/default.nix b/pkgs/development/rocm-modules/5/rocm-smi/default.nix new file mode 100644 index 0000000000000..2e1692539e23c --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-smi/default.nix @@ -0,0 +1,54 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, wrapPython +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-smi"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rocm_smi_lib"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-swCRO4PBMBJ6fO2bLq/xxFZIYw2IgiFB490wsU8Wm2o="; + }; + + patches = [ ./cmake.patch ]; + + nativeBuildInputs = [ + cmake + wrapPython + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postInstall = '' + wrapPythonProgramsIn $out + mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "System management interface for AMD GPUs supported by ROCm"; + homepage = "https://github.com/RadeonOpenCompute/rocm_smi_lib"; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = [ "x86_64-linux" ]; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocm-thunk/default.nix b/pkgs/development/rocm-modules/5/rocm-thunk/default.nix new file mode 100644 index 0000000000000..73368dbb0e7f1 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocm-thunk/default.nix @@ -0,0 +1,54 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, pkg-config +, cmake +, libdrm +, numactl +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocm-thunk"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "ROCT-Thunk-Interface"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-jAMBks2/JaXiA45B3qvLHY8fPeFcr1GHT5Jieuduqhw="; + }; + + nativeBuildInputs = [ + pkg-config + cmake + ]; + + buildInputs = [ + libdrm + numactl + ]; + + cmakeFlags = [ + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Radeon open compute thunk interface"; + homepage = "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"; + license = with licenses; [ bsd2 mit ]; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocminfo/default.nix b/pkgs/development/rocm-modules/5/rocminfo/default.nix new file mode 100644 index 0000000000000..c9ff79e380ffa --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocminfo/default.nix @@ -0,0 +1,63 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocm-runtime +, busybox +, python3 +, gnugrep + # rocminfo requires that the calling user have a password and be in + # the video group. If we let rocm_agent_enumerator rely upon + # rocminfo's output, then it, too, has those requirements. Instead, + # we can specify the GPU targets for this system (e.g. "gfx803" for + # Polaris) such that no system call is needed for downstream + # compilers to determine the desired target. +, defaultTargets ? [] +}: + +stdenv.mkDerivation (finalAttrs: { + version = "5.7.0"; + pname = "rocminfo"; + + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rocminfo"; + rev = "rocm-${finalAttrs.version}"; + sha256 = "sha256-UzOo2qDT/uM+vdGdBM4pV5e143mfa+/6sZLBExOO26g="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + ]; + + buildInputs = [ rocm-runtime ]; + propagatedBuildInputs = [ python3 ]; + cmakeFlags = [ "-DROCRTST_BLD_TYPE=Release" ]; + + prePatch = '' + patchShebangs rocm_agent_enumerator + sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc + ''; + + postInstall = lib.optionalString (defaultTargets != [ ]) '' + echo '${lib.concatStringsSep "\n" defaultTargets}' > $out/bin/target.lst + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm Application for Reporting System Info"; + homepage = "https://github.com/RadeonOpenCompute/rocminfo"; + license = licenses.ncsa; + maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members; + platforms = platforms.linux; + broken = stdenv.isAarch64 || versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocmlir/default.nix b/pkgs/development/rocm-modules/5/rocmlir/default.nix new file mode 100644 index 0000000000000..a2a4923148a0b --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocmlir/default.nix @@ -0,0 +1,106 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, ninja +, hip +, rocminfo +, git +, libxml2 +, libedit +, zlib +, ncurses +, python3 +, buildRockCompiler ? false +}: + +# 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: { + pname = "rocmlir"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals (!buildRockCompiler) [ + "external" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocMLIR"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-vPi4UVljohVAfnwDVQqeOVaJPa6v8aV5uBOtqLddTtc="; + }; + + nativeBuildInputs = [ + cmake + ninja + ] ++ lib.optionals (!buildRockCompiler) [ + hip + ]; + + buildInputs = [ + git + libxml2 + libedit + python3 + ]; + + propagatedBuildInputs = [ + zlib + ncurses + ]; + + cmakeFlags = [ + "-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}" + "-DLLVM_ENABLE_ZLIB=ON" + "-DLLVM_ENABLE_TERMINFO=ON" + ] ++ lib.optionals buildRockCompiler [ + "-DBUILD_FAT_LIBROCKCOMPILER=ON" + ] ++ lib.optionals (!buildRockCompiler) [ + "-DROCM_PATH=${rocminfo}" + "-DROCM_TEST_CHIPSET=gfx000" + ]; + + 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*} + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + page = "tags?per_page=2"; + filter = ".[1].name | split(\"-\") | .[1]"; + }; + + meta = with lib; { + description = "MLIR-based convolution and GEMM kernel generator"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocMLIR"; + license = with licenses; [ asl20 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocprim/default.nix b/pkgs/development/rocm-modules/5/rocprim/default.nix new file mode 100644 index 0000000000000..e8233547664f1 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocprim/default.nix @@ -0,0 +1,82 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, gtest +, gbenchmark +, buildTests ? false +, buildBenchmarks ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprim"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocPRIM"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-+ukFWsWv3RhS+Z6tmR4TRT8QTYEDuAEk12F9Gv1eXGU="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = lib.optionals buildTests [ + gtest + ] ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm parallel primitives"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocPRIM"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocprofiler/default.nix b/pkgs/development/rocm-modules/5/rocprofiler/default.nix new file mode 100644 index 0000000000000..ec24a3f41e59b --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocprofiler/default.nix @@ -0,0 +1,108 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, clang +, clr +, rocm-thunk +, roctracer +, rocm-smi +, hsa-amd-aqlprofile-bin +, numactl +, libpciaccess +, libxml2 +, elfutils +, mpi +, gtest +, python3Packages +, gpuTargets ? [ + "gfx900" + "gfx906" + "gfx908" + "gfx90a" + "gfx940" + "gfx941" + "gfx942" + "gfx1030" + "gfx1100" + "gfx1101" + "gfx1102" +] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocprofiler"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "rocprofiler"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-ue/2uiLbhOv/5XY4cIJuZ8DUMRhniYgxolq9xMwO1FY="; + }; + + nativeBuildInputs = [ + cmake + clang + clr + python3Packages.lxml + python3Packages.cppheaderparser + python3Packages.pyyaml + python3Packages.barectf + ]; + + buildInputs = [ + rocm-thunk + rocm-smi + hsa-amd-aqlprofile-bin + numactl + libpciaccess + libxml2 + elfutils + mpi + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" + "-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext" + "-DHIP_ROOT_DIR=${clr}" + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + postPatch = '' + patchShebangs . + + # Cannot find ROCm device library, pointless + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(tests-v2)" "" \ + --replace "add_subdirectory(samples)" "" + ''; + + postBuild = '' + # HSACO aren't being built for some reason + substituteInPlace test/cmake_install.cmake \ + --replace "file(INSTALL DESTINATION \"\''${CMAKE_INSTALL_PREFIX}/share/rocprofiler/tests-v1\" TYPE FILE FILES \"" "message(\"" + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Profiling with perf-counters and derived metrics"; + homepage = "https://github.com/ROCm-Developer-Tools/rocprofiler"; + license = with licenses; [ mit ]; # mitx11 + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor clr.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix b/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix new file mode 100644 index 0000000000000..dfc8580b3e140 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocr-debug-agent/default.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, clr +, git +, rocdbgapi +, elfutils +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocr-debug-agent"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "rocr_debug_agent"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-AUDbNrFtUQ5Hm+uv5KMovh7P9wXQKLyRNx9gEQFnv6Y="; + }; + + nativeBuildInputs = [ + cmake + clr + git + ]; + + buildInputs = [ + rocdbgapi + elfutils + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip" + "-DHIP_ROOT_DIR=${clr}" + "-DHIP_PATH=${clr}" + ]; + + # Weird install target + postInstall = '' + rm -rf $out/src + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Library that provides some debugging functionality for ROCr"; + homepage = "https://github.com/ROCm-Developer-Tools/rocr_debug_agent"; + license = with licenses; [ ncsa ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocrand/default.nix b/pkgs/development/rocm-modules/5/rocrand/default.nix new file mode 100644 index 0000000000000..daa24b870cebb --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocrand/default.nix @@ -0,0 +1,85 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, gtest +, gbenchmark +, buildTests ? false +, buildBenchmarks ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocrand"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocRAND"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-cFH38fLD8tk6V9JERcqHokuwKemdDgHCZ75bZNEqmdY="; + fetchSubmodules = true; # For inline hipRAND + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = lib.optionals buildTests [ + gtest + ] ++ lib.optionals buildBenchmarks [ + gbenchmark + ]; + + cmakeFlags = [ + "-DCMAKE_C_COMPILER=hipcc" + "-DCMAKE_CXX_COMPILER=hipcc" + "-DHIP_ROOT_DIR=${hip}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARK=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/test_* $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Generate pseudo-random and quasi-random numbers"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocRAND"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocsolver/default.nix b/pkgs/development/rocm-modules/5/rocsolver/default.nix new file mode 100644 index 0000000000000..3a0858af63356 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocsolver/default.nix @@ -0,0 +1,95 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocblas +, hip +, fmt +, gtest +, gfortran +, lapack-reference +, buildTests ? false +, buildBenchmarks ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx803" "gfx900" "gfx906:xnack-" ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocsolver"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocSOLVER"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-qxmjm4tgpCnfJ2SqUXndk6y0MsPJUKHvjv/3Uc0smr4="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gfortran + ]; + + buildInputs = [ + rocblas + fmt + ] ++ lib.optionals buildTests [ + gtest + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + lapack-reference + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals (gpuTargets != [ ]) [ + "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] ++ lib.optionals buildTests [ + "-DBUILD_CLIENTS_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/rocsolver-test $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/rocsolver-bench $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rmdir $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + requiredSystemFeatures = [ "big-parallel" ]; + + meta = with lib; { + description = "ROCm LAPACK implementation"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocSOLVER"; + license = with licenses; [ bsd2 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocsparse/default.nix b/pkgs/development/rocm-modules/5/rocsparse/default.nix new file mode 100644 index 0000000000000..d97951530119d --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocsparse/default.nix @@ -0,0 +1,146 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchzip +, rocmUpdateScript +, cmake +, rocm-cmake +, rocprim +, hip +, gfortran +, git +, gtest +, boost +, python3Packages +, buildTests ? false +, buildBenchmarks ? false # Seems to depend on tests +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocsparse"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocSPARSE"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-30q9bqgZJUaNrkMXTAG+Z34yjsQ5DpJP+WBcCiEmF58="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + gfortran + ]; + + buildInputs = [ + rocprim + git + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + boost + python3Packages.python + python3Packages.pyyaml + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DBUILD_CLIENTS_TESTS=ON" + "-DCMAKE_MATRICES_DIR=/build/source/matrices" + "-Dpython=python3" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_CLIENTS_BENCHMARKS=ON" + ]; + + # We have to manually generate the matrices + postPatch = lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p matrices + + ln -s ${finalAttrs.passthru.matrices.matrix-01}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-02}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-03}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-04}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-05}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-06}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-07}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-08}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-09}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-10}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-11}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-12}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-13}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-14}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-15}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-16}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-17}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-18}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-19}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-20}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-21}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-22}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-23}/*.mtx matrices + ln -s ${finalAttrs.passthru.matrices.matrix-24}/*.mtx matrices + + # Not used by the original cmake, causes an error + rm matrices/*_b.mtx + + echo "deps/convert.cpp -> deps/mtx2csr" + hipcc deps/convert.cpp -O3 -o deps/mtx2csr + + for mat in $(ls -1 matrices | cut -d "." -f 1); do + echo "mtx2csr: $mat.mtx -> $mat.csr" + deps/mtx2csr matrices/$mat.mtx matrices/$mat.csr + unlink matrices/$mat.mtx + done + ''; + + postInstall = lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + cp -a $out/bin/* $benchmark/bin + rm $benchmark/bin/rocsparse-test + '' + lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p $test/bin + mv $out/bin/* $test/bin + rm $test/bin/rocsparse-bench || true + mv /build/source/matrices $test + rmdir $out/bin + ''; + + passthru = { + matrices = import ./deps.nix { + inherit fetchzip; + mirror1 = "https://sparse.tamu.edu/MM"; + mirror2 = "https://www.cise.ufl.edu/research/sparse/MM"; + }; + + updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + }; + + meta = with lib; { + description = "ROCm SPARSE implementation"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocSPARSE"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocsparse/deps.nix b/pkgs/development/rocm-modules/5/rocsparse/deps.nix new file mode 100644 index 0000000000000..cef880ab3232d --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocsparse/deps.nix @@ -0,0 +1,222 @@ +{ fetchzip +, mirror1 +, mirror2 +}: + +{ + matrix-01 = fetchzip { + sha256 = "sha256-AHur5ZIDZTFRrO2GV0ieXrffq4KUiGWiZ59pv0fUtEQ="; + + urls = [ + "${mirror1}/SNAP/amazon0312.tar.gz" + "${mirror2}/SNAP/amazon0312.tar.gz" + ]; + }; + + matrix-02 = fetchzip { + sha256 = "sha256-0rSxaN4lQcdaCLsvlgicG70FXUxXeERPiEmQ4MzbRdE="; + + urls = [ + "${mirror1}/Muite/Chebyshev4.tar.gz" + "${mirror2}/Muite/Chebyshev4.tar.gz" + ]; + }; + + matrix-03 = fetchzip { + sha256 = "sha256-hDzDWDUnHEyFedX/tMNq83ZH8uWyM4xtZYUUAD3rizo="; + + urls = [ + "${mirror1}/FEMLAB/sme3Dc.tar.gz" + "${mirror2}/FEMLAB/sme3Dc.tar.gz" + ]; + }; + + matrix-04 = fetchzip { + sha256 = "sha256-GmN2yOt/MoX01rKe05aTyB3ypUP4YbQGOITZ0BqPmC0="; + + urls = [ + "${mirror1}/Williams/webbase-1M.tar.gz" + "${mirror2}/Williams/webbase-1M.tar.gz" + ]; + }; + + matrix-05 = fetchzip { + sha256 = "sha256-gQNjfVyWzNM9RwImJGhkhahRmZz74LzDs1oijL7mI7k="; + + urls = [ + "${mirror1}/Williams/mac_econ_fwd500.tar.gz" + "${mirror2}/Williams/mac_econ_fwd500.tar.gz" + ]; + }; + + matrix-06 = fetchzip { + sha256 = "sha256-87cdZjntNcTuz5BtO59irhcuRbPllWSbhCEX3Td02qc="; + + urls = [ + "${mirror1}/Williams/mc2depi.tar.gz" + "${mirror2}/Williams/mc2depi.tar.gz" + ]; + }; + + matrix-07 = fetchzip { + sha256 = "sha256-WRamuJX3D8Tm+k0q67RjUDG3DeNAxhKiaPkk5afY5eU="; + + urls = [ + "${mirror1}/Bova/rma10.tar.gz" + "${mirror2}/Bova/rma10.tar.gz" + ]; + }; + + matrix-08 = fetchzip { + sha256 = "sha256-5dhkm293Mc3lzakKxHy5W5XIn4Rw+gihVh7gyrjEHXo="; + + urls = [ + "${mirror1}/JGD_BIBD/bibd_22_8.tar.gz" + "${mirror2}/JGD_BIBD/bibd_22_8.tar.gz" + ]; + }; + + matrix-09 = fetchzip { + sha256 = "sha256-czjLWCjXAjZCk5TGYHaEkwSAzQu3TQ3QyB6eNKR4G88="; + + urls = [ + "${mirror1}/Hamm/scircuit.tar.gz" + "${mirror2}/Hamm/scircuit.tar.gz" + ]; + }; + + matrix-10 = fetchzip { + sha256 = "sha256-bYuLnJViAIcIejAkh69/bsNAVIDU4wfTLtD+nmHd6FM="; + + urls = [ + "${mirror1}/Sandia/ASIC_320k.tar.gz" + "${mirror2}/Sandia/ASIC_320k.tar.gz" + ]; + }; + + matrix-11 = fetchzip { + sha256 = "sha256-aDwn8P1khYjo2Agbq5m9ZBInJUxf/knJNvyptt0fak0="; + + urls = [ + "${mirror1}/GHS_psdef/bmwcra_1.tar.gz" + "${mirror2}/GHS_psdef/bmwcra_1.tar.gz" + ]; + }; + + matrix-12 = fetchzip { + sha256 = "sha256-8OJqA/byhlAZd869TPUzZFdsOiwOoRGfKyhM+RMjXoY="; + + urls = [ + "${mirror1}/HB/nos1.tar.gz" + "${mirror2}/HB/nos1.tar.gz" + ]; + }; + + matrix-13 = fetchzip { + sha256 = "sha256-FS0rKqmg+uHwsM/yGfQLBdd7LH/rUrdutkNGBD/Mh1I="; + + urls = [ + "${mirror1}/HB/nos2.tar.gz" + "${mirror2}/HB/nos2.tar.gz" + ]; + }; + + matrix-14 = fetchzip { + sha256 = "sha256-DANnlrNJikrI7Pst9vRedtbuxepyHmCIu2yhltc4Qcs="; + + urls = [ + "${mirror1}/HB/nos3.tar.gz" + "${mirror2}/HB/nos3.tar.gz" + ]; + }; + + matrix-15 = fetchzip { + sha256 = "sha256-21mUgqjWGUfYgiWwSrKh9vH8Vdt3xzcefmqYNYRpxiY="; + + urls = [ + "${mirror1}/HB/nos4.tar.gz" + "${mirror2}/HB/nos4.tar.gz" + ]; + }; + + matrix-16 = fetchzip { + sha256 = "sha256-FOuXvGqBBFNkVS6cexmkluret54hCfCOdK+DOZllE4c="; + + urls = [ + "${mirror1}/HB/nos5.tar.gz" + "${mirror2}/HB/nos5.tar.gz" + ]; + }; + + matrix-17 = fetchzip { + sha256 = "sha256-+7NI1rA/qQxYPpjXKHvAaCZ+LSaAJ4xuJvMRMBEUYxg="; + + urls = [ + "${mirror1}/HB/nos6.tar.gz" + "${mirror2}/HB/nos6.tar.gz" + ]; + }; + + matrix-18 = fetchzip { + sha256 = "sha256-q3NxJjbwGGcFiQ9nhWfUKgZmdVwCfPmgQoqy0AqOsNc="; + + urls = [ + "${mirror1}/HB/nos7.tar.gz" + "${mirror2}/HB/nos7.tar.gz" + ]; + }; + + matrix-19 = fetchzip { + sha256 = "sha256-0GAN6qmVfD+tprIigzuUUUwm5KVhkN9X65wMEvFltDY="; + + urls = [ + "${mirror1}/DNVS/shipsec1.tar.gz" + "${mirror2}/DNVS/shipsec1.tar.gz" + ]; + }; + + matrix-20 = fetchzip { + sha256 = "sha256-f28Du/Urxsiq5NkRmRO10Zz9vvGRjEchquzHzbZpZ7U="; + + urls = [ + "${mirror1}/Cote/mplate.tar.gz" + "${mirror2}/Cote/mplate.tar.gz" + ]; + }; + + matrix-21 = fetchzip { + sha256 = "sha256-O+Wy0NfCU1hVUOfNR1dJpvDHLBwwa301IRJDrQJnhak="; + + urls = [ + "${mirror1}/Bai/qc2534.tar.gz" + "${mirror2}/Bai/qc2534.tar.gz" + ]; + }; + + matrix-22 = fetchzip { + sha256 = "sha256-oxMnt8U5Cf1ILWcBdU6W9jdSMMm+U6bIVl8nm3n3+OA="; + + urls = [ + "${mirror1}/Chevron/Chevron2.tar.gz" + "${mirror2}/Chevron/Chevron2.tar.gz" + ]; + }; + + matrix-23 = fetchzip { + sha256 = "sha256-MFD9BxFI/3IS7yatW121BAI04fbqrXpgYDT5UKjeKcU="; + + urls = [ + "${mirror1}/Chevron/Chevron3.tar.gz" + "${mirror2}/Chevron/Chevron3.tar.gz" + ]; + }; + + matrix-24 = fetchzip { + sha256 = "sha256-ikS8O51pe1nt3BNyhvfvqCbVL0+bg/da9bqGqeBDkTg="; + + urls = [ + "${mirror1}/Chevron/Chevron4.tar.gz" + "${mirror2}/Chevron/Chevron4.tar.gz" + ]; + }; +} diff --git a/pkgs/development/rocm-modules/5/rocthrust/default.nix b/pkgs/development/rocm-modules/5/rocthrust/default.nix new file mode 100644 index 0000000000000..e441709f89f77 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocthrust/default.nix @@ -0,0 +1,84 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, rocprim +, hip +, gtest +, buildTests ? false +, buildBenchmarks ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "rocthrust"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildTests [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocThrust"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-i0XCtJth8caVQT5oUgsxWXNzcePa02Gb7AQsthYTOv8="; + }; + + nativeBuildInputs = [ + cmake + rocm-cmake + rocprim + hip + ]; + + buildInputs = lib.optionals buildTests [ + gtest + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + "-DHIP_ROOT_DIR=${hip}" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals buildTests [ + "-DBUILD_TEST=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DBUILD_BENCHMARKS=ON" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "-DCMAKE_CXX_FLAGS=-Wno-deprecated-builtins" # Too much spam + ]; + + postInstall = lib.optionalString buildTests '' + mkdir -p $test/bin + mv $out/bin/{test_*,*.hip} $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/benchmark_* $benchmark/bin + '' + lib.optionalString (buildTests || buildBenchmarks) '' + rm -rf $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "ROCm parallel algorithm library"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocThrust"; + license = with licenses; [ asl20 ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/roctracer/default.nix b/pkgs/development/rocm-modules/5/roctracer/default.nix new file mode 100644 index 0000000000000..92e557426b10c --- /dev/null +++ b/pkgs/development/rocm-modules/5/roctracer/default.nix @@ -0,0 +1,105 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, clang +, clr +, rocm-device-libs +, rocprofiler +, libxml2 +, doxygen +, graphviz +, gcc-unwrapped +, rocm-runtime +, python3Packages +, buildDocs ? false # Nothing seems to be generated, so not making the output +, buildTests ? false +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "roctracer"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals buildTests [ + "test" + ]; + + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "roctracer"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-P6QYyAjMRwFFWKF8AhbrYGe+mYVJXdbBW1or6vcobYU="; + }; + + nativeBuildInputs = [ + cmake + clang + clr + ] ++ lib.optionals buildDocs [ + doxygen + graphviz + ]; + + buildInputs = [ + rocprofiler + libxml2 + python3Packages.python + python3Packages.cppheaderparser + ]; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; + + env.NIX_CFLAGS_COMPILE = toString [ + # Needed with GCC 12 + "-Wno-error=array-bounds" + ]; + + postPatch = '' + export HIP_DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode + '' + lib.optionalString (!buildTests) '' + substituteInPlace CMakeLists.txt \ + --replace "add_subdirectory(test)" "" + ''; + + # Tests always fail, probably need GPU + # doCheck = buildTests; + + postInstall = lib.optionalString buildDocs '' + mkdir -p $doc + '' + lib.optionalString buildTests '' + mkdir -p $test/bin + # Not sure why this is an install target + find $out/test -executable -type f -exec mv {} $test/bin \; + rm $test/bin/{*.sh,*.py} + patchelf --set-rpath $out/lib:${lib.makeLibraryPath ( + finalAttrs.buildInputs ++ [ clr gcc-unwrapped.lib rocm-runtime ])} $test/bin/* + rm -rf $out/test + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Tracer callback/activity library"; + homepage = "https://github.com/ROCm-Developer-Tools/roctracer"; + license = with licenses; [ mit ]; # mitx11 + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor clr.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch b/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch new file mode 100644 index 0000000000000..cee6036797580 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocwmma/0000-dont-fetch-googletest.patch @@ -0,0 +1,31 @@ +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index e1160bb..2a5462e 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -30,26 +30,6 @@ cmake_dependent_option( ROCWMMA_BUILD_VALIDATION_TESTS "Build validation tests" + cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests" OFF "ROCWMMA_BUILD_TESTS" OFF ) + cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF ) + +-# Test/benchmark requires additional dependencies +-include( FetchContent ) +- +-FetchContent_Declare( +- googletest +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG 609281088cfefc76f9d0ce82e1ff6c30cc3591e5 +-) +-FetchContent_GetProperties(googletest) +-if(NOT googletest_POPULATED) +- # Fetch the content using default details +- FetchContent_Populate(googletest) +- # Save the shared libs setting, then force to static libs +- set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) +- set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries" FORCE) +- # Add gtest targets as static libs +- add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) +- # Restore shared libs setting +- set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE INTERNAL "Build SHARED libraries" FORCE) +-endif() + + set(ROCWMMA_TEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) + set(ROCWMMA_COMMON_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hip_device.cpp diff --git a/pkgs/development/rocm-modules/5/rocwmma/default.nix b/pkgs/development/rocm-modules/5/rocwmma/default.nix new file mode 100644 index 0000000000000..ef21ed86248a3 --- /dev/null +++ b/pkgs/development/rocm-modules/5/rocwmma/default.nix @@ -0,0 +1,146 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, cmake +, rocm-cmake +, hip +, openmp +, gtest +, rocblas +, texlive +, doxygen +, sphinx +, python3Packages +, buildDocs ? true +, buildTests ? false +, buildExtendedTests ? false +, buildBenchmarks ? false +, buildSamples ? false +, gpuTargets ? [ ] # gpuTargets = [ "gfx908:xnack-" "gfx90a:xnack-" "gfx90a:xnack+" ... ] +}: + +let + latex = lib.optionalAttrs buildDocs texlive.combine { + inherit (texlive) scheme-small + latexmk + tex-gyre + fncychap + wrapfig + capt-of + framed + needspace + tabulary + varwidth + titlesec; + }; +in stdenv.mkDerivation (finalAttrs: { + pname = "rocwmma"; + version = "5.7.0"; + + outputs = [ + "out" + ] ++ lib.optionals buildDocs [ + "doc" + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + "test" + ] ++ lib.optionals buildBenchmarks [ + "benchmark" + ] ++ lib.optionals buildSamples [ + "sample" + ]; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "rocWMMA"; + rev = "rocm-${finalAttrs.version}"; + hash = "sha256-/EuBBSjhlMwJfsqYvRb9oCNC0hNkEa1JH1KUDLMSs08="; + }; + + patches = lib.optionals (buildTests || buildBenchmarks) [ + ./0000-dont-fetch-googletest.patch + ]; + + nativeBuildInputs = [ + cmake + rocm-cmake + hip + ]; + + buildInputs = [ + openmp + ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest + rocblas + ] ++ lib.optionals buildDocs [ + latex + doxygen + sphinx + python3Packages.sphinx-rtd-theme + python3Packages.breathe + ]; + + cmakeFlags = [ + "-DCMAKE_CXX_COMPILER=hipcc" + "-DROCWMMA_BUILD_TESTS=${if buildTests || buildBenchmarks then "ON" else "OFF"}" + "-DROCWMMA_BUILD_VALIDATION_TESTS=ON" + "-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}" + "-DROCWMMA_VALIDATE_WITH_ROCBLAS=ON" + # Manually define CMAKE_INSTALL_<DIR> + # See: https://github.com/NixOS/nixpkgs/pull/197838 + "-DCMAKE_INSTALL_BINDIR=bin" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ] ++ lib.optionals (gpuTargets != [ ]) [ + "-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" + ] ++ lib.optionals buildExtendedTests [ + "-DROCWMMA_BUILD_EXTENDED_TESTS=ON" + ] ++ lib.optionals buildBenchmarks [ + "-DROCWMMA_BUILD_BENCHMARK_TESTS=ON" + "-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON" + ]; + + postPatch = lib.optionalString buildDocs '' + patchShebangs docs/*.sh + ''; + + # Unfortunately, it seems like we have to call make on this manually + # -DROCWMMA_BUILD_DOCS=ON is invalid, despite being on the README + postBuild = lib.optionalString buildDocs '' + export HOME=$(mktemp -d) + ../docs/run_doc.sh + ''; + + postInstall = lib.optionalString buildDocs '' + mv ../docs/source/_build/html $out/share/doc/rocwmma + mv ../docs/source/_build/latex/rocWMMA.pdf $out/share/doc/rocwmma + '' + lib.optionalString (buildTests || buildBenchmarks) '' + mkdir -p $test/bin + mv $out/bin/{*_test,*-validate} $test/bin + '' + lib.optionalString buildBenchmarks '' + mkdir -p $benchmark/bin + mv $out/bin/*-bench $benchmark/bin + '' + lib.optionalString buildSamples '' + mkdir -p $sample/bin + mv $out/bin/sgemmv $sample/bin + mv $out/bin/simple_gemm $sample/bin + mv $out/bin/simple_dlrm $sample/bin + '' + lib.optionalString (buildTests || buildBenchmarks || buildSamples) '' + rm -rf $out/bin + ''; + + passthru.updateScript = rocmUpdateScript { + name = finalAttrs.pname; + owner = finalAttrs.src.owner; + repo = finalAttrs.src.repo; + }; + + meta = with lib; { + description = "Mixed precision matrix multiplication and accumulation"; + homepage = "https://github.com/ROCmSoftwarePlatform/rocWMMA"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version; + }; +}) diff --git a/pkgs/development/rocm-modules/5/tensile/default.nix b/pkgs/development/rocm-modules/5/tensile/default.nix new file mode 100644 index 0000000000000..7d0165a420603 --- /dev/null +++ b/pkgs/development/rocm-modules/5/tensile/default.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, fetchFromGitHub +, rocmUpdateScript +, buildPythonPackage +, pyyaml +, msgpack +, pandas +}: + +buildPythonPackage rec { + pname = "tensile"; + version = "5.7.0"; + + src = fetchFromGitHub { + owner = "ROCmSoftwarePlatform"; + repo = "Tensile"; + rev = "rocm-${version}"; + hash = "sha256-CyPGiM/53duJc/oNtOsl6JSsl9uOOYm5R7O6YXaVOm4="; + }; + + buildInputs = [ + pyyaml + msgpack + pandas + ]; + + passthru.updateScript = rocmUpdateScript { + name = pname; + owner = src.owner; + repo = src.repo; + }; + + meta = with lib; { + description = "GEMMs and tensor contractions"; + homepage = "https://github.com/ROCmSoftwarePlatform/Tensile"; + license = with licenses; [ mit ]; + maintainers = teams.rocm.members; + platforms = platforms.linux; + broken = versions.minor version != versions.minor stdenv.cc.version; + }; +} diff --git a/pkgs/development/rocm-modules/5/update.nix b/pkgs/development/rocm-modules/5/update.nix index abd434776ef92..1cc7e354d2409 100644 --- a/pkgs/development/rocm-modules/5/update.nix +++ b/pkgs/development/rocm-modules/5/update.nix @@ -12,7 +12,7 @@ let pname = if lib.hasPrefix "rocm-llvm-" name - then "rocmPackages_5.llvm.${lib.removePrefix "rocm-llvm-" name}" + then "llvm.${lib.removePrefix "rocm-llvm-" name}" else name; updateScript = writeScript "update.sh" '' @@ -27,6 +27,6 @@ let version="''${version}.0" fi - update-source-version ${pname} "$version" --ignore-same-hash + update-source-version rocmPackages_5.${pname} "$version" --ignore-same-hash ''; in [ updateScript ] |