PDA

View Full Version : clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY erro



chanakya.sun
07-11-2011, 04:15 AM
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

david.garcia
07-13-2011, 03:31 PM
Can you show us how you declare and initialize the variables source_str and source_size?

vamsidhar
01-27-2012, 09:38 AM
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 \n";
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,_re t_num_devices,_device_id,NULL);
std::cout<<"Available GPU units = "<<_ret_num_devices<<"\n";
char pbuf[100];
ret = clGetPlatformInfo(_platform_id, CL_PLATFORM_VENDOR, sizeof(pbuf), pbuf, NULL);
printf("\n\tUsing : %s\n\n", pbuf);



context = clCreateContext(NULL, _ret_num_devices, _device_id, NULL, NULL, 0);
//std::cout<<"Context Created with "<<_ret<<" \n";
commandQueue = clCreateCommandQueue(context, _device_id[0], 0, &ret);

//std::cout<<"Commandqueue Created with "<<ret<<" \n";
cl_program _program[1];
_program[0] = clCreateProgramWithSource(context, CL_TRUE,
(const char **) &kernelSource, &kernelSourceSize, &ret);
std::cout<<ret<<"program return \n";

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

vamsidhar
01-27-2012, 09:42 AM
Never Mind.. I found the bug... I am stupid.. :oops:

david.garcia
01-27-2012, 04:04 PM
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.

vamsidhar
01-27-2012, 07:01 PM
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