cl-cuda icon indicating copy to clipboard operation
cl-cuda copied to clipboard

Bit shifting operators

Open Disclosure opened this issue 7 years ago • 3 comments

I am trying to apply a bit shifting shr operator in a do loop that I found in built-in.lisp (line 127) like so:

(defkernel reduce-array (void ((in float*) (out float*)))
  (let ((x thread-idx-x))
    (with-shared-memory ((acc float 64))
      (set (aref acc x) (aref in x))
      (syncthreads)
      (do ((j 32 (shr j 1)))
	  ((< j 1))
	(when (< x j)
	  (set (aref acc x) (+ (aref acc x)
			       (aref acc (+ x j)))))
	(syncthreads))
      (when (= x 0)
	(set (aref out 0) (aref acc 0)))))

However in a Ubuntu 16.04 sbcl I am getting a function undefined error:

The function SHR is undefined.
   [Condition of type SIMPLE-ERROR]

The symbol appears to be exported in the built-in.lisp file but it seems like it cannot be found for some reason, when one tries to list all autocomplete symbols in slime, the shr symbol does not appear to be there:

capture

The CL ASH function does not appear (expectedly) to work inside the kernel definition either, so how do I go about applying bit shifting in defkernel? Please excuse me if I am asking something entirely obvious, I am quite rusty on my Lisp skills after all these years.

Disclosure avatar Jan 22 '17 16:01 Disclosure

Thanks for reporting. I will check it.

takagi avatar Jan 23 '17 09:01 takagi

Not entirely unrelated, but when i tried AVM it complained that coerce was not found.

guicho271828 avatar Jan 23 '17 10:01 guicho271828

@guicho271828 Yes, it is reported in https://github.com/takagi/avm/issues/44 . I need to take care of it too.

takagi avatar Jan 23 '17 10:01 takagi