taichi.profiler.kernelprofiler

Module Contents

Classes

StatisticalResult

Statistical result of records.

KernelProfiler

Kernel profiler of Taichi.

Functions

get_default_kernel_profiler()

We have only one KernelProfiler instance(i.e. _ti_kernel_profiler) now.

class taichi.profiler.kernelprofiler.StatisticalResult(name)

Statistical result of records.

Profiling records with the same kernel name will be counted in a StatisticalResult instance via function insert_record(time). Currently, only the kernel elapsed time is counted, other statistics related to the kernel will be added in the feature.

insert_record(self, time)

Insert records with the same kernel name.

Currently, only the kernel elapsed time is counted.

class taichi.profiler.kernelprofiler.KernelProfiler

Kernel profiler of Taichi.

Kernel profiler acquires kernel profiling records from backend, counts records in Python scope, and prints the results to the console by print_info().

KernelProfiler now support detailed low-level performance metrics (such as memory bandwidth consumption) in its advanced mode. This mode is only available for the CUDA backend with CUPTI toolkit, i.e. you need ti.init(kernel_profiler=True, arch=ti.cuda).

Note

For details about using CUPTI in Taichi, please visit https://docs.taichi.graphics/docs/lang/articles/misc/profiler#advanced-mode.

COUNT = count
TRACE = trace
set_kernel_profiler_mode(self, mode=False)

Turn on or off KernelProfiler.

get_kernel_profiler_mode(self)

Get status of KernelProfiler.

set_toolkit(self, toolkit_name='default')
get_total_time(self)

Get elapsed time of all kernels recorded in KernelProfiler.

Returns

total time in second.

Return type

time (float)

clear_info(self)

Clear all records both in front-end KernelProfiler and back-end instance KernelProfilerBase.

Note

The values of self._profiling_mode and self._metric_list will not be cleared.

query_info(self, name)

For docsting of this function, see query_kernel_profile_info().

set_metrics(self, metric_list=default_cupti_metrics)

For docsting of this function, see set_kernel_profile_metrics().

collect_metrics_in_context(self, metric_list=default_cupti_metrics)

This function is not exposed to user now.

For usage of this function, see collect_kernel_profile_metrics().

print_info(self, mode=COUNT)

Print the profiling results of Taichi kernels.

For usage of this function, see print_kernel_profile_info().

Parameters

mode (str) – the way to print profiling results.

taichi.profiler.kernelprofiler.get_default_kernel_profiler()

We have only one KernelProfiler instance(i.e. _ti_kernel_profiler) now.

For KernelProfiler using CuptiToolkit, GPU devices can only work in a certain configuration. Profiling mode and metrics are configured by the host(CPU) via CUPTI APIs, and device(GPU) will use its counter registers to collect specific metrics. So if there are multiple instances of KernelProfiler, the device will work in the latest configuration, the profiling configuration of other instances will be changed as a result. For data retention purposes, multiple instances will be considered in the future.