clGetDeviceAndHostTimer: Some(cl_get_device_and_host_timer),
clGetHostTimer: Some(cl_get_host_timer),
clGetKernelSubGroupInfo: Some(cl_get_kernel_sub_group_info),
- clSetDefaultDeviceCommandQueue: None,
+ clSetDefaultDeviceCommandQueue: Some(cl_set_default_device_command_queue),
clSetProgramReleaseCallback: Some(cl_set_program_release_callback),
clSetProgramSpecializationConstant: Some(cl_set_program_specialization_constant),
clCreateBufferWithProperties: Some(cl_create_buffer_with_properties),
extern "C" fn cl_create_command_queue_with_properties(
context: cl_context,
device: cl_device_id,
- _arg3: *const cl_queue_properties,
+ properties: *const cl_queue_properties,
errcode_ret: *mut cl_int,
) -> cl_command_queue {
- // TODO use own impl, this is enough to run the CL 3.0 CTS
- match_obj!(create_command_queue(context, device, 0), errcode_ret)
+ match_obj!(
+ create_command_queue_with_properties(context, device, properties),
+ errcode_ret
+ )
}
extern "C" fn cl_create_pipe(
))
}
+extern "C" fn cl_set_default_device_command_queue(
+ context: cl_context,
+ device: cl_device_id,
+ command_queue: cl_command_queue,
+) -> cl_int {
+ match_err!(set_default_device_command_queue(
+ context,
+ device,
+ command_queue,
+ ))
+}
+
extern "C" fn cl_set_program_release_callback(
program: cl_program,
pfn_notify: ::std::option::Option<ProgramCB>,
+extern crate mesa_rust_util;
extern crate rusticl_opencl_gen;
use crate::api::event::create_and_queue;
use crate::core::event::*;
use crate::core::queue::*;
+use self::mesa_rust_util::properties::*;
use self::rusticl_opencl_gen::*;
+use std::ptr;
use std::sync::Arc;
impl CLInfo<cl_command_queue_info> for cl_command_queue {
let ptr = Arc::as_ptr(&queue.device);
cl_prop::<cl_device_id>(cl_device_id::from_ptr(ptr))
}
+ CL_QUEUE_DEVICE_DEFAULT => cl_prop::<cl_command_queue>(ptr::null_mut()),
CL_QUEUE_PROPERTIES => cl_prop::<cl_command_queue_properties>(queue.props),
+ CL_QUEUE_PROPERTIES_ARRAY => {
+ cl_prop::<&Option<Properties<cl_queue_properties>>>(&queue.props_v2)
+ }
CL_QUEUE_REFERENCE_COUNT => cl_prop::<cl_uint>(self.refcnt()?),
+ // clGetCommandQueueInfo, passing CL_QUEUE_SIZE Returns CL_INVALID_COMMAND_QUEUE since
+ // command_queue cannot be a valid device command-queue.
+ CL_QUEUE_SIZE => return Err(CL_INVALID_COMMAND_QUEUE),
// CL_INVALID_VALUE if param_name is not one of the supported values
_ => return Err(CL_INVALID_VALUE),
})
properties & !valid_flags == 0
}
-pub fn create_command_queue(
+pub fn create_command_queue_impl(
context: cl_context,
device: cl_device_id,
properties: cl_command_queue_properties,
+ properties_v2: Option<Properties<cl_queue_properties>>,
) -> CLResult<cl_command_queue> {
- // CL_INVALID_CONTEXT if context is not a valid context.
let c = context.get_arc()?;
-
- // CL_INVALID_DEVICE if device is not a valid device
let d = device.get_arc()?;
- // ... or is not associated with context.
+ // CL_INVALID_DEVICE if device [...] is not associated with context.
if !c.devs.contains(&d) {
return Err(CL_INVALID_DEVICE);
}
return Err(CL_INVALID_QUEUE_PROPERTIES);
}
- Ok(cl_command_queue::from_arc(Queue::new(c, d, properties)?))
+ Ok(cl_command_queue::from_arc(Queue::new(
+ c,
+ d,
+ properties,
+ properties_v2,
+ )?))
+}
+
+pub fn create_command_queue(
+ context: cl_context,
+ device: cl_device_id,
+ properties: cl_command_queue_properties,
+) -> CLResult<cl_command_queue> {
+ create_command_queue_impl(context, device, properties, None)
+}
+
+pub fn create_command_queue_with_properties(
+ context: cl_context,
+ device: cl_device_id,
+ properties: *const cl_queue_properties,
+) -> CLResult<cl_command_queue> {
+ let c = context.get_arc()?;
+ let d = device.get_arc()?;
+
+ let mut queue_properties = cl_command_queue_properties::default();
+ let properties = if properties.is_null() {
+ None
+ } else {
+ let properties = Properties::from_ptr(properties).ok_or(CL_INVALID_PROPERTY)?;
+
+ for (k, v) in &properties.props {
+ match *k as cl_uint {
+ CL_QUEUE_PROPERTIES => queue_properties = *v,
+ // CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not
+ // supported by the device.
+ CL_QUEUE_SIZE => return Err(CL_INVALID_QUEUE_PROPERTIES),
+ _ => return Err(CL_INVALID_PROPERTY),
+ }
+ }
+
+ Some(properties)
+ };
+
+ Ok(cl_command_queue::from_arc(Queue::new(
+ c,
+ d,
+ queue_properties,
+ properties,
+ )?))
}
pub fn enqueue_marker(command_queue: cl_command_queue, event: *mut cl_event) -> CLResult<()> {
-extern crate mesa_rust;
+extern crate mesa_rust_util;
extern crate rusticl_opencl_gen;
use crate::api::icd::*;
use crate::core::event::*;
use crate::impl_cl_type_trait;
+use self::mesa_rust_util::properties::*;
use self::rusticl_opencl_gen::*;
use std::sync::mpsc;
pub context: Arc<Context>,
pub device: Arc<Device>,
pub props: cl_command_queue_properties,
+ pub props_v2: Option<Properties<cl_queue_properties>>,
pending: Mutex<Vec<Arc<Event>>>,
_thrd: Option<JoinHandle<()>>,
chan_in: mpsc::Sender<Vec<Arc<Event>>>,
context: Arc<Context>,
device: Arc<Device>,
props: cl_command_queue_properties,
+ props_v2: Option<Properties<cl_queue_properties>>,
) -> CLResult<Arc<Queue>> {
// we assume that memory allocation is the only possible failure. Any other failure reason
// should be detected earlier (e.g.: checking for CAPs).
context: context,
device: device,
props: props,
+ props_v2: props_v2,
pending: Mutex::new(Vec::new()),
_thrd: Some(
thread::Builder::new()