~ruther/guix-local

ref: f3d2705f64ac3ef2dcdcd0d48eed413fb1fdab40 guix-local/gnu/packages/oneapi.scm -rw-r--r-- 12.2 KiB
f3d2705f — Cayetano Santos gnu: ieee-p1076: Move to hdl. 30 days ago
                                                                                
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2025 Cayetano Santos <csantosb@inventati.org>
;;;
;;; 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 (gnu packages oneapi)
  #:use-module (gnu packages)
  #:use-module (gnu packages check)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages logging)
  #:use-module (gnu packages mpi)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages swig)
  #:use-module (guix build-system cmake)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils))

(define-public level-zero
  (package
    (name "level-zero")
    (version "1.27.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/oneapi-src/level-zero/")
              (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (snippet
        #~(begin
            (use-modules (guix build utils))
            (with-directory-excursion "third_party"
              (delete-file-recursively "spdlog_headers"))))
       (sha256
        (base32
         "1f08046g4anbqn3sk8fdpi6xdb8pkq1y28a5rxrai9rmah1v07kw"))))
    (build-system cmake-build-system)
    (arguments
     (list
      #:tests? #f
      #:configure-flags
      #~(list "-DSYSTEM_SPDLOG=ON"
              (string-append "-DVERSION_SHA=" #$version))))
    (inputs (list spdlog-1.14))
    (native-inputs (list pkg-config python-minimal-wrapper))
    (home-page
     "https://oneapi-src.github.io/level-zero-spec/level-zero/latest/index.html")
    (synopsis "OneAPI Level Zero specification headers and loader")
    (description
     "Level Zero contains the following components of oneAPI:
@itemize
@item copies of the Level Zero Specification API C/C++ header files
@item loader
@item validation layer
@item tracing layer
@end itemize")
    (license
     (list license:expat                ;level-zero
           license:asl2.0))))           ;third-party/xla

;;; Updates and replaces oneapi-dnnl in (gnu packages machine-learning)
(define-public onednn
  ;; See doc/build/build.md.
  (package
    (name "onednn")
    (version "3.10.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/uxlfoundation/oneDNN/")
              (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1imwsaj4sfsr4m6szhn272f7yikg0ixif4savbzyjdn1haz7pvpx"))
       (modules '((guix build utils)
                  (ice-9 rdelim)))
       ;; Copyright date used by code generation script
       (snippet
        '(for-each
          (lambda (file)
            (with-atomic-file-replacement
             file
             (lambda (in out)
               (let loop ((line (read-line in 'concat)))
                 (if (string-contains line "Copyright")
                     (display line out)
                     (loop (read-line in 'concat)))))))
          '("include/oneapi/dnnl/dnnl_debug.h"
            "src/common/dnnl_debug_autogenerated.cpp"
            "tests/benchdnn/dnnl_debug_autogenerated.cpp"
            "tests/benchdnn/dnnl_debug.hpp")))))
    (build-system cmake-build-system)
    (arguments
     (list
      #:configure-flags                 ;see doc/build/build_options.md
      #~(list
         #$@(if (target-riscv64?)
                (list "-DDNNL_CPU_RUNTIME=SEQ")
                ;; Default; also tbb and sycl.
                (list "-DDNNL_CPU_RUNTIME=OMP"))
         "-DDNNL_EXPERIMENTAL_UKERNEL=ON" ;Used in PyTorch
         "-DONEDNN_BUILD_GRAPH=OFF") ;See scripts/README.md
      #:phases
      #~(modify-phases %standard-phases
          ;; This test times out after 3600 seconds.
          (add-after 'unpack 'disable-matmul-testing
            (lambda _
              (substitute* "tests/benchdnn/benchdnn.cpp"
                (("matmul::bench.*") ";\n"))))
          ;; See scripts/README.md.
          (add-after 'configure 'codegen
            (lambda _
              (with-directory-excursion "../source"
                ;; Generate types.xml.
                (invoke "castxml" "--castxml-cc-gnu-c" "clang"
                        "--castxml-output=1" "-Iinclude" "-I../build/include"
                        "include/oneapi/dnnl/dnnl_types.h" "-o" "types.xml")
                ;; Run generate_dnnl_debug.py.
                (invoke
                 "python3" "scripts/generate_dnnl_debug.py" "types.xml")
                ;; Generating format tags.
                ;; Modifies include/oneapi/dnnl/dnnl.hpp
                (invoke "python3" "scripts/generate_format_tags.py")))))))
    (native-inputs
     (list castxml clang-17 googletest python-minimal-wrapper))
    (home-page "https://uxlfoundation.github.io/oneDNN/")
    (synopsis "Deep neural network library")
    (description
     "@acronym{OneDNN, OneAPI Deep Neural Network Library} is a cross-platform
performance library of basic building blocks for deep learning applications.")
    (supported-systems %64bit-supported-systems)
    (license license:asl2.0)))

(define-public oneapi-dnnl (deprecated-package "oneapi-dnnl" onednn))

;;; Updates and replaces tbb in (gnu packages tbb)
(define-public onetbb
  (package
    (name "onetbb")
    (version "2022.3.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/uxlfoundation/oneTBB/")
              (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0ibwr5cw0zw5dfcdhavr5zbmwqqf7vnsai0gh4mqw475l7lcb08w"))
       (patches (search-patches "onetbb-other-arches.patch"))))
    (build-system cmake-build-system)
    (arguments
     (list
      #:configure-flags
      #~(list #$@(if (or (target-riscv64?)
                         (target-ppc32?))
                     '(list "-DTBB_TEST_LINK_FLAGS=-latomic")
                     '())
              #$@(if (or (target-arm32?)
                         (target-ppc32?))
                     '("-DTBB_TEST_COMPILE_FLAGS=-DTBB_TEST_LOW_WORKLOAD")
                     '())
              ;; Don't fail on warnings.
              "-DTBB_STRICT=OFF")
      #:phases
      #~(modify-phases %standard-phases
          #$@(cond
              ((target-arm32?)
               `((add-after 'unpack 'adjust-test-suite
                   (lambda _
                     (substitute* "test/CMakeLists.txt"
                       ;; Bus error, skipped on mips.
                       ((".*test_malloc_pools.*") ""))))))
              ((target-ppc32?)
               `((add-after 'unpack 'adjust-test-suite
                   (lambda _
                     (substitute* "test/CMakeLists.txt"
                       ;; These tests hang forever.
                       ((".*test_function_node.*") "")
                       ((".*test_multifunction_node.*") "")
                       ((".*test_async_node.*") ""))))))
              ((target-riscv64?)
               `((add-after 'unpack 'adjust-test-suite
                   (lambda _
                     (substitute* "test/CMakeLists.txt"
                       ;; This tests hangs forever.
                       ((".*test_task_group.*") ""))))))
              (else '())))))
    (home-page "https://uxlfoundation.github.io/oneTBB/")
    (synopsis "C++ library for parallel programming")
    (description
     "@acronym{OneTBB, OneAPI Threading Building Blocks} is a C++ runtime
library that abstracts the low-level threading details necessary for optimal
multi-core performance.  It uses common C++ templates and coding style to
eliminate tedious threading implementation work.  It provides parallel loop
constructs, asynchronous tasks, synchronization primitives, atomic operations,
and more.")
    (license license:asl2.0)))

(define-public python-onetbb
  (package
    (inherit onetbb)
    (name "python-onetbb")
    (arguments
     (list
      #:configure-flags
      #~(list "-DTBB4PY_BUILD=ON")
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'patch-python-install-directory
            (lambda _
              (substitute* "python/setup.py"
                (("extra_link_args=tbb_flag,")
                 (string-append
                  "extra_link_args=['-Wl,-rpath="
                  #$(this-package-input "onetbb") "/lib"
                  "', '-Wl,-rpath=" #$output "/lib'] + tbb_flag,")))))
          (replace 'build
            (lambda _
              (setenv "PYTHONHASHSEED" "0")
              (invoke "make" "python_build")))
          ;; The 'build phase already installs the modules
          (replace 'install
            (lambda _
              (with-directory-excursion "python/rml"
                (invoke "make" "install"))))
          (replace 'check
            (lambda* (#:key tests? #:allow-other-keys)
              (when tests?
                (invoke "ctest" "-R" "python_test" "--output-on-failure")))))))
    (native-inputs (list swig python-minimal))
    (inputs (list onetbb))
    (synopsis "Python bindings for the oneTBB parallel library")
    (description
     "@acronym{OneTBB, OneAPI Threading Building Blocks} is a C++ runtime
library that abstracts the low-level threading details necessary for optimal
multi-core performance.  It uses common C++ templates and coding style to
eliminate tedious threading implementation work.  It provides parallel loop
constructs, asynchronous tasks, synchronization primitives, atomic operations,
and more.  @code{python-onetbb} enables threading composability between two or
more thread-enabled Python libraries.")))

(define-public umf
  (package
    (name "umf")
    (version "1.0.3")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/oneapi-src/unified-memory-framework/")
              (commit (string-append "v" version))))
       (sha256
        (base32
         "16svxs1damgv29fcksw7538lyvrfa33b5ziwn7sjf85d2z091flg"))))
    (build-system cmake-build-system)
    (arguments
     (list
      #:tests? #f                    ;errors with "function not implemented"
      #:configure-flags
      #~(list "-DUMF_BUILD_CUDA_PROVIDER=OFF"
              "-DUMF_BUILD_EXAMPLES=OFF")
      #:phases
      #~(modify-phases %standard-phases
          (add-before 'check 'set-ld-library-path
            (lambda _
              (for-each
               (lambda (f)
                 (delete-file (format #f "test/~a" f)))
               '("test_memspace_highest_capacity"
                 "test_memtarget"))
              (setenv "LD_LIBRARY_PATH"
                      (string-append #$(this-package-input "onetbb")
                                     "/lib"))))
          (add-after 'unpack 'fix-googletest
            (lambda _
              (substitute* "test/CMakeLists.txt"
                (("FetchContent_MakeAvailable\\(googletest\\)")
                 "find_package(GTest REQUIRED)")))))))
    (inputs
     (list `(,hwloc "lib") level-zero numactl onetbb))
    (native-inputs
     (list pkg-config python-minimal-wrapper googletest))
    (home-page "https://oneapi-src.github.io/unified-memory-framework/")
    (synopsis "OneAPI @acronym{UMG, Unified Memory Framework}")
    (description
     "The UMF is a library for constructing allocators and memory pools. It
also contains broadly useful abstractions and utilities for memory
management.  UMF allows users to manage multiple memory pools characterized by
different attributes, allowing certain allocation types to be isolated from
others and allocated using different hardware resources as required..")
    (license license:asl2.0)))