summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/clblas/cuda/default.nix
blob: 0b5a3323ec15082027746343ec684869331f4b65 (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
{ stdenv
, fetchFromGitHub
, cmake
, gfortran
, blas
, boost
, python
, cudatoolkit
, nvidia_x11
}:

stdenv.mkDerivation rec {
  name = "clblas-cuda-${version}"; 
  version = "git-20160505"; 

  src = fetchFromGitHub {
    owner = "clMathLibraries"; 
    repo = "clBLAS";
    rev = "d20977ec4389c6b3751e318779410007c5e272f8";
    sha256 = "1jna176cxznv7iz43svd6cjrbbf0fc2lrbpfpg4s08vc7xnwp0n4";
  }; 

  patches = [ ./platform.patch ]; 

  postPatch = ''
    sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt
  '';

  configurePhase = ''
    findInputs ${boost} boost_dirs propagated-native-build-inputs

    export BOOST_INCLUDEDIR=$(echo $boost_dirs | sed -e s/\ /\\n/g - | grep '\-dev')/include
    export BOOST_LIBRARYDIR=$(echo $boost_dirs | sed -e s/\ /\\n/g - | grep -v '\-dev')/lib

    mkdir -p Build
    pushd Build

    export LD_LIBRARY_PATH="${stdenv.lib.makeLibraryPath [ blas nvidia_x11 ]}"

    cmake ../src -DCMAKE_INSTALL_PREFIX=$out \
                 -DCMAKE_BUILD_TYPE=Release \
                 -DOPENCL_ROOT=${cudatoolkit} \
  '';

  dontStrip = true; 

  buildInputs = [
    cmake
    gfortran
    blas
    python
    cudatoolkit
    nvidia_x11
  ]; 

  meta = with stdenv.lib; {
    homepage = https://github.com/clMathLibraries/clBLAS;
    description = "A software library containing BLAS functions written in OpenCL";
    longDescription = ''
      This package contains a library of BLAS functions on top of OpenCL. 
      The current version is linked to the NVIDIA OpenCL implementation provided by the CUDA toolkit. 
    '';
    license = licenses.asl20;
    maintainers = with maintainers; [ artuuge ];
    platforms = platforms.linux;
  };

}