From 999120732310aec3db2ab3e4775e0981315afccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Wed, 10 Dec 2025 18:52:11 +0100 Subject: [PATCH] Add test to run sycl applications with PoCL --- overlay.nix | 3 +++ test/compilers/hello-sycl.nix | 27 ++++++++++++++++++++++----- test/compilers/icpx-ompss2.nix | 30 ++++++++++++++++++------------ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/overlay.nix b/overlay.nix index c948024..41f1107 100644 --- a/overlay.nix +++ b/overlay.nix @@ -82,6 +82,9 @@ let hello-cpp = callPackage ./test/compilers/hello-cpp.nix { }; hello-sycl = callPackage ./test/compilers/hello-sycl.nix { }; hello-syclompss = callPackage ./test/compilers/icpx-ompss2.nix { }; + hello-sycl-pocl = (callPackage ./test/compilers/hello-sycl.nix { }).withPocl; + hello-syclompss-pocl = (callPackage ./test/compilers/icpx-ompss2.nix { }).withPocl; + lto = callPackage ./test/compilers/lto.nix { }; asan = callPackage ./test/compilers/asan.nix { }; intel2023-icx-c = hello-c.override { stdenv = final.intelPackages_2023.stdenv; }; diff --git a/test/compilers/hello-sycl.nix b/test/compilers/hello-sycl.nix index e8fd671..1438ae4 100644 --- a/test/compilers/hello-sycl.nix +++ b/test/compilers/hello-sycl.nix @@ -2,6 +2,7 @@ intelPackages, writeText, strace, + pocl, }: let @@ -35,10 +36,10 @@ let ''; in -stdenv.mkDerivation { +stdenv.mkDerivation (finalAttrs: { version = "0.0.1"; name = "hello-sycl"; - buildInputs = [ + nativeBuildInputs = [ stdenv strace ]; @@ -52,11 +53,27 @@ stdenv.mkDerivation { echo CXX=$CXX command -v $CXX $CXX -fsycl hello.cpp -o hello - ./hello + ./hello | tee test-output set +x ''; installPhase = '' - touch $out + cp test-output $out ''; -} + + passthru.withPocl = finalAttrs.finalPackage.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pocl ]; + env = (old.env or { }) // { + POCL_DEBUG = "error,warn"; + POCL_CACHE_DIR = "/build/pocl_cache"; + + # Make PoCL report Intel vendor id so oneapi SYCL works + POCL_DRIVER_VERSION_OVERRIDE = "2024.18.6.0.02_160000"; + POCL_CPU_VENDOR_ID_OVERRIDE = 32902; + }; + doInstallCheck = true; + installCheckPhase = '' + grep "Hello World! (on device)" $out + ''; + }); +}) diff --git a/test/compilers/icpx-ompss2.nix b/test/compilers/icpx-ompss2.nix index c70089d..e41a10a 100644 --- a/test/compilers/icpx-ompss2.nix +++ b/test/compilers/icpx-ompss2.nix @@ -37,7 +37,7 @@ let ''; in -intelPackages.stdenv.mkDerivation { +intelPackages.stdenv.mkDerivation (finalAttrs: { version = "0.0.1"; name = "hello-syclompss"; @@ -47,17 +47,23 @@ intelPackages.stdenv.mkDerivation { strace nodes nosv - pocl ]; - env = { - POCL_DEBUG = "error,warn"; - POCL_CACHE_DIR = "/build/pocl_cache"; + passthru.withPocl = finalAttrs.finalPackage.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pocl ]; + env = (old.env or { }) // { + POCL_DEBUG = "error,warn"; + POCL_CACHE_DIR = "/build/pocl_cache"; - # Make PoCL report Intel vendor id so oneapi SYCL works - POCL_DRIVER_VERSION_OVERRIDE = "2024.18.6.0.02_160000"; - POCL_CPU_VENDOR_ID_OVERRIDE = 32902; - }; + # Make PoCL report Intel vendor id so oneapi SYCL works + POCL_DRIVER_VERSION_OVERRIDE = "2024.18.6.0.02_160000"; + POCL_CPU_VENDOR_ID_OVERRIDE = 32902; + }; + doInstallCheck = true; + installCheckPhase = '' + grep "Hello World! (on device)" $out + ''; + }); dontUnpack = true; dontConfigure = true; @@ -82,11 +88,11 @@ intelPackages.stdenv.mkDerivation { $NODES_HOME/lib/nodes-main-wrapper.o \ hello.cpp -o hello - ./hello + ./hello | tee test-output set +x ''; installPhase = '' - touch $out + cp test-output $out ''; -} +})