From: Akshay S. <ak...@us...> - 2012-08-03 07:07:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "matlisp". The branch, tensor has been updated via f27e7165a4d1127a21c7cdb9148b986d92b401d7 (commit) via 381148cb7fe30e07d45ce8a49d87be081ba795ab (commit) from b9bf26aaa85df12dec80c1c5b822d8821ed6e9df (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f27e7165a4d1127a21c7cdb9148b986d92b401d7 Author: Akshay Srinivasan <aks...@gm...> Date: Fri Aug 3 12:31:59 2012 +0530 o Added file tweakable.lisp to the repo. This file contains the fortran call lower bounds for every BLAS level. diff --git a/src/base/tweakable.lisp b/src/base/tweakable.lisp new file mode 100644 index 0000000..a8cc8cf --- /dev/null +++ b/src/base/tweakable.lisp @@ -0,0 +1,47 @@ +(in-package #:matlisp) + +;;Level 1--------------------------------------------------------;; +(defparameter *real-l1-fcall-lb* 20000 + "If the size of the array is less than this parameter, the + lisp version of axpy is called in order to avoid FFI overheads") + +(defparameter *complex-l1-fcall-lb* 10000 + "If the size of the array is less than this parameter, the + lisp version of axpy is called in order to avoid FFI overheads") + +;;Level 2--------------------------------------------------------;; +(defparameter *real-l2-fcall-lb* 1000 + " + If the maximum dimension in the MV is lower than this + parameter, then the lisp code is used by default, instead of + calling BLAS. Used to avoid the FFI overhead when calling + MM with small matrices. + Default set with SBCL on x86-64 linux. A reasonable value + is something between 800 and 2000.") + +(defparameter *complex-l2-fcall-lb* 600 + " + If the maximum dimension in the MV is lower than this + parameter, then the lisp code is used by default, instead of + calling BLAS. Used to avoid the FFI overhead when calling + MM with small matrices. + Default set with SBCL on x86-64 linux. A reasonable value + is something between 400 and 1000.") +;;Level 3--------------------------------------------------------;; +(defparameter *real-l3-fcall-lb* 100 + " + If the maximum dimension in the MM is lower than this + parameter, then the lisp code is used by default, instead of + calling BLAS. Used to avoid the FFI overhead when calling + MM with small matrices. + Default set with SBCL on x86-64 linux. A reasonable value + is something between 20 and 200.") + +(defparameter *complex-l3-fcall-lb* 60 + " + If the maximum dimension in the MM is lower than this + parameter, then the lisp code is used by default, instead of + calling BLAS. Used to avoid the FFI overhead when calling + MM with small matrices. + Default set with SBCL on x86-64 linux. A reasonable value + is something between 20 and 200.") commit 381148cb7fe30e07d45ce8a49d87be081ba795ab Author: Akshay Srinivasan <aks...@gm...> Date: Fri Aug 3 10:20:24 2012 +0530 o Changed from defparameter to defvar to create hash-tables in standard-tensor.lisp o Tweaks to :before copy! methods diff --git a/packages.lisp b/packages.lisp index 2d65f54..1693289 100644 --- a/packages.lisp +++ b/packages.lisp @@ -79,7 +79,7 @@ #:lvec->list #:lvec->list! ;;Macros #:when-let #:if-let #:if-ret #:with-gensyms #:let-rec - #:mlet* #:make-array-allocator #:let-typed + #:mlet* #:make-array-allocator #:let-typed #:let*-typed #:nconsc #:define-constant #:macrofy #:looped-mapcar #:defun-compiler-macro ;; diff --git a/src/base/generic-copy.lisp b/src/base/generic-copy.lisp index d560d93..71431fa 100644 --- a/src/base/generic-copy.lisp +++ b/src/base/generic-copy.lisp @@ -27,11 +27,7 @@ (= (array-rank x) (array-rank y)) (reduce #'(lambda (x y) (and x y)) (mapcar #'= (array-dimensions x) (array-dimensions y)))) - nil 'dimension-mismatch)) - (:method :before (x (y array)) - (assert (subtypep (type-of x) (array-element-type y)) - nil 'invalid-type - :given (type-of x) :expected (array-element-type x)))) + nil 'dimension-mismatch))) (defmethod copy! ((from cons) (to cons)) (let-rec cdr-writer ((flst from) (tlst to)) @@ -40,7 +36,7 @@ (rplaca tlst (car flst)) (cdr-writer (cdr flst) (cdr tlst)))))) -(defmethod copy! ((from t) (to cons)) +(defmethod copy! (from (to cons)) (mapl #'(lambda (lst) (rplaca lst from)) to) to) @@ -52,6 +48,14 @@ (setf (apply #'aref to lst) (apply #'aref from lst))))) to) +(defmethod copy! (from (to array)) + (let ((lst (make-list (array-rank to)))) + (mod-dotimes (idx (make-index-store (array-dimensions to))) + do (progn + (lvec->list! idx lst) + (setf (apply #'aref to lst) from))) + to)) + ;; (defgeneric copy (object) (:documentation diff --git a/src/base/standard-tensor.lisp b/src/base/standard-tensor.lisp index a1898e7..9899186 100644 --- a/src/base/standard-tensor.lisp +++ b/src/base/standard-tensor.lisp @@ -31,7 +31,7 @@ :initial-contents contents)) (definline idxv (&rest contents) - (apply #'make-index-store contents)) + (make-index-store contents)) ;; (defclass standard-tensor () @@ -123,7 +123,7 @@ (error 'tensor-not-vector :rank (rank old)))) ;; -(defparameter *tensor-counterclass* (make-hash-table) +(defvar *tensor-counterclass* (make-hash-table) " Contains the CLOS counterpart classes of every tensor class. This is used to change the tensor class automatically to a matrix @@ -146,7 +146,7 @@ :vector standard-vector)) ;; -(defparameter *tensor-class-optimizations* (make-hash-table) +(defvar *tensor-class-optimizations* (make-hash-table) " Contains a either: o A property list containing: diff --git a/src/level-1/copy.lisp b/src/level-1/copy.lisp index 1afffce..a981a66 100644 --- a/src/level-1/copy.lisp +++ b/src/level-1/copy.lisp @@ -182,8 +182,8 @@ :expected (array-element-type y)) (assert (and (= (rank x) (array-rank y)) - (reduce #'(lambda (x y) (and x y)) - (mapcar #'= (lvec->list (dimensions x)) (array-dimensions y)))) + (dolist (ele (mapcar #'= (lvec->list (dimensions x)) (array-dimensions y)) t) + (unless ele (return nil)))) nil 'dimension-mismatch)) (defmethod copy! ((x real-tensor) (y array)) @@ -216,8 +216,8 @@ :given (array-element-type x) :expected (element-type y)) (assert (and (= (array-rank x) (rank y)) - (reduce #'(lambda (x y) (= x y)) - (mapcar #'= (array-dimensions x) (lvec->list (dimensions y))))) + (dolist (ele (mapcar #'= (array-dimensions x) (lvec->list (dimensions y))) t) + (unless ele (return nil)))) nil 'dimension-mismatch)) (defmethod copy! ((x array) (y real-tensor)) diff --git a/src/level-1/tensor-maker.lisp b/src/level-1/tensor-maker.lisp index 3933496..541d1d2 100644 --- a/src/level-1/tensor-maker.lisp +++ b/src/level-1/tensor-maker.lisp @@ -8,10 +8,10 @@ `(defun ,func-name (&rest args) (labels ((make-dims (dims) (declare (type cons dims)) - (let* ((vdim (make-index-store dims)) - (ss (reduce #'* vdim)) - (store (,(getf opt :store-allocator) ss)) - (rnk (length vdim))) + (let*-typed ((vdim (make-index-store dims) :type index-store-vector) + (ss (very-quickly (lvec-foldl #'(lambda (x y) (the index-type (* x y))) vdim))) + (store (,(getf opt :store-allocator) ss)) + (rnk (length vdim))) (make-instance (case rnk (2 ',(getf cocl :matrix)) (1 ',(getf cocl :vector)) (t ',tensor-class)) :store store :dimensions vdim))) (make-from-array (arr) @@ -21,22 +21,20 @@ (lst (make-list (rank ret)))) (declare (type ,tensor-class ret) (type ,(linear-array-type (getf opt :store-type)) st-r)) - (very-quickly - (mod-dotimes (idx (dimensions ret)) - with (linear-sums - (of-r (strides ret) (head ret))) - do ,(funcall (getf opt :value-writer) `(,(getf opt :coercer) (apply #'aref arr (lvec->list! idx lst))) 'st-r 'of-r))) + (mod-dotimes (idx (dimensions ret)) + with (linear-sums + (of-r (strides ret) (head ret))) + do ,(funcall (getf opt :value-writer) `(,(getf opt :coercer) (apply #'aref arr (lvec->list! idx lst))) 'st-r 'of-r)) ret)) (make-from-list (lst) (let* ((ret (make-dims (list-dimensions lst))) (st-r (store ret))) (declare (type ,tensor-class ret) (type ,(linear-array-type (getf opt :store-type)) st-r)) - (very-quickly - (list-loop (idx ele lst) - with (linear-sums - (of-r (strides ret) (head ret))) - do ,(funcall (getf opt :value-writer) `(,(getf opt :coercer) ele) 'st-r 'of-r))) + (list-loop (idx ele lst) + with (linear-sums + (of-r (strides ret) (head ret))) + do ,(funcall (getf opt :value-writer) `(,(getf opt :coercer) ele) 'st-r 'of-r)) ret))) (let ((largs (length args))) (if (= largs 1) @@ -55,4 +53,3 @@ ;;Had to move it here in the wait for copy! (definline sub-tensor (tensor subscripts) (copy (sub-tensor~ tensor subscripts))) - ----------------------------------------------------------------------- Summary of changes: packages.lisp | 2 +- src/base/generic-copy.lisp | 16 ++++++++----- src/base/standard-tensor.lisp | 6 ++-- src/base/tweakable.lisp | 47 +++++++++++++++++++++++++++++++++++++++++ src/level-1/copy.lisp | 8 +++--- src/level-1/tensor-maker.lisp | 27 ++++++++++------------- 6 files changed, 77 insertions(+), 29 deletions(-) create mode 100644 src/base/tweakable.lisp hooks/post-receive -- matlisp |