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

[doc] Better clarify the difference between two profilers #1759

Merged
merged 6 commits into from
Aug 28, 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
48 changes: 27 additions & 21 deletions docs/profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,74 @@
Profiler
========

Taichi's profiler can help you analyze the run-time cost of your program. There are two profiling systems in Taichi: ``ScopedProfiler`` and ``KernelProfiler``.
Taichi's profiler can help you analyze the run-time cost of your program. There are two profiling systems in Taichi: ``KernelProfiler`` and ``ScopedProfiler``.

ScopedProfiler
``KernelProfiler`` is used to analyze the performance of user kernels.

While ``ScopedProfiler`` is used by Taichi developers to analyze the
performance of the compiler itself.

KernelProfiler
##############

1. ``ScopedProfiler`` measures time spent on the **host tasks** hierarchically.
1. ``KernelProfiler`` records the costs of Taichi kernels on devices. To enable this profiler, set ``kernel_profiler=True`` in ``ti.init``.

2. This profiler is automatically on. To show its results, call ``ti.print_profile_info()``. For example:
2. Call ``ti.kernel_profiler_print()`` to show the kernel profiling result. For example:

.. code-block:: python
:emphasize-lines: 3, 13

import taichi as ti

ti.init(arch=ti.cpu)
ti.init(ti.cpu, kernel_profiler=True)
var = ti.field(ti.f32, shape=1)


@ti.kernel
def compute():
var[0] = 1.0
print("Setting var[0] =", var[0])


compute()
ti.print_profile_info()
ti.kernel_profiler_print()


``ti.print_profile_info()`` prints profiling results in a hierarchical format.
The outputs would be:

.. Note::
::

``ScopedProfiler`` is a C++ class in the core of Taichi. It is not exposed to Python users.
[ 22.73%] jit_evaluator_0_kernel_0_serial min 0.001 ms avg 0.001 ms max 0.001 ms total 0.000 s [ 1x]
[ 0.00%] jit_evaluator_1_kernel_1_serial min 0.000 ms avg 0.000 ms max 0.000 ms total 0.000 s [ 1x]
[ 77.27%] compute_c4_0_kernel_2_serial min 0.004 ms avg 0.004 ms max 0.004 ms total 0.000 s [ 1x]

KernelProfiler

ScopedProfiler
##############

1. ``KernelProfiler`` records the costs of Taichi kernels on devices. To enable this profiler, set ``kernel_profiler=True`` in ``ti.init``.
1. ``ScopedProfiler`` measures time spent on the **host tasks** hierarchically.

2. Call ``ti.kernel_profiler_print()`` to show the kernel profiling result. For example:
2. This profiler is automatically on. To show its results, call ``ti.print_profile_info()``. For example:

.. code-block:: python
:emphasize-lines: 3, 13

import taichi as ti

ti.init(ti.cpu, kernel_profiler=True)
ti.init(arch=ti.cpu)
var = ti.field(ti.f32, shape=1)


@ti.kernel
def compute():
var[0] = 1.0
print("Setting var[0] =", var[0])


compute()
ti.kernel_profiler_print()
ti.print_profile_info()


The outputs would be:
``ti.print_profile_info()`` prints profiling results in a hierarchical format.

::
.. Note::

[ 22.73%] jit_evaluator_0_kernel_0_serial min 0.001 ms avg 0.001 ms max 0.001 ms total 0.000 s [ 1x]
[ 0.00%] jit_evaluator_1_kernel_1_serial min 0.000 ms avg 0.000 ms max 0.000 ms total 0.000 s [ 1x]
[ 77.27%] compute_c4_0_kernel_2_serial min 0.004 ms avg 0.004 ms max 0.004 ms total 0.000 s [ 1x]
``ScopedProfiler`` is a C++ class in the core of Taichi. It is not exposed to Python users.
2 changes: 1 addition & 1 deletion docs/sparse.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _sparse:

Sparse computation (WIP)
===============================================
========================

.. warning::

Expand Down
2 changes: 2 additions & 0 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _syntax:

Kernels and functions
=====================

Expand Down
2 changes: 1 addition & 1 deletion docs/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Implicit casts
The type of a variable is **determinated on it's initialization**.

When a *low-precision* variable is assigned to a *high-precision* variable, it will be
implicitly promoted to the *wide* type and no warning will be raised:
implicitly promoted to the *high-precision* type and no warning will be raised:

.. code-block:: python

Expand Down
1 change: 1 addition & 0 deletions taichi/backends/cc/runtime/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static inline Ti_f32 Ti_rand_f32(void) {
return (Ti_f32) drand48(); // [0.0, 1.0)
}

) "\n" STR(
)

#define _CC_INSIDE_KERNEL
Expand Down
2 changes: 1 addition & 1 deletion taichi/transforms/reverse_segments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void reverse_segments(IRNode *root) {
"Invalid program input for autodiff. Please check the documentation "
"for the \"Kernel Simplicity Rule\":\n"
"https://taichi.readthedocs.io/en/stable/"
"autodiff.html#simplicity_rule");
"differentiable_programming.html#simplicity_rule");
for (auto &sblock : statement_blocks) {
for (auto &&s : sblock) {
block->statements.push_back(std::move(s));
Expand Down