Results 1 to 3 of 3

Thread: Creating context using multiple devices from openGL context

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    2

    Creating context using multiple devices from openGL context

    What I want to do is

    Render a Image using openGL
    process the image using several CL devices.

    OS: is XP
    cards: 2x NVIDIA GTX 480
    cl driver: 197.41
    cl develop: cuda 3.0
    Im using OSG to handle openGL calls.

    However I run into problems when trying to create context that contains several devices when i create the context from OpenGL.

    Code :
    cl_int err;
     
        cl_platform_id platforms[10];
        cl_uint nrPlatforms;
        err = clGetPlatformIDs(10, platforms,&nrPlatforms );
        CL_REPORT_IF_ERROR(err)    
     
        cl_uint maxDevices = 100;
        cl_device_id* devices = new cl_device_id[maxDevices];
        cl_uint nrDevices;
        err = clGetDeviceIDs(platforms[0], deviceType, maxDevices, devices, &nrDevices);
        CL_REPORT_IF_ERROR(err)
     
     
        cl_context_properties props[] =
        {
            CL_GL_CONTEXT_KHR, gcAdapter->getCL_GL_CONTEXT_KHR(), // The gl context handel
            CL_WGL_HDC_KHR,  gcAdapter->getCL_WGL_HDC_KHR(), //
            0
        };
     
        cl_context gl_to_cl_context;
     
        gl_to_cl_context = clCreateContext(props, nrDevices,
            devices, NULL, NULL, &err);
     
        //Error CL_INVALID_OPERATION
        CL_REPORT_IF_ERROR(err)
     
        // Set the context
        _context = gl_to_cl_context;

    if i replace

    gl_to_cl_context = clCreateContext(props, nrDevices,
    devices, NULL, NULL, &err);

    with:

    gl_to_cl_context = clCreateContext(props, 1,
    devices[0], NULL, NULL, &err);

    or

    gl_to_cl_context = clCreateContext(props, 1,
    devices[1], NULL, NULL, &err);


    No error is reported and everything is working. The later option is working but with weary low performance.
    But I want to use several devices.

    Is it even possible to use several devices operating on gl Recourses?


    Regards Ragnar

  2. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    2

    Re: Creating context using multiple devices from openGL context

    I guess that no one has tried using more then one graphic card for this kind of things.
    No one have any clue?

  3. #3

    Re: Creating context using multiple devices from openGL context

    I am just trying to achieve the exact same thing and I am stuck at the same place. I have two different cards in my system and they are both detected by a call to clGetDeviceIDs.

    My first confusion starts right here


    gl_to_cl_context = clCreateContext(props, 1,
    devices[0], NULL, NULL, &err);

    or

    gl_to_cl_context = clCreateContext(props, 1,
    devices[1], NULL, NULL, &err);
    In my case this also works and the ouput of an OpenCL program that shares buffers with OpenGL produces the correct results in each case. However, only device[0] is actually hooked up to the monitor!! It seems to me that even if you create a context with only one of the devices, both cards are picking up all of the OpenCL commands. Actually both cards are also picking up the wgl and gl calls. i.e. a call to wglCreateContext creates a context on both cards. So, basically both cards work in unicense.

    That now leaves me with the question of how to use the two cards for different purposes. I,e. one for OpenGL and maybe some OpenCL kernels that require interoperability, and another card for some visualizaiton unrelated OpenCL computation ?
    OpenCL Studio --- http://www.opencldev.com

Similar Threads

  1. Creating GL-Sharing context with SDL
    By mollitz in forum OpenCL
    Replies: 2
    Last Post: 07-19-2010, 05:20 AM
  2. Replies: 4
    Last Post: 04-04-2010, 04:04 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
  •