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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gn packages arrayfire)
#:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix git-download)
#:use-module (guix build-system cmake)
#:use-module (gnu packages)
#:use-module (guix utils)
#:use-module (gnu packages algebra)
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
#:use-module (gnu packages gcc)
#:use-module (gnu packages maths)
#:use-module (gnu packages opencl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python))
(define-public arrayfire
(package
(name "arrayfire")
(version "3.3.2")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/arrayfire/arrayfire.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"113ldnqsil4p84sayv7jh8vnn0nalxibhdyvvwp94vqk20kqg4lw"))
(patches (search-patches "arrayfire-lapack-detection.patch"
"arrayfire-newer-boost-compute.patch"))))
(native-inputs
`(("pkg-config" ,pkg-config)
("googletest" ,googletest)
("assets" ,(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/arrayfire/assets.git")
(commit "729c7b64039e6433ae5ee521658ba20147efcb02"))) ; March 4, 2019
(file-name (git-file-name "arrayfire-assets" "submodule"))
(sha256
(base32
"05zg7m6zlwi3llbv7l5wd9qi9ppb9p3ad2i5xmqwvcbgx5ry4l2s"))))
("threads" ,(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/alltheflops/threads.git")
(commit "5e778ce0a7f0f80af9d32ea3569df3dbec834f59"))) ; Dec 16, 2015
(file-name (git-file-name "arrayfire-threads" "submodule"))
(sha256
(base32
"1rj2357r124b4ry0s467fz9hs4jxcyacliwprggvai85a39pqabx"))))))
(inputs
`(("boost" ,boost)
("clBLAS" ,clBLAS)
("clFFT" ,clFFT)
("fftw-openmpi" ,fftw-openmpi)
("fftwf" ,fftwf)
("ocl-icd" ,ocl-icd)
("openblas" ,openblas)
("opencl-headers" ,opencl-headers)))
(build-system cmake-build-system)
(arguments
`(#:configure-flags
'("-DBUILD_OPENCL=ON"
"-DBUILD_CUDA=OFF"
"-DBUILD_GRAPHICS=OFF"
"-DBUILD_TEST=OFF" ; building tests segfaults
"-DUSE_SYSTEM_CLBLAS=ON"
"-DUSE_SYSTEM_CLFFT=ON"
"-DUSE_SYSTEM_GTEST=ON")
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'add-more-sources
(lambda* (#:key inputs #:allow-other-keys)
(let ((assets (assoc-ref inputs "assets"))
(threads (assoc-ref inputs "threads")))
(copy-recursively assets "assets")
(copy-recursively threads "src/backend/cpu/threads"))
#t))
(add-after 'unpack 'fix-sources
(lambda _
(substitute* "src/backend/opencl/blas.cpp"
;; https://github.com/arrayfire/arrayfire/commit/90a9ffbce5c38352a365e03a634ffaf0d2fb9933
(("#undef BLAS_FUNC_DEF")
"#undef BLAS_FUNC_DEF\n#undef BLAS_FUNC"))
(substitute* '("src/backend/cpu/blas.cpp"
"src/backend/opencl/cpu/cpu_blas.cpp")
;; https://github.com/arrayfire/arrayfire/pull/2538/files
(("&cblas_##PREFIX##FUNC;")
"(FUNC##_func_def<TYPE>)&cblas_##PREFIX##FUNC;"))
#t)))
#:tests? #f)) ; Building the tests fail linking, so we build the examples as a test.
(home-page "https://arrayfire.com/")
(synopsis "High performance library for parallel computing")
(description
"ArrayFire is a high performance software library for parallel computing
with an easy-to-use API. Its array based function set makes parallel
programming simple.")
(license (list license:bsd-3 ; everything except CMakeModules folder
license:cc0)))) ; assets
(define-public clBLAS
(package
(name "clBLAS")
(version "2.12")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/clMathLibraries/clBLAS.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs"))))
(build-system cmake-build-system)
(arguments
`(#:tests? #f
#:configure-flags
(list "../source/src"
"-DUSE_SYSTEM_GTEST=ON"
;"-DBoost_USE_STATIC_LIBS=OFF" ; this does not seem to apply
"-DBUILD_TEST=OFF")
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-source
(lambda _
(substitute* "src/CMakeLists.txt"
(("Boost_USE_STATIC_LIBS ON")
"Boost_USE_STATIC_LIBS OFF"))
#t)))))
(native-inputs
`(("gfortran" ,gfortran)
("openblas" ,openblas)
("opencl-headers" ,opencl-headers)
("python" ,python-2)))
(inputs
`(("boost" ,boost)
("ocl-icd" ,ocl-icd)))
(home-page "https://github.com/clMathLibraries/clBLAS")
(synopsis "Library containing BLAS functions written in OpenCL")
(description
"The primary goal of @code{clBLAS} is to make it easier for developers to
utilize the inherent performance and power efficiency benefits of heterogeneous
computing. @code{clBLAS} interfaces do not hide nor wrap @code{OpenCL}
interfaces, but rather leaves @code{OpenCL} state management to the control of
the user to allow for maximum performance and flexibility. The @code{clBLAS}
library does generate and enqueue optimized @code{OpenCL} kernels, relieving the
user from the task of writing, optimizing and maintaining kernel code themselves.")
(license license:asl2.0)))
(define-public clFFT
(package
(name "clFFT")
(version "2.10.1")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/clMathLibraries/clFFT.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"1ksmcsqf25bmaq9rr2z1m936mxgh9cx6can2l7nna4mzlj0aghrs"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags '("../source/src"
"-DBUILD_TEST=ON"
"-DUSE_SYSTEM_GTEST=ON"
"-DBoost_USE_STATIC_LIBS=OFF")
#:test-target "Test"))
(native-inputs
`(("boost" ,boost)
("fftw-openmpi" ,fftw-openmpi)
("fftwf" ,fftwf)
("googletest" ,googletest)))
(inputs
`(("ocl-icd" ,ocl-icd)
("opencl-headers" ,opencl-headers)))
(home-page "https://github.com/clMathLibraries/clFFT/")
(synopsis "Library containing FFT functions written in OpenCL")
(description "@code{clFFT} is a software library containing FFT functions
written in @code{OpenCL}. In addition to GPU devices, the library also supports
running on CPU devices to facilitate debugging and heterogeneous programming.")
(license license:asl2.0)))
(define-public compute ; superceeded by boost-1.61+
(package
(name "compute")
(version "0.5")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/boostorg/compute.git")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"0jc04k43br49hqgzrxfn3wfz2m94q1z45zfg5nahqb7p0lbfgwyx"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags '("-DBUILD_SHARED_LIBS=ON"
"-DCMAKE_BUILD_TYPE=Release")
#:tests? #f)) ; tests require OpenCL device
(native-inputs
`(("boost" ,boost-for-mysql) ; 1.59.0
("opencl-headers" ,opencl-headers)
("ocl-icd" ,ocl-icd)))
(home-page "http://boostorg.github.io/compute/")
(synopsis "C++ GPU Computing Library for OpenCL")
(description
"@code{Boost.Compute} is a GPU/parallel-computing library for C++ based on
@code{OpenCL}. The core library is a thin C++ wrapper over the @code{OpenCL
API} and provides access to compute devices, contexts, command queues and memory
buffers.")
(license license:boost1.0)))
|