-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathmagicl.asd
executable file
·211 lines (193 loc) · 6.96 KB
/
magicl.asd
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
;;;; magicl.asd
;;;;
;;;; Author: Robert Smith
;;; XXX: For now, load all extensions when loading MAGICL so as to not
;;; break users' code. In the future, however, we may make MAGICL a
;;; synonym for MAGICL/CORE.
(asdf:defsystem #:magicl
:license "BSD 3-Clause (See LICENSE.txt)"
:description "Matrix Algebra proGrams In Common Lisp"
:maintainer "Rigetti Computing"
:author "Rigetti Computing"
:version (:read-file-form "VERSION.txt")
:in-order-to ((asdf:test-op (asdf:test-op #:magicl-tests)))
:depends-on (#:magicl/core
#:magicl/ext
#:magicl/ext-blas
#:magicl/ext-lapack))
(asdf:defsystem #:magicl/core
:license "BSD 3-Clause (See LICENSE.txt)"
:description "Matrix Algebra proGrams In Common Lisp (pure Lisp core)"
:maintainer "Rigetti Computing"
:author "Rigetti Computing"
:version (:read-file-form "VERSION.txt")
:depends-on (#:alexandria
#:policy-cond
#:interface ; for CALLING-FORM
#:static-vectors
#:trivial-garbage
)
:around-compile (lambda (compile)
(let (#+sbcl (sb-ext:*derive-function-types* t))
(funcall compile)))
:pathname "src/"
:serial t
:components
((:file "packages")
(:file "backend-function")
(:file "benchmark-utilities")
(:module "high-level"
:serial t
:components ((:file "util")
(:file "allocation")
(:file "allocation-allegro" :if-feature :allegro)
(:file "shape")
(:file "abstract-tensor")
(:file "specialize-tensor")
(:file "tensor")
(:file "vector")
(:file "matrix")
(:file "types/single-float")
(:file "types/double-float")
(:file "types/complex-single-float")
(:file "types/complex-double-float")
(:file "types/int32")
(:file "types/specialized-vector")
(:file "constructors")
(:file "specialize-constructor")
(:file "polynomial-solver")
(:module "matrix-functions"
:serial t
:components ((:file "row-column-matrices")
(:file "mult-definition")
(:file "mult-methods")
(:file "givens")
(:file "householder")
(:file "qr")
(:file "lu")
(:file "tridiagonal-form")
(:file "hermitian-eig")
(:file "svd")
(:file "random-hermitian")
(:file "csd")))))
(:file "magicl")))
;;; Extension common code
(asdf:defsystem #:magicl/ext
:description "Common code for extending MAGICL with foreign libraries."
:depends-on (#:magicl/core
#:cffi
#:cffi-libffi)
:serial t
:pathname "src/extensions/common"
:components
((:file "package")
(:file "library-tracking")
(:file "with-array-pointers")
(:file "cffi-types")
(:file "ptr-ref")))
;;; BLAS
(asdf:defsystem #:magicl/ext-blas
:description "Native BLAS routines in MAGICL."
:depends-on (#:magicl/core
#:magicl/ext
#:cffi)
:serial t
:pathname "src/"
:components
((:file "extensions/blas/package")
(:file "extensions/blas/load-libs")
(:module "bindings/allegro" :if-feature :allegro
:components #1=((:file "blas-cffi")))
(:module "bindings" :if-feature (:not :allegro)
:components #1#)
(:file "extensions/blas/arithmetic")))
;;; LAPACK
(asdf:defsystem #:magicl/ext-lapack
:description "Native LAPACK routines in MAGICL."
:depends-on (#:magicl/core
#:magicl/ext
#:magicl/ext-blas
#:cffi
#:policy-cond)
:serial t
:pathname "src/"
:components
((:file "extensions/lapack/package")
(:file "extensions/lapack/load-libs")
(:module "bindings/allegro" :if-feature :allegro
:components ((:file "lapack00-cffi")
(:file "lapack02-cffi")
(:file "lapack03-cffi")
(:file "lapack04-cffi")
(:file "lapack05-cffi")
(:file "lapack06-cffi")
(:file "lapack07-cffi")))
(:module "bindings" :if-feature (:not :allegro)
:components ((:file "lapack-cffi")))
(:module "extensions/lapack"
:components ((:file "lapack-generics")
(:file "lapack-templates")
(:file "lapack-bindings")
(:file "lapack-schur")
(:file "lapack-qz")
(:file "lapack-csd")))))
;;; EXPOKIT
;;; Adapted from commonqt's qt.asd
(defclass f->so (asdf:source-file)
()
(:default-initargs
:type "f"))
(defun dynamic-library-extension ()
"Return the dynamic library extension on the current OS as a string."
(cond
((uiop:os-windows-p) "dll")
((uiop:os-macosx-p) "dylib")
((uiop:os-unix-p) "so")
(t (error "unsupported OS"))))
(defmethod output-files ((operation compile-op) (component f->so))
(values (list (apply-output-translations
(make-pathname :name "libexpokit"
:type (dynamic-library-extension)
:defaults (component-pathname component))))
t))
(defmethod perform ((operation load-op) (component f->so))
t)
(defmethod perform ((operation compile-op) (component f->so))
(flet ((nn (x) (uiop:native-namestring x)))
(let* ((fortran-file (component-pathname component))
(object-file (apply-output-translations
(make-pathname :type "o" :defaults fortran-file)))
(shared-object (first (output-files operation component))))
(ensure-directories-exist shared-object)
(uiop:run-program
(list "gfortran" "-fPIC" "-std=legacy"
"-c"
(nn fortran-file)
"-o"
(nn object-file)))
(uiop:run-program
(list "gfortran" #+darwin "-dynamiclib" #-darwin "-shared"
"-o" (nn shared-object)
(nn object-file)
#+darwin "-lblas"
#+darwin "-llapack"))
(delete-file object-file))))
(asdf:defsystem #:magicl/ext-expokit
:description "Expokit for MAGICL."
:depends-on (#:alexandria
#:cffi
#:cffi-libffi
#:magicl/core
#:magicl/ext
#:magicl/ext-blas
#:magicl/ext-lapack)
:serial t
:components
((:module "expokit"
:components ((f->so "expokit")))
(:module "src/extensions/expokit"
:components ((:file "package")
(:file "load-libs")))
(:file #+allegro "src/bindings/allegro/expokit-cffi"
#-allegro "src/bindings/expokit-cffi")
(:file "src/extensions/expokit/expm")))