HsOpenCL-0.0.1: A binding to the OpenCL parallel computing framework.



This module contains Template Haskell commands which eliminate much of the boilerplate of using an OpenCL source file while providing an additional layer of type safety.

For example, suppose that file.cl contained two kernels:

 __kernel void add(__global float *a, __global int* b, __global float* c)
 __kernel void scale(float x, __global float *y, __local float *z)

Then the splice $(declareKernelsFromFile "ProgAdd" "path/to/file.cl") would generate the following declarations:

 data ProgAdd = ProgAdd {
           add :: forall d . NDRange d =>
                       Buffer Float -> Buffer Int32 -> Bufer Float -> Command
           , scale :: forall d . NDRange d =>
                       Float -> Buffer Float -> Local Float -> Command

 buildProgAdd :: MonadQueue m => String -> m ProgAdd
 buildProgAdd options = ...

Note that the generated code requires the Rank2Types extension.

Quasiquoting can also be used to integrate OpenCL code into a Haskell module. For example:

 $(declareKernels "Reverse" [$clProg| __kernel void reverse(__global float *a) {
                   } |] )