Add SYCL test compilation

This commit is contained in:
Aleix Boné 2025-04-11 15:03:15 +02:00
parent f836ffe7dc
commit f15055ccdb
No known key found for this signature in database
2 changed files with 56 additions and 0 deletions

View File

@ -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; };

View File

@ -0,0 +1,55 @@
{ intelPackages, writeText, strace }:
let
stdenv = intelPackages.stdenv;
hello_sycl = writeText "hello.cpp" ''
#include <sycl/sycl.hpp>
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<sycl::info::device::name>()
<< std::endl;
queue.submit([&] (sycl::handler& cgh) {
auto os = sycl::stream{128, 128, cgh};
cgh.single_task<hello_world>([=]() {
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
'';
}