Results 1 to 6 of 6

Thread: "clDevicePointer" function needed!

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    6

    "clDevicePointer" function needed!

    A function to retrieve the device memory pointer in order to use in
    other OpenCL buffers. This gives the possibility to pass graph or
    other structures relying heavily on pointers by keeping their
    "topology".

    Example thread about the feature:
    http://www.khronos.org/message_board...hp?f=37&t=2900

    Special note: a similar function already exists in CUDA.

  2. #2
    Junior Member
    Join Date
    May 2011
    Posts
    1

    Re: "clDevicePointer" function needed!

    I agree. I have an object that has a list of objects that have lists of
    objects. Flattening this is going to be such a pain.

    Doing this with a bunch of buffers containing references to each other
    would be so much better. This structure is only written once, so
    the performance hit would be negligible.

    These kind of hierarchial structures are common so some way to handle them
    would be beneficial to paraller computing.
    You can only do so much with just arrays.

    I realize that buffers move around and so on, so the system
    should really know that this is a buffer, not just a memory address.

    something like (in OpenCL-C)
    Code :
     
    struct Blaa{
     int resurgence;
     float revorbitance;
     Buffer minions; // This a buffer object
    };
     
    struct Minion{
     Buffer henchmen; // Our structure is multidimensional
    };
     
    kernel addMinion(global Blaa* blaa,global Minion* minion){
       if(blaa.minions.size < blaa.minions.capacity){ // The size of the buffer is static
        bufferAppend(blaa.minions,minion); // system function
       }
    }
     
    kernel commandMinion(global Blaa* blaa,int index){
       commandMinion( (Minion*)minions.address[index] );
    }

    I hope that gives you the idea.
    Henchman could also have a buffer member and so on.
    This would allow arbitrarily complex hierarchies to be built.

    At the moment i can't see a way to do something like
    this that doesn't involve flattening the entire data structure
    or implementing my own malloc against a buffer i would use as general memory.
    Are there better ways since, as someone said in the other thread,
    just getting the address that a certain buffer happens to be
    in is not safe?

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    1

    Re: "clDevicePointer" function needed!

    I third this!

  4. #4
    Member
    Join Date
    Oct 2010
    Location
    Vancouver, Canada
    Posts
    63

    Re: "clDevicePointer" function needed!

    Why not use indices instead of pointers? This way they are independent of buffer location, devices, address spaces, etc. The same index could be applied to multiple buffers. Index size can be chosen based on data size in order to optimize its storage (i.e. 8, 16, 32, or 64 bit -- or even encoded into a large field as an arbitrary number of bits). The index can also be in terms of structure size, or in terms of bytes (or something else).

  5. #5

    Re: "clDevicePointer" function needed!

    for the same reason that one wants to use a linked list: constant-time insertion and removal anywhere in the list.

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

    Re: "clDevicePointer" function needed!

    for the same reason that one wants to use a linked list: constant-time insertion and removal anywhere in the list.
    You can do that with offsets as well. Offsets and pointers are fundamentally the same thing.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Replies: 1
    Last Post: 02-29-2012, 06:34 PM
  2. include files using "I -dir" function
    By yakovm in forum OpenCL
    Replies: 3
    Last Post: 07-26-2011, 05:21 PM

Posting Permissions

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