Merge pull request #250753 from twesterhout/arrayfire-3.9.0

arrayfire: 3.7.3 -> 3.9.0
This commit is contained in:
Silvan Mosberger 2023-11-26 13:42:12 +01:00 committed by GitHub
commit 16c9ed6b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 335 additions and 111 deletions

View File

@ -1,62 +1,210 @@
{ lib
, stdenv
, fetchFromGitHub
{ blas
, boost
, clblast
, cmake
, pkg-config
, opencl-clhpp
, ocl-icd
, config
, cudaPackages
, fetchFromGitHub
, fftw
, fftwFloat
, blas
, lapack
, boost
, mesa
, libGLU
, libGL
, fmt_9
, forge
, freeimage
, gtest
, lapack
, lib
, libGL
, mesa
, ocl-icd
, opencl-clhpp
, pkg-config
, python3
, clfft
, clblas
, doxygen
, buildDocs ? false
, config
, span-lite
, stdenv
# NOTE: We disable tests by default, because they cannot be run easily on
# non-NixOS systems when either CUDA or OpenCL support is enabled (CUDA and
# OpenCL need access to drivers that are installed outside of Nix on
# non-NixOS systems).
, doCheck ? false
, cpuSupport ? true
, cudaSupport ? config.cudaSupport
, cudatoolkit
, darwin
# OpenCL needs mesa which is broken on Darwin
, openclSupport ? !stdenv.isDarwin
# This argument lets one run CUDA & OpenCL tests on non-NixOS systems by
# telling Nix where to find the drivers. If you know the version of the
# NVidia driver that is installed on your system, you can do:
#
# arrayfire.override {
# nvidiaComputeDrivers =
# callPackage
# (prev.linuxPackages.nvidiaPackages.mkDriver {
# version = cudaVersion; # our driver version
# sha256_64bit = cudaHash; # sha256 of the .run binary
# useGLVND = false;
# useProfiles = false;
# useSettings = false;
# usePersistenced = false;
# ...
# })
# { libsOnly = true; };
# }
, nvidiaComputeDrivers ? null
}:
# ArrayFire compiles with 64-bit BLAS, but some tests segfault or throw
# exceptions, which means that it isn't really supported yet...
assert blas.isILP64 == false;
stdenv.mkDerivation rec {
pname = "arrayfire";
version = "3.7.3";
version = "3.9.0";
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "v${version}";
sha256 = "0gcbg6b6gs38xhks5pp0vkcqs89zl7rh9982jqlzsd0h724qddw0";
fetchSubmodules = true;
rev = "v3.9.0";
hash = "sha256-80fxdkaeAQ5u0X/UGPaI/900cdkZ/vXNcOn5tkZ+C3Y=";
};
# We cannot use the clfft from Nixpkgs because ArrayFire maintain a fork
# of clfft where they've modified the CMake build system, and the
# CMakeLists.txt of ArrayFire assumes that we're using that fork.
#
# This can be removed once ArrayFire upstream their changes.
clfft = fetchFromGitHub {
owner = pname;
repo = "clfft";
rev = "760096b37dcc4f18ccd1aac53f3501a83b83449c";
sha256 = "sha256-vJo1YfC2AJIbbRj/zTfcOUmi0Oj9v64NfA9MfK8ecoY=";
};
glad = fetchFromGitHub {
owner = pname;
repo = "glad";
rev = "ef8c5508e72456b714820c98e034d9a55b970650";
sha256 = "sha256-u9Vec7XLhE3xW9vzM7uuf+b18wZsh/VMtGbB6nMVlno=";
};
threads = fetchFromGitHub {
owner = pname;
repo = "threads";
rev = "4d4a4f0384d1ac2f25b2c4fc1d57b9e25f4d6818";
sha256 = "sha256-qqsT9woJDtQvzuV323OYXm68pExygYs/+zZNmg2sN34=";
};
test-data = fetchFromGitHub {
owner = pname;
repo = "arrayfire-data";
rev = "a5f533d7b864a4d8f0dd7c9aaad5ff06018c4867";
sha256 = "sha256-AWzhsrDXyZrQN2bd0Ng/XlE8v02x7QWTiFTyaAuRXSw=";
};
# ArrayFire fails to compile with newer versions of spdlog, so we can't use
# the one in Nixpkgs. Once they upgrade, we can switch to using spdlog from
# Nixpkgs.
spdlog = fetchFromGitHub {
owner = "gabime";
repo = "spdlog";
rev = "v1.9.2";
hash = "sha256-GSUdHtvV/97RyDKy8i+ticnSlQCubGGWHg4Oo+YAr8Y=";
};
cmakeFlags = [
"-DAF_BUILD_OPENCL=OFF"
"-DBUILD_TESTING=ON"
# We do not build examples, because building tests already takes long enough...
"-DAF_BUILD_EXAMPLES=OFF"
"-DBUILD_TESTING=OFF"
] ++ lib.optional cudaSupport "-DCMAKE_LIBRARY_PATH=${cudatoolkit}/lib/stubs";
# No need to build forge, because it's a separate package
"-DAF_BUILD_FORGE=OFF"
"-DAF_COMPUTE_LIBRARY='FFTW/LAPACK/BLAS'"
# Prevent ArrayFire from trying to download some matrices from the Internet
"-DAF_TEST_WITH_MTX_FILES=OFF"
# Have to use the header-only version, because we're not using the version
# from Nixpkgs. Otherwise, libaf.so won't be able to find the shared
# library, because ArrayFire's CMake files do not run the install step of
# spdlog.
"-DAF_WITH_SPDLOG_HEADER_ONLY=ON"
(if cpuSupport then "-DAF_BUILD_CPU=ON" else "-DAF_BUILD_CPU=OFF")
(if openclSupport then "-DAF_BUILD_OPENCL=ON" else "-DAF_BUILD_OPENCL=OFF")
(if cudaSupport then "-DAF_BUILD_CUDA=ON" else "-DAF_BUILD_CUDA=OFF")
] ++ lib.optionals cudaSupport [
# ArrayFire use deprecated FindCUDA in their CMake files, so we help CMake
# locate cudatoolkit.
"-DCUDA_LIBRARIES_PATH=${cudaPackages.cudatoolkit}/lib"
];
patches = [ ./no-download.patch ];
# ArrayFire have a repo with assets for the examples. Since we don't build
# the examples anyway, remove the dependency on assets.
patches = [ ./no-assets.patch ./no-download.patch ];
postPatch = ''
mkdir -p ./build/third_party/clFFT/src
cp -R --no-preserve=mode,ownership ${clfft.src}/ ./build/third_party/clFFT/src/clFFT-ext/
mkdir -p ./build/third_party/clBLAS/src
cp -R --no-preserve=mode,ownership ${clblas.src}/ ./build/third_party/clBLAS/src/clBLAS-ext/
mkdir -p ./build/include/CL
cp -R --no-preserve=mode,ownership ${opencl-clhpp}/include/CL/cl2.hpp ./build/include/CL/cl2.hpp
mkdir -p ./extern/af_glad-src
mkdir -p ./extern/af_threads-src
mkdir -p ./extern/af_test_data-src
mkdir -p ./extern/ocl_clfft-src
mkdir -p ./extern/spdlog-src
cp -R --no-preserve=mode,ownership ${glad}/* ./extern/af_glad-src/
cp -R --no-preserve=mode,ownership ${threads}/* ./extern/af_threads-src/
cp -R --no-preserve=mode,ownership ${test-data}/* ./extern/af_test_data-src/
cp -R --no-preserve=mode,ownership ${clfft}/* ./extern/ocl_clfft-src/
cp -R --no-preserve=mode,ownership ${spdlog}/* ./extern/spdlog-src/
# libaf.so (the unified backend) tries to load the right shared library at
# runtime, and the search paths are hard-coded... We tweak them to point to
# the installation directory in the Nix store.
substituteInPlace src/api/unified/symbol_manager.cpp \
--replace '"/opt/arrayfire-3/lib/",' \
"\"$out/lib/\", \"/opt/arrayfire-3/lib/\","
'';
preBuild = lib.optionalString cudaSupport ''
export CUDA_PATH="${cudatoolkit}"
'';
inherit doCheck;
checkPhase =
let
LD_LIBRARY_PATH = builtins.concatStringsSep ":" (
[ "${forge}/lib" "${freeimage}/lib" ]
++ lib.optional cudaSupport "${cudaPackages.cudatoolkit}/lib64"
# On non-NixOS systems, help the tests find Nvidia drivers
++ lib.optional (nvidiaComputeDrivers != null) "${nvidiaComputeDrivers}/lib"
);
ctestFlags = builtins.concatStringsSep " " (
# We have to run with "-j1" otherwise various segfaults occur on non-NixOS systems.
[ "--output-on-errors" "-j1" ]
# See https://github.com/arrayfire/arrayfire/issues/3484
++ lib.optional openclSupport "-E '(inverse_dense|cholesky_dense)'"
);
in
''
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
'' +
# On non-NixOS systems, help the tests find Nvidia drivers
lib.optionalString (openclSupport && nvidiaComputeDrivers != null) ''
export OCL_ICD_VENDORS=${nvidiaComputeDrivers}/etc/OpenCL/vendors
'' + ''
# Note: for debugging, enable AF_TRACE=all
AF_PRINT_ERRORS=1 ctest ${ctestFlags}
'';
buildInputs = [
blas
boost.dev
boost.out
clblast
fftw
fftwFloat
# We need fmt_9 because ArrayFire fails to compile with newer versions.
fmt_9
forge
freeimage
gtest
lapack
libGL
ocl-icd
opencl-clhpp
span-lite
]
++ lib.optionals cudaSupport [
cudaPackages.cudatoolkit
cudaPackages.cudnn
cudaPackages.cuda_cccl
]
++ lib.optionals openclSupport [
mesa
];
nativeBuildInputs = [
cmake
@ -64,30 +212,6 @@ stdenv.mkDerivation rec {
python3
];
strictDeps = true;
buildInputs = [
opencl-clhpp
fftw
fftwFloat
blas
lapack
libGLU
libGL
mesa
freeimage
boost.out
boost.dev
] ++ lib.optionals stdenv.isLinux [
ocl-icd
] ++ lib.optionals cudaSupport [
cudatoolkit
] ++ lib.optionals buildDocs [
doxygen
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk_11_0.frameworks.Accelerate
];
meta = with lib; {
description = "A general-purpose library for parallel and massively-parallel computations";
longDescription = ''
@ -95,7 +219,7 @@ stdenv.mkDerivation rec {
'';
license = licenses.bsd3;
homepage = "https://arrayfire.com/";
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ chessai ];
platforms = platforms.linux;
maintainers = with maintainers; [ chessai twesterhout ];
};
}

View File

@ -0,0 +1,35 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12d6e557c..cc004555d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -321,11 +321,6 @@ if(NOT TARGET nonstd::span-lite)
endif()
-af_dep_check_and_populate(${assets_prefix}
- URI https://github.com/arrayfire/assets.git
- REF master
-)
-set(ASSETS_DIR ${${assets_prefix}_SOURCE_DIR})
# when crosscompiling use the bin2cpp file from the native bin directory
if(CMAKE_CROSSCOMPILING)
@@ -473,18 +468,6 @@ install(FILES ${ArrayFire_BINARY_DIR}/include/af/version.h
DESTINATION "${AF_INSTALL_INC_DIR}/af/"
COMPONENT headers)
-# install the examples irrespective of the AF_BUILD_EXAMPLES value
-# only the examples source files are installed, so the installation of these
-# source files does not depend on AF_BUILD_EXAMPLES
-# when AF_BUILD_EXAMPLES is OFF, the examples source is installed without
-# building the example executables
-install(DIRECTORY examples/ #NOTE The slash at the end is important
- DESTINATION ${AF_INSTALL_EXAMPLE_DIR}
- COMPONENT examples)
-
-install(DIRECTORY ${ASSETS_DIR}/examples/ #NOTE The slash at the end is important
- DESTINATION ${AF_INSTALL_EXAMPLE_DIR}
- COMPONENT examples)
install(DIRECTORY "${ArrayFire_SOURCE_DIR}/LICENSES/"
DESTINATION LICENSES

View File

@ -1,28 +1,31 @@
diff --git a/CMakeModules/build_clBLAS.cmake b/CMakeModules/build_clBLAS.cmake
index 8de529e8..6361b613 100644
--- a/CMakeModules/build_clBLAS.cmake
+++ b/CMakeModules/build_clBLAS.cmake
@@ -14,8 +14,7 @@ find_package(OpenCL)
ExternalProject_Add(
clBLAS-ext
- GIT_REPOSITORY https://github.com/arrayfire/clBLAS.git
- GIT_TAG arrayfire-release
+ DOWNLOAD_COMMAND true
BUILD_BYPRODUCTS ${clBLAS_location}
PREFIX "${prefix}"
INSTALL_DIR "${prefix}"
diff --git a/CMakeModules/build_clFFT.cmake b/CMakeModules/build_clFFT.cmake
index 28be38a3..85e3915e 100644
--- a/CMakeModules/build_clFFT.cmake
+++ b/CMakeModules/build_clFFT.cmake
@@ -20,8 +20,7 @@ ENDIF()
ExternalProject_Add(
clFFT-ext
- GIT_REPOSITORY https://github.com/arrayfire/clFFT.git
- GIT_TAG arrayfire-release
+ DOWNLOAD_COMMAND true
PREFIX "${prefix}"
INSTALL_DIR "${prefix}"
UPDATE_COMMAND ""
diff --git a/CMakeModules/AFconfigure_deps_vars.cmake b/CMakeModules/AFconfigure_deps_vars.cmake
index aac332f5a..e9e711159 100644
--- a/CMakeModules/AFconfigure_deps_vars.cmake
+++ b/CMakeModules/AFconfigure_deps_vars.cmake
@@ -94,7 +94,7 @@ macro(af_dep_check_and_populate dep_prefix)
URL ${adcp_args_URI}
URL_HASH ${adcp_args_REF}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${ArrayFire_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-subbuild"
@@ -104,7 +104,7 @@ macro(af_dep_check_and_populate dep_prefix)
QUIET
URL ${adcp_args_URI}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${ArrayFire_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-subbuild"
@@ -116,7 +116,7 @@ macro(af_dep_check_and_populate dep_prefix)
GIT_REPOSITORY ${adcp_args_URI}
GIT_TAG ${adcp_args_REF}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${ArrayFire_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${ArrayFire_BINARY_DIR}/extern/${dep_prefix}-subbuild"

View File

@ -1,19 +1,50 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config
, arrayfire, expat, fontconfig, freeimage, freetype, boost
, mesa, libGLU, libGL, glfw3, SDL2, cudatoolkit
{ boost
, cmake
, expat
, fetchFromGitHub
, fontconfig
, freeimage
, freetype
, glfw3
, glm
, lib
, libGLU
, libGL
, mesa
, opencl-clhpp
, pkg-config
, stdenv
, SDL2
}:
stdenv.mkDerivation rec {
pname = "forge";
version = "1.0.4";
version = "1.0.8";
src = fetchFromGitHub {
owner = "arrayfire";
repo = "forge";
rev = "v${version}";
sha256 = "00pmky6kccd7pwi8sma79qpmzr2f9pbn6gym3gyqm64yckw6m484";
fetchSubmodules = true;
repo = pname;
rev = "v1.0.8";
sha256 = "sha256-lSZAwcqAHiuZkpYcVfwvZCfNmEF3xGN9S/HuZQrGeKU=";
};
glad = fetchFromGitHub {
owner = "arrayfire";
repo = "glad";
rev = "b94680aee5b8ce01ae1644c5f2661769366c765a";
hash = "sha256-CrZy76gOGMpy9f1NuMK4tokZ57U//zYeNH5ZYY0SC2U=";
};
# This patch ensures that Forge does not try to fetch glad from GitHub and
# uses our sources that we've checked out via Nix.
patches = [ ./no-download-glad.patch ];
postPatch = ''
mkdir -p ./extern
cp -R --no-preserve=mode,ownership ${glad} ./extern/fg_glad-src
ln -s ${opencl-clhpp} ./extern/cl2hpp
'';
cmakeFlags = [ "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" ];
nativeBuildInputs = [
cmake
@ -21,18 +52,19 @@ stdenv.mkDerivation rec {
];
buildInputs = [
expat
fontconfig
freetype
boost.out
boost.dev
expat
fontconfig
freeimage
mesa
libGLU libGL
freetype
glfw3
glm
libGL
libGLU
opencl-clhpp
SDL2
cudatoolkit
arrayfire
mesa
];
meta = with lib; {
@ -45,7 +77,6 @@ stdenv.mkDerivation rec {
license = licenses.bsd3;
homepage = "https://arrayfire.com/";
platforms = platforms.linux;
maintainers = with maintainers; [ chessai ];
maintainers = with maintainers; [ chessai twesterhout ];
};
}

View File

@ -0,0 +1,31 @@
diff --git a/CMakeModules/ForgeConfigureDepsVars.cmake b/CMakeModules/ForgeConfigureDepsVars.cmake
index ee5c2fc..2f75181 100644
--- a/CMakeModules/ForgeConfigureDepsVars.cmake
+++ b/CMakeModules/ForgeConfigureDepsVars.cmake
@@ -84,7 +84,7 @@ macro(fg_dep_check_and_populate dep_prefix)
URL ${fdcp_args_URI}
URL_HASH ${fdcp_args_REF}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"
@@ -94,7 +94,7 @@ macro(fg_dep_check_and_populate dep_prefix)
QUIET
URL ${fdcp_args_URI}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"
@@ -106,7 +106,7 @@ macro(fg_dep_check_and_populate dep_prefix)
GIT_REPOSITORY ${fdcp_args_URI}
GIT_TAG ${fdcp_args_REF}
DOWNLOAD_COMMAND \"\"
- UPDATE_DISCONNECTED ON
+ UPDATE_COMMAND \"\"
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"

View File

@ -20544,7 +20544,9 @@ with pkgs;
armadillo = callPackage ../development/libraries/armadillo { };
arrayfire = darwin.apple_sdk_11_0.callPackage ../development/libraries/arrayfire { };
arrayfire = callPackage ../development/libraries/arrayfire {
cudaPackages = cudaPackages_12;
};
arrow-cpp = callPackage ../development/libraries/arrow-cpp { };
@ -21186,9 +21188,7 @@ with pkgs;
fflas-ffpack = callPackage ../development/libraries/fflas-ffpack { };
forge = callPackage ../development/libraries/forge {
cudatoolkit = buildPackages.cudatoolkit_11;
};
forge = callPackage ../development/libraries/forge { };
linbox = callPackage ../development/libraries/linbox { };