|
75 | 75 | '(:fully-connected :linear))
|
76 | 76 |
|
77 | 77 | (defun build-benchmark-chip (nq type)
|
78 |
| - (ecase type |
79 |
| - (:fully-connected |
80 |
| - (cl-quil::build-nq-fully-connected-chip nq)) |
81 |
| - (:linear |
82 |
| - (cl-quil::build-nq-linear-chip nq)))) |
| 78 | + (let ((chip-spec |
| 79 | + (ecase type |
| 80 | + (:fully-connected |
| 81 | + (cl-quil::build-nq-fully-connected-chip nq)) |
| 82 | + (:linear |
| 83 | + (cl-quil::build-nq-linear-chip nq))))) |
| 84 | + (prepare-chip-for-benchmarking chip-spec) |
| 85 | + chip-spec)) |
83 | 86 |
|
84 | 87 | (defun build-benchmark-program (nq type)
|
85 | 88 | (ecase type
|
|
173 | 176 |
|
174 | 177 |
|
175 | 178 |
|
| 179 | +(defun get-epsilon-program () |
| 180 | + "Get a 'null' or 'nop' program, i.e., the most minimal program that |
| 181 | + makes the compiler go through its paces, e.g., doing any warming or |
| 182 | + caching that may take considerable time and that would normally be |
| 183 | + avoided on subsequent runs. For now, the program is merely \"I 0\"." |
| 184 | + (quil:parse "I 0")) |
| 185 | + |
| 186 | +(defun prepare-chip-for-benchmarking (chip-spec) |
| 187 | + "Do normal preparations for chip benchmarking, namely, by doing a |
| 188 | + compilation on a minimal program, which presumably may result in |
| 189 | + 'warming up' and/or caching. The idea is to NOT have time for this |
| 190 | + dominate the results of the first program benchmarked." |
| 191 | + (do-one-quilc-perf-run (get-epsilon-program) chip-spec)) |
| 192 | + |
| 193 | +;; Consider moving the above function (or some variant) to cl-quil and |
| 194 | +;; then making it a standard or optional part of building a chip |
| 195 | +;; and/or at least calling it from places, e.g., from the app. |
| 196 | + |
| 197 | + |
176 | 198 | (defun benchmark-one-quilc-perf (nq program-type chip-type)
|
177 | 199 | (let* ((program (get-or-build-benchmark-program nq program-type))
|
178 | 200 | (chip (get-or-build-benchmark-chip nq chip-type)))
|
|
0 commit comments