Hello everyone.
I’m french, so please excuse my spelling mistakes.
I need to implement an octree structure on GPU (using 3D texture).
I thought OpenCL was a good idea to do that: 3D Image reading and writing seem easy to use.
Unfortunately, I really don’t know OpenCL, and more I’m searching, more lost I am.
Plus, I’m working in a really unfriendly environment (Windows 7 + Visual Studio 2008). That’s not my choice.
I’m not even sure that Visual Studio is able to understand OpenCL.
I found the headers here: Khronos OpenCL Registry - The Khronos Group Inc
I have: cl.h, cl.hpp, cl_ext.h, cl_gl.h, cl_gl_ext.h, cl_platform.h, opencl.h.
And I have OpenCL.lib (I don’t remember where I got it).
However, even a very simple code doesn’t compile. A lot of functions, types, and macros are not know by the compiler.
I get 4 errors on this line:
sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_REPEAT | CLK_FILTER_NEAREST;
Type sampler_t, and the 3 next macros are unknown (undeclared identifiers).
The function
clCreateImage3D
is understood. The code compile.
But I can’t check if it really works because the function
read_imageui
is unknown.
A last example.
All the types float2, float4, int2, int4, unsigned int4, etc… are undefined.
If I add ‘cl_’ before the names, it “works”:
cl_float4 v;
float test = v.s[1];
However, I can only access to v.s, which is a table of float. I can’t acces to v.x, v.y, v.z, and v.w I expected.
The types float4 and cl_float4 seem different.
I put in my header the following:
#include <CL/opencl.h>
And VS is set to use “CL/openCL.lib”.
I have this basic code compiling (I don’t really know if it is working):
// OpenCL Init
cl_uint numDevicesReturned;
cl_device_id devices[1];
cl_int err = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, 1, &devices[0], &numDevicesReturned);
cl_context context;
context = clCreateContext (0, 1, devices, NULL, NULL, &err);
cl_command_queue queueGpu;
queueGpu = clCreateCommandQueue (context, devices[0], 0, &err);
// OpenCL Init end
Is there something I did wrong ?
Do you have any idea on where I can find the headers which declares the functions, variables, and macros I need ?
Or if it is a problem from Visual Studio, do you know how to configure it correctly ?
If you need more information to help me, don’t hesitate to ask me.
And, of course, do you know where I can find a complete implementation of octree on GPU using OpenCL ?
Anyway
Thank you for your help.
Ganesh