at master 102 lines 2.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rocmUpdateScript, 6 cmake, 7 rocm-cmake, 8 rocm-docs-core, 9 half, 10 clr, 11 openmp, 12 boost, 13 python3Packages, 14 buildDocs ? false, # Needs internet 15 useOpenCL ? false, 16 useCPU ? false, 17 gpuTargets ? [ ], 18}: 19 20stdenv.mkDerivation (finalAttrs: { 21 pname = 22 "rpp-" 23 + ( 24 if (!useOpenCL && !useCPU) then 25 "hip" 26 else if (!useOpenCL && !useCPU) then 27 "opencl" 28 else 29 "cpu" 30 ); 31 32 version = "6.3.3"; 33 34 src = fetchFromGitHub { 35 owner = "ROCm"; 36 repo = "rpp"; 37 rev = "rocm-${finalAttrs.version}"; 38 hash = "sha256-METwagek17/DdZGaOTQqvyU6xGt7OBMLHk4YM4KmgtA="; 39 }; 40 41 nativeBuildInputs = [ 42 cmake 43 rocm-cmake 44 clr 45 ] 46 ++ lib.optionals buildDocs [ 47 rocm-docs-core 48 python3Packages.python 49 ]; 50 51 buildInputs = [ 52 half 53 openmp 54 boost 55 ]; 56 57 CFLAGS = "-I${openmp.dev}/include"; 58 CXXFLAGS = "-I${openmp.dev}/include"; 59 cmakeFlags = [ 60 "-DOpenMP_C_INCLUDE_DIR=${openmp.dev}/include" 61 "-DOpenMP_CXX_INCLUDE_DIR=${openmp.dev}/include" 62 "-DOpenMP_omp_LIBRARY=${openmp}/lib" 63 "-DROCM_PATH=${clr}" 64 ] 65 ++ lib.optionals (gpuTargets != [ ]) [ 66 "-DAMDGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}" 67 ] 68 ++ lib.optionals (!useOpenCL && !useCPU) [ 69 "-DBACKEND=HIP" 70 ] 71 ++ lib.optionals (useOpenCL && !useCPU) [ 72 "-DBACKEND=OCL" 73 ] 74 ++ lib.optionals useCPU [ 75 "-DBACKEND=CPU" 76 ]; 77 78 postPatch = lib.optionalString (!useOpenCL && !useCPU) '' 79 # Bad path 80 substituteInPlace CMakeLists.txt \ 81 --replace "COMPILER_FOR_HIP \''${ROCM_PATH}/llvm/bin/clang++" "COMPILER_FOR_HIP ${clr}/bin/hipcc" 82 ''; 83 84 postBuild = lib.optionalString buildDocs '' 85 python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en ../docs _build/html 86 ''; 87 88 passthru.updateScript = rocmUpdateScript { 89 name = finalAttrs.pname; 90 inherit (finalAttrs.src) owner; 91 inherit (finalAttrs.src) repo; 92 }; 93 94 meta = with lib; { 95 description = "Comprehensive high-performance computer vision library for AMD processors"; 96 homepage = "https://github.com/ROCm/rpp"; 97 license = with licenses; [ mit ]; 98 teams = [ teams.rocm ]; 99 platforms = platforms.linux; 100 broken = useOpenCL; 101 }; 102})