clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY erro

Hi,

I used the API in the following manner
program = clCreateProgramWithSource(context, 1,
(const char **)&source_str, (const size_t *)&source_size, &ret);

All the variables show valid data,
initially I thought kernel is not proper, then i replaced with proper kernel from other workspace, still giveing the same error code( CL_OUT_OF_HOST_MEMORY ).

I am using VS2008

Regards

Can you show us how you declare and initialize the variables source_str and source_size?

Hey, I keep getting the same error. I tried hell lot of options but still stuck. Can you please check into this.

ret = clGetPlatformIDs(1, &_platform_id, &_ret_num_platforms);
	//std::cout<<_ret_num_platforms<<" num of platforms 
";
	ret = clGetDeviceIDs(_platform_id, CL_DEVICE_TYPE_GPU, 0, NULL, &_ret_num_devices);
	_device_id = (cl_device_id *) malloc(_ret_num_devices * sizeof(cl_device_id));
	clGetDeviceIDs(_platform_id,CL_DEVICE_TYPE_GPU,_ret_num_devices,_device_id,NULL);
	std::cout<<"Available GPU units = "<<_ret_num_devices<<"
";
	char pbuf[100];
	ret = clGetPlatformInfo(_platform_id, CL_PLATFORM_VENDOR, sizeof(pbuf), pbuf, NULL);
	printf("
	Using : %s

", pbuf);

	

	context = clCreateContext(NULL, _ret_num_devices, _device_id, NULL, NULL, 0);
	//std::cout<<"Context Created with "<<_ret<<" 
";
	commandQueue = clCreateCommandQueue(context, _device_id[0], 0, &ret);
	
	//std::cout<<"Commandqueue Created with "<<ret<<" 
";
	cl_program _program[1];
	_program[0] = clCreateProgramWithSource(context, CL_TRUE,
		(const char **) &kernelSource, &kernelSourceSize, &ret);
	std::cout<<ret<<"program return 
";

here are some initializations

class CLAbstract{
public:
	char* kernelSource;
	size_t kernelSourceSize;
	cl_context context;
	cl_command_queue commandQueue;
	cl_kernel kernel;
	
	int ret;
	
	CLAbstract(std::string);
		
private:
	cl_platform_id _platform_id;
	cl_device_id* _device_id;
	unsigned int _ret_num_devices;
	unsigned int _ret_num_platforms;
	
	
	void initialiseGPU(std::string);
	void loadKernelSource(std::string);
	

Please help me out

Never Mind… I found the bug… I am stupid… :oops:

It may be a good idea if you explain how you fixed the issue so that if somebody else reads this thread and has a similar problem they can find out how to fix it as well.

I created the _program before I read the kernel file. It should be the other way round.

And the random initialization of VS2008 for the kernelSourceSize was quite huge and hence the error (-6) which is OUT_OF_HOST_MEMORY