I am having difficulty getting code to compile in VS 2008. I have copied the .h files to the CL directory like it says to on http://www.khronos.org/registry/cl/ page but when I started to write a small segment of code to just make sure it will build i am getting the error: Cannot find CL\cl.h and if i change it to openCL.h for my include it tells me the same thing just cannot find CL\openCL.h
This is only a short piece of the code that should compile and build according to this website and also straight out of the book Heterogeneous Computing chapter 2 full source code.
#include <stdio.h>
#include <stdlib.h>
#include <CL\opencl.h>
const char* programSource =
"__kernel
"
"void vecadd(__global int *A,
"
" __global int *B,
"
" __global int *C,
"
"{
"
"
"
" // Get the work -item’s unique ID
"
" int idx = get_global_id(0);
"
"
"
" // Add the corresponding locations of
"
" // ‘A’ and ‘B’, and store result in ‘C’
"
" C[idx] = A[idx] + B[idx];
"
"}
"
;
int main()
{
int *A = NULL;
int *B = NULL;
int *C = NULL;
const int iElements = 2048;
size_t datasize = sizeof(int) * iElements;
A = (int*)malloc(datasize);
B = (int*)malloc(datasize);
C = (int*)malloc(datasize);
for ( int i = 0; i < iElements; i++)
{
A[i] = i;
B[i] = i;
}
cl_int status;
//STEP 1
cl_uint numPlatforms = 0;
cl_platform_id *platforms = NULL;
status = clGetPlatformIDS(0, NULL, &numPlatforms);
platforms = (cl_platform_id*)malloc(numPlatforms * sizeof(cl_platform_id));
status = clGetPlatformIDs(numPlatforms, platforms, NULL);
//STEP 2
cl_uint numDevices = 0;
cl_device_id*devices = NULL;
status = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices);
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
status = clGetDEviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, numDevices, devices, NULL);
// STEP 3
}
I have tried to “include” this directory within the VS IDE by going to Tools/options/ VC++ directories and manually adding C:\CL to it but it still fails to build because it cannot find the file. Also it really seems like something is missing from the website because while i see all of the .h files as includes and i have looked into everyone of them I see function prototypes and a ton of define statements but i don’t see any actual function code. Am I missing a library? Is it vendor specific? If so where do I get it? Yeah I’m a noob programmer but I tell you the thing I hate and that frustrates so many “noob” programmers is not having all of the files in the right places to build with. I am really interested in Learning openCL and i have a lot of experience in C but I swear Microsoft programmers should be shot for making VS so damned complicated to use. Yeah I’ve tried other IDE’s like Net beans but cant even get them to build the simple examples in Deitel and Deitel with out 500 errors. Thanks for any help and please forgive the rant but its something that really needs to be addressed in the programming community so that “noobs” can learn to program and not fight the IDE’s.