forked from rarias/bscpkgs
		
	Add SYCL test compilation
This commit is contained in:
		
							parent
							
								
									5869ad06c2
								
							
						
					
					
						commit
						762a455589
					
				| @ -61,6 +61,7 @@ in bscPkgs // { | ||||
|       #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; }; | ||||
|  | ||||
							
								
								
									
										55
									
								
								test/compilers/hello-sycl.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								test/compilers/hello-sycl.nix
									
									
									
									
									
										Normal 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 | ||||
|   ''; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user