Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 27 lines (20 sloc) 1.291 kb
59deea0 @ztellman update everything to be reasonably current before officially abandoni…
authored
1 *This project is not under active development.*
2
2a16172 @ztellman further changes to readme
authored
3 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).
1f6b522 @ztellman first real commit
authored
4
79e18c9 @ztellman fix readme
authored
5 The OpenCL API is not known for its terseness; consider this "'Hello World' example":http://developer.apple.com/mac/library/samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html#//apple_ref/doc/uid/DTS40008187-hello_c-DontLinkElementID_4 example demonstrating the necessary steps to square a list of floating point numbers. Using Calx, the same result can be achieved like so:
1f6b522 @ztellman first real commit
authored
6
d8eb9cf @ztellman use just plain 'calx as namespace
authored
7 <pre><code>(use 'calx)
59deea0 @ztellman update everything to be reasonably current before officially abandoni…
authored
8
1f6b522 @ztellman first real commit
authored
9 (def source
10 "__kernel void square (
a2fc757 @ztellman fix a few mistakes
authored
11 __global const float *a,
3833f46 @ztellman etc., etc., etc.
authored
12 __global float *b) {
1f6b522 @ztellman first real commit
authored
13 int gid = get_global_id(0);
3833f46 @ztellman etc., etc., etc.
authored
14 b[gid] = a[gid] * a[gid];
1f6b522 @ztellman first real commit
authored
15 }")
16
17 (with-cl
18 (with-program (compile-program source)
0a117f9 @ztellman update readme
authored
19 (let [a (wrap [1 2 3] :float32-le)
a2fc757 @ztellman fix a few mistakes
authored
20 b (mimic a)]
3edcaff @ztellman still further changes
authored
21 (enqueue-kernel :square 3 a b)
22 (enqueue-read b))))
1f6b522 @ztellman first real commit
authored
23 </code></pre>
59deea0 @ztellman update everything to be reasonably current before officially abandoni…
authored
24
76ba477 @ztellman update README to point at documentation.
authored
25 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.
26
27 The complete documentation can be found "here":http://ztellman.github.com/calx/calx-api.html.
Something went wrong with that request. Please try again.