Skip to content

Commit f1c5d6d

Browse files
authored
adaptivecpp: init at 24.10.0 (#360893)
2 parents 3ac3a47 + b022814 commit f1c5d6d

File tree

5 files changed

+227
-87
lines changed

5 files changed

+227
-87
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
lib,
3+
fetchFromGitHub,
4+
llvmPackages_18,
5+
python3,
6+
cmake,
7+
boost,
8+
libxml2,
9+
libffi,
10+
makeWrapper,
11+
config,
12+
cudaPackages,
13+
rocmPackages_6,
14+
ompSupport ? true,
15+
openclSupport ? false,
16+
rocmSupport ? config.rocmSupport,
17+
cudaSupport ? config.cudaSupport,
18+
autoAddDriverRunpath,
19+
runCommand,
20+
callPackage,
21+
symlinkJoin,
22+
nix-update-script,
23+
}:
24+
let
25+
inherit (llvmPackages) stdenv;
26+
rocmPackages = rocmPackages_6;
27+
llvmPackages = llvmPackages_18;
28+
in
29+
stdenv.mkDerivation (finalAttrs: {
30+
pname = "adaptivecpp";
31+
version = "24.10.0";
32+
33+
src = fetchFromGitHub {
34+
owner = "AdaptiveCpp";
35+
repo = "AdaptiveCpp";
36+
rev = "v${finalAttrs.version}";
37+
sha256 = "sha256-ZwHDiwv1ybC+2UhiOe2f7fnfqcul+CD9Uta8PT9ICr4=";
38+
};
39+
40+
# we may be able to get away with just wrapping hipcc and nothing more
41+
# this is mainly so that if acpp tries doing <PATH_TO_HIPCC>/../amdgcn/bitcode
42+
rocmMerged = symlinkJoin {
43+
name = "rocm-merged";
44+
paths = with rocmPackages; [
45+
clr
46+
rocm-core
47+
rocm-device-libs
48+
rocm-runtime
49+
];
50+
buildInputs = [ makeWrapper ];
51+
postBuild = ''
52+
wrapProgram $out/bin/hipcc \
53+
--add-flags "--rocm-device-lib-path=$out/amdgcn/bitcode"
54+
'';
55+
};
56+
57+
nativeBuildInputs =
58+
[
59+
cmake
60+
makeWrapper
61+
]
62+
++ lib.optionals cudaSupport [
63+
autoAddDriverRunpath
64+
cudaPackages.cuda_nvcc
65+
];
66+
67+
buildInputs =
68+
[
69+
libxml2
70+
libffi
71+
boost
72+
python3
73+
llvmPackages.openmp
74+
llvmPackages.libclang.dev
75+
llvmPackages.llvm
76+
]
77+
++ lib.optionals cudaSupport [
78+
cudaPackages.cuda_cudart
79+
(lib.getOutput "stubs" cudaPackages.cuda_cudart)
80+
];
81+
82+
# adaptivecpp makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually
83+
cmakeFlags =
84+
[
85+
(lib.cmakeFeature "CLANG_INCLUDE_PATH" "${llvmPackages.libclang.dev}/include")
86+
(lib.cmakeBool "WITH_CPU_BACKEND" ompSupport)
87+
(lib.cmakeBool "WITH_CUDA_BACKEND" cudaSupport)
88+
(lib.cmakeBool "WITH_ROCM_BACKEND" rocmSupport)
89+
(lib.cmakeBool "WITH_OPENCL_BACKEND" openclSupport)
90+
]
91+
++ lib.optionals rocmSupport [
92+
(lib.cmakeFeature "HIPCC_COMPILER" "${finalAttrs.rocmMerged}/bin/hipcc")
93+
(lib.cmakeFeature "ROCM_PATH" "${finalAttrs.rocmMerged}")
94+
];
95+
96+
# this hardening option breaks rocm builds
97+
hardeningDisable = [ "zerocallusedregs" ];
98+
99+
passthru = {
100+
tests =
101+
# Loosely based on the AdaptiveCpp GitHub CI: https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/.github/workflows/linux.yml
102+
# This may be overkill, especially as this won't be run on GPU on the CI
103+
let
104+
runner = targets: enablePstlTests: callPackage ./tests.nix { inherit enablePstlTests; };
105+
run =
106+
runner: cmd: mask:
107+
runCommand cmd { } ''
108+
# the test runner wants to write to $HOME/.acpp, so we need to have it point to a real directory
109+
mkdir home
110+
export HOME=`pwd`/home
111+
112+
ACPP_VISIBILITY_MASK="${mask}" ${runner}/bin/${cmd} && touch $out
113+
'';
114+
runSycl = runner: mask: run runner "sycl_tests" mask;
115+
runPstl = runner: mask: run runner "pstl_tests" mask;
116+
runner-omp = runner "omp" false;
117+
runner-sscp = runner "generic" true;
118+
in
119+
{
120+
inherit runner-omp runner-sscp;
121+
sycl-omp = runSycl runner-omp "omp";
122+
sycl-sscp = runSycl runner-sscp "omp";
123+
pstl-sscp = runPstl runner-sscp "omp";
124+
}
125+
// lib.optionalAttrs rocmSupport (
126+
let
127+
runner-rocm = runner "hip:gfx906" false;
128+
runner-rocm-integrated-multipass = runner "omp;hip:gfx906" false;
129+
runner-rocm-explicit-multipass = runner "omp;hip.explicit-multipass:gfx906;cuda:sm_61" false;
130+
in
131+
{
132+
inherit runner-rocm runner-rocm-integrated-multipass runner-rocm-explicit-multipass;
133+
sycl-rocm = runSycl runner-rocm "omp;hip";
134+
sycl-rocm-imp = runSycl runner-rocm-integrated-multipass "omp;hip";
135+
sycl-rocm-emp = runSycl runner-rocm-explicit-multipass "omp;hip";
136+
sycl-rocm-sscp = runSycl runner-sscp "omp;hip";
137+
pstl-rocm-sscp = runPstl runner-sscp "omp;hip";
138+
}
139+
)
140+
// lib.optionalAttrs cudaSupport (
141+
let
142+
runner-cuda = runner "cuda:sm_60" false;
143+
runner-cuda-integrated-multipass = runner "omp;cuda_61" true;
144+
runner-cuda-explicit-multipass = runner "omp;cuda.explicit-multipass:sm_61;hip:gfx906" false;
145+
in
146+
{
147+
inherit runner-cuda runner-cuda-integrated-multipass runner-cuda-explicit-multipass;
148+
sycl-cuda = runSycl runner-cuda "omp;cuda";
149+
sycl-cuda-imp = runSycl runner-cuda-integrated-multipass "omp;cuda";
150+
sycl-cuda-emp = runSycl runner-cuda-explicit-multipass "omp;cuda";
151+
sycl-cuda-sscp = runSycl runner-sscp "omp;cuda";
152+
pstl-cuda-imp = runPstl runner-cuda-integrated-multipass "omp;cuda";
153+
pstl-cuda-sscp = runPstl runner-sscp "omp;cuda";
154+
}
155+
);
156+
157+
updateScript = nix-update-script { };
158+
};
159+
160+
meta = with lib; {
161+
homepage = "https://github.com/AdaptiveCpp/AdaptiveCpp";
162+
description = "Multi-backend implementation of SYCL for CPUs and GPUs";
163+
mainProgram = "acpp";
164+
maintainers = with maintainers; [ yboettcher ];
165+
# Broken with current nixpkgs ROCm 6.0.2
166+
# Works with updated ROCm, see https://github.com/NixOS/nixpkgs/pull/367695
167+
broken = rocmSupport && strings.versionOlder rocmPackages.clr.version "6.3.1";
168+
license = licenses.bsd2;
169+
};
170+
})
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
lib,
3+
stdenv,
4+
adaptivecpp,
5+
# Within the nix sandbox, and on the CI especially, the tests will likely be unable to access a gpu.
6+
# While the CI won't be able to test on a GPU, we can do a sanity check with OMP atleast
7+
#
8+
# The bulk of work in acpp focuses on the generic target, so we want to test that first and foremost.
9+
# Not setting an explicit target makes it default to the generic target.
10+
targets ? null,
11+
enablePstlTests ? false,
12+
tbb,
13+
cmake,
14+
boost,
15+
}:
16+
stdenv.mkDerivation (finalAttrs: {
17+
pname = "${adaptivecpp.pname}-tests";
18+
inherit (adaptivecpp)
19+
version
20+
src
21+
;
22+
23+
nativeBuildInputs = [
24+
cmake
25+
tbb
26+
];
27+
buildInputs = [ boost ];
28+
29+
sourceRoot = "${adaptivecpp.src.name}/tests";
30+
31+
cmakeFlags =
32+
[
33+
(lib.cmakeFeature "AdaptiveCpp_DIR" "${adaptivecpp}/lib/cmake/AdaptiveCpp")
34+
(lib.cmakeBool "WITH_PSTL_TESTS" enablePstlTests)
35+
]
36+
++ lib.optionals (targets != null) [
37+
(lib.cmakeFeature "DACCP_TARGETS" "${targets}")
38+
];
39+
40+
installPhase =
41+
''
42+
mkdir $out
43+
install -Dm755 sycl_tests -t $out/bin/
44+
install -Dm755 rt_tests -t $out/bin/
45+
install -Dm755 device_compilation_tests -t $out/bin/
46+
install -Dm755 dump_test/dump_test -t $out/bin/
47+
install -Dm755 platform_api/platform_api -t $out/bin/
48+
''
49+
+ lib.optionalString enablePstlTests ''
50+
install -Dm755 pstl_tests -t $out/bin/
51+
'';
52+
})

