Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adaptivecpp: init at 24.06.0 #360893

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions pkgs/by-name/ad/adaptivecpp/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
lib,
fetchFromGitHub,
llvmPackages_17,
python3,
cmake,
boost,
libxml2,
libffi,
makeWrapper,
config,
cudaPackages,
rocmPackages_6,
ompSupport ? true,
openclSupport ? false,
rocmSupport ? config.rocmSupport,
cudaSupport ? config.cudaSupport,
autoAddDriverRunpath,
callPackage,
symlinkJoin,
runCommand,
nix-update-script,
}:
let
inherit (llvmPackages) stdenv;
rocmPackages = rocmPackages_6;
llvmPackages = llvmPackages_17;
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 =
[
"-DCLANG_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 [
"-DHIPCC_COMPILER=${finalAttrs.rocmMerged}/bin/hipcc"
"-DROCM_PATH=${finalAttrs.rocmMerged}"
];

# this hardening option breaks rocm builds
hardeningDisable = [ "zerocallusedregs" ];

passthru = {
# For tests
inherit (finalAttrs) nativeBuildInputs buildInputs;

tests =
let
runner = callPackage ./tests.nix { };
run =
cmd:
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

${runner}/bin/${cmd} && touch $out
'';
in
{
inherit runner;
sycl = run "sycl_tests";
rt = run "rt_tests";
deviceCompilation = run "device_compilation_tests";
dump = run "dump_tests";
platformApi = run "platform_api";
};

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 = rocmSupport && lib.versionOlder rocmPackages.clr.version "6.3.1";
license = licenses.bsd2;
};
})
45 changes: 45 additions & 0 deletions pkgs/by-name/ad/adaptivecpp/tests.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
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,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "${adaptivecpp.pname}-tests";
inherit (adaptivecpp)
version
src
nativeBuildInputs
buildInputs
;

sourceRoot = "${adaptivecpp.src.name}/tests";

cmakeFlags =
[
"-DAdaptiveCpp_DIR=${adaptivecpp}/lib/cmake/AdaptiveCpp"
]
++ lib.optionals (targets != null) [
"-DACCP_TARGETS=\"${targets}\""
];

doCheck = false;

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/
'';

# currently fails to build
# see https://logs.ofborg.org/?key=nixos/nixpkgs.360893&attempt_id=3b1feb45-0b7d-4cf1-8e38-917afcc12c67
meta.broken = stdenv.isDarwin;
})
84 changes: 0 additions & 84 deletions pkgs/development/compilers/opensycl/default.nix

This file was deleted.

2 changes: 2 additions & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ mapAliases {
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
openmpt123 = throw "'openmpt123' has been renamed to/replaced by 'libopenmpt'"; # Converted to throw 2024-10-17
openssl_3_0 = openssl_3; # Added 2022-06-27
opensycl = lib.warn "'opensycl' has been renamed to 'adaptivecpp'" adaptivecpp; # Added 2024-12-04
opensyclWithRocm = lib.warn "'opensyclWithRocm ' has been renamed to 'adaptivecppWithRocm '" adaptivecppWithRocm; # Added 2024-12-04
orchis = throw "'orchis' has been renamed to/replaced by 'orchis-theme'"; # Converted to throw 2024-10-17
onlyoffice-bin = onlyoffice-desktopeditors; # Added 2024-09-20
onlyoffice-bin_latest = onlyoffice-bin; # Added 2024-07-03
Expand Down
5 changes: 2 additions & 3 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5884,6 +5884,8 @@ with pkgs;
semeru-bin = semeru-bin-21;
semeru-jre-bin = semeru-jre-bin-21;

adaptivecppWithRocm = adaptivecpp.override { rocmSupport = true; };

adoptopenjdk-icedtea-web = callPackage ../development/compilers/adoptopenjdk-icedtea-web {
jdk = jdk8;
};
Expand Down Expand Up @@ -6963,9 +6965,6 @@ with pkgs;

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

opensycl = darwin.apple_sdk_11_0.callPackage ../development/compilers/opensycl { };
opensyclWithRocm = opensycl.override { rocmSupport = true; };

rustfmt = rustPackages.rustfmt;
rust-bindgen-unwrapped = callPackage ../development/tools/rust/bindgen/unwrapped.nix { };
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
Expand Down