Results 1 to 6 of 6

Thread: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY erro

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    10

    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

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY

    Can you show us how you declare and initialize the variables source_str and source_size?
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    3

    Re: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY

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

    Code :
    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,_ret_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
    Code :
    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

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Posts
    3

    Re: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY

    Never Mind.. I found the bug... I am stupid..

  5. #5
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY

    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.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  6. #6
    Junior Member
    Join Date
    Jan 2012
    Posts
    3

    Re: clCreateProgramWithSource returns CL_OUT_OF_HOST_MEMORY

    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

Similar Threads

  1. clFinish returns CL_OUT_OF_HOST_MEMORY (-6)
    By barraqueiro in forum OpenCL
    Replies: 0
    Last Post: 10-12-2012, 08:25 AM
  2. Replies: 2
    Last Post: 08-14-2012, 05:49 AM

Posting Permissions

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