takagi / cl-cuda

Cl-cuda is a library to use NVIDIA CUDA in Common Lisp programs.
MIT License
280 stars 24 forks source link

Bit shifting operators #85

Open Disclosure opened 7 years ago

Disclosure commented 7 years ago

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.

takagi commented 7 years ago

Thanks for reporting. I will check it.

guicho271828 commented 7 years ago

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

takagi commented 7 years ago

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