about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/arrayfire/default.nix
blob: 8692aa3017f77ff9ba9faaa5b47f429f9f7817ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
, opencl-clhpp
, ocl-icd
, fftw
, fftwFloat
, blas
, lapack
, boost
, mesa
, libGLU
, libGL
, freeimage
, python3
, clfft
, clblas
, doxygen
, buildDocs ? false
, cudaSupport ? false
, cudatoolkit
, darwin
}:

stdenv.mkDerivation rec {
  pname = "arrayfire";
  version = "3.7.3";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = "v${version}";
    sha256 = "0gcbg6b6gs38xhks5pp0vkcqs89zl7rh9982jqlzsd0h724qddw0";
    fetchSubmodules = true;
  };

  cmakeFlags = [
    "-DAF_BUILD_OPENCL=OFF"
    "-DAF_BUILD_EXAMPLES=OFF"
    "-DBUILD_TESTING=OFF"
  ] ++ lib.optional cudaSupport "-DCMAKE_LIBRARY_PATH=${cudatoolkit}/lib/stubs";

  patches = [ ./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
  '';

  preBuild = lib.optionalString cudaSupport ''
    export CUDA_PATH="${cudatoolkit}"
  '';

  nativeBuildInputs = [
    cmake
    pkg-config
    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 = ''
      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.";
    '';
    license = licenses.bsd3;
    homepage = "https://arrayfire.com/";
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ chessai ];
  };
}