- Clojure 93.2%
- C 6.8%
|
|
||
|---|---|---|
| dev-resources/kernels | move structgen to :dev dependencies, update debug test | |
| export | updating read me, updating JOCL dependency, adding /export dummy | |
| src/thi/ng/simplecl | add device-name (core), str->stream fns (utils), add hellocl demo/test | |
| test/thi/ng/simplecl/test | add -main fns for tests/examples, update readme | |
| .gitignore | update gitignore | |
| LICENSE | update deps, restructure namespace & tests, update readme | |
| project.clj | 0.2.2 release, only minor updates (update clj dependency to RC1, update readme) | |
| README.org | docs: remove video links (anti-AI bot measures) | |
thi.ng/simplecl
Clojure wrapper & highlevel processing pipeline ops for JOCL/OpenCL
SimpleCL intends to enable a somewhat declarative interop approach between Clojure and OpenCL compute kernels. It provides thin wrappers for basic OpenCL data structures (contexts, devices, buffers, programs, kernels), as well as an highlevel API to define & configure multi-kernel & multi-program workflows and transforming data between Clojure's data structures and their native OpenCL representation as byte buffers.
SimpleCL is still a young project (although it's was originally created in 2012, it has been dormant for a while), yet has been sucessfully used in production in several projects and is fairly well documented.
Leiningen coordinates
[thi.ng/simplecl "0.2.2"]
Usage & examples
Please see the extensive doc strings in the source and the examples below:
Hello CL example
A trivial "Hello world" style example is located in this namespace. It defines a kernel to factor two float arrays and shows the required steps to run this on either CPU or GPU devices (by default the most performant is chosen automatically):
;; chooses max performance device
lein trampoline run -m thi.ng.simplecl.test.hello
;; or force usage of given device type
lein trampoline run -m thi.ng.simplecl.test.hello gpu
lein trampoline run -m thi.ng.simplecl.test.hello cpu
Verlet cloth sim
Running the command below will run a basic 2d cloth simulation with
40,000 particles & 80,000 springs and generate an image sequence of
120 PNGs in the /export sub-directory.
lein trampoline run -m thi.ng.simplecl.test.verlet
The image sequence can then be converted into an MP4 using this `ffmpeg` command:
ffmpeg -r 30 -f image2 -start_number 5 -i "export/verlet-%04d.png" \
-vcodec libx264 -preset slow -crf 23 -pix_fmt yuv420p \
-f mp4 -threads 0 verlet.mp4 -y
This demo is also showcasing usage & integration of the structgen partner library to ease the task of aligning nested Clojure data structures in an OpenCL compatible way (mapping to OpenCL structs).
Voxel raymarching
See thi.ng/raymarchcl for full details.
3D Strange attractor
A sneak peak of an upcoming example kernel pipeline to:
- compute a 2d strange attractor
- apply a 2D distortion filter to all points
- map the result points onto the surface of a sphere and
- apply a 3D distortion filter to all points
- do a standard 3d > 2d camera-screen projection
More examples & documentation will be added ASAP.
License
Copyright © 2012 - 2015 Karsten Schmidt
Distributed under the Apache Software License 2.0