projects/guix·blob javascript-team · refs

324 lines · 12.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Cayetano Santos <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages oneapi)
20 #:use-module (gnu packages)
21 #:use-module (gnu packages check)
22 #:use-module (gnu packages cpp)
23 #:use-module (gnu packages linux)
24 #:use-module (gnu packages llvm)
25 #:use-module (gnu packages logging)
26 #:use-module (gnu packages mpi)
27 #:use-module (gnu packages pkg-config)
28 #:use-module (gnu packages python)
29 #:use-module (gnu packages python-build)
30 #:use-module (gnu packages swig)
31 #:use-module (guix build-system cmake)
32 #:use-module (guix gexp)
33 #:use-module (guix git-download)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (guix packages)
36 #:use-module (guix utils))
37
38(define-public level-zero
39 (package
40 (name "level-zero")
41 (version "1.34.0")
42 (source
43 (origin
44 (method git-fetch)
45 (uri (git-reference
46 (url "https://github.com/oneapi-src/level-zero/")
47 (commit (string-append "v" version))))
48 (file-name (git-file-name name version))
49 (sha256
50 (base32
51 "0r5rx01d3rzg8hpn3qrl4c8vvk14iris1yb1jxk0jcapw49ryzv1"))))
52 (build-system cmake-build-system)
53 (arguments
54 (list
55 #:tests? #f
56 #:configure-flags
57 #~(list (string-append "-DVERSION_SHA=" #$version))))
58 (native-inputs (list pkg-config python-minimal-wrapper))
59 (home-page
60 "https://oneapi-src.github.io/level-zero-spec/level-zero/latest/index.html")
61 (synopsis "OneAPI Level Zero specification headers and loader")
62 (description
63 "Level Zero contains the following components of oneAPI:
64@itemize
65@item copies of the Level Zero Specification API C/C++ header files
66@item loader
67@item validation layer
68@item tracing layer
69@end itemize")
70 (license
71 (list license:expat ;level-zero
72 license:asl2.0)))) ;third-party/xla
73
74;;; Updates and replaces oneapi-dnnl in (gnu packages machine-learning)
75(define-public onednn
76 ;; See doc/build/build.md.
77 (package
78 (name "onednn")
79 (version "3.13.2")
80 (source
81 (origin
82 (method git-fetch)
83 (uri (git-reference
84 (url "https://github.com/uxlfoundation/oneDNN/")
85 (commit (string-append "v" version))))
86 (file-name (git-file-name name version))
87 (sha256
88 (base32 "0abrqhj33prdc17dw9r4mil1x9vg53kq615w0dncqm6vyvgx57ib"))
89 (modules '((guix build utils)
90 (ice-9 rdelim)))
91 ;; Copyright date used by code generation script
92 (snippet
93 '(for-each
94 (lambda (file)
95 (with-atomic-file-replacement
96 file
97 (lambda (in out)
98 (let loop ((line (read-line in 'concat)))
99 (if (string-contains line "Copyright")
100 (display line out)
101 (loop (read-line in 'concat)))))))
102 '("include/oneapi/dnnl/dnnl_debug.h"
103 "src/common/dnnl_debug_autogenerated.cpp"
104 "tests/benchdnn/dnnl_debug_autogenerated.cpp"
105 "tests/benchdnn/dnnl_debug.hpp")))))
106 (build-system cmake-build-system)
107 (arguments
108 (list
109 #:configure-flags ;see doc/build/build_options.md
110 #~(list
111 #$@(if (target-riscv64?)
112 (list "-DDNNL_CPU_RUNTIME=SEQ")
113 ;; Default; also tbb and sycl.
114 (list "-DDNNL_CPU_RUNTIME=OMP"))
115 "-DDNNL_EXPERIMENTAL_UKERNEL=ON" ;Used in PyTorch
116 "-DONEDNN_BUILD_GRAPH=OFF") ;See scripts/README.md
117 #:phases
118 #~(modify-phases %standard-phases
119 ;; Benchdnn tests takes hours in a 100 cpu machine.
120 (add-after 'unpack 'disable-benchdnn-testing
121 (lambda _
122 (substitute* "tests/CMakeLists.txt"
123 (("add_subdirectory\\(benchdnn\\)") ""))))
124 ;; See scripts/README.md.
125 (add-after 'configure 'codegen
126 (lambda _
127 (with-directory-excursion "../source"
128 ;; Generate types.xml.
129 (invoke "castxml" "--castxml-cc-gnu-c" "clang"
130 "--castxml-output=1" "-Iinclude" "-I../build/include"
131 "include/oneapi/dnnl/dnnl_types.h" "-o" "types.xml")
132 ;; Run generate_dnnl_debug.py.
133 (invoke
134 "python3" "scripts/generate_dnnl_debug.py" "types.xml")
135 ;; Generating format tags.
136 ;; Modifies include/oneapi/dnnl/dnnl.hpp
137 (invoke "python3" "scripts/generate_format_tags.py")))))))
138 (native-inputs
139 (list castxml clang googletest python-minimal-wrapper))
140 (home-page "https://uxlfoundation.github.io/oneDNN/")
141 (synopsis "Deep neural network library")
142 (description
143 "@acronym{OneDNN, OneAPI Deep Neural Network Library} is a cross-platform
144performance library of basic building blocks for deep learning applications.")
145 (supported-systems %64bit-supported-systems)
146 (license license:asl2.0)))
147
148(define-public oneapi-dnnl (deprecated-package "oneapi-dnnl" onednn))
149
150;;; Updates and replaces tbb in (gnu packages tbb)
151(define-public onetbb
152 (package
153 (name "onetbb")
154 (version "2023.1.0")
155 (source
156 (origin
157 (method git-fetch)
158 (uri (git-reference
159 (url "https://github.com/uxlfoundation/oneTBB/")
160 (commit (string-append "v" version))))
161 (file-name (git-file-name name version))
162 (sha256
163 (base32
164 "15knh7rwdvwjylk4kcxlkhgdwla4m3k5zkxg4xvznnqh0zds2bpc"))
165 (patches (search-patches "onetbb-other-arches.patch"))))
166 (build-system cmake-build-system)
167 (arguments
168 (list
169 #:configure-flags
170 #~(list #$@(if (or (target-riscv64?)
171 (target-ppc32?))
172 '(list "-DTBB_TEST_LINK_FLAGS=-latomic")
173 '())
174 #$@(if (or (target-arm32?)
175 (target-ppc32?))
176 '("-DTBB_TEST_COMPILE_FLAGS=-DTBB_TEST_LOW_WORKLOAD")
177 '())
178 ;; Don't fail on warnings.
179 "-DTBB_STRICT=OFF")
180 #:phases
181 #~(modify-phases %standard-phases
182 #$@(cond
183 ((target-arm32?)
184 `((add-after 'unpack 'adjust-test-suite
185 (lambda _
186 (substitute* "test/CMakeLists.txt"
187 ;; Bus error, skipped on mips.
188 ((".*test_malloc_pools.*") ""))))))
189 ((target-ppc32?)
190 `((add-after 'unpack 'adjust-test-suite
191 (lambda _
192 (substitute* "test/CMakeLists.txt"
193 ;; These tests hang forever.
194 ((".*test_function_node.*") "")
195 ((".*test_multifunction_node.*") "")
196 ((".*test_async_node.*") ""))))))
197 ((target-riscv64?)
198 `((add-after 'unpack 'adjust-test-suite
199 (lambda _
200 (substitute* "test/CMakeLists.txt"
201 ;; This tests hangs forever.
202 ((".*test_task_group.*") ""))))))
203 (else '())))))
204 (home-page "https://uxlfoundation.github.io/oneTBB/")
205 (synopsis "C++ library for parallel programming")
206 (description
207 "@acronym{OneTBB, OneAPI Threading Building Blocks} is a C++ runtime
208library that abstracts the low-level threading details necessary for optimal
209multi-core performance. It uses common C++ templates and coding style to
210eliminate tedious threading implementation work. It provides parallel loop
211constructs, asynchronous tasks, synchronization primitives, atomic operations,
212and more.")
213 (license license:asl2.0)))
214
215(define-public onetbb-2022
216 (package
217 (inherit onetbb)
218 (name "onetbb")
219 (version "2022.3.0")
220 (source
221 (origin
222 (method git-fetch)
223 (uri (git-reference
224 (url "https://github.com/uxlfoundation/oneTBB/")
225 (commit (string-append "v" version))))
226 (file-name (git-file-name name version))
227 (sha256
228 (base32
229 "0ibwr5cw0zw5dfcdhavr5zbmwqqf7vnsai0gh4mqw475l7lcb08w"))
230 (patches (search-patches "onetbb-other-arches.patch"))))))
231
232(define-public python-onetbb
233 (package
234 (inherit onetbb)
235 (name "python-onetbb")
236 (arguments
237 (list
238 #:configure-flags
239 #~(list "-DTBB4PY_BUILD=ON")
240 #:phases
241 #~(modify-phases %standard-phases
242 (add-after 'unpack 'patch-python-install-directory
243 (lambda _
244 (substitute* "python/setup.py"
245 (("extra_link_args=tbb_flag,")
246 (string-append
247 "extra_link_args=['-Wl,-rpath="
248 #$(this-package-input "onetbb") "/lib"
249 "', '-Wl,-rpath=" #$output "/lib'] + tbb_flag,")))))
250 (replace 'build
251 (lambda _
252 (setenv "PYTHONHASHSEED" "0")
253 (invoke "make" "python_build")))
254 ;; The 'build phase already installs the modules
255 (replace 'install
256 (lambda _
257 (with-directory-excursion "python/rml"
258 (invoke "make" "install"))))
259 (replace 'check
260 (lambda* (#:key tests? #:allow-other-keys)
261 (when tests?
262 (invoke "ctest" "-R" "python_test" "--output-on-failure")))))))
263 (native-inputs (list swig-4.4 python-minimal python-setuptools))
264 (inputs (list onetbb))
265 (synopsis "Python bindings for the oneTBB parallel library")
266 (description
267 "@acronym{OneTBB, OneAPI Threading Building Blocks} is a C++ runtime
268library that abstracts the low-level threading details necessary for optimal
269multi-core performance. It uses common C++ templates and coding style to
270eliminate tedious threading implementation work. It provides parallel loop
271constructs, asynchronous tasks, synchronization primitives, atomic operations,
272and more. @code{python-onetbb} enables threading composability between two or
273more thread-enabled Python libraries.")))
274
275(define-public umf
276 (package
277 (name "umf")
278 (version "1.2.0")
279 (source
280 (origin
281 (method git-fetch)
282 (uri (git-reference
283 (url "https://github.com/oneapi-src/unified-memory-framework/")
284 (commit (string-append "v" version))))
285 (sha256
286 (base32
287 "0g264s9zz4mcckd3cajmn2i1pz7y8cbrx2dmj8yqcwkbdysijbhw"))))
288 (build-system cmake-build-system)
289 (arguments
290 (list
291 #:tests? #f ;errors with "function not implemented"
292 #:configure-flags
293 #~(list "-DUMF_BUILD_CUDA_PROVIDER=OFF"
294 "-DUMF_BUILD_EXAMPLES=OFF")
295 #:phases
296 #~(modify-phases %standard-phases
297 (add-before 'check 'set-ld-library-path
298 (lambda _
299 (for-each
300 (lambda (f)
301 (delete-file (format #f "test/~a" f)))
302 '("test_memspace_highest_capacity"
303 "test_memtarget"))
304 (setenv "LD_LIBRARY_PATH"
305 (string-append #$(this-package-input "onetbb")
306 "/lib"))))
307 (add-after 'unpack 'fix-googletest
308 (lambda _
309 (substitute* "test/CMakeLists.txt"
310 (("FetchContent_MakeAvailable\\(googletest\\)")
311 "find_package(GTest REQUIRED)")))))))
312 (inputs
313 (list `(,hwloc "lib") level-zero numactl onetbb))
314 (native-inputs
315 (list pkg-config python-minimal-wrapper googletest))
316 (home-page "https://oneapi-src.github.io/unified-memory-framework/")
317 (synopsis "OneAPI @acronym{UMG, Unified Memory Framework}")
318 (description
319 "The UMF is a library for constructing allocators and memory pools. It
320also contains broadly useful abstractions and utilities for memory
321management. UMF allows users to manage multiple memory pools characterized by
322different attributes, allowing certain allocation types to be isolated from
323others and allocated using different hardware resources as required..")
324 (license license:asl2.0)))