dpctl.SyclTimer

class dpctl.SyclTimer(host_timer=timeit.default_timer, time_scale=1)[source]

Python class to measure device time of execution of commands submitted to dpctl.SyclQueue as well as the wall-time.

Example:
import dpctl

# Create a default SyclQueue
q = dpctl.SyclQueue(property='enable_profiling')

# create the timer
milliseconds_sc = 1e-3
timer = dpctl.SyclTimer(time_scale = milliseconds_sc)

# use the timer
with timer(queue=q):
    code_block

# retrieve elapsed times in milliseconds
wall_dt, device_dt = timer.dt
Remark:

The timer submits barriers to the queue at the entrance and the exit of the context and uses profiling information from events associated with these submissions to perform the timing. Thus dpctl.SyclTimer requires the queue with “enable_profiling” property. In order to be able to collect the profiling information the property dt ensures that both submitted barriers complete their execution and thus effectively synchronizing the queue.

Parameters:
  • host_timer (callable) – A callable such that host_timer() returns current host time in seconds.

  • time_scale (int, float) – Ratio of the unit of time of interest and one second.

Attributes:

dt

Returns a pair of elapsed times (host_dt, device_dt).

Attributes

SyclTimer.dt

Returns a pair of elapsed times (host_dt, device_dt).

The host_dt is the duration as measured by the host timer, while the device_dt is the duration as measured by the device timer and encoded in profiling events.