https://github.com/gos-k/oclcl.git
git clone 'https://github.com/gos-k/oclcl.git'
(ql:quickload :oclcl)
oclcl is a library to use OpenCL in Common Lisp programs. It provides the kernel description language with which users can define OpenCL kernel functions in S-expression. The kernel description language also provides facilities to define kernel macros and kernel symbol macros in addition to kernel functions. oclcl's kernel macro and kernel symbol macro offer powerful abstraction that OpenCL C itself does not have and provide enormous advantage in resource-limited GPU programming.
oclcl is now available on Quicklisp.
(ql:quickload :oclcl)
oclcl requires following:
(ql:quickload :prove)
(prove:run :oclcl-test)
or
$ ros install prove
$ run-prove oclcl/oclcl-test.asd
oclcl is verified to work in following environments:
Support types.
char char2 char3 char4 char8 char16char* char2* char3* char4* char8* char16*uchar uchar2 uchar3 uchar4 uchar8 uchar16uchar* uchar2* uchar3* uchar4* uchar8* uchar16*short short2 short3 short4 short8 short16short* short2* short3* short4* short8* short16*ushort ushort2 ushort3 ushort4 ushort8 ushort16ushort* ushort2* ushort3* ushort4* ushort8* ushort16*int int2 int3 int4 int8 int16int* int2* int3* int4* int8* int16*uint uint2 uint3 uint4 uint8 uint16uint* uint2* uint3* uint4* uint8* uint16*long long2 long3 long4 long8 long16long* long2* long3* long4* long8* long16*ulong ulong2 ulong3 ulong4 ulong8 ulong16ulong* ulong2* ulong3* ulong4* ulong8* ulong16*float float2 float3 float4 float8 float16float* float2* float3* float4* float8* float16*double double2 double3 double4 double8 double16double* double2* double3* double4* double8* double16*bool void size-tIF test-form then-form [else-form]
if allows the execution of a form to be dependent on a single test-form. First test-form is evaluated. If the result is true, then then-form is selected; otherwise else-form is selected. Whichever form is selected is then evaluated. If else-form is not provided, does nothing when else-form is selected.
Example:
(if (= a 0)
(return 0)
(return 1))
Compiled:
if (a == 0) {
return 0;
} else {
return 1;
}
LET ({(var init-form)}*) statement*
let declares new variable bindings and set corresponding init-forms to them and execute a series of statements that use these bindings. let performs the bindings in parallel. For sequentially, use let* kernel macro instead.
Example:
(let ((i 0))
(return i))
Compiled:
{
int i = 0;
return i;
}
SYMBOL-MACROLET ({(symbol expansion)}*) statement*
symbol-macrolet establishes symbol expansion rules in the variable environment and execute a series of statements that use these rules. In cl-cuda's compilation process, the symbol macros found in a form are replaces by corresponding expansions.
Example:
(symbol-macrolet ((x 1.0))
(return x))
Compiled:
{
return 1.0;
}
DO ({(var init-form step-form)}*) (test-form) statement*
do iterates over a group of statements while test-form holds. do accepts an arbitrary number of iteration vars and their initial values are supplied by init-forms. step-forms supply how the vars should be updated on succeeding iterations through the loop.
Example:
(do ((a 0 (+ a 1))
(b 0 (+ b 1)))
((> a 15))
(do-some-statement))
Compiled:
for ( int a = 0, int b = 0; ! (a > 15); a = a + 1, b = b + 1 )
{
do_some_statement();
}
WITH-LOCAL-MEMORY ({(var type size*)}*) statement*
with-local-memory declares new variable bindings on local memory by adding __local variable specifiers. It allows to declare array variables if dimensions are provided. A series of statements are executed with these bindings.
Example:
(with-local-memory ((a int 16)
(b float 16 16))
(return))
Compiled:
{
__local int a[16];
__local float b[16][16];
return;
}
SET reference expression
set provides simple variable assignment. It accepts one of variable, structure and array references as reference.
Example:
(set x 1.0)
(set (float4-x y 1.0)
(set (aref z 0) 1.0)
Compiled:
x = 1.0;
y.x = 1.0;
z[0] = 1.0;
PROGN statement*
progn evaluates statements, in the order in which they are given.
Example:
(progn
(do-some-statements)
(do-more-statements))
Compiled:
do_some_statements();
do_more_statements();
RETURN [return-form]
return returns control, with return-form if supplied, from a kernel function.
Example:
(return 0)
Compiled:
return 0;
Implementation status of built in functions.
| Status | Functions | |:——:|:———-| | Yes | Work-Item | | Part | Math | | Part | Integer | | Part | Common | | Yes | Geometric | | No | Relational | | No | Vector Data Load and Store | | Yes | Synchronization | | Yes | Explicit Memory Fence | | No | Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch | | Yes | Atomic | | Part | Miscellaneous Vector | | Yes | printf | | No | Image Read and Write Functions |
C source generator is forked from cl-cuda.
2015 gos-k (mag4.elan@gmail.com)
Copyright (c) 2012 Masayuki Takagi (kamonama@gmail.com)
Licensed under the LLGPL License.