Skip to content
Browse files

xecto-impl: initialize in parallel context

  • Loading branch information...
1 parent 24821cb commit 966198b7ceeacef2382731bdef049e54b01275b4 @pkhuong committed Dec 17, 2011
Showing with 56 additions and 10 deletions.
  1. +56 −10 xecto-impl.lisp
View
66 xecto-impl.lisp
@@ -84,11 +84,15 @@
(defun make-xecto (dimensions &key initial-element)
(multiple-value-bind (size shape)
(size-and-shape dimensions)
- (let ((xecto (%make-xecto shape (vector-future:make size '() #()))))
+ (let ((xecto (%make-xecto shape
+ (vector-future:make size
+ '()
+ (if initial-element
+ (vector (lambda (data)
+ (fill (vector-future:data data)
+ (float initial-element 1d0))))
+ #())))))
(set-finalizer xecto)
- (when initial-element
- (future:wait (xecto-data xecto) :done)
- (fill (vector-future:data (xecto-data xecto)) (float initial-element 1d0)))
xecto)))
(defun wait (xecto &rest condition)
@@ -104,11 +108,53 @@
(set-finalizer new)))
#||
-(defparameter *x* (make-xecto '(2048 2048) :initial-element 1))
-(defparameter *y* (transpose (make-xecto '(2048 2048) :initial-element 1) 0 1))
-
(gc :full t)
-(time (let ((x (map-xecto #'+ *x* *y*))
- (y (scan-xecto #'+ *y*)))
- (wait (reduce-xecto #'+ (map-xecto #'+ x y)) :done)))
+(setf *print-circle* t *print-length* 20)
+(defvar xx)
+(defvar yy)
+(sb-thread:join-thread
+ (sb-thread:make-thread
+ (lambda ()
+ (parallel-future:with-context (11)
+ (let ()
+ #+nil ((xx (make-xecto '(16384 16384) :initial-element 1))
+ (yy (transpose (make-xecto '(16384 16384) :initial-element 5) 0 1)))
+ (setf xx (make-xecto '(16384 16384) :initial-element 1)
+ yy (transpose (make-xecto '(16384 16384) :initial-element 5) 0 1))
+ (time (let ((x (map-xecto #'+ xx yy))
+ (y (scan-xecto #'+ xx)))
+ (wait (reduce-xecto #'+ (reduce-xecto #'+ (map-xecto #'+ x y)))
+ :done)))
+ (setf *print-length* 20 xx nil yy nil))
+ parallel-future:*context*))))
+
+Evaluation took:
+ 104.652 seconds of real time
+ 104.462529 seconds of total run time (101.230327 user, 3.232202 system)
+ [ Run times consist of 0.248 seconds GC time, and 104.215 seconds non-GC time. ]
+ 99.82% CPU
+
+Evaluation took:
+ 49.085 seconds of real time
+ 97.618102 seconds of total run time (94.157885 user, 3.460217 system)
+ [ Run times consist of 0.256 seconds GC time, and 97.363 seconds non-GC time. ]
+ 198.88% CPU
+
+Evaluation took:
+ 26.356 seconds of real time
+ 103.402463 seconds of total run time (100.010251 user, 3.392212 system)
+ [ Run times consist of 0.404 seconds GC time, and 102.999 seconds non-GC time. ]
+ 392.33% CPU
+
+Evaluation took:
+ 14.404 seconds of real time
+ 108.718794 seconds of total run time (105.314582 user, 3.404212 system)
+ [ Run times consist of 0.612 seconds GC time, and 108.107 seconds non-GC time. ]
+ 754.78% CPU
+
+Evaluation took:
+ 11.439 seconds of real time
+ 110.318895 seconds of total run time (106.422651 user, 3.896244 system)
+ [ Run times consist of 0.896 seconds GC time, and 109.423 seconds non-GC time. ]
+ 964.41% CPU
||#

0 comments on commit 966198b

Please sign in to comment.
Something went wrong with that request. Please try again.