pkgs/development/compilers/opensycl/default.nix

Lines changed: 0 additions & 84 deletions
This file was deleted.

pkgs/top-level/aliases.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ mapAliases {
11101110
openlp = throw "openlp has been removed for now because the outdated version depended on insecure and removed packages and it needs help to upgrade and maintain it; see https://github.com/NixOS/nixpkgs/pull/314882"; # Added 2024-07-29
11111111
openmpt123 = throw "'openmpt123' has been renamed to/replaced by 'libopenmpt'"; # Converted to throw 2024-10-17
11121112
openssl_3_0 = openssl_3; # Added 2022-06-27
1113+
opensycl = lib.warn "'opensycl' has been renamed to 'adaptivecpp'" adaptivecpp; # Added 2024-12-04
1114+
opensyclWithRocm = lib.warn "'opensyclWithRocm ' has been renamed to 'adaptivecppWithRocm '" adaptivecppWithRocm; # Added 2024-12-04
11131115
orchis = throw "'orchis' has been renamed to/replaced by 'orchis-theme'"; # Converted to throw 2024-10-17
11141116
onlyoffice-bin = onlyoffice-desktopeditors; # Added 2024-09-20
11151117
onlyoffice-bin_latest = onlyoffice-bin; # Added 2024-07-03

pkgs/top-level/all-packages.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5586,6 +5586,9 @@ with pkgs;
55865586
semeru-bin = semeru-bin-21;
55875587
semeru-jre-bin = semeru-jre-bin-21;
55885588

5589+
adaptivecppWithCuda = adaptivecpp.override { cudaSupport = true; };
5590+
adaptivecppWithRocm = adaptivecpp.override { rocmSupport = true; };
5591+
55895592
adoptopenjdk-icedtea-web = callPackage ../development/compilers/adoptopenjdk-icedtea-web {
55905593
jdk = jdk8;
55915594
};
@@ -6640,9 +6643,6 @@ with pkgs;
66406643

66416644
opensmalltalk-vm = callPackage ../development/compilers/opensmalltalk-vm { };
66426645

6643-
opensycl = darwin.apple_sdk_11_0.callPackage ../development/compilers/opensycl { };
6644-
opensyclWithRocm = opensycl.override { rocmSupport = true; };
6645-
66466646
rustfmt = rustPackages.rustfmt;
66476647
rust-bindgen-unwrapped = callPackage ../development/tools/rust/bindgen/unwrapped.nix { };
66486648
rust-bindgen = callPackage ../development/tools/rust/bindgen { };

0 commit comments

Comments
 (0)