Raymond Toy pushed to branch rtoy-xoro at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/rand-xoroshiro.lisp
    ... ... @@ -142,13 +142,12 @@
    142 142
     	   (let ((s (xoro-random-state-state rng-state)))
    
    143 143
     	     (declare (type (simple-array double-float (2)) s))
    
    144 144
     	     (multiple-value-bind (r1 r0)
    
    145
    -		 (vm::xoroshiro-next s)
    
    145
    +		 (xoroshiro-next-portable s)
    
    146 146
     	       (setf (xoro-random-state-rand rng-state) r0)
    
    147 147
     	       (setf (xoro-random-state-cached-p rng-state) t)
    
    148 148
     	       r1))))))
    
    149 149
     
    
    150
    -#-x86
    
    151
    -(defun xoroshiro-next (state)
    
    150
    +(defun xoroshiro-next-portable (state)
    
    152 151
       (declare (type (simple-array double-float (2)) state))
    
    153 152
       (flet ((rotl-55 (x1 x0)
    
    154 153
     	   (declare (type (unsigned-byte 32) x0 x1)
    
    ... ... @@ -192,10 +191,8 @@
    192 191
         (let ((s0-1 0)
    
    193 192
     	  (s0-0 0)
    
    194 193
     	  (s1-1 0)
    
    195
    -	  (s1-0 0)
    
    196
    -	  (r1 0)
    
    197
    -	  (r0 0))
    
    198
    -      (declare (type (unsigned-byte 32)) s0-1 s0-0 s1-1 s1-0 r1 r0)
    
    194
    +	  (s1-0 0))
    
    195
    +      (declare (type (unsigned-byte 32) s0-1 s0-0 s1-1 s1-0))
    
    199 196
           (multiple-value-bind (x1 x0)
    
    200 197
     	  (kernel:double-float-bits (aref state 0))
    
    201 198
     	(setf s0-1 (ldb (byte 32 0) x1)
    
    ... ... @@ -210,27 +207,23 @@
    210 207
     	      (bignum::%add-with-carry s0-0 s1-0 0)
    
    211 208
     	    (values (bignum::%add-with-carry s0-1 s1-1 c)
    
    212 209
     		    sum-0))
    
    213
    -      ;; s1 ^= s0
    
    214
    -      (setf s1-1 (logxor s1-1 s0-1)
    
    215
    -	    s1-0 (logxor s1-0 s0-0))
    
    216
    -      ;; s[0] = rotl(s0,55) ^ s1 ^ (s1 << 14)
    
    217
    -      (multiple-value-setq (s0-1 s0-0)
    
    218
    -	(rotl-55 s0-1 s0-0))
    
    219
    -      (setf s0-1 (logxor s0-1 s1-1)
    
    220
    -	    s0-0 (logxor s0-0 s1-0))
    
    221
    -      (multiple-value-bind (s14-1 s14-0)
    
    222
    -	  (shl-14 s1-1 s1-0)
    
    223
    -	(setf s0-1 (logxor s0-1 s14-1)
    
    224
    -	      s0-0 (logxor s0-0 s14-0)))
    
    225
    -      (setf (aref s 0) s0-0)
    
    226
    -      (setf (aref s 1) s0-1)
    
    210
    +	;; s1 ^= s0
    
    211
    +	(setf s1-1 (logxor s1-1 s0-1)
    
    212
    +	      s1-0 (logxor s1-0 s0-0))
    
    213
    +	;; s[0] = rotl(s0,55) ^ s1 ^ (s1 << 14)
    
    214
    +	(multiple-value-setq (s0-1 s0-0)
    
    215
    +	  (rotl-55 s0-1 s0-0))
    
    216
    +	(setf s0-1 (logxor s0-1 s1-1)
    
    217
    +	      s0-0 (logxor s0-0 s1-0))
    
    218
    +	(multiple-value-bind (s14-1 s14-0)
    
    219
    +	    (shl-14 s1-1 s1-0)
    
    220
    +	  (setf s0-1 (logxor s0-1 s14-1)
    
    221
    +		s0-0 (logxor s0-0 s14-0)))
    
    227 222
     
    
    228
    -      (multiple-value-bind (r1 r0)
    
    229
    -	  (rotl-36 s1-1 s1-0)
    
    230
    -	(setf (aref s 2) r0
    
    231
    -	      (aref s 3) r1))
    
    232
    -      (setf (aref state 0) (make-double s0-1 s0-0)
    
    233
    -	    (aref state 1) (make-double s1-1 s1-0))))))
    
    223
    +	(multiple-value-bind (r1 r0)
    
    224
    +	    (rotl-36 s1-1 s1-0)
    
    225
    +	  (setf (aref state 0) (make-double s0-1 s0-0)
    
    226
    +		(aref state 1) (make-double r1 r0)))))))
    
    234 227
     
    
    235 228
     ;;; %RANDOM-SINGLE-FLOAT, %RANDOM-DOUBLE-FLOAT  --  Interface
    
    236 229
     ;;;