Compare commits

..

3 Commits

Author SHA1 Message Date
bdbfd77446
Simplify findMatch in intel-oneapi 2023
This should be a noop
2025-06-16 13:54:25 +02:00
83ae2f489d
Fix parsing of new apt package list for oneapi 2023
New apt list does not have Package: as the first entry for all packages
2025-06-16 13:54:24 +02:00
39157ea318
Add oneMath
With support for MKL and CUDA enabled by default
2025-06-16 13:54:24 +02:00
4 changed files with 37 additions and 97 deletions

View File

@ -147,13 +147,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
ln -s $out/bin/icpx $out/bin/c++ ln -s $out/bin/icpx $out/bin/c++
ln -s $out/bin/icx $out/bin/cc ln -s $out/bin/icx $out/bin/cc
# Use this to detect when a compiler subprocess is called
# from icpx (--fsycl-host-compiler)
echo 'export "NIX_CC_WRAPPER_INTEL=1"' >> $out/nix-support/cc-wrapper-hook
sed -i 's/.*isCxx=0/isCxx=1/' $out/bin/icpx sed -i 's/.*isCxx=0/isCxx=1/' $out/bin/icpx
# oneMath looks for sycl libraries in bin/../lib
ln -s ${finalAttrs.finalPackage.pkgs.compiler}/lib $out/lib ln -s ${finalAttrs.finalPackage.pkgs.compiler}/lib $out/lib
ln -s ${finalAttrs.finalPackage.pkgs.compiler}/include $out/include ln -s ${finalAttrs.finalPackage.pkgs.compiler}/include $out/include
''; '';

View File

