diff --git a/pkgs/by-name/ad/adaptivecpp/package.nix b/pkgs/by-name/ad/adaptivecpp/package.nix index ad768f216339..4b8c29105013 100644 --- a/pkgs/by-name/ad/adaptivecpp/package.nix +++ b/pkgs/by-name/ad/adaptivecpp/package.nix @@ -16,6 +16,7 @@ rocmSupport ? config.rocmSupport, cudaSupport ? config.cudaSupport, autoAddDriverRunpath, + runCommand, callPackage, symlinkJoin, nix-update-script, @@ -81,27 +82,77 @@ stdenv.mkDerivation (finalAttrs: { # 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.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 [ - "-DHIPCC_COMPILER=${finalAttrs.rocmMerged}/bin/hipcc" - "-DROCM_PATH=${finalAttrs.rocmMerged}" + (lib.cmakeFeature "HIPCC_COMPILER" "${finalAttrs.rocmMerged}/bin/hipcc") + (lib.cmakeFeature "ROCM_PATH" "${finalAttrs.rocmMerged}") ]; # this hardening option breaks rocm builds hardeningDisable = [ "zerocallusedregs" ]; passthru = { - # For tests - inherit (finalAttrs) nativeBuildInputs buildInputs; + 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 - tests = { - sycl = callPackage ./tests.nix { }; - }; + 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 { }; }; diff --git a/pkgs/by-name/ad/adaptivecpp/tests.nix b/pkgs/by-name/ad/adaptivecpp/tests.nix index 572f56696aec..409caeabce94 100644 --- a/pkgs/by-name/ad/adaptivecpp/tests.nix +++ b/pkgs/by-name/ad/adaptivecpp/tests.nix @@ -2,45 +2,46 @@ lib, stdenv, adaptivecpp, - # within the nix sandbox, the tests will likely be unable to access the gpu. - # for now we just test omp by default as a sanity check, - # however the bulk of work in acpp focuses on the generic target, so we want to switch to that. - targetsBuild ? "omp", - targetsRun ? "omp", + # 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 - buildInputs ; + nativeBuildInputs = [ cmake tbb ]; + buildInputs = [ boost ]; + sourceRoot = "${adaptivecpp.src.name}/tests"; cmakeFlags = [ - # see above - "-DAdaptiveCpp_DIR=${adaptivecpp}/lib/cmake/AdaptiveCpp" + (lib.cmakeFeature "AdaptiveCpp_DIR" "${adaptivecpp}/lib/cmake/AdaptiveCpp") + (lib.cmakeBool "WITH_PSTL_TESTS" enablePstlTests) ] - ++ lib.optionals (targetsBuild != null) [ - "-DACCP_TARGETS=\"${targetsBuild}\"" + ++ lib.optionals (targets != null) [ + (lib.cmakeFeature "DACCP_TARGETS" "${targets}") ]; - doCheck = true; - checkPhase = '' - # 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 - - ${lib.strings.optionalString (targetsRun != null) "export ACPP_VISIBILITY_MASK=\"${targetsRun}\""} - ./sycl_tests + 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/ ''; - - installPhase = "touch $out"; - - # currently fails to build - # see https://logs.ofborg.org/?key=nixos/nixpkgs.360893&attempt_id=3b1feb45-0b7d-4cf1-8e38-917afcc12c67 - meta.broken = stdenv.isDarwin; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8521c7748579..b651f6f7adf7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5884,6 +5884,7 @@ with pkgs; semeru-bin = semeru-bin-21; semeru-jre-bin = semeru-jre-bin-21; + adaptivecppWithCuda = adaptivecpp.override { cudaSupport = true; }; adaptivecppWithRocm = adaptivecpp.override { rocmSupport = true; }; adoptopenjdk-icedtea-web = callPackage ../development/compilers/adoptopenjdk-icedtea-web {