about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/rocm-modules/5/rocprofiler/default.nix
blob: ec24a3f41e59bbe1a10c5ef79d2573e6152062b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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;
  };
})