Results 1 to 4 of 4

Thread: where is stored my cl_mem

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

    where is stored my cl_mem

    Hi,

    OpenCL Programming Guide for Mac OS X say (page 34):
    In this example, the first read buffer is allocated with the CL_MEM_USE_HOST_PTR flag set. In contrast, the second read buffer is allocated with CL_MEM_COPY_HOST_PTR flag set. In both cases, you must also provide a pointer to your data. When the CL_MEM_USE_HOST_PTR flag is set, the OpenCL implementation has the option of caching the data on the OpenCL device, but it keeps the buffers on the two devices synchronized ; when that flag is not set, it always allocates the memory on the host device.
    I have trouble with the last sentence of the quote. Is it true that "no flag = cl_mem on the host memory" ?!

    If I create a buffer with :
    Code :
    memObj = clCreateBuffer(context, FLAG, sizeof(cl_float) * n, NULL, NULL);
    memory is allocated on the device memory, right ?

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Location
    California
    Posts
    6

    Re: where is stored my cl_mem

    I have trouble with the last sentence of the quote. Is it true that "no flag = cl_mem on the host memory" ?!
    If I understand what you are asking, the answer is NO. If you call something like:
    Code :
    clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * NUM_ELEMENTS, NULL, &err)
    this will tell OpenCL that you want to create space on the device. You must later populate this space with actual data, possibly with a call like this:
    Code :
    clEnqueueWriteBuffer(commands, input, CL_TRUE, 0, sizeof(float) * NUM_ELEMENTS, (void*) zeros, 0, NULL, NULL)
    Make sense? All calls to clCreateBuffer are about allocating space on the device, it's just a question of whether or not that space is populated by an existing host-side buffer (CL_MEM_COPY_HOST_PTR), or tied to and synchronized with an existing host-side buffer (CL_MEM_USE_HOST_PTR).

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Location
    California
    Posts
    6

    Re: where is stored my cl_mem

    To clarify; you were correct in your assumption that "no flag" concerning the buffer location when calling clCreateBuffer will allocate space on the device.

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    Re: where is stored my cl_mem

    ok thanks, that confirms what I thought.

Similar Threads

  1. Replies: 0
    Last Post: 12-19-2011, 05:07 PM
  2. Whare are the Buffer objects stored ??
    By Sayantan in forum OpenCL
    Replies: 2
    Last Post: 05-30-2011, 05:17 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
  •