forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adaptivecpp: init at 24.10.0 (NixOS#360893)
- Loading branch information
Showing
5 changed files
with
227 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
lib, | ||
fetchFromGitHub, | ||
llvmPackages_18, | ||
python3, | ||
cmake, | ||
boost, | ||
libxml2, | ||
libffi, | ||
makeWrapper, | ||
config, | ||
cudaPackages, | ||
rocmPackages_6, | ||
ompSupport ? true, | ||
openclSupport ? false, | ||
rocmSupport ? config.rocmSupport, | ||
cudaSupport ? config.cudaSupport, | ||
autoAddDriverRunpath, | ||
runCommand, | ||
callPackage, | ||
symlinkJoin, | ||
nix-update-script, | ||
}: | ||
let | ||
inherit (llvmPackages) stdenv; | ||
rocmPackages = rocmPackages_6; | ||
llvmPackages = llvmPackages_18; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "adaptivecpp"; | ||
version = "24.10.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "AdaptiveCpp"; | ||
repo = "AdaptiveCpp"; | ||
rev = "v${finalAttrs.version}"; | ||
sha256 = "sha256-ZwHDiwv1ybC+2UhiOe2f7fnfqcul+CD9Uta8PT9ICr4="; | ||
}; | ||
|
||
# we may be able to get away with just wrapping hipcc and nothing more | ||
# this is mainly so that if acpp tries doing <PATH_TO_HIPCC>/../amdgcn/bitcode | ||
rocmMerged = symlinkJoin { | ||
name = "rocm-merged"; | ||
paths = with rocmPackages; [ | ||
clr | ||
rocm-core | ||
rocm-device-libs | ||
rocm-runtime | ||
]; | ||
buildInputs = [ makeWrapper ]; | ||
postBuild = '' | ||
wrapProgram $out/bin/hipcc \ | ||
--add-flags "--rocm-device-lib-path=$out/amdgcn/bitcode" | ||
''; | ||
}; | ||
|
||
nativeBuildInputs = | ||
[ | ||
cmake | ||
makeWrapper | ||
] | ||
++ lib.optionals cudaSupport [ | ||
autoAddDriverRunpath | ||
cudaPackages.cuda_nvcc | ||
]; | ||
|
||
buildInputs = | ||
[ | ||
libxml2 | ||
libffi | ||
boost | ||
python3 | ||
llvmPackages.openmp | ||
llvmPackages.libclang.dev | ||
llvmPackages.llvm | ||
] | ||
++ lib.optionals cudaSupport [ | ||
cudaPackages.cuda_cudart | ||
(lib.getOutput "stubs" cudaPackages.cuda_cudart) | ||
]; | ||
|
||
# adaptivecpp makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually | ||
cmakeFlags = | ||
[ | ||
(lib.cmakeFeature "CLANG_INCLUDE_PATH" "${llvmPackages.libclang.dev}/include") | ||
(lib.cmakeBool "WITH_CPU_BACKEND" ompSupport) | ||
(lib.cmakeBool "WITH_CUDA_BACKEND" cudaSupport) | ||
(lib.cmakeBool "WITH_ROCM_BACKEND" rocmSupport) | ||
(lib.cmakeBool "WITH_OPENCL_BACKEND" openclSupport) | ||
] | ||
++ lib.optionals rocmSupport [ | ||
(lib.cmakeFeature "HIPCC_COMPILER" "${finalAttrs.rocmMerged}/bin/hipcc") | ||
(lib.cmakeFeature "ROCM_PATH" "${finalAttrs.rocmMerged}") | ||
]; | ||
|
||
# this hardening option breaks rocm builds | ||
hardeningDisable = [ "zerocallusedregs" ]; | ||
|
||
passthru = { | ||
tests = | ||
# Loosely based on the AdaptiveCpp GitHub CI: https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/.github/workflows/linux.yml | ||
# This may be overkill, especially as this won't be run on GPU on the CI | ||
let | ||
runner = targets: enablePstlTests: callPackage ./tests.nix { inherit enablePstlTests; }; | ||
run = | ||
runner: cmd: mask: | ||
runCommand cmd { } '' | ||
# the test runner wants to write to $HOME/.acpp, so we need to have it point to a real directory | ||
mkdir home | ||
export HOME=`pwd`/home | ||
ACPP_VISIBILITY_MASK="${mask}" ${runner}/bin/${cmd} && touch $out | ||
''; | ||
runSycl = runner: mask: run runner "sycl_tests" mask; | ||
runPstl = runner: mask: run runner "pstl_tests" mask; | ||
runner-omp = runner "omp" false; | ||
runner-sscp = runner "generic" true; | ||
in | ||
{ | ||
inherit runner-omp runner-sscp; | ||
sycl-omp = runSycl runner-omp "omp"; | ||
sycl-sscp = runSycl runner-sscp "omp"; | ||
pstl-sscp = runPstl runner-sscp "omp"; | ||
} | ||
// lib.optionalAttrs rocmSupport ( | ||
let | ||
runner-rocm = runner "hip:gfx906" false; | ||
runner-rocm-integrated-multipass = runner "omp;hip:gfx906" false; | ||
runner-rocm-explicit-multipass = runner "omp;hip.explicit-multipass:gfx906;cuda:sm_61" false; | ||
in | ||
{ | ||
inherit runner-rocm runner-rocm-integrated-multipass runner-rocm-explicit-multipass; | ||
sycl-rocm = runSycl runner-rocm "omp;hip"; | ||
sycl-rocm-imp = runSycl runner-rocm-integrated-multipass "omp;hip"; | ||
sycl-rocm-emp = runSycl runner-rocm-explicit-multipass "omp;hip"; | ||
sycl-rocm-sscp = runSycl runner-sscp "omp;hip"; | ||
pstl-rocm-sscp = runPstl runner-sscp "omp;hip"; | ||
} | ||
) | ||
// lib.optionalAttrs cudaSupport ( | ||
let | ||
runner-cuda = runner "cuda:sm_60" false; | ||
runner-cuda-integrated-multipass = runner "omp;cuda_61" true; | ||
runner-cuda-explicit-multipass = runner "omp;cuda.explicit-multipass:sm_61;hip:gfx906" false; | ||
in | ||
{ | ||
inherit runner-cuda runner-cuda-integrated-multipass runner-cuda-explicit-multipass; | ||
sycl-cuda = runSycl runner-cuda "omp;cuda"; | ||
sycl-cuda-imp = runSycl runner-cuda-integrated-multipass "omp;cuda"; | ||
sycl-cuda-emp = runSycl runner-cuda-explicit-multipass "omp;cuda"; | ||
sycl-cuda-sscp = runSycl runner-sscp "omp;cuda"; | ||
pstl-cuda-imp = runPstl runner-cuda-integrated-multipass "omp;cuda"; | ||
pstl-cuda-sscp = runPstl runner-sscp "omp;cuda"; | ||
} | ||
); | ||
|
||
updateScript = nix-update-script { }; | ||
}; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/AdaptiveCpp/AdaptiveCpp"; | ||
description = "Multi-backend implementation of SYCL for CPUs and GPUs"; | ||
mainProgram = "acpp"; | ||
maintainers = with maintainers; [ yboettcher ]; | ||
# Broken with current nixpkgs ROCm 6.0.2 | ||
# Works with updated ROCm, see https://github.com/NixOS/nixpkgs/pull/367695 | ||
broken = rocmSupport && strings.versionOlder rocmPackages.clr.version "6.3.1"; | ||
license = licenses.bsd2; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
adaptivecpp, | ||
# Within the nix sandbox, and on the CI especially, the tests will likely be unable to access a gpu. | ||
# While the CI won't be able to test on a GPU, we can do a sanity check with OMP atleast | ||
# | ||
# The bulk of work in acpp focuses on the generic target, so we want to test that first and foremost. | ||
# Not setting an explicit target makes it default to the generic target. | ||
targets ? null, | ||
enablePstlTests ? false, | ||
tbb, | ||
cmake, | ||
boost, | ||
}: | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "${adaptivecpp.pname}-tests"; | ||
inherit (adaptivecpp) | ||
version | ||
src | ||
; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
tbb | ||
]; | ||
buildInputs = [ boost ]; | ||
|
||
sourceRoot = "${adaptivecpp.src.name}/tests"; | ||
|
||
cmakeFlags = | ||
[ | ||
(lib.cmakeFeature "AdaptiveCpp_DIR" "${adaptivecpp}/lib/cmake/AdaptiveCpp") | ||
(lib.cmakeBool "WITH_PSTL_TESTS" enablePstlTests) | ||
] | ||
++ lib.optionals (targets != null) [ | ||
(lib.cmakeFeature "DACCP_TARGETS" "${targets}") | ||
]; | ||
|
||
installPhase = | ||
'' | ||
mkdir $out | ||
install -Dm755 sycl_tests -t $out/bin/ | ||
install -Dm755 rt_tests -t $out/bin/ | ||
install -Dm755 device_compilation_tests -t $out/bin/ | ||
install -Dm755 dump_test/dump_test -t $out/bin/ | ||
install -Dm755 platform_api/platform_api -t $out/bin/ | ||
'' | ||
+ lib.optionalString enablePstlTests '' | ||
install -Dm755 pstl_tests -t $out/bin/ | ||
''; | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters