Skip to content

Instantly share code, notes, and snippets.

@taktoa
Last active April 14, 2019 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taktoa/aa51ae9c14aa6e0a635dd67d1cd079d2 to your computer and use it in GitHub Desktop.
Save taktoa/aa51ae9c14aa6e0a635dd67d1cd079d2 to your computer and use it in GitHub Desktop.

ArrayFire Nix Package

I haven't tested this under the full Nix sandbox, so it may still have some impurities.

If you have rustup installed and you want to build the ArrayFire Rust bindings impurely, just remember to set the AF_PATH environment variable to the output path resulting from building arrayfire.nix.

{ stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig,
opencl-clhpp, ocl-icd, fftw, fftwFloat,
blas, openblas, liblapack, boost, mesa_noglu, freeimage, python
}:
with {
clfftSource = fetchFromGitHub {
owner = "arrayfire";
repo = "clFFT";
rev = "16925fb93338b3cac66490b5cf764953d6a5dac7";
sha256 = "0y35nrdz7w4n1l17myhkni3hwm37z775xn6f76xmf1ph7dbkslsc";
fetchSubmodules = true;
};
clblasSource = fetchFromGitHub {
owner = "arrayfire";
repo = "clBLAS";
rev = "1f3de2ae5582972f665c685b18ef0df43c1792bb";
sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs";
fetchSubmodules = true;
};
cl2hppSource = fetchurl {
url = "https://github.com/KhronosGroup/OpenCL-CLHPP/releases/download/v2.0.10/cl2.hpp";
sha256 = "1v4q0g6b6mwwsi0kn7kbjn749j3qafb9r4ld3zdq1163ln9cwnvw";
};
};
stdenv.mkDerivation {
name = "arrayfire-3.6.1";
src = fetchFromGitHub {
owner = "arrayfire";
repo = "arrayfire";
rev = "b443e146b6747c73caaaae4d65dd6b3a32936745";
sha256 = "1f6zq0n0675wgs5dbiasz6dv9qrpg20jdrb1fk14hyyz0mbg8yhr";
fetchSubmodules = true;
};
cmakeFlags = [ ];
patches = [ ./no-download.patch ];
postPatch = ''
mkdir -p ./build/third_party/clFFT/src
cp -Rv --no-preserve=mode,ownership ${clfftSource}/ ./build/third_party/clFFT/src/clFFT-ext/
mkdir -p ./build/third_party/clBLAS/src
cp -Rv --no-preserve=mode,ownership ${clblasSource}/ ./build/third_party/clBLAS/src/clBLAS-ext/
mkdir -p ./build/include/CL
cp -Rv --no-preserve=mode,ownership ${cl2hppSource} ./build/include/CL/cl2.hpp
'';
buildInputs = [
cmake pkgconfig
opencl-clhpp ocl-icd fftw fftwFloat blas openblas liblapack mesa_noglu freeimage
boost.out boost.dev python
];
}
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 ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment