quadrants.profiler.kernel_metrics#

Classes#

CuptiMetric

A class to add CUPTI metric for KernelProfiler.

Functions#

get_predefined_cupti_metrics([name])

Returns the specified cupti metric.

Module Contents#

class quadrants.profiler.kernel_metrics.CuptiMetric(name='', header='unnamed_header', val_format='     {:8.0f} ', scale=1.0)[source]#

A class to add CUPTI metric for KernelProfiler.

This class is designed to add user selected CUPTI metrics. Only available for the CUDA backend now, i.e. you need ti.init(kernel_profiler=True, arch=ti.cuda). For usage of this class, see examples in func set_kernel_profiler_metrics() and collect_kernel_profiler_metrics().

Parameters:
  • name (str) – name of metric that collected by CUPTI toolkit. used by set_kernel_profiler_metrics() and collect_kernel_profiler_metrics().

  • header (str) – column header of this metric, used by print_kernel_profiler_info().

  • val_format (str) – format for print metric value (and unit of this value), used by print_kernel_profiler_info().

  • scale (float) – scale of metric value, used by print_kernel_profiler_info().

Example:

>>> import quadrants as ti

>>> ti.init(kernel_profiler=True, arch=ti.cuda)
>>> num_elements = 128*1024*1024

>>> x = ti.field(ti.f32, shape=num_elements)
>>> y = ti.field(ti.f32, shape=())
>>> y[None] = 0

>>> @ti.kernel
>>> def reduction():
>>>     for i in x:
>>>         y[None] += x[i]

>>> global_op_atom = ti.profiler.CuptiMetric(
>>>     name='l1tex__t_set_accesses_pipe_lsu_mem_global_op_atom.sum',
>>>     header=' global.atom ',
>>>     val_format='    {:8.0f} ')

>>> # add and set user defined metrics
>>> profiling_metrics = ti.profiler.get_predefined_cupti_metrics('global_access') + [global_op_atom]
>>> ti.profiler.set_kernel_profile_metrics(profiling_metrics)

>>> for i in range(16):
>>>     reduction()
>>> ti.profiler.print_kernel_profiler_info('trace')

Note

For details about using CUPTI in Quadrants, please visit https://docs.taichi-lang.org/docs/profiler#advanced-mode.

name = ''[source]#
header = 'unnamed_header'[source]#
val_format = '     {:8.0f} '[source]#
scale = 1.0[source]#
quadrants.profiler.kernel_metrics.get_predefined_cupti_metrics(name='')[source]#

Returns the specified cupti metric.

Accepted arguments are ‘global_access’, ‘shared_access’, ‘atomic_access’, ‘cache_hit_rate’, ‘device_utilization’.

Parameters:

name (str) – cupti metri name.