コード例 #1
0
ファイル: api_device.cpp プロジェクト: grubbymits/esdg-opencl
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);
}
コード例 #2
0
ファイル: api_command.cpp プロジェクト: jakebolewski/clover
// 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;
}
コード例 #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;
}