1 Reply Latest reply on Nov 12, 2009 8:17 PM by Stib

    Extracting pointer to data from the cl::Buffer object

    dstokac

      We have a kernel

      __kernel kern(__global int* a_arg){},

      with argument a_arg initialized by

      kern_kernel.setArg(0, a_buf),

      where

      cl::Buffer a_buf(...).

       

      Is it possible to extract value of a_arg from a_buf?

       

        • Extracting pointer to data from the cl::Buffer object
          Stib

          If you want to do, what i think you want, then use:

          cl_int cl::CommandQueue::enqueueReadBuffer ( const Buffer & buffer, cl_bool blocking, ::size_t offset, ::size_t size, void * ptr, const VECTOR_CLASS< Event > * events = NULL, Event * event = NULL ) const [inline] Enqueue a command to read from a buffer object to host memory. Parameters: buffer refers to a valid buffer object. blocking indicates if the read operation is blocking or nonblocking. If blocking is CL_TRUE i.e. the read command is blocking, enqueueReadBuffer does not return until the buffer data has been read and copied into memory pointed to by ptr. If blocking is CL_FALSE i.e. the read command is non-blocking, enqueueReadBuffer queues a non-blocking read command and returns. The contents of the buffer that ptr points to cannot be used until the read command has completed. The event argument returns an event object which can be used to query the execution status of the read command. When the read command has completed, the contents of the buffer that ptr points to can be used by the application. offset is the offset in bytes in the buffer object to read from or write to. cb is the size in bytes of data being read or written. ptr is the pointer to buffer in host memory where data is to be read into or to be written from. events specifies events that need to complete before this particular command can be executed. If events is NULL, its default, then this particular command does not wait on any event to complete. The events specified in events act as synchronization points. event returns an event object that identifies this particular read command and can be used to query or queue a wait for this particular command to complete. event can be NULL, its default, in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. Returns: CL_SUCCESS if the function is executed successfully. Otherwise it returns one of the following errors: * CL_INVALID_CONTEXT if the context associated with command_queue and buffer are not the same. * CL_INVALID_MEM_OBJECT if buffer is not a valid buffer object. * CL_INVALID_VALUE if the region being read or written specified by (offset, size) is out of bounds or if ptr is a NULL value. * CL_INVALID_EVENT_WAIT_LIST if event objects in events are not valid events. * CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the runtime. Note: In the case that exceptions are enabled and error value other than CL_SUCCESS is generated, then cl::Error exception is generated.