You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Background
Previously, to add NVTX function annotation for profiling, one of the following methods is used:
```cpp
namespace kvikio::detail {
// Method 1
void f() {
KVIKIO_NVTX_FUNC_RANGE();
}
// Method 2
void f() {
KVIKIO_NVTX_SCOPED_RANGE("detail::f()", 0);
}
} // end namespace kvikio::detail
```
Method 1 has the limitation that:
- `__func__` is used as the function name, which is unqualified and contains no information on namespace. Function overloads cannot be well handled.
- Users cannot specify NVTX payload or color.
- There is no way to annotate a lambda. Any lambda is simply named `operator()`.
Method 2 has the limitation that:
- Users have to manually enter the function name. Naming inconsistency has been observed across different source files.
- Users have to specify an NVTX payload value.
## This PR
This PR eliminates the limitations above to improve the annotation experience. More concretely:
- `KVIKIO_NVTX_FUNC_RANGE()` now uses fully qualified name with namespace, return type and parameter types. Function overloads can be properly handled.
- `KVIKIO_NVTX_FUNC_RANGE()` now works for lambdas. For example, for a lambda inside a function `kvikio::sample::foo()`, the name of the lambda will be: `kvikio::sample::foo::<lambda()>`
- `KVIKIO_NVTX_FUNC_RANGE()` now accepts two optional parameters: payload and color.
- `KVIKIO_NVTX_SCOPED_RANGE()` now only has one mandatory parameter, which is the message; both the payload and color have become optional.
With the flexible `KVIKIO_NVTX_FUNC_RANGE()` available, **this PR adds additional traces to many functions**.
Authors:
- Tianyu Liu (https://github.com/kingcrimsontianyu)
Approvers:
- Mads R. B. Kristensen (https://github.com/madsbk)
URL: #671
0 commit comments