From f15055ccdbc7b4bab1fd2bd9d324b1940bc87573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 11 Apr 2025 15:03:15 +0200 Subject: [PATCH] Add SYCL test compilation --- overlay.nix | 1 + test/compilers/hello-sycl.nix | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 test/compilers/hello-sycl.nix diff --git a/overlay.nix b/overlay.nix index 1b892ae..e1b7805 100644 --- a/overlay.nix +++ b/overlay.nix @@ -70,6 +70,7 @@ let #sigsegv = callPackage ./test/reproducers/sigsegv.nix { }; hello-c = callPackage ./test/compilers/hello-c.nix { }; hello-cpp = callPackage ./test/compilers/hello-cpp.nix { }; + hello-sycl = callPackage ./test/compilers/hello-sycl.nix { }; 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 new file mode 100644 index 0000000..01cffb8 --- /dev/null +++ b/test/compilers/hello-sycl.nix @@ -0,0 +1,55 @@ +{ intelPackages, writeText, strace }: + +let + stdenv = intelPackages.stdenv; + hello_sycl = writeText "hello.cpp" '' + #include + + class hello_world; + + int main(int argc, char** argv) try { + auto device_selector = sycl::default_selector_v; + + sycl::queue queue(device_selector); + + std::cout << "Running on: " + << queue.get_device().get_info() + << std::endl; + + queue.submit([&] (sycl::handler& cgh) { + auto os = sycl::stream{128, 128, cgh}; + cgh.single_task([=]() { + os << "Hello World! (on device)\n"; + }); + }); + + return 0; + } catch (sycl::exception &e) { + std::cout << "SYCL exception: " << e.what() << std::endl; + return 0; // we excpect to fail since no devices should be available; + } + ''; +in + +stdenv.mkDerivation { + version = "0.0.1"; + name = "hello-sycl"; + buildInputs = [ stdenv strace ]; + src = hello_sycl; + dontUnpack = true; + dontConfigure = true; + NIX_DEBUG = 0; + buildPhase = '' + cp $src hello.cpp + set -x + echo CXX=$CXX + command -v $CXX + $CXX -fsycl hello.cpp -o hello + ./hello + set +x + ''; + + installPhase = '' + touch $out + ''; +}