Although a CLJ->OpenCL translator has crossed my mind recently too,
here's something slightly different to what you're trying, but still
related... A few weeks ago I started a new Clojure wrapper around JOCL
(jogamp.org) to at least help to take out the hassle/tedium of setting
up, configuring and queuing CL resources and replace all that with a
more succinct, declarative solution based on the processing pipeline
idea. The example below defines a 3-pass pipeline (Strange attractor
-> 2d twirl effect -> 3d sphere map) with each step defining its
inputs, outputs, data transfers (sync & async) and kernel args. By
default a step's outputs are considered inputs for the next one,
however each step can also explicitly refer back to buffers of
previous steps, enabling memory sharing & iterative ping-pong
processing.

(with-state
  (init-state
    :program (resource-stream "kernels/attractor.cl"))
  (execute-pipeline
    (compile-pipeline
      :final-size (* 2 n block-size)
      :verbose true
      :release true
      :steps [{:name "Clifford2d"
               :in {:type :float :size (* 2 n) :usage :readonly :fill rand}
               :out {:type :float :size (* 2 n block-size)}
               :n n
               :write [:in]
               :args [[a :float] [b :float] [c :float] [d :float] [n
:int] [block-size :int]]}
              {:name "Twirl2d"
               :out {:type :float :size (* 2 n block-size) :usage :readwrite}
               :n (* n block-size)
               :args [[(* n block-size) :int] [-1.0 :float]]}
              {:name "SphereMap2d3d"
               :out {:type :float :size (* 3 n block-size) :usage :writeonly}
               :read [:out]
               :n (* n block-size)
               :args [[(* n block-size) :int]]}])))

The thing I like about this approach is that I can write small
pipeline step builder fns and get a nice, composable system. The next
thing to tackle is support for C struct wrapping in Clojure similar to
jogamp's gluegen/superglue projects... Will share more details/code
ASAP.

Best, K.

On 5 September 2012 22:09, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> OpenCL has some pretty major limitations that CUDA does not have. Namely, no
> support for function pointers, vtables (needed for OOP) or malloc on the
> device. These all make it quite hard to implement something as dynamic as a
> Java VM. The only RootBeer example I can see actually is more like a C
> program than Java. So when they say it can translate "many Java programs"
> does that include ones with dynamic memory freeing (requires a GC) and full
> polymorphism?
>
> Timothy
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to