@ -3,7 +3,6 @@
, lib , lib
, gcc , gcc
, clangOmpss2Unwrapped , clangOmpss2Unwrapped
, writeShellScript
, openmp ? null , openmp ? null
, wrapCCWith , wrapCCWith
, llvmPackages_latest , llvmPackages_latest
@ -38,16 +37,16 @@ let
inherit gcc; inherit gcc;
cc = clangOmpss2Unwrapped; cc = clangOmpss2Unwrapped;
gccVersion = with versions; let v = gcc.version; in concatStringsSep "." [(major v) (minor v) (patch v)]; gccVersion = with versions; let v = gcc.version; in concatStringsSep "." [(major v) (minor v) (patch v)];
in wrapCCWith {
inherit cc bintools;
# extraPackages adds packages to depsTargetTargetPropagated
extraPackages = optional (openmp != null) openmp;
extraBuildCommands = '' extraBuildCommands = ''
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-cflags echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-cflags
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-ldflags echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-ldflags
echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags
for dir in ${gcc.cc}/lib/gcc/${targetConfig}/*/include; do
echo "-isystem $dir" >> $out/nix-support/cc-cflags
done
for dir in ${gcc.cc}/include/c++/*; do for dir in ${gcc.cc}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done done
@ -59,52 +58,13 @@ let
wrap clang++ $wrapper $ccPath/clang++ wrap clang++ $wrapper $ccPath/clang++
sed -i 's|# Flirting.*|source ${resetIntelCCFlags}\n\n&|' $out/bin/clang '' + optionalString (openmp != null) ''
sed -i 's|# Flirting.*|&\nsource ${resetIntelCCFlags}\n\n&|' $out/bin/clang++ echo "export OPENMP_RUNTIME=${ompname}" >> $out/nix-support/cc-wrapper-hook
'' + optionalString (ompss2rt != null) ''
echo "export OMPSS2_RUNTIME=${rtname}" >> $out/nix-support/cc-wrapper-hook
echo "export ${homevar}=${ompss2rt}" >> $out/nix-support/cc-wrapper-hook
'' + optionalString (ompss2rt != null && ompss2rt.pname == "nodes") ''
echo "export NOSV_HOME=${ompss2rt.nosv}" >> $out/nix-support/cc-wrapper-hook
''; '';
}
envExports = lib.optionalString (openmp != null) ''
echo "export OPENMP_RUNTIME=${ompname}" >> $out/nix-support/cc-wrapper-hook
'' + optionalString (ompss2rt != null) ''
echo "export OMPSS2_RUNTIME=${rtname}" >> $out/nix-support/cc-wrapper-hook
echo "export ${homevar}=${ompss2rt}" >> $out/nix-support/cc-wrapper-hook
'' + optionalString (ompss2rt != null && ompss2rt.pname == "nodes") ''
echo "export NOSV_HOME=${ompss2rt.nosv}" >> $out/nix-support/cc-wrapper-hook
'';
extraPackages = optional (openmp != null) openmp;
wrappedCC = wrapCCWith {
# extraPackages adds packages to depsTargetTargetPropagated
inherit cc bintools extraPackages;
extraBuildCommands = extraBuildCommands + envExports;
};
resetIntelCCFlags = let tconf = builtins.replaceStrings ["-"] ["_"] targetConfig;
in writeShellScript "remove-intel.sh" ''
if [ "''${NIX_CC_WRAPPER_INTEL:-0}" = 1 ]; then
unset NIX_CFLAGS_COMPILE_${tconf}
unset NIX_CC_WRAPPER_FLAGS_SET_${tconf}
if (( "''${NIX_DEBUG:-0}" >= 1 )); then
echo "ompss2: cleaned NIX_CFLAGS_COMPILE_${tconf} (invokation from intel compiler detected)"
fi
fi
'';
intelExtraBuildCommands = ''
sed -i 's|# Flirting.*|source ${resetIntelCCFlags}\n\n&|' $out/bin/clang
sed -i 's|# Flirting.*|&\nsource ${resetIntelCCFlags}\n\n&|' $out/bin/clang++
'';
wrappedCCIntel = wrapCCWith {
inherit cc bintools extraPackages;
# extraPackages adds packages to depsTargetTargetPropagated
extraBuildCommands = intelExtraBuildCommands + envExports;
};
in wrappedCC.overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
forIcpx = wrappedCCIntel;
};
})

View File

@ -1,51 +1,40 @@
{ lib { lib
, intelPackages
, withCFlags
, fetchFromGitHub , fetchFromGitHub
, cmake , cmake
, withCFlags , cudaPackages
, intelPackages , enableNvidia ? true
, withHipTargets ? null # only one target at a time supported
, mklSupport ? true , rocmPackages
, enableMkl ? true
, config
, cudaSupport ? config.cudaSupport
, cudaPackages ? { }
, rocmSupport ? config.rocmSupport
, hipTargets ? null # only one target at a time supported
, rocmPackages ? { }
}: }:
let let
# rocmSupport is not enough, we need a specific target enableHip = withHipTargets != null;
enableHip = rocmSupport && hipTargets != null;
stdenv = withCFlags (lib.optionals cudaSupport [ "--cuda-path=${cudaPackages.cudatoolkit}" ]) intelPackages.stdenv; stdenv = withCFlags (lib.optionals enableNvidia [ "--cuda-path=${cudaPackages.cudatoolkit}" ]) intelPackages.stdenv;
in in
# at least one backend has to be enabled
assert mklSupport || cudaSupport || enableHip;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "oneMath"; pname = "oneMath";
version = "0.8"; version = "0.7";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "uxlfoundation"; owner = "uxlfoundation";
repo = "oneMath"; repo = "oneMath";
rev = "v${version}"; rev = "v${version}";
sha256 = "sha256-xK8lKI3oqKlx3xtvdScpMq+HXAuoYCP0BZdkEqnJP5o="; sha256 = "sha256-De04PUmI68Jx4rJ+MRb+RepayZCapgnouCUCrAu6G38=";
}; };
cmakeFlags = [ cmakeFlags = [
(lib.cmakeBool "ENABLE_MKLCPU_BACKEND" mklSupport) (lib.cmakeBool "ENABLE_MKLCPU_BACKEND" enableMkl)
(lib.cmakeBool "ENABLE_MKLGPU_BACKEND" mklSupport) (lib.cmakeBool "ENABLE_MKLGPU_BACKEND" enableMkl)
(lib.cmakeBool "ENABLE_CUBLAS_BACKEND" cudaSupport) (lib.cmakeBool "ENABLE_CUBLAS_BACKEND" enableNvidia)
(lib.cmakeBool "ENABLE_CUFFT_BACKEND" cudaSupport) (lib.cmakeBool "ENABLE_CUFFT_BACKEND" enableNvidia)
(lib.cmakeBool "ENABLE_CURAND_BACKEND" cudaSupport) (lib.cmakeBool "ENABLE_CURAND_BACKEND" enableNvidia)
(lib.cmakeBool "ENABLE_CUSOLVER_BACKEND" cudaSupport) (lib.cmakeBool "ENABLE_CUSOLVER_BACKEND" enableNvidia)
(lib.cmakeBool "ENABLE_CUSPARSE_BACKEND" cudaSupport) (lib.cmakeBool "ENABLE_CUSPARSE_BACKEND" enableNvidia)
(lib.cmakeBool "ENABLE_ROCBLAS_BACKEND" enableHip) (lib.cmakeBool "ENABLE_ROCBLAS_BACKEND" enableHip)
(lib.cmakeBool "ENABLE_ROCFFT_BACKEND" enableHip) (lib.cmakeBool "ENABLE_ROCFFT_BACKEND" enableHip)
@ -56,11 +45,11 @@ stdenv.mkDerivation rec {
(lib.cmakeBool "BUILD_FUNCTIONAL_TESTS" false) (lib.cmakeBool "BUILD_FUNCTIONAL_TESTS" false)
(lib.cmakeBool "BUILD_EXAMPLES" false) (lib.cmakeBool "BUILD_EXAMPLES" false)
] ++ lib.optionals enableHip [ ] ++ lib.optionals enableHip [
(lib.cmakeFeature "HIP_TARGETS" hipTargets) (lib.cmakeFeature "HIP_TARGETS" withHipTargets)
]; ];
nativeBuildInputs = [ cmake ]; nativeBuildInputs = [ cmake ];
buildInputs = lib.optionals (mklSupport) [ buildInputs = lib.optionals (enableMkl) [
intelPackages.mkl intelPackages.mkl
intelPackages.tbb intelPackages.tbb
] ++ lib.optionals (enableHip) [ ] ++ lib.optionals (enableHip) [
@ -70,7 +59,7 @@ stdenv.mkDerivation rec {
rocmPackages.rocsolver rocmPackages.rocsolver
rocmPackages.rocrand rocmPackages.rocrand
rocmPackages.rocsparse rocmPackages.rocsparse
] ++ lib.optionals (cudaSupport) [ ] ++ lib.optionals (enableNvidia) [
(lib.getDev cudaPackages.cuda_cudart) (lib.getDev cudaPackages.cuda_cudart)
cudaPackages.cudatoolkit cudaPackages.cudatoolkit

View File

@ -1,4 +1,4 @@
{ writeText, intelPackages, nodes, nosv, clangOmpss2Nodes, strace }: { writeText, intelPackages, nodes, nosv, clangOmpss2Nodes, clangOmpss2Unwrapped, clangOmpss2, strace }:
let let
hello_cpp = writeText "hello.cpp" '' hello_cpp = writeText "hello.cpp" ''
@ -44,10 +44,6 @@ intelPackages.stdenv.mkDerivation {
dontUnpack = true; dontUnpack = true;
dontConfigure = true; dontConfigure = true;
# NODES requires access to /sys/devices to request NUMA information. It will
# fail to run otherwise, so we disable the sandbox for this test.
__noChroot = true;
env.NODES_HOME = nodes; env.NODES_HOME = nodes;
NIX_DEBUG = 0; NIX_DEBUG = 0;
@ -58,9 +54,9 @@ intelPackages.stdenv.mkDerivation {
echo NODES_HOME=$NODES_HOME echo NODES_HOME=$NODES_HOME
command -v $CXX command -v $CXX
icpx -Wno-deprecated-declarations -fsycl \ icpx -fsycl \
-fsycl-host-compiler=${clangOmpss2Nodes.forIcpx}/bin/clang++ \ -fsycl-host-compiler=${clangOmpss2Nodes}/bin/clang++ \
-fsycl-host-compiler-options='-Wno-deprecated-declarations -fompss-2=libnodes' \ -fsycl-host-compiler-options='-fompss-2=libnodes' \
-lnodes -lnosv \ -lnodes -lnosv \
$NODES_HOME/lib/nodes-main-wrapper.o \ $NODES_HOME/lib/nodes-main-wrapper.o \
hello.cpp -o hello hello.cpp -o hello