Compare commits
8 Commits
bdbfd77446
...
ab90f49af9
| Author | SHA1 | Date | |
|---|---|---|---|
| ab90f49af9 | |||
| a2b0171a06 | |||
| 1909b68999 | |||
| 9785ff3ca4 | |||
| daccf248af | |||
| 77de71bf1f | |||
| d5aa80de5a | |||
| 6b6ffa864d |
@ -147,8 +147,13 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
ln -s $out/bin/icpx $out/bin/c++
|
||||
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
|
||||
|
||||
# oneMath looks for sycl libraries in bin/../lib
|
||||
ln -s ${finalAttrs.finalPackage.pkgs.compiler}/lib $out/lib
|
||||
ln -s ${finalAttrs.finalPackage.pkgs.compiler}/include $out/include
|
||||
'';
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
, lib
|
||||
, gcc
|
||||
, clangOmpss2Unwrapped
|
||||
, writeShellScript
|
||||
, openmp ? null
|
||||
, wrapCCWith
|
||||
, llvmPackages_latest
|
||||
@ -37,16 +38,16 @@ let
|
||||
inherit gcc;
|
||||
cc = clangOmpss2Unwrapped;
|
||||
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 = ''
|
||||
echo "-target ${targetConfig}" >> $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}/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
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
@ -58,13 +59,52 @@ in wrapCCWith {
|
||||
|
||||
wrap clang++ $wrapper $ccPath/clang++
|
||||
|
||||
'' + 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
|
||||
sed -i 's|# Flirting.*|source ${resetIntelCCFlags}\n\n&|' $out/bin/clang
|
||||
sed -i 's|# Flirting.*|&\nsource ${resetIntelCCFlags}\n\n&|' $out/bin/clang++
|
||||
'';
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
})
|
||||
|
||||
@ -1,40 +1,51 @@
|
||||
{ lib
|
||||
, intelPackages
|
||||
, withCFlags
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, cudaPackages
|
||||
, enableNvidia ? true
|
||||
, withHipTargets ? null # only one target at a time supported
|
||||
, rocmPackages
|
||||
, enableMkl ? true
|
||||
, withCFlags
|
||||
, intelPackages
|
||||
|
||||
, mklSupport ? true
|
||||
|
||||
, config
|
||||
|
||||
, cudaSupport ? config.cudaSupport
|
||||
, cudaPackages ? { }
|
||||
|
||||
, rocmSupport ? config.rocmSupport
|
||||
, hipTargets ? null # only one target at a time supported
|
||||
, rocmPackages ? { }
|
||||
}:
|
||||
|
||||
let
|
||||
enableHip = withHipTargets != null;
|
||||
# rocmSupport is not enough, we need a specific target
|
||||
enableHip = rocmSupport && hipTargets != null;
|
||||
|
||||
stdenv = withCFlags (lib.optionals enableNvidia [ "--cuda-path=${cudaPackages.cudatoolkit}" ]) intelPackages.stdenv;
|
||||
stdenv = withCFlags (lib.optionals cudaSupport [ "--cuda-path=${cudaPackages.cudatoolkit}" ]) intelPackages.stdenv;
|
||||
in
|
||||
|
||||
# at least one backend has to be enabled
|
||||
assert mklSupport || cudaSupport || enableHip;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "oneMath";
|
||||
version = "0.7";
|
||||
version = "0.8";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "uxlfoundation";
|
||||
repo = "oneMath";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-De04PUmI68Jx4rJ+MRb+RepayZCapgnouCUCrAu6G38=";
|
||||
sha256 = "sha256-xK8lKI3oqKlx3xtvdScpMq+HXAuoYCP0BZdkEqnJP5o=";
|
||||
};
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "ENABLE_MKLCPU_BACKEND" enableMkl)
|
||||
(lib.cmakeBool "ENABLE_MKLGPU_BACKEND" enableMkl)
|
||||
(lib.cmakeBool "ENABLE_MKLCPU_BACKEND" mklSupport)
|
||||
(lib.cmakeBool "ENABLE_MKLGPU_BACKEND" mklSupport)
|
||||
|
||||
(lib.cmakeBool "ENABLE_CUBLAS_BACKEND" enableNvidia)
|
||||
(lib.cmakeBool "ENABLE_CUFFT_BACKEND" enableNvidia)
|
||||
(lib.cmakeBool "ENABLE_CURAND_BACKEND" enableNvidia)
|
||||
(lib.cmakeBool "ENABLE_CUSOLVER_BACKEND" enableNvidia)
|
||||
(lib.cmakeBool "ENABLE_CUSPARSE_BACKEND" enableNvidia)
|
||||
(lib.cmakeBool "ENABLE_CUBLAS_BACKEND" cudaSupport)
|
||||
(lib.cmakeBool "ENABLE_CUFFT_BACKEND" cudaSupport)
|
||||
(lib.cmakeBool "ENABLE_CURAND_BACKEND" cudaSupport)
|
||||
(lib.cmakeBool "ENABLE_CUSOLVER_BACKEND" cudaSupport)
|
||||
(lib.cmakeBool "ENABLE_CUSPARSE_BACKEND" cudaSupport)
|
||||
|
||||
(lib.cmakeBool "ENABLE_ROCBLAS_BACKEND" enableHip)
|
||||
(lib.cmakeBool "ENABLE_ROCFFT_BACKEND" enableHip)
|
||||
@ -45,11 +56,11 @@ stdenv.mkDerivation rec {
|
||||
(lib.cmakeBool "BUILD_FUNCTIONAL_TESTS" false)
|
||||
(lib.cmakeBool "BUILD_EXAMPLES" false)
|
||||
] ++ lib.optionals enableHip [
|
||||
(lib.cmakeFeature "HIP_TARGETS" withHipTargets)
|
||||
(lib.cmakeFeature "HIP_TARGETS" hipTargets)
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = lib.optionals (enableMkl) [
|
||||
buildInputs = lib.optionals (mklSupport) [
|
||||
intelPackages.mkl
|
||||
intelPackages.tbb
|
||||
] ++ lib.optionals (enableHip) [
|
||||
@ -59,7 +70,7 @@ stdenv.mkDerivation rec {
|
||||
rocmPackages.rocsolver
|
||||
rocmPackages.rocrand
|
||||
rocmPackages.rocsparse
|
||||
] ++ lib.optionals (enableNvidia) [
|
||||
] ++ lib.optionals (cudaSupport) [
|
||||
(lib.getDev cudaPackages.cuda_cudart)
|
||||
cudaPackages.cudatoolkit
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{ writeText, intelPackages, nodes, nosv, clangOmpss2Nodes, clangOmpss2Unwrapped, clangOmpss2, strace }:
|
||||
{ writeText, intelPackages, nodes, nosv, clangOmpss2Nodes, strace }:
|
||||
|
||||
let
|
||||
hello_cpp = writeText "hello.cpp" ''
|
||||
@ -44,6 +44,10 @@ intelPackages.stdenv.mkDerivation {
|
||||
dontUnpack = 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;
|
||||
|
||||
NIX_DEBUG = 0;
|
||||
@ -54,9 +58,9 @@ intelPackages.stdenv.mkDerivation {
|
||||
echo NODES_HOME=$NODES_HOME
|
||||
command -v $CXX
|
||||
|
||||
icpx -fsycl \
|
||||
-fsycl-host-compiler=${clangOmpss2Nodes}/bin/clang++ \
|
||||
-fsycl-host-compiler-options='-fompss-2=libnodes' \
|
||||
icpx -Wno-deprecated-declarations -fsycl \
|
||||
-fsycl-host-compiler=${clangOmpss2Nodes.forIcpx}/bin/clang++ \
|
||||
-fsycl-host-compiler-options='-Wno-deprecated-declarations -fompss-2=libnodes' \
|
||||
-lnodes -lnosv \
|
||||
$NODES_HOME/lib/nodes-main-wrapper.o \
|
||||
hello.cpp -o hello
|
||||
|
||||
Reference in New Issue
Block a user