forked from quil-lang/quilc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl-quil.asd
193 lines (184 loc) · 8.44 KB
/
cl-quil.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
;;;; cl-quil.asd
;;;;
;;;; Author: Robert Smith
(asdf:defsystem #:cl-quil
:description "A parser and optimizing compiler for the Quantum Instruction Language (Quil)."
:author "Robert Smith <[email protected]>, Eric Peterson <[email protected]>, Rigetti Computing"
:license "Apache License 2.0 (See LICENSE.txt)"
:version (:read-file-form "VERSION.txt")
:pathname "src/"
:depends-on ((:version #:alexa "2.1.1")
; Lexical analysis
#:yacc ; Arithmetic parsing
#:alexandria ; Utilities
#:parse-float ; Float parsing
(:version #:magicl "0.6.2")
; internal linear algebra library
#:cl-grnm ; nelder-mead implementation
#:singleton-classes
#:abstract-classes
#:yason ; JSON generation
#:uiop
#:split-sequence
#:closer-mop
#:optima
#:cl-algebraic-data-type
#:global-vars ; Static globals
#:salza2 ; God table compression
#:trivial-garbage ; weak hash tables
#:cl-heap
#:cl-permutation
#:queues.priority-queue
#+sbcl #:sb-rotate-byte
)
:in-order-to ((asdf:test-op (asdf:test-op #:cl-quil-tests)))
:around-compile (lambda (compile)
(let (#+sbcl(sb-ext:*derive-function-types* t))
(funcall compile)))
:serial t
:components ((:module "quil"
:serial t
:components ((:static-file "stdgates.quil")))
(:file "package")
(:file "options")
(:file "types")
(:file "utilities")
(:file "relabeling")
(:file "matrix-operations")
(:file "transformable-mixin")
(:file "classical-memory")
(:file "ast")
(:file "resource")
(:file "define-pragma")
(:file "pragmas")
(:file "parser")
(:file "gates")
(:file "environment")
(:file "context")
(:file "build-gate")
(:file "define-compiler")
(:module "clifford"
:serial t
:components ((:file "qubit-algebra")
(:file "pauli")
(:file "symplectic")
(:file "clifford")
(:file "stabilizer")
(:file "god-table")
(:file "god-table-utilities")
(:file "swap-representation")
(:file "benchmarking-procedures")))
(:module "compilers"
:serial t
:components ((:file "ucr-explode")
(:file "euler-compile")
(:file "qs-compile")
(:file "ucr-recognize")
(:file "approx")
(:file "state-prep")
(:file "translators")
(:file "optimal-2q")
;; attic'd file / pedagogical purposes only
(:static-file "cs-compile")))
(:module "analysis"
:serial t
:components ((:file "process-includes")
(:file "type-safety")
(:file "patch-labels")
(:file "resolve-applications")
(:file "qubits-needed")
(:file "compress-qubits")
(:file "expand-circuits")
(:file "rewrite-arithmetic")
(:file "fusion")))
(:file "cfg")
(:file "compilation-methods")
(:file "chip-specification")
(:file "chip-reader")
(:module "addresser"
:serial t
:components ((:file "rewiring")
(:file "initial-rewiring")
(:file "logical-schedule")
(:file "outgoing-schedule")
(:file "cost-function")
(:file "astar-rewiring-search")
(:file "path-heuristic")
(:file "temporal-addresser")))
(:module "compressor"
:serial t
:components ((:file "compressor-configuration")
(:file "compressor")
(:file "wavefunctions")
(:file "rewriting-rules")))
(:file "cl-quil")))
;;; Contribs
;; Adapted from magicl's magicl-transcendental adapted from commonqt's
;; qt.asd.
;; NOTE: The following contrib requires a C++17 compiler, and is untested on
;; Windows
(defclass c->so (asdf:source-file)
())
(defmethod output-files ((operation compile-op) (component c->so))
(values (list (make-pathname :name "libtweedledum"
:type #-darwin "so" #+darwin "dylib"
:defaults (component-pathname component)))
t))
(defmethod perform ((operation load-op) (component c->so))
t)
(defmethod perform ((operation compile-op) (component c->so))
(labels ((nn (x) (uiop:native-namestring x))
(compile-it (c++17 c++17-args)
(uiop:run-program
;; TODO This needs to be platform agnostic. The difficulty is
;; in picking up a c++17 compiler automatically.
(cons c++17 c++17-args)
:error-output t)))
(let* ((c-file (component-pathname component))
(cwd (namestring (make-pathname :directory (pathname-directory c-file))))
(tweedlelibdir (merge-pathnames "tweedledum/" cwd))
(shared-object (make-pathname :type #+darwin "dylib" #-darwin "so"
:name "libtweedledum"
:defaults c-file)))
(unless (uiop:directory-exists-p tweedlelibdir)
(error "tweedledum library directory missing. Did you run ~
`git submodule init && git submodule update --init`?"))
(let ((c++17 (or (uiop:getenv "CXX")
"g++"))
(c++17-args (list "-std=c++17"
"-shared"
"-fPIC"
"-DFMT_HEADER_ONLY"
(format nil "-I~a" (merge-pathnames "libs/fmt" tweedlelibdir))
(format nil "-I~a" (merge-pathnames "libs/easy" tweedlelibdir))
(format nil "-I~a" (merge-pathnames "libs/glucose" tweedlelibdir))
(format nil "-I~a" (merge-pathnames "libs/kitty" tweedlelibdir))
(format nil "-I~a" (merge-pathnames "include" tweedlelibdir))
"-o" (nn shared-object)
(nn c-file))))
(restart-case
(compile-it c++17 c++17-args)
(restart-with-c++17-path-input (c++17)
:report "Enter path to C++17 compiler and restart"
:interactive (lambda ()
(format *query-io* "Enter path to C++17 compiler and restart: ")
(force-output *query-io*)
(list (read-line)))
(compile-it c++17 c++17-args)))))))
(asdf:defsystem #:cl-quil/tweedledum
:license "Apache License 2.0 (See LICENSE.txt)"
:maintainer "Rigetti Computing"
:author "Rigetti Computing"
:description "C++17 Library for writing, manipulating, and optimizing quantum circuits"
:depends-on (#:cffi #:cl-quil)
:in-order-to ((asdf:test-op (asdf:test-op #:cl-quil/tweedledum-tests)))
:pathname "src/contrib/tweedledum/"
:serial t
:components
((c->so "tweedledum.c")
(:file "tweedledum")))
(asdf:defsystem #:cl-quil/tweedledum-tests
:depends-on (#:cl-quil-tests #:cl-quil/tweedledum)
:perform (asdf:test-op (o s)
(uiop:symbol-call ':cl-quil.tweedledum
'#:run-tweedledum-tests)))