about summary refs log tree commit diff
path: root/pkgs/development/rocm-modules/5
diff options
context:
space:
mode:
authorFlakebi <flakebi@t-online.de>2023-04-08 02:00:18 +0200
committerFlakebi <flakebi@t-online.de>2023-10-11 22:29:24 +0200
commit01cada7dc60efe33481f22dbe58762cc7fcc3384 (patch)
tree9c7069bf47074a51b36e7dcd9f35e8177c02af71 /pkgs/development/rocm-modules/5
parent116bc09a7d8cb2bc39e947d4cb25d280d6017dd2 (diff)
rocmPackages.clr: Add OpenCL test
Add a test that runs a simple OpenCL example on the GPU.
Run with `eval $(nix-build -A rocmPackages.impureTests.opencl-example)`.
Diffstat (limited to 'pkgs/development/rocm-modules/5')
-rw-r--r--pkgs/development/rocm-modules/5/clr/default.nix5
-rw-r--r--pkgs/development/rocm-modules/5/clr/test-opencl-example.nix75
-rw-r--r--pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix (renamed from pkgs/development/rocm-modules/5/clr/test.nix)4
3 files changed, 81 insertions, 3 deletions
diff --git a/pkgs/development/rocm-modules/5/clr/default.nix b/pkgs/development/rocm-modules/5/clr/default.nix
index c0d4de8cbb7c2..8a5d695e2b4cf 100644
--- a/pkgs/development/rocm-modules/5/clr/default.nix
+++ b/pkgs/development/rocm-modules/5/clr/default.nix
@@ -147,10 +147,13 @@ in stdenv.mkDerivation (finalAttrs: {
     };
 
     impureTests = {
-      clr-icd = callPackage ./test.nix {
+      rocm-smi = callPackage ./test-rocm-smi.nix {
         inherit rocm-smi;
         clr = finalAttrs.finalPackage;
       };
+      opencl-example = callPackage ./test-opencl-example.nix {
+        clr = finalAttrs.finalPackage;
+      };
     };
   };
 
diff --git a/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix b/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix
new file mode 100644
index 0000000000000..d6714c6b7d632
--- /dev/null
+++ b/pkgs/development/rocm-modules/5/clr/test-opencl-example.nix
@@ -0,0 +1,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_5.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;
+  };
+}
diff --git a/pkgs/development/rocm-modules/5/clr/test.nix b/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix
index c02bb4da88860..25c0a7e0c32c6 100644
--- a/pkgs/development/rocm-modules/5/clr/test.nix
+++ b/pkgs/development/rocm-modules/5/clr/test-rocm-smi.nix
@@ -6,8 +6,8 @@
 }:
 
 makeImpureTest {
-  name = "clr-icd";
-  testedPackage = "rocmPackages.clr";
+  name = "rocm-smi";
+  testedPackage = "rocmPackages_5.clr";
   nativeBuildInputs = [ clinfo rocm-smi ];
   OCL_ICD_VENDORS = "${clr.icd}/etc/OpenCL/vendors";