forked from rarias/jungle
56 lines
1.3 KiB
Nix
56 lines
1.3 KiB
Nix
{ 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
|
|
'';
|
|
}
|