nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 makeImpureTest,
5 fetchFromGitHub,
6 clr,
7 cmake,
8 pkg-config,
9 glew,
10 libglut,
11 opencl-headers,
12 ocl-icd,
13}:
14
15let
16
17 examples = stdenv.mkDerivation {
18 pname = "amd-app-samples";
19 version = "2018-06-10";
20
21 src = fetchFromGitHub {
22 owner = "OpenCL";
23 repo = "AMD_APP_samples";
24 rev = "54da6ca465634e78fc51fc25edf5840467ee2411";
25 hash = "sha256-qARQpUiYsamHbko/I1gPZE9pUGJ+3396Vk2n7ERSftA=";
26 };
27
28 nativeBuildInputs = [
29 cmake
30 pkg-config
31 ];
32
33 buildInputs = [
34 glew
35 libglut
36 opencl-headers
37 ocl-icd
38 ];
39
40 installPhase = ''
41 runHook preInstall
42
43 mkdir -p $out/bin
44 # Example path is bin/x86_64/Release/cl/Reduction/Reduction
45 cp -r bin/*/*/*/*/* $out/bin/
46
47 runHook postInstall
48 '';
49
50 cmakeFlags = [ "-DBUILD_CPP_CL=OFF" ];
51
52 meta = {
53 description = "Samples from the AMD APP SDK (with OpenCRun support)";
54 homepage = "https://github.com/OpenCL/AMD_APP_samples";
55 license = lib.licenses.bsd2;
56 platforms = lib.platforms.linux;
57 teams = [ lib.teams.rocm ];
58 };
59 };
60
61in
62makeImpureTest {
63 name = "opencl-example";
64 testedPackage = "rocmPackages.clr";
65
66 sandboxPaths = [
67 "/sys"
68 "/dev/dri"
69 "/dev/kfd"
70 ];
71
72 nativeBuildInputs = [ examples ];
73
74 OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors";
75
76 testScript = ''
77 # Examples load resources from current directory
78 cd ${examples}/bin
79 echo OCL_ICD_VENDORS=$OCL_ICD_VENDORS
80 pwd
81
82 HelloWorld | grep HelloWorld
83 '';
84
85 meta = {
86 teams = [ lib.teams.rocm ];
87 };
88}