Skip to content

UnderstandOpenCLKernelArguments

Olivier Chafik edited this page Nov 10, 2022 · 2 revisions

Description of the behaviour of OpenCL kernel argument types

Mapping OpenCL C types to JavaCL

Here are the different kinds of values accepted as kernel arguments in CLKernel.setArgs

Scalar data types

|| OpenCL C type || JavaCL type || || int/uint || int || || long/ulong || long || || short/ushort || short || || char/uchar || byte || || float || float || || double || double || || size_t, ptrdiff_t, intptr_t, uintptr_t || NativeSize ||

Vector data types

|| * OpenCL C type* || JavaCL type || || int2, int3, int4, int8... || int[] ||

Array/Buffer types (including arrays of vector types)

Please also read [ReadFromAndWriteToBuffersAndImages].

|| OpenCL C type || JavaCL type || || __global int*
__global uint*
__global int2*
... || CLBuffer || || __global long* || CLBuffer || || __global short* || CLBuffer || || __global char* || CLBuffer || || __global float* || CLBuffer || || __global double* || CLBuffer ||

Image-related types

Please also read [ReadFromAndWriteToBuffersAndImages].

|| OpenCL C type || JavaCL type || || [sampler_t] || https://nativelibs4java.sourceforge.net/sites/javacl/apidocs/com/nativelibs4java/opencl/CLSampler.html CLSampler || || image2d_t || CLImage2D || || image3d_t || CLImage3D ||

Local Arguments

Their memory storage is shared by all the work items in the same work group

|| OpenCL C type || JavaCL type || || local int* || LocalSize : Mere indication of the size of a local argument ||