Ejemplo n.º 1
0
cl_int
clGetDeviceInfo(cl_device_id    device,
                cl_device_info  param_name,
                size_t          param_value_size,
                void *          param_value,
                size_t *        param_value_size_ret)
{
#ifdef DBG_API
  std::cerr << "clGetDeviceInfo\n";
#endif
    if (!device->isA(Coal::Object::T_Device))
        return CL_INVALID_DEVICE;

    Coal::DeviceInterface *iface = (Coal::DeviceInterface *)device;
    return iface->info(param_name, param_value_size, param_value,
                       param_value_size_ret);
}
Ejemplo n.º 2
0
// Command Queue APIs
cl_command_queue
clCreateCommandQueue(cl_context                     context,
                     cl_device_id                   device,
                     cl_command_queue_properties    properties,
                     cl_int *                       errcode_ret)
{
    cl_int default_errcode_ret;

    // No errcode_ret ?
    if (!errcode_ret)
        errcode_ret = &default_errcode_ret;

    if (!device->isA(Coal::Object::T_Device))
    {
        *errcode_ret = CL_INVALID_DEVICE;
        return 0;
    }

    if (!context->isA(Coal::Object::T_Context))
    {
        *errcode_ret = CL_INVALID_CONTEXT;
        return 0;
    }

    *errcode_ret = CL_SUCCESS;
    Coal::CommandQueue *queue = new Coal::CommandQueue(
                                        (Coal::Context *)context,
                                        (Coal::DeviceInterface *)device,
                                        properties,
                                        errcode_ret);

    if (*errcode_ret != CL_SUCCESS)
    {
        // Initialization failed, destroy context
        delete queue;
        return 0;
    }

    return (_cl_command_queue *)queue;
}
Ejemplo n.º 3
0
// Command Queue APIs
cl_command_queue
clCreateCommandQueue(cl_context                     context,
                     cl_device_id                   device,
                     cl_command_queue_properties    properties,
                     cl_int *                       errcode_ret)
{
#ifdef DBG_API
  std::cerr << "Entering clCreateCommandQueue\n";
#endif
    cl_int default_errcode_ret;

    // No errcode_ret ?
    if (!errcode_ret)
        errcode_ret = &default_errcode_ret;



#ifdef DBG_API
    std::cerr << "Check if the device is an object\n";
#endif
    if (!device->isA(Coal::Object::T_Device))
    {
      std::cerr << "INVALID_DEVICE\n";
        *errcode_ret = CL_INVALID_DEVICE;
        return 0;
    }

    if (!context->isA(Coal::Object::T_Context))
    {
#ifdef DBG_OUTPUT
      std::cout << "!!! ERROR: INVALID_CONTEXT" << std::endl;
#endif
      *errcode_ret = CL_INVALID_CONTEXT;
      return 0;
    }
#ifdef DBG_API
    std::cerr << "Attempt to initialise device\n";
#endif
    if (!device->init()) {
#ifdef DBG_OUTPUT
      std::cout << "!!!ERROR: Device initialisation failed!\n";
#endif
      *errcode_ret = CL_DEVICE_NOT_AVAILABLE;
      return 0;
    }

    *errcode_ret = CL_SUCCESS;
    Coal::CommandQueue *queue = new Coal::CommandQueue(
                                        (Coal::Context *)context,
                                        (Coal::DeviceInterface *)device,
                                        properties,
                                        errcode_ret);

    if (*errcode_ret != CL_SUCCESS)
    {
#ifdef DBG_OUTPUT
      std::cout << "!!! ERROR: CommandQueue create failed" << std::endl;
#endif
        // Initialization failed, destroy context
        delete queue;
        return 0;
    }

    return (_cl_command_queue *)queue;
}