Results 1 to 1 of 1

Thread: CL_OUT_OF_RESOURCES when crate opencl context

Threaded View

  1. #1
    Newbie
    Join Date
    Aug 2013
    Posts
    1

    CL_OUT_OF_RESOURCES when crate opencl context

    I want to interop Opencl and Opengl and my device have cl_khr_gl_sharing extention but when I create context has error CL_OUT_OF_RESOURCES

    Code :
    cl_uint num_platforms;
    	err = clGetPlatformIDs(1, NULL, &num_platforms);
    	if(err < 0) {
    		perror("Couldn't find any platforms.");
    		exit(1);
    	}
    	platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * num_platforms);
    	err = clGetPlatformIDs(num_platforms, platforms, NULL);
    	if(err < 0) {
    		printf("clGetPlatformIDs %s",get_error_string(err));
    		system("pause");
    		//perror("Couldn't create a context");
    		//exit(1);
    	}else{
    		printf("Create Plateform Success\n");
    	}
     
    	cl_uint num_devices;
    	err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 1, NULL, &num_devices);
    	if(err < 0) {
    		perror("Couldn't find any devices");
    		exit(1);
    	}
     
    	devices = (cl_device_id*)malloc(sizeof(cl_device_id) * num_devices);
    	err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU,num_devices, devices, NULL);
    	if(err < 0) {
    		printf("clGetDeviceIDs %s",get_error_string(err));
    		system("pause");
    		//perror("Couldn't create a context");
    		//exit(1);
    	}else{
    		printf("Create Device Success\n");
    	}
     
    	cl_context_properties props[] =
    	  {
    		CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(platforms[0]),
    		CL_GL_CONTEXT_KHR, reinterpret_cast<cl_context_properties>(wglGetCurrentContext() ),
    		CL_WGL_HDC_KHR, reinterpret_cast<cl_context_properties>( wglGetCurrentDC() ),
    		0
    	  };
     
    	context = clCreateContext(props, 1, &devices[0], NULL, NULL, &err);
    	if(err < 0) {
    		printf("//// %s",get_error_string(err));
     
    		system("pause");
    		//perror("Couldn't create a context");
    		//exit(1);
    	}

    And output is

    ------------------------------
    Create Platform Success
    Create Device Success
    //// CL_OUT_OF_RESOURCES
    ------------------------------

    But When I create context with
    Code :
    clCreateContext(NULL, 1, &devices[0], NULL, NULL, &err);

    Context can create. Does anybody have any suggestions?

    Thank
    Wijuk
    Last edited by octoboy; 08-26-2013 at 02:16 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
  •