1{ stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig
2, cudatoolkit, opencl-clhpp, ocl-icd, fftw, fftwFloat, mkl
3, blas, openblas, boost, mesa, libGLU, libGL
4, freeimage, python, clfft, clblas
5, doxygen, buildDocs ? false
6}:
7
8let
9 strOnLinux = stdenv.lib.optionalString stdenv.isLinux;
10
11in stdenv.mkDerivation rec {
12 pname = "arrayfire";
13 version = "3.6.4";
14
15 src = fetchurl {
16 url = "http://arrayfire.com/arrayfire_source/arrayfire-full-${version}.tar.bz2";
17 sha256 = "1fin7a9rliyqic3z83agkpb8zlq663q6gdxsnm156cs8s7f7rc9h";
18 };
19
20 cmakeFlags = [
21 "-DAF_BUILD_OPENCL=OFF"
22 "-DAF_BUILD_EXAMPLES=OFF"
23 "-DBUILD_TESTING=OFF"
24 (strOnLinux "-DCMAKE_LIBRARY_PATH=${cudatoolkit}/lib/stubs")
25 ];
26
27 patches = [ ./no-download.patch ];
28
29 postPatch = ''
30 mkdir -p ./build/third_party/clFFT/src
31 cp -R --no-preserve=mode,ownership ${clfft.src}/ ./build/third_party/clFFT/src/clFFT-ext/
32 mkdir -p ./build/third_party/clBLAS/src
33 cp -R --no-preserve=mode,ownership ${clblas.src}/ ./build/third_party/clBLAS/src/clBLAS-ext/
34 mkdir -p ./build/include/CL
35 cp -R --no-preserve=mode,ownership ${opencl-clhpp}/include/CL/cl2.hpp ./build/include/CL/cl2.hpp
36 '';
37
38 preBuild = strOnLinux ''
39 export CUDA_PATH="${cudatoolkit}"
40 '';
41
42 enableParallelBuilding = true;
43
44 nativeBuildInputs = [
45 cmake
46 pkgconfig
47 python
48 ];
49
50 buildInputs = [
51 opencl-clhpp fftw fftwFloat
52 mkl
53 openblas
54 libGLU libGL
55 mesa freeimage
56 boost.out boost.dev
57 ] ++ (stdenv.lib.optional stdenv.isLinux [ cudatoolkit ocl-icd ])
58 ++ (stdenv.lib.optional buildDocs [ doxygen ]);
59
60 meta = with stdenv.lib; {
61 description = "A general-purpose library for parallel and massively-parallel computations";
62 longDescription = ''
63 A general-purpose library that simplifies the process of developing software that targets parallel and massively-parallel architectures including CPUs, GPUs, and other hardware acceleration devices.";
64 '';
65 license = licenses.bsd3;
66 homepage = "https://arrayfire.com/";
67 platforms = platforms.linux ++ platforms.darwin;
68 maintainers = with maintainers; [ chessai ];
69 };
70}