dpctl.utils

dpctl.utils.onetrace_enabled()[source]

Enable onetrace collection for kernels executed in this context.

Note

Proper working of this utility assumes that Python interpreter has been launched by onetrace or unitrace tool from project intel/pti-gpu.

Example:

Launch the Python interpreter using onetrace tool:

$ onetrace --conditional-collection -v -t --demangle python app.py

Now using the context manager in the Python sessions enables data collection and its output for every offloaded kernel:

import use_kernel as eg

import dpctl.memory as dpmem
from dpctl.utils import onetrace_enabled

x_dev = dpmem.MemoryUSMDevice(1024)

# onetrace output reporting on execution of the kernel
# should be seen, starting with "Device Timeline"
with onetrace_enabled():
    eg.run_kernel(x_dev)
dpctl.utils.intel_device_info(sycl_device)[source]

For Intel(R) GPU devices returns a dictionary with device architectural details, and an empty dictionary otherwise. The dictionary contains the following keys:

device_id:

32-bits device PCI identifier

gpu_eu_count:

Total number of execution units

gpu_hw_threads_per_eu:

Number of thread contexts in EU

gpu_eu_simd_width:

Physical SIMD width of EU

gpu_slices:

Total number of slices

gpu_subslices_per_slice:

Number of sub-slices per slice

gpu_eu_count_per_subslice:

Number of EUs in subslice

max_mem_bandwidth:

Maximum memory bandwidth in bytes/second

free_memory:

Global memory available on the device in units of bytes

Unsupported descriptors are omitted from the dictionary.

Descriptors other than the PCI identifier are supported only for SyclDevices with Level-Zero backend.

Note

Environment variable ZES_ENABLE_SYSMAN may need to be set to 1 for the "free_memory" key to be reported.

dpctl.utils.SequentialOrderManager

Thread-local object mapping each dpctl.SyclQueue to an order manager, used to ensure sequential ordering of offloaded tasks.

Record submitted tasks with add_event and use submitted_events as the dependency list of subsequent submissions. To keep Python objects referenced by a task alive until it completes, use dpctl.SyclQueue.keep_args_alive().

Record events that gate the release of objects used by a task with add_cleanup_event, and find them in cleanup_events. They are waited on, but never become dependencies of later tasks.

Waiting with wait also drops the references that dpctl.SyclQueue.keep_args_alive() took for tasks that have since completed, which dpctl otherwise does on a thread of its own. This is best-effort: references that thread is already dropping are left to it, so they may still be held when wait returns.

For an in-order queue, if dpctl.SyclQueue.is_get_last_event_available() is True, submitted_events also has the event of the last command submitted to the queue. That covers tasks submitted to the queue without being added to the order manager, e.g. by other threads, and may be the event of an empty kernel submitted by dpctl.SyclQueue.keep_args_alive(). wait, clear and thread exit wait for all work on the queue, including work submitted by other threads.

Deprecated since version 0.24.0: add_event_pair, host_task_events and num_host_task_events are deprecated. Tasks are no longer paired with a host task event, so add_event takes the computational event alone, and cleanup is tracked by add_cleanup_event, cleanup_events and num_cleanup_events.