Skip to content

Instantly share code, notes, and snippets.

@taktoa
Last active April 14, 2019 06:19
Show Gist options
  • Save taktoa/aa51ae9c14aa6e0a635dd67d1cd079d2 to your computer and use it in GitHub Desktop.
Save taktoa/aa51ae9c14aa6e0a635dd67d1cd079d2 to your computer and use it in GitHub Desktop.

Revisions

  1. taktoa revised this gist Apr 14, 2019. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions arrayfire.nix
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    { stdenv, fetchFromGitHub, cmake, pkgconfig,
    opencl-clhpp, ocl-icd, fftw, fftwFloat, blas, liblapack, boost, mesa, freeimage, python
    { stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig,
    opencl-clhpp, ocl-icd, fftw, fftwFloat,
    blas, openblas, liblapack, boost, mesa_noglu, freeimage, python
    }:

    with {
    @@ -18,6 +19,11 @@ with {
    sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs";
    fetchSubmodules = true;
    };

    cl2hppSource = fetchurl {
    url = "https://github.com/KhronosGroup/OpenCL-CLHPP/releases/download/v2.0.10/cl2.hpp";
    sha256 = "1v4q0g6b6mwwsi0kn7kbjn749j3qafb9r4ld3zdq1163ln9cwnvw";
    };
    };

    stdenv.mkDerivation {
    @@ -40,11 +46,13 @@ stdenv.mkDerivation {
    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 liblapack mesa freeimage
    opencl-clhpp ocl-icd fftw fftwFloat blas openblas liblapack mesa_noglu freeimage
    boost.out boost.dev python
    ];
    }
    }
  2. taktoa renamed this gist Jul 13, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. taktoa revised this gist Jul 13, 2018. 2 changed files with 33 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # 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`.
    28 changes: 28 additions & 0 deletions no-download.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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 ""
  4. taktoa renamed this gist Jul 13, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. taktoa created this gist Jul 13, 2018.
    50 changes: 50 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    { stdenv, fetchFromGitHub, cmake, pkgconfig,
    opencl-clhpp, ocl-icd, fftw, fftwFloat, blas, liblapack, boost, mesa, 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;
    };
    };

    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/
    '';

    buildInputs = [
    cmake pkgconfig
    opencl-clhpp ocl-icd fftw fftwFloat blas liblapack mesa freeimage
    boost.out boost.dev python
    ];
    }