2023-07-11 19:26:02 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, llvmPackages_15
|
|
|
|
, lld_15
|
|
|
|
, python3
|
|
|
|
, cmake
|
|
|
|
, boost
|
|
|
|
, libxml2
|
|
|
|
, libffi
|
|
|
|
, makeWrapper
|
2023-11-14 00:51:57 +00:00
|
|
|
, config
|
2024-06-27 15:36:39 +00:00
|
|
|
, cudaPackages
|
2024-03-02 17:37:46 +00:00
|
|
|
, rocmPackages_5
|
2024-06-27 15:36:39 +00:00
|
|
|
, ompSupport ? true
|
|
|
|
, openclSupport ? false
|
2023-11-14 00:51:57 +00:00
|
|
|
, rocmSupport ? config.rocmSupport
|
2024-06-27 15:36:39 +00:00
|
|
|
, cudaSupport ? config.cudaSupport
|
|
|
|
, autoAddDriverRunpath
|
2023-07-11 19:26:02 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (llvmPackages_15) stdenv;
|
2024-03-02 17:37:46 +00:00
|
|
|
# move to newer ROCm version once supported
|
|
|
|
rocmPackages = rocmPackages_5;
|
2023-07-11 19:26:02 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "OpenSYCL";
|
|
|
|
version = "0.9.4";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "OpenSYCL";
|
|
|
|
repo = "OpenSYCL";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "sha256-5YkuUOAnvoAD5xDKxKMPq0B7+1pb6hVisPAhs0Za1ls=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
makeWrapper
|
2024-06-27 15:36:39 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
autoAddDriverRunpath
|
|
|
|
cudaPackages.cuda_nvcc
|
2023-07-11 19:26:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libxml2
|
|
|
|
libffi
|
|
|
|
boost
|
|
|
|
llvmPackages_15.openmp
|
|
|
|
llvmPackages_15.libclang.dev
|
|
|
|
llvmPackages_15.llvm
|
|
|
|
] ++ lib.optionals rocmSupport [
|
2023-10-05 21:58:02 +00:00
|
|
|
rocmPackages.clr
|
|
|
|
rocmPackages.rocm-runtime
|
2024-06-27 15:36:39 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudaPackages.cuda_cudart
|
|
|
|
(lib.getOutput "stubs" cudaPackages.cuda_cudart)
|
2023-07-11 19:26:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# opensycl makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCLANG_INCLUDE_PATH=${llvmPackages_15.libclang.dev}/include"
|
2024-06-27 15:36:39 +00:00
|
|
|
(lib.cmakeBool "WITH_CPU_BACKEND" ompSupport)
|
|
|
|
(lib.cmakeBool "WITH_CUDA_BACKEND" cudaSupport)
|
|
|
|
(lib.cmakeBool "WITH_ROCM_BACKEND" rocmSupport)
|
|
|
|
] ++ lib.optionals (lib.versionAtLeast version "24") [
|
|
|
|
(lib.cmakeBool "WITH_OPENCL_BACKEND" openclSupport)
|
2023-07-11 19:26:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/bin/syclcc-clang \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ python3 lld_15 ]} \
|
|
|
|
--add-flags "-L${llvmPackages_15.openmp}/lib" \
|
|
|
|
--add-flags "-I${llvmPackages_15.openmp.dev}/include" \
|
|
|
|
'' + lib.optionalString rocmSupport ''
|
2023-10-05 21:58:02 +00:00
|
|
|
--add-flags "--rocm-device-lib-path=${rocmPackages.rocm-device-libs}/amdgcn/bitcode"
|
2023-07-11 19:26:02 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/OpenSYCL/OpenSYCL";
|
|
|
|
description = "Multi-backend implementation of SYCL for CPUs and GPUs";
|
|
|
|
maintainers = with maintainers; [ yboettcher ];
|
|
|
|
license = licenses.bsd2;
|
|
|
|
};
|
|
|
|
}
|