示例#1
0
cl_int
clEnqueueNativeKernel(cl_command_queue  command_queue,
                      void (*user_func)(void *),
                      void *            args,
                      size_t            cb_args,
                      cl_uint           num_mem_objects,
                      const cl_mem *    mem_list,
                      const void **     args_mem_loc,
                      cl_uint           num_events_in_wait_list,
                      const cl_event *  event_wait_list,
                      cl_event *        event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::NativeKernelEvent *command = new Coal::NativeKernelEvent(
        (Coal::CommandQueue *)command_queue,
        user_func, args, cb_args, num_mem_objects,
        (const Coal::MemObject **)mem_list, args_mem_loc,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, false);
}
示例#2
0
// Enqueued Commands APIs
cl_int
clEnqueueReadBuffer(cl_command_queue    command_queue,
                    cl_mem              buffer,
                    cl_bool             blocking_read,
                    size_t              offset,
                    size_t              cb,
                    void *              ptr,
                    cl_uint             num_events_in_wait_list,
                    const cl_event *    event_wait_list,
                    cl_event *          event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::ReadBufferEvent *command = new Coal::ReadBufferEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::MemObject *)buffer,
        offset, cb, ptr,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, blocking_read);
}
示例#3
0
cl_int
clEnqueueNDRangeKernel(cl_command_queue command_queue,
                       cl_kernel        kernel,
                       cl_uint          work_dim,
                       const size_t *   global_work_offset,
                       const size_t *   global_work_size,
                       const size_t *   local_work_size,
                       cl_uint          num_events_in_wait_list,
                       const cl_event * event_wait_list,
                       cl_event *       event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
    {
        return CL_INVALID_COMMAND_QUEUE;
    }

    Coal::KernelEvent *command = new Coal::KernelEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::Kernel *)kernel,
        work_dim, global_work_offset, global_work_size, local_work_size,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, false);
}
示例#4
0
cl_int
clEnqueueTask(cl_command_queue  command_queue,
              cl_kernel         kernel,
              cl_uint           num_events_in_wait_list,
              const cl_event *  event_wait_list,
              cl_event *        event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
    {
        return CL_INVALID_COMMAND_QUEUE;
    }

    Coal::TaskEvent *command = new Coal::TaskEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::Kernel *)kernel,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, false);
}
示例#5
0
cl_int
clEnqueueUnmapMemObject(cl_command_queue command_queue,
                        cl_mem           memobj,
                        void *           mapped_ptr,
                        cl_uint          num_events_in_wait_list,
                        const cl_event *  event_wait_list,
                        cl_event *        event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
    {
        return CL_INVALID_COMMAND_QUEUE;
    }

    Coal::UnmapBufferEvent *command = new Coal::UnmapBufferEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::MemObject *)memobj,
        mapped_ptr,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, false);
}
示例#6
0
cl_int
clEnqueueCopyBufferToImage(cl_command_queue command_queue,
                           cl_mem           src_buffer,
                           cl_mem           dst_image,
                           size_t           src_offset,
                           const size_t *   dst_origin,
                           const size_t *   region,
                           cl_uint          num_events_in_wait_list,
                           const cl_event * event_wait_list,
                           cl_event *       event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::CopyBufferToImageEvent *command = new Coal::CopyBufferToImageEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::MemObject *)src_buffer, (Coal::Image2D *)dst_image,
        src_offset, dst_origin, region,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, false);
}
示例#7
0
cl_int
clEnqueueWriteImage(cl_command_queue    command_queue,
                    cl_mem              image,
                    cl_bool             blocking_write,
                    const size_t *      origin,
                    const size_t *      region,
                    size_t              row_pitch,
                    size_t              slice_pitch,
                    const void *        ptr,
                    cl_uint             num_events_in_wait_list,
                    const cl_event *    event_wait_list,
                    cl_event *          event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::WriteImageEvent *command = new Coal::WriteImageEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::Image2D *)image,
        origin, region, row_pitch, slice_pitch, (void *)ptr,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, blocking_write);
}
示例#8
0
cl_int
clRetainCommandQueue(cl_command_queue command_queue)
{
    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    command_queue->reference();

    return CL_SUCCESS;
}
示例#9
0
cl_int
clSetCommandQueueProperty(cl_command_queue              command_queue,
                          cl_command_queue_properties   properties,
                          cl_bool                       enable,
                          cl_command_queue_properties * old_properties)
{
    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    return command_queue->setProperty(properties, enable, old_properties);
}
示例#10
0
cl_int
clGetCommandQueueInfo(cl_command_queue      command_queue,
                      cl_command_queue_info param_name,
                      size_t                param_value_size,
                      void *                param_value,
                      size_t *              param_value_size_ret)
{
    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    return command_queue->info(param_name, param_value_size, param_value,
                               param_value_size_ret);
}
示例#11
0
cl_int
clReleaseCommandQueue(cl_command_queue command_queue)
{
    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    command_queue->flush();

    if (command_queue->dereference())
        delete command_queue;

    return CL_SUCCESS;
}
示例#12
0
cl_int
clReleaseCommandQueue(cl_command_queue command_queue)
{
    if (!command_queue->isA(Coal::Object::T_CommandQueue)) {
#ifdef DBG_OUTPUT
      std::cout << "clReleaseCommandQueue failed" << std::endl;
#endif
      return CL_INVALID_COMMAND_QUEUE;
    }

    command_queue->flush();

    if (command_queue->dereference())
        delete command_queue;

    return CL_SUCCESS;
}
示例#13
0
cl_int
clEnqueueBarrier(cl_command_queue command_queue)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::BarrierEvent *command = new Coal::BarrierEvent(
        (Coal::CommandQueue *)command_queue, &rs);

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, 0, false);
}
示例#14
0
cl_int
clEnqueueWaitForEvents(cl_command_queue command_queue,
                       cl_uint          num_events,
                       const cl_event * event_list)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::WaitForEventsEvent *command = new Coal::WaitForEventsEvent(
        (Coal::CommandQueue *)command_queue,
        num_events, (const Coal::Event **)event_list, &rs);

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, 0, false);
}
示例#15
0
cl_int
clEnqueueWriteBufferRect(cl_command_queue    command_queue,
                        cl_mem              buffer,
                        cl_bool             blocking_write,
                        const size_t *      buffer_origin,
                        const size_t *      host_origin,
                        const size_t *      region,
                        size_t              buffer_row_pitch,
                        size_t              buffer_slice_pitch,
                        size_t              host_row_pitch,
                        size_t              host_slice_pitch,
                        const void *        ptr,
                        cl_uint             num_events_in_wait_list,
                        const cl_event *    event_wait_list,
                        cl_event *          event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    Coal::WriteBufferRectEvent *command = new Coal::WriteBufferRectEvent(
        (Coal::CommandQueue *)command_queue,
        (Coal::MemObject *)buffer,
        buffer_origin, host_origin, region, buffer_row_pitch, buffer_slice_pitch,
        host_row_pitch, host_slice_pitch, (void *)ptr,
        num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
    );

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    return queueEvent(command_queue, command, event, blocking_write);
}
示例#16
0
cl_int
clEnqueueMarker(cl_command_queue    command_queue,
                cl_event *          event)
{
    cl_int rs = CL_SUCCESS;

    if (!command_queue->isA(Coal::Object::T_CommandQueue))
        return CL_INVALID_COMMAND_QUEUE;

    if (!event)
        return CL_INVALID_VALUE;

    // Get the events in command_queue
    unsigned int count;
    Coal::Event **events = command_queue->events(count);

    Coal::MarkerEvent *command = new Coal::MarkerEvent(
        (Coal::CommandQueue *)command_queue,
        count, (const Coal::Event **)events, &rs);

    if (rs != CL_SUCCESS)
    {
        delete command;
        return rs;
    }

    // Free events, they were memcpyed by Coal::Event
    for (unsigned int i=0; i<count; ++i)
    {
        events[i]->dereference();
    }

    std::free(events);

    return queueEvent(command_queue, command, event, false);
}