There are many occasions where a function can be optimized under certain assumptions about the system. But since most aspects of Common Lisp can be redefined almost arbitrarily, there are few assumptions that a compiler can generally make. (A notable exception is the behavior of definitions in the CL package, and of built-in objects.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cl:defpackage #:avx2 | |
(:use :cl) | |
(:export #:d4+ #:d4* #:d4ref #:d4set)) | |
(cl:in-package #:avx2) | |
(sb-c:defknown (d4+ d4*) ((sb-ext:simd-pack-256 double-float) | |
(sb-ext:simd-pack-256 double-float)) | |
(sb-ext:simd-pack-256 double-float) | |
(sb-c:movable sb-c:flushable sb-c:always-translatable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Benchmark results: | |
(SICL-SEQUENCE::FIND-AUX 1 SHORT-LIST NIL #'EQL NIL 0 NIL NIL) 77.93 nanoseconds | |
(FIND 1 SHORT-LIST) 46.56 nanoseconds | |
(SICL-SEQUENCE::FIND-AUX 1 LONG-LIST NIL #'EQL NIL 0 NIL NIL) 90.53 microseconds | |
(FIND 1 LONG-LIST) 29.86 microseconds | |
(SICL-SEQUENCE::FIND-AUX 1 SHORT-VECTOR NIL #'EQL NIL 0 NIL NIL) 6.55 microseconds | |
(FIND 1 SHORT-VECTOR) 42.00 nanoseconds | |
(SICL-SEQUENCE::FIND-AUX 1 LONG-VECTOR NIL #'EQL NIL 0 NIL NIL) 124.40 microseconds | |
(FIND 1 LONG-VECTOR) 91.50 microseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun simd-sum (array &aux (n (array-total-size array))) | |
"Compute the sum of the elements of the supplied simple double-float ARRAY." | |
(declare (type (simple-array double-float 1) array) | |
(optimize speed (safety 0))) | |
(do ((index 0 (the (integer 0 #.(- array-total-size-limit 16)) (+ index 16))) | |
(acc1 (make-f64.4 0 0 0 0) (f64.4+ acc1 (f64.4-row-major-aref array (+ index 0)))) | |
(acc2 (make-f64.4 0 0 0 0) (f64.4+ acc2 (f64.4-row-major-aref array (+ index 4)))) | |
(acc3 (make-f64.4 0 0 0 0) (f64.4+ acc3 (f64.4-row-major-aref array (+ index 8)))) | |
(acc4 (make-f64.4 0 0 0 0) (f64.4+ acc4 (f64.4-row-major-aref array (+ index 12))))) | |
((>= index (- n 16)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package #:cl-user) | |
(defpackage #:list-iterators | |
(:use #:cl)) | |
(in-package #:list-iterators) | |
(declaim (inline make-read-iterator)) | |
(defun make-read-iterator (list terminate) | |
(lambda () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(defmacro debug-defun (name lambda-list &body body) | |
(multiple-value-bind (forms decls doc) | |
(alexandria:parse-body body :documentation t) | |
`(progn | |
(declaim (notinline ,name)) | |
(defun ,name (.debug-flag. ,@lambda-list) | |
,@(when doc (list doc)) | |
,@decls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(lambda | |
(#:x-1 &key ((:y #:y-2) nil #:suppliedp-3) ((:z #:z-4) nil #:suppliedp-5)) | |
(declare (ignorable #:x-1 #:y-2 #:suppliedp-3 #:z-4 #:suppliedp-5)) | |
(let ((sealable-metaobjects::.gf. #'keyword-function)) | |
(declare (ignorable sealable-metaobjects::.gf.)) | |
(declare (sb-ext:disable-package-locks call-method)) | |
(declare (sb-ext:disable-package-locks make-method)) | |
(declare (sb-ext:disable-package-locks sb-pcl::check-applicable-keywords)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun quickload-all () | |
(loop for system in (ql:provided-systems t) do | |
(ignore-errors | |
(trivial-timeout:with-timeout (20) | |
(ql:quickload (ql-dist:short-description system)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun make-function-cell (value) | |
(check-type value function) | |
(values | |
(lambda () value) | |
(lambda (new-value) | |
(check-type new-value function) | |
(setf value new-value)))) | |
;; In order to make typed cells as fast as cons cells, | |
;; the compiler has to be able to inline the first value returned by |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Note: You should also put something like (ql:quickload :clouseau) in your initialization file. | |
(defun clouseau-inspect (string) | |
(interactive | |
(list (slime-read-from-minibuffer | |
"Inspect value (evaluated): " | |
(slime-sexp-at-point)))) | |
(let ((inspector 'cl-user::*clouseau-inspector*)) | |
(slime-eval-async | |
`(cl:progn |
OlderNewer