Float3?

Hi

In the samples I’ve seen ways of handling float2 and in QuadFloat.cl and Mandelbrot sample of handling float4. But what about float3?

I’m particularly interested in this as it’s a key type for 3D vectors.

Thanks.

Graham

*** Edit ***

Presumably I use as follows:

__kernel void compute(…, float3 vector, …)

and simply specify 3*Sizeof.cl_float in clSetKernelArg():

clSetKernelArg(kernel, 3, 3*Sizeof.cl_float, Pointer.to(new float[]{ x,y,z }));

Graham

Hello

cl_float3 is the same as cl_float4. According to the definition from the official Khronos cl_platform.h:


/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
typedef  cl_float4  cl_float3;

The name ‘cl_float3’ is just … well … “syntactic sugar”, to emphasisze that it is a 3D vector.

So you should not use the factor 3, but factor 4 instead, and pass in a 4-element array/vector:
clSetKernelArg(kernel, n, 4*Sizeof.cl_float, Pointer.to(new float[]{ x,y,z,0 }));

I’ll probably add a Sizeof.cl_float3 in the next version - although I’m not entirely sure whether this might lead to a wrong usage, when people assume that it is 3Sizeof.cl_float. (I’ll have to test what happens when you specify a kernel argument as cl_float3 (with a size of 4float!) but only provide a 3-element array…)

bye
Marco