Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

update everything to be reasonably current before officially abandoni…

…ng it
  • Loading branch information...
commit 59deea0c708a6190f872711a1340ac36401e916b 1 parent 1a7494f
@ztellman authored
3  .gitignore
@@ -4,4 +4,5 @@ lib
6 README.textile
@@ -1,9 +1,11 @@
+*This project is not under active development.*
Calx is an idiomatic wrapper for OpenCL, which is an abstraction layer for parallel computation. Using a C-variant language, a programmer can target CPUs, GPUs, and more exotic hardware (the Cell processor used in the PS3, for instance).
The OpenCL API is not known for its terseness; consider this "'Hello World' example": example demonstrating the necessary steps to square a list of floating point numbers. Using Calx, the same result can be achieved like so:
<pre><code>(use 'calx)
(def source
"__kernel void square (
__global const float *a,
@@ -19,7 +21,7 @@ The OpenCL API is not known for its terseness; consider this "'Hello World' exam
(enqueue-kernel :square 3 a b)
(enqueue-read b))))
This is very much a work in progress, but still can be immediately useful for some purposes. Anyone using it is encouraged to give feedback.
The complete documentation can be found "here":
10 project.clj
@@ -1,7 +1,7 @@
-(defproject calx "0.2.1-SNAPSHOT"
+(defproject calx "0.2.1"
:description "An idiomatic wrapper for OpenCL."
:dependencies [[calx/javacl "1.0.4b"]
- [gloss "0.1.1-SNAPSHOT"]
- [org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]
- ])
+ [gloss "0.2.1"]
+ [potemkin "0.1.5"]
+ [org.clojure/clojure "1.4.0"]
+ ])
24 src/calx.clj
@@ -11,7 +11,7 @@
:doc "An idiomatic wrapper for OpenCL."}
- [clojure.contrib.def :only (defmacro- defvar-)])
+ [potemkin])
[core :as core]
@@ -22,14 +22,6 @@
-(defmacro- import-fn [sym]
- (let [m (meta (eval sym))
- m (meta (intern (:ns m) (:name m)))
- n (:name m)
- arglists (:arglists m)
- doc (:doc m)]
- (list `def (with-meta n {:doc doc :arglists (list 'quote arglists)}) (eval sym))))
(import-fn core/available-platforms)
(import-fn core/available-devices)
(import-fn core/available-cpu-devices)
@@ -58,12 +50,12 @@
(import-fn data/to-buffer)
(import-fn data/from-buffer)
(import-fn data/wrap)
-(import-fn #'data/mimic)
-(import-fn #'data/release!)
-(import-fn #'data/acquire!)
-(import-fn #'data/enqueue-read)
-(import-fn #'data/enqueue-copy)
-(import-fn #'data/enqueue-overwrite)
+(import-fn data/mimic)
+(import-fn data/release!)
+(import-fn data/acquire!)
+(import-fn data/enqueue-read)
+(import-fn data/enqueue-copy)
+(import-fn data/enqueue-overwrite)
(import-fn data/create-buffer)
@@ -130,7 +122,7 @@
-(defvar- event-type-map
+(def ^:private event-type-map
{CLEvent$CommandType/CopyBuffer :copy-buffer
CLEvent$CommandType/CopyBufferToImage :copy-buffer-to-image
CLEvent$CommandType/CopyImageToBuffer :copy-image-to-buffer
19 src/calx/core.clj
@@ -9,9 +9,6 @@
^{:skip-wiki true}
- (:use
- [clojure.contrib.def :only (defvar defvar-)]
- [clojure.contrib.seq :only (indexed)])
JavaCL CLContext CLPlatform
@@ -28,13 +25,13 @@
-(defvar *platform* nil "The current platform.")
-(defvar *context* nil "The current context.")
-(defvar *queue* nil "The current queue.")
-(defvar *program* nil "The current program")
-(defvar *workgroup-size* nil "The size of the workgroup")
-(defvar *params* nil "The params given to a kernel")
-(defvar *program-template* nil "A function which will return a program, given the current params.")
+(def ^{:doc "The current platform."} ^:dynamic *platform* nil)
+(def ^{:doc "The current context."} ^:dynamic *context* nil)
+(def ^{:doc "The current queue."} ^:dynamic *queue* nil)
+(def ^{:doc "The current program"} ^:dynamic *program* nil)
+(def ^{:doc "The size of the workgroup"} ^:dynamic *workgroup-size* nil)
+(def ^{:doc "The params given to a kernel"} ^:dynamic *params* nil)
+(def ^{:doc "A function which will return a program, given the current params."} ^:dynamic *program-template* nil)
(defn platform
"Returns the current platform, or throws an exception if it's not defined."
@@ -214,6 +211,6 @@
(defn enqueue-kernel
([kernel global-size & args]
(let [kernel ^CLKernel ((program) kernel)]
- (doseq [[idx arg] (indexed (map get-cl-object args))]
+ (doseq [[idx arg] (map vector (iterate inc 0) (map get-cl-object args))]
(.setArg kernel idx arg))
(.enqueueNDRange kernel (queue) (to-dim-array global-size) *workgroup-size* (make-array CLEvent 0)))))
3  src/calx/data.clj
@@ -10,7 +10,6 @@
^{:skip-wiki true}
- [clojure.contrib.def :only (defmacro- defvar- defvar)]
[gloss core io]
(:import [com.nativelibs4java.opencl CLContext CLByteBuffer CLMem CLMem$Usage CLEvent]
@@ -19,7 +18,7 @@
-(defvar- usage-types
+(def usage-types
{:in CLMem$Usage/Input
:out CLMem$Usage/Output
:in-out CLMem$Usage/InputOutput})
2  test/calx/test/mixed_datatype.clj
@@ -29,7 +29,7 @@
b[gid] = m;
-(def frame [:int16 :byte])
+(def frame [:int16-le :byte])
(deftest invert
(let [value (with-cl
6 test/calx/test/simple_addition.clj
@@ -22,9 +22,9 @@
(deftest simple-addition
(let [value (with-cl
(with-program (compile-program source)
- (let [a (wrap [1 2 3] :float32)
- b (wrap [1 2 3] :float32)
+ (let [a (wrap [1 2 3] :float32-le)
+ b (wrap [1 2 3] :float32-le)
c (mimic a)]
(enqueue-kernel :vec-add 3 a b c)
(enqueue-read c))))]
- (is (= [2 4 6] @value))))
+ (is (= [2.0 4.0 6.0] @value))))

0 comments on commit 59deea0

Please sign in to comment.
Something went wrong with that request. Please try again.