Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: opencl build error..!!

  1. #11
    Junior Member
    Join Date
    Mar 2010
    Posts
    22

    Re: opencl build error..!!

    I got an error like yours and the answer was casting types. Cast everything you see and compile again!

  2. #12
    Junior Member
    Join Date
    Aug 2010
    Posts
    6

    Re: opencl build error..!!

    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:
    Code :
    __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
    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,
    									&param_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 << "\n";
     
    		// 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.

  3. #13

    Re: opencl build error..!!

    Quote Originally Posted by sumeetsen
    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 '('
    }様様様様様様様
    ^


    the host code
    Code :
    // 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);
    Can someone suggest me some solution to debug this error.
    I looks like the string you are passing to the OpenCL compiler contains more than the actual file content. I suggest you carefully read the 'readTextFile' function and ensure that the value written to 'sourceLength' is correct. If you are on Windows, then pay particular attention to newline characters.

  4. #14
    Junior Member
    Join Date
    Aug 2010
    Posts
    6

    Re: opencl build error..!!

    Thanks friend, you were correct.

  5. #15
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    Re: opencl build error..!!

    To solve the error CL_Build_program_Failure is because the build file is not loaded properly or the systems file is missing .For this you have go through the newer version of the document 1.0.44 provided by the KHRONOS.

    There is definetly a problem with the configuration files.Once that is set up.The program will restart and them will b running fine.Try rebuilding the mfc ,if that doesnt work either ,there is a problem with the source code.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. error to build program executable
    By zovasili in forum OpenCL
    Replies: 6
    Last Post: 01-15-2013, 08:59 AM
  2. Program Build Error
    By dlw in forum OpenCL
    Replies: 5
    Last Post: 06-28-2011, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •