about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/rocm-modules/6/clr/test-opencl-example.nix
blob: 24fc483847d3a39ba3e119c6eda6e85c1c51ff89 (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
{ lib
, stdenv
, makeImpureTest
, fetchFromGitHub
, clr
, cmake
, pkg-config
, glew
, freeglut
, opencl-headers
, ocl-icd
}:

let

  examples = stdenv.mkDerivation {
    pname = "amd-app-samples";
    version = "2018-06-10";

    src = fetchFromGitHub {
      owner = "OpenCL";
      repo = "AMD_APP_samples";
      rev = "54da6ca465634e78fc51fc25edf5840467ee2411";
      hash = "sha256-qARQpUiYsamHbko/I1gPZE9pUGJ+3396Vk2n7ERSftA=";
    };

    nativeBuildInputs = [ cmake pkg-config ];

    buildInputs = [ glew freeglut opencl-headers ocl-icd ];

    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin
      # Example path is bin/x86_64/Release/cl/Reduction/Reduction
      cp -r bin/*/*/*/*/* $out/bin/

      runHook postInstall
    '';

    cmakeFlags = [ "-DBUILD_CPP_CL=OFF" ];

    meta = with lib; {
      description = "Samples from the AMD APP SDK (with OpenCRun support) ";
      homepage    = "https://github.com/OpenCL/AMD_APP_samples";
      license     = licenses.bsd2;
      platforms   = platforms.linux;
      maintainers = lib.teams.rocm.members;
    };
  };

in
makeImpureTest {
  name = "opencl-example";
  testedPackage = "rocmPackages_6.clr";

  sandboxPaths = [ "/sys" "/dev/dri" "/dev/kfd" ];

  nativeBuildInputs = [ examples ];

  OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors";

  testScript = ''
    # Examples load resources from current directory
    cd ${examples}/bin
    echo OCL_ICD_VENDORS=$OCL_ICD_VENDORS
    pwd

    HelloWorld | grep HelloWorld
  '';

  meta = with lib; {
    maintainers = teams.rocm.members;
  };
}