taichi.profiler.kernel_metrics
#
- class taichi.profiler.kernel_metrics.CuptiMetric(name='', header='unnamed_header', val_format=' {:8.0f} ', scale=1.0)#
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 funcset_kernel_profiler_metrics()
andcollect_kernel_profiler_metrics()
.- Parameters:
name (str) – name of metric that collected by CUPTI toolkit. used by
set_kernel_profiler_metrics()
andcollect_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 taichi 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 Taichi, please visit https://docs.taichi-lang.org/docs/profiler#advanced-mode.
- taichi.profiler.kernel_metrics.get_predefined_cupti_metrics(name='')#
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.