about summary refs log tree commit diff
path: root/pkgs/applications/misc/gpu-burn/default.nix
blob: eaf0fc44d29ddf9134495f2ed1e53599f8dfb793 (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
{ lib, stdenv, fetchFromGitHub, addOpenGLRunpath, cudatoolkit }:

stdenv.mkDerivation {
  pname = "gpu-burn";
  version = "unstable-2023-11-10";

  src = fetchFromGitHub {
    owner = "wilicc";
    repo = "gpu-burn";
    rev = "b99aedce3e020d2ca419832ee27b7f29dfa6373e";
    sha256 = "sha256-cLO0GXvujZ+g64j+OY31n43MsVER3ljo8Qrt+EzSKjc=";
  };

  postPatch = ''
    substituteInPlace gpu_burn-drv.cpp \
      --replace "#define COMPARE_KERNEL \"compare.ptx\"" \
                "#define COMPARE_KERNEL \"$out/share/compare.ptx\""
  '';

  buildInputs = [ cudatoolkit ];

  nativeBuildInputs = [ addOpenGLRunpath ];

  makeFlags = [ "CUDAPATH=${cudatoolkit}" ];

  LDFLAGS = "-L${cudatoolkit}/lib/stubs";

  installPhase = ''
    mkdir -p $out/{bin,share}
    cp gpu_burn $out/bin/
    cp compare.ptx $out/share/
  '';

  postFixup = ''
    addOpenGLRunpath $out/bin/gpu_burn
  '';

  meta = with lib; {
    homepage = "http://wili.cc/blog/gpu-burn.html";
    description = "Multi-GPU CUDA stress test";
    platforms = platforms.linux;
    license = licenses.bsd2;
    mainProgram = "gpu_burn";
  };
}