Hi, even I am facing the same problem which is being discussed. So in order to debug i removed all other lines of the code except two. But still i am getting the same errors.
:16: error: expected identifier or ‘(’
}ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
^
I am using Visual Studio and the kernel code is as follows:
__kernel void hypothesis_opencl(__global uchar *Edges,
__global uchar *Depth,
__global uchar *Filtered,
__global float *weights_table,
__global float *dist_table,
int height,
int width,
int fltr_radius,
float search_limit)
{
int x = (int)get_global_id(0);
Filtered[x] = Depth[x];
}
the host code
#include "yuv_reader.h"
#include "hypothesis_opencl.h"
#include "pugixml.hpp"
#include "config.h"
// Main function
// *********************************************************************
int main(int argc, char **argv)
{
...
...
...
// Get platforms
cl_uint nPlatform = 0;
clGetPlatformIDs(0, NULL, &nPlatform);
cl_platform_id* plInfos = (cl_platform_id*)malloc(nPlatform * sizeof(cl_platform_id));
clGetPlatformIDs(nPlatform, plInfos, NULL);
// Get device
cl_context GPUContext;
for (cl_uint i = 0; i < nPlatform; i++)
{
cl_uint nDev = 0;
clGetDeviceIDs(plInfos[i], CL_DEVICE_TYPE_GPU, 0, 0, &nDev);
cl_device_id* GPUDevices = (cl_device_id*)malloc(nDev * sizeof(cl_device_id));
clGetDeviceIDs(plInfos[i], CL_DEVICE_TYPE_GPU, nDev, GPUDevices, 0);
// Create a context to run OpenCL on our CUDA-enabled NVIDIA GPU
cl_int errNum;
GPUContext = clCreateContext(NULL, nDev, GPUDevices, 0, 0, &errNum);
if(errNum != CL_SUCCESS)
{
std::cout << "ERROR: OpenCL::clCreateContext" << std::endl;
return -1;
}
}
// Get the list of GPU devices associated with this context
size_t ParmDataBytes;
clGetContextInfo(GPUContext, CL_CONTEXT_DEVICES, 0, NULL, &ParmDataBytes);
cl_device_id* GPUDevices = (cl_device_id*)malloc(ParmDataBytes);
clGetContextInfo(GPUContext, CL_CONTEXT_DEVICES, ParmDataBytes, GPUDevices, NULL);
// Create a command-queue on the first GPU device
cl_command_queue GPUCommandQueue = clCreateCommandQueue(GPUContext, GPUDevices[0], 0, NULL);
// Read OpenCL code from file
size_t sourceLength = 0;
char* sourceCL = readTextFile((char*)filenameCL.c_str(), &sourceLength);
if(sourceCL == NULL || sourceLength<10)
{
std::cout << "ERROR::main::readTextFile: Cannot open " << filenameCL << " file" << std::endl;
return -2;
}
cl_int errNum;
// Create OpenCL program with source code
cl_program OpenCLProgram = clCreateProgramWithSource( GPUContext,
1,
(const char **)&sourceCL,
&sourceLength,
&errNum);
delete[] sourceCL;
if(errNum != CL_SUCCESS)
{
std::cout << "ERROR::main::clCreateProgramWithSource: Unable to create opencl program" << std::endl;
return -1;
}
// Build the program (OpenCL JIT compilation)
retVal = clBuildProgram(OpenCLProgram, 1, GPUDevices, NULL, NULL, NULL);
//if(retVal != CL_SUCCESS)
//{
// std::cout << "ERROR::main::clBuildProgram: " << retVal << std::endl;
// return -1;
//}
size_t paramValueSize = 1024 * 1024,
param_value_size_ret;
char *paramValue;
paramValue = (char*)calloc(paramValueSize, sizeof(char));
retVal = clGetProgramBuildInfo( OpenCLProgram,
GPUDevices[0],
CL_PROGRAM_BUILD_LOG,
paramValueSize,
paramValue,
¶m_value_size_ret);
fprintf(errLog, paramValue);
fclose(errLog);
// Create a handle to the compiled OpenCL function (Kernel)
cl_kernel openCLKernel = clCreateKernel( OpenCLProgram,
"hypothesis_opencl",
&errNum);
//if(errNum != CL_SUCCESS)
//{
// std::cout << "ERROR::main::clCreateKernel: " << errNum << std::endl;
// return -1;
//}
// Set kernel arguments
LocalBuffer buffLoc;
GPUBuffer buffGPU;
initLocalBuffer(&buffLoc, w, h);
initGPUBuffer(&buffGPU, GPUContext, w, h, searchLimit, radius);
// Fill local buffer with appropriate values
// pre-calculation of color & distance weights
init_color_SAD(buffLoc.weightTable, sigmaColor, MAXDIFF);
init_distance(buffLoc.distTable, sigmaDistance, radius);
// Loop till the end of video file
while((CIYuv_depth.readOneFrame(pf_read_depth, frameno)) == true)
{
CIYuv_col.readOneFrame(pf_read_col, frameno);
std::cout << "Processing frmne no. " << frameno << "
";
// Set the YUV image format to 444
CIYuv_col444.setData444_inIYUV(&CIYuv_col);
int i = 0,
j = h * w,
k = h * w * 2;
// Initialize with some interesting data
// Copy Y U V data to the local buffer
for(int r = 0; r < h; r++)
{
for(int c = 0; c < w; c++)
{
buffLoc.frameCol[i] = CIYuv_col444.Y[r][c];
buffLoc.frameCol[j++] = CIYuv_col444.U[r][c];
buffLoc.frameCol[k++] = CIYuv_col444.V[r][c];
buffLoc.frameDepth[i++] = CIYuv_depth.Y[r][c];
}
}
// Copy the output in CPU memory TO GPU memory
//clEnqueueWriteBuffer(GPUCommandQueue, GPUVector1, CL_TRUE, 0,
//sizeof(int) * CIYuv_col.getSizeInByte(), HostVector1, 0, NULL, NULL);
// Copy the output in CPU memory TO GPU memory
fillGPUBuffer( GPUCommandQueue,
&CIYuv_col,
&CIYuv_depth,
&buffGPU,
&buffLoc );
initKernel( openCLKernel,
&CIYuv_col,
&CIYuv_depth,
&buffGPU);
// Launch the Kernel on the GPU
size_t workSize[2] = {w, h}; // two dimensional Range
clEnqueueNDRangeKernel( GPUCommandQueue,
openCLKernel,
2,
NULL,
workSize,
NULL,
0,
NULL,
NULL);
// Copy the output in GPU memory back to CPU memory
clEnqueueReadBuffer( GPUCommandQueue,
buffGPU.frameFilteredDepth,
CL_TRUE,
0,
sizeof(uchar) * (w * h),
buffLoc.frameFilteredDepth,
0,
NULL,
NULL);
...
...
...
// Increment the frame index
frameno ++;
}
_getch();
return 0;
}
Can someone suggest me some solution to debug this error.