Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix a few mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
ztellman committed Jun 21, 2010
1 parent 3833f46 commit a2fc757
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.textile
Expand Up @@ -6,7 +6,7 @@ The OpenCL API is not known for its terseness; consider this "'Hello World' exam

(def source
"__kernel void square (
__global const float *a
__global const float *a,
__global float *b) {
int gid = get_global_id(0);
b[gid] = a[gid] * a[gid];
Expand All @@ -15,7 +15,7 @@ The OpenCL API is not known for its terseness; consider this "'Hello World' exam
(with-cl
(with-program (compile-program source)
(let [a (wrap [1 2 3] :float)
b (create-buffer 3 :float)]
b (mimic a)]
(enqueue-kernel :square 3 a b)
(enqueue-read b))))
</code></pre>
Expand Down
3 changes: 2 additions & 1 deletion src/calx/core.clj
Expand Up @@ -282,8 +282,9 @@
(sequential? x) (into-array x)))

(defn enqueue-kernel
([kernel global-size block-size & args]
([kernel global-size & args]
(let [kernel ^CLKernel ((program) kernel)]
(doseq [[idx arg] (indexed (map get-cl-object args))]
(println idx arg)
(.setArg kernel idx arg))
(.enqueueNDRange kernel (queue) (to-dim-array global-size) *workgroup-size* (make-array CLEvent 0)))))
13 changes: 9 additions & 4 deletions src/calx/data.clj
Expand Up @@ -80,8 +80,8 @@
;;;

(defprotocol Data
(mimic [d] [d dim]
"Create a different buffer of the same type. 'dim' defaults to the buffer's dimensions.")
(mimic [d] [d dim usage]
"Create a different buffer of the same type. 'dim' and 'usage' default to those of the original buffer.")
(enqueue-read [d] [d range]
"Asynchronously copies a subset of the buffer into local memory. 'range' defaults to the full buffer.
Returns an object that, when dereferenced, halts execution until the copy is complete, then returns a seq.")
Expand All @@ -97,8 +97,13 @@
^{:cl-object cl-buf}
(reify
Data
(mimic [this] (mimic this dim))
(mimic [_ dim] (.createByteBuffer (context) (usage-types usage) (* dim element-bytes) false))
(mimic [this] (mimic this dim usage))
(mimic [_ dim usage]
(create-buffer-
(.createByteBuffer (context) (usage-types usage) (* dim element-bytes))
sig
dim
usage))
(signature [_] sig)
(dim [_] dim)
(enqueue-read [this] (enqueue-read this (interval 0 dim)))
Expand Down

0 comments on commit a2fc757

Please sign in to comment.