Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[async] Add ti.misc.util.print_async_stats #2095

Merged
merged 2 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/mpm_lagrangian_forces.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import taichi as ti
import numpy as np

ti.init(arch=ti.gpu, kernel_profiler=True)
ti.init(arch=ti.gpu)

dim = 2
quality = 1 # Use a larger integral number for higher quality
Expand Down
1 change: 0 additions & 1 deletion python/taichi/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
'a.normalized()')(Matrix.normalized)

cfg = default_cfg()
current_cfg = current_cfg()
x86_64 = core.x64
x64 = core.x64
arm64 = core.arm64
Expand Down
18 changes: 18 additions & 0 deletions python/taichi/misc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,24 @@ def get_kernel_stats():
return ti_core.get_kernel_stats()


def print_async_stats(include_kernel_profiler=False):
import taichi as ti
if include_kernel_profiler:
ti.kernel_profiler_print()
print()
stat = ti.get_kernel_stats()
counters = stat.get_counters()
print('=======================')
print('Async benchmark metrics')
print('-----------------------')
print(f'Async mode: {ti.current_cfg().async_mode}')
print(f'Kernel time: {ti.kernel_profiler_total_time():.3f} s')
print(f'Tasks launched: {int(counters["launched_tasks"])}')
print(f'Instructions emitted: {int(counters["codegen_statements"])}')
print(f'Tasks compiled: {int(counters["codegen_offloaded_tasks"])}')
print('=======================')


__all__ = [
'vec',
'veci',
Expand Down