ztellman / calx

not under active development - idiomatic opencl bindings for clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

(use 'calx)

(def source
  "__kernel void square (
       __global const float *a,
       __global float *b) {
    int gid = get_global_id(0);
    b[gid] = a[gid] * a[gid];
  }")

(with-cl
  (with-program (compile-program source)
    (let [a (wrap [1 2 3] :float32-le)
          b (mimic a)]
      (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.

About

not under active development - idiomatic opencl bindings for clojure


Languages

Language:Clojure 100.0%