dpctl.SyclQueue¶
- class dpctl.SyclQueue(*args, **kwargs)¶
Python class representing
sycl::queue.There are multiple ways to create a
dpctl.SyclQueueobject:Invoking the constructor with no arguments creates a context using the default selector.
- Example:
import dpctl # Create a default SyclQueue q = dpctl.SyclQueue() print(q.sycl_device)
Invoking the constructor with specific filter selector string that creates a queue for the device corresponding to the filter string.
- Example:
import dpctl # Create in-order SyclQueue for either gpu, or cpu device q = dpctl.SyclQueue("gpu,cpu", property="in_order") print([q.sycl_device.is_gpu, q.sycl_device.is_cpu])
Invoking the constructor with a
dpctl.SyclDeviceobject creates a queue for that device, automatically finding/creating adpctl.SyclContextfor the given device.
- Example:
import dpctl d = dpctl.SyclDevice("gpu") q = dpctl.SyclQueue(d) ctx = q.sycl_context print(q.sycl_device == d) print(any([ d == ctx_d for ctx_d in ctx.get_devices()]))
Invoking the constructor with a
dpctl.SyclContextand adpctl.SyclDevicecreates a queue for given context and device.
- Example:
import dpctl # Create a CPU device using the opencl driver cpu_d = dpctl.SyclDevice("opencl:cpu") # Partition the CPU device into sub-devices with two cores each. sub_devices = cpu_d.create_sub_devices(partition=2) # Create a context common to all the sub-devices. ctx = dpctl.SyclContext(sub_devices) # create a queue for each sub-device using the common context queues = [dpctl.SyclQueue(ctx, sub_d) for sub_d in sub_devices]
Invoking the constructor with a named
PyCapsulewith the name “SyclQueueRef” that carries a pointer to asycl::queueobject. The capsule will be renamed upon successful consumption to ensure one-time use. A new named capsule can be constructed by usingdpctl.SyclQueue._get_capsule()method.
A queue can be pickled if its device is a root device and its context is the default context of that device. Unpickling creates or looks up a queue rather than restoring the original one:
a queue with default properties is restored as the cached queue of its device, as returned by
dpctl._sycl_queue_manager.get_device_cached_queue(). Distinct queues on the same device, and USM memory allocated on them, are all restored onto that one queue.a queue with
"in_order"or"enable_profiling"is restored as a new queue on every unpickling. Only objects pickled in onepickle.dumps()call that share adpctl.SyclQueueobject are restored onto one queue.the restored queue is equal to the original only if the original is the cached queue.
- Parameters:
ctx (
dpctl.SyclContext, optional) – Sycl context to createdpctl.SyclQueuefrom. If not specified, a single-device context will be created from the specified device.dev (str,
dpctl.SyclDevice, capsule, optional) –Sycl device to create
dpctl.SyclQueuefrom. If not specified, sycl device selected bysycl::default_selectoris used. The argument must be explicitly specified if ctxt argument is provided.If dev is a named
PyCapsulecalled “SyclQueueRef” and ctxt is not specified,dpctl.SyclQueueinstance is created from foreign sycl::queue object referenced by the capsule.property (str, tuple(str), list(str), optional) – Defaults to None. The argument can be either “default”, “in_order”, “enable_profiling”, or a tuple containing these.
- Raises:
SyclQueueCreationError – If the
dpctl.SyclQueueobject creation failed.TypeError – In case of incorrect arguments given to constructors, unexpected types of input arguments, or in the case the input capsule contained a null pointer or could not be renamed.
Methods
Returns the address of the C API
DPCTLSyclQueueRefpointer as integral value of typesize_t.copy(dest, src, count[, dtype])Copy
countelements of typedtypefromsrctodestand wait.copy_async(dest, src, count[, dEvents, dtype])Copy
countelements of typedtypefromsrctodestasynchronously.fill(dest, value, count[, dtype])Fill
destwithcountcopies ofvalueand wait.fill_async(dest, value, count[, dEvents, dtype])Fill
destwithcountcopies ofvalueasynchronously.Returns the event of the last command submitted to an in-order queue.
Returns
Trueif dpctl was built with a compiler that supports the DPC++sycl_ext_oneapi_in_order_queue_eventsextension used bydpctl.SyclQueue.get_last_event().keep_args_alive(args[, depends])Keeps objects in
argsalive until the work on this queue that uses them completes.mem_advise(mem, count, advice)memcpy(dest, src, count)Copy memory from src to dst
memcpy_async(dest, src, count[, dEvents])Copy memory from
srctodstmemset(mem, val[, count])Fill USM allocation
memwith the byte valuevaland wait.memset_async(mem, val[, count, dEvents])Fill USM allocation
memwith the byte valuevalasynchronously.prefetch(mem[, count])Print information about the SYCL device associated with this queue.
submit(kernel, args, gS[, lS, dEvents])Submit
dpctl.compiler.SyclKernelfor execution.submit_async(kernel, args, gS[, lS, dEvents])Asynchronously submit
dpctl.compiler.SyclKernelfor execution.submit_barrier([dependent_events])Submits a barrier to this queue.
wait()Attributes
Returns the
backend_typeenum value for this queue.Returns the driver version for the device associated with this queue.
TrueifSyclQueuewas constructed with"enabled_profiling"property,Falseotherwise.TrueifSyclQueue`is in-order,Falseif it is out-of-order.Returns the device name for the device associated with this queue.
Returns
SyclContextunderlying this queue.Returns
SyclDevicetargeted by this queue.