context(device const &d, cl_context_properties *props = 0) { OVXX_PRECONDITION(d.id() != 0); cl_device_id id = d.id(); cl_int status; impl_ = clCreateContext(props, 1, &id, context::callback, this, &status); if (status < 0) OVXX_DO_THROW(exception("clCreateContext", status)); }
T get_work_group_info(const device &device, cl_kernel_work_group_info info) { T value; cl_int ret = clGetKernelWorkGroupInfo(m_kernel, device.id(), info, sizeof(T), &value, 0); if(ret != CL_SUCCESS){ BOOST_THROW_EXCEPTION(runtime_exception(ret)); } return value; }
device default_device() { static device dev; if (!dev.id()) { platform pl = default_platform(); std::vector<device> devices = pl.devices(device::accelerator); if (devices.size()) dev = devices[0]; else // no accelerators found, try all { std::vector<device> devices = pl.devices(device::all); if (devices.size()) dev = devices[0]; else OVXX_DO_THROW(std::runtime_error("No OpenCL devices found.")); } } return dev; }
cl::queue::queue(const context &__context, const device &__device) throw(cl_exception) : queue(__context.id(),__device.id()) { }
T get_build_info(cl_program_build_info info, const device &device) const { return detail::get_object_info<T>(clGetProgramBuildInfo, m_program, info, device.id()); }