From: rlaakso Date: Tue, 9 Aug 2005 17:18:15 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://repo.or.cz/w/sb-simd.git/commitdiff_plain/be51dd71f74fcf71e7307719de0bb7b48ab6df74 *** empty log message *** --- diff --git a/detect-simd.lisp b/detect-simd.lisp new file mode 100644 index 0000000..cb4bd58 --- /dev/null +++ b/detect-simd.lisp @@ -0,0 +1,67 @@ +#| +Copyright (c) 2005 Risto Laakso +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +|# +(in-package :sb-vm) + +;; simpler version + +(define-vop (%detect-simd/x86) + (:policy :fast) + + (:results (res :scs (descriptor-reg))) + + (:temporary (:sc unsigned-reg :offset eax-offset :from (:argument 0)) eax) + (:temporary (:sc unsigned-reg :offset ebx-offset) ebx) + (:temporary (:sc unsigned-reg :offset ecx-offset) ecx) + (:temporary (:sc unsigned-reg :offset edx-offset) edx) + + (:generator 10 + (inst mov eax 1) + (inst cpuid) + (inst mov ebx edx) + + ;; sse3 + (inst and ecx 1) + (inst shl ecx 2) + + ;; sse2/3 + (inst shr edx 25) + (inst and edx #b11) + (inst or edx ecx) + + ;; fixnumize + (inst shl edx 2) + + (inst mov res edx))) + + +(eval-when (:load-toplevel) + (let ((res (sb-sys:%primitive sb-vm::%detect-simd/x86))) +;; (format t "res is ~A~%" res) + (if (/= (logand res #b001) 0) (pushnew :sse sb-vm::*backend-subfeatures*)) + (if (/= (logand res #b010) 0) (pushnew :sse2 sb-vm::*backend-subfeatures*)) + (if (/= (logand res #b100) 0) (pushnew :sse3 sb-vm::*backend-subfeatures*)))) + \ No newline at end of file diff --git a/load.lisp b/load.lisp index 56dd962..d17b614 100644 --- a/load.lisp +++ b/load.lisp @@ -4,11 +4,16 @@ (load (compile-file "example-test.lisp")) )) -(if t +(if nil (progn (load (compile-file "sse-matrix.lisp")) (load (compile-file "timing.lisp")) (load (compile-file "test-matrix.lisp")) )) +(if t + (progn + (load (compile-file "detect-simd.lisp")) + (load (compile-file "push-simd-features.lisp")) + )) \ No newline at end of file diff --git a/sb-simd.asd b/sb-simd.asd new file mode 100644 index 0000000..3707c3d --- /dev/null +++ b/sb-simd.asd @@ -0,0 +1,16 @@ +;;; -*- Lisp -*- + +(in-package #:asdf) + +(defsystem sb-simd + :version "cvs" + :components ((:file "detect-simd") + (:file "sse-vops" :depends-on ("detect-simd")) + (:file "sse-matrix" :depends-on ("sse-vops"))) + ) + +(defmethod perform :after ((o load-op (c (eql (find-system :sb-simd))))) + (provide 'sb-simd)) + + +