Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, rocmUpdateScript 5, pkg-config 6, cmake 7, rocm-cmake 8, hip 9, clang-tools-extra 10, openmp 11, rocblas 12, rocmlir 13, miopengemm 14, miopen 15, protobuf 16, half 17, nlohmann_json 18, msgpack 19, sqlite 20, oneDNN 21, blaze 22, texlive 23, doxygen 24, sphinx 25, docutils 26, ghostscript 27, python3Packages 28, buildDocs ? false 29, buildTests ? false 30}: 31 32let 33 latex = lib.optionalAttrs buildDocs texlive.combine { 34 inherit (texlive) scheme-small 35 latexmk 36 tex-gyre 37 fncychap 38 wrapfig 39 capt-of 40 framed 41 needspace 42 tabulary 43 varwidth 44 titlesec 45 epstopdf; 46 }; 47in stdenv.mkDerivation (finalAttrs: { 48 pname = "migraphx"; 49 version = "5.4.3"; 50 51 outputs = [ 52 "out" 53 ] ++ lib.optionals buildDocs [ 54 "doc" 55 ] ++ lib.optionals buildTests [ 56 "test" 57 ]; 58 59 src = fetchFromGitHub { 60 owner = "ROCmSoftwarePlatform"; 61 repo = "AMDMIGraphX"; 62 rev = "rocm-${finalAttrs.version}"; 63 hash = "sha256-UDhm+j9qs4Rk81C1PE4kkacytfY2StYbfsCOtFL+p6s="; 64 }; 65 66 nativeBuildInputs = [ 67 pkg-config 68 cmake 69 rocm-cmake 70 hip 71 clang-tools-extra 72 python3Packages.python 73 ] ++ lib.optionals buildDocs [ 74 latex 75 doxygen 76 sphinx 77 docutils 78 ghostscript 79 python3Packages.sphinx-rtd-theme 80 python3Packages.breathe 81 ]; 82 83 buildInputs = [ 84 openmp 85 rocblas 86 rocmlir 87 miopengemm 88 miopen 89 protobuf 90 half 91 nlohmann_json 92 msgpack 93 sqlite 94 oneDNN 95 blaze 96 python3Packages.pybind11 97 python3Packages.onnx 98 ]; 99 100 cmakeFlags = [ 101 "-DCMAKE_POLICY_DEFAULT_CMP0079=NEW" 102 # "-DCMAKE_C_COMPILER=hipcc" 103 # "-DCMAKE_CXX_COMPILER=hipcc" 104 "-DMIGRAPHX_ENABLE_GPU=OFF" # GPU compilation is broken, don't know why 105 "-DMIGRAPHX_ENABLE_CPU=ON" 106 "-DMIGRAPHX_ENABLE_FPGA=ON" 107 "-DMIGRAPHX_ENABLE_MLIR=ON" 108 # Manually define CMAKE_INSTALL_<DIR> 109 # See: https://github.com/NixOS/nixpkgs/pull/197838 110 "-DCMAKE_INSTALL_BINDIR=bin" 111 "-DCMAKE_INSTALL_LIBDIR=lib" 112 "-DCMAKE_INSTALL_INCLUDEDIR=include" 113 ]; 114 115 postPatch = '' 116 patchShebangs tools 117 118 substituteInPlace src/targets/gpu/CMakeLists.txt \ 119 --replace "CMAKE_CXX_COMPILER MATCHES \".*clang\\\+\\\+\$\"" "TRUE" 120 '' + lib.optionalString (!buildDocs) '' 121 substituteInPlace CMakeLists.txt \ 122 --replace "add_subdirectory(doc)" "" 123 '' + lib.optionalString (!buildTests) '' 124 substituteInPlace CMakeLists.txt \ 125 --replace "add_subdirectory(test)" "" 126 ''; 127 128 # Unfortunately, it seems like we have to call make on this manually 129 preInstall = lib.optionalString buildDocs '' 130 export HOME=$(mktemp -d) 131 make -j$NIX_BUILD_CORES doc 132 cd ../doc/pdf 133 make -j$NIX_BUILD_CORES 134 cd - 135 ''; 136 137 postInstall = lib.optionalString buildDocs '' 138 mv ../doc/html $out/share/doc/migraphx 139 mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx 140 '' + lib.optionalString buildTests '' 141 mkdir -p $test/bin 142 mv bin/test_* $test/bin 143 patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes /nix/store 144 ''; 145 146 passthru.updateScript = rocmUpdateScript { 147 name = finalAttrs.pname; 148 owner = finalAttrs.src.owner; 149 repo = finalAttrs.src.repo; 150 }; 151 152 meta = with lib; { 153 description = "AMD's graph optimization engine"; 154 homepage = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX"; 155 license = with licenses; [ mit ]; 156 maintainers = teams.rocm.members; 157 platforms = platforms.linux; 158 broken = versions.minor finalAttrs.version != versions.minor hip.version; 159 }; 160})