-
Notifications
You must be signed in to change notification settings - Fork 76
Home
Kokkos Tools provides a collection of lightweight profiling and debugging utilities that interface with instrumentation hooks in the Kokkos runtime. Relative to vendor-specific tools such as NVTX or ROCTx, these utilities emphasize kernel-centric analysis and preserve application labels attached to Kokkos constructs (for example, kernel launches and Views).
Profiling hooks are compiled into Kokkos executables by default. Compatible applications can therefore load tools at runtime without recompilation or changes to the application build.
Requirement: Dynamic loading of tools requires Kokkos_ENABLE_LIBDL=ON in the Kokkos configuration (the default in most builds).
A typical workflow is:
- Build one or more tool shared libraries.
- Identify those libraries to the application via
KOKKOS_TOOLS_LIBSor--kokkos-tools-libs. - Set any tool-specific environment variables, then run the application.
Configure, build, and install with CMake (recommended):
cd ${YOUR_KTO_SRC_DIR}
mkdir -p mybuild && cd mybuild
cmake .. -DCMAKE_INSTALL_PREFIX=${YOUR_KTO_INSTALL}
make
make installLoad the sampler and memory-events libraries, configure sampling and fencing, and run:
export KOKKOS_TOOLS_LIBS="${YOUR_KTO_INSTALL}/lib/libkp_kokkos_sampler.so;${YOUR_KTO_INSTALL}/lib/libkp_memory_events.so"
export KOKKOS_TOOLS_SAMPLER_SKIP=1
export KOKKOS_TOOLS_GLOBALFENCES=1
./myKokkosApp.exeIn this configuration, KOKKOS_TOOLS_SAMPLER_SKIP=1 profiles every other Kokkos kernel invocation, and KOKKOS_TOOLS_GLOBALFENCES=1 inserts global fences so memory-event state is consistent at sampling points.
Many tools write output whose filenames incorporate the hostname and process ID.
To link or discover a particular Kokkos installation, pass -DKokkos_ROOT=${YOUR_KOKKOS_INSTALL} to CMake. This is especially important for connectors that depend on backend-specific APIs (for example, nvtx-connector).
As an alternative to the environment variable, Kokkos accepts a tools-library path on the application command line:
./myApp.exe --kokkos-tools-libs="${YOUR_KTO_INSTALL}/lib/libkp_memory_events.so"Per-tool Makefiles remain supported. Shared libraries are produced in each tool’s source directory (often named kp_*.so rather than libkp_*.so):
cd ${YOUR_KTO_SRC_DIR}/profiling/memory-events && make
cd ${YOUR_KTO_SRC_DIR}/common/kokkos-sampler && makeSet KOKKOS_TOOLS_LIBS to those generated library paths before running the application.
Applications and libraries may also call Kokkos profiling APIs directly. Region and section hooks use a push/pop model to delimit coarser scopes:
void foo() {
Kokkos::Profiling::pushRegion("foo");
bar();
stool();
Kokkos::Profiling::popRegion();
}- KernelFilter — Restricts analysis tools to a selected subset of Kokkos kernels and regions.
- KernelSampler — Restricts analysis tools to sampled Kokkos kernel invocations.
- MemoryHighWater — Reports the high-water mark of application memory usage.
- MemoryUsage — Produces a per–memory-space timeline of utilization and transfers.
- MemoryEvents — Tracks allocations and deallocations, and provides MemoryUsage-style information.
- Space Time Stack — Reports nested, stack-based timing and memory usage across kernels and regions.
- SimpleKernelTimer — Captures basic kernel timing information.
- KernelLogger — Prints Kokkos kernel and region events at runtime.
- Chrome Tracing — Emits Chrome trace events for timeline visualization.
- Perfetto — Emits Perfetto trace data for system- and application-level analysis.
- nvtxConnector — Forwards Kokkos kernel names to NVTX for per-kernel analysis (formerly nvprof-connector).
- nvtxFocusedConnector — As nvtxConnector, with profiling disabled for filtered-out kernels; intended for use with KernelFilter (formerly nvprof-focused-connector).
- roctxConnector — Forwards Kokkos kernel names to ROCTx for per-kernel analysis.
- VTuneConnector — Forwards Kokkos kernel names to Intel VTune.
- VTuneFocusedConnector — As VTuneConnector, with profiling disabled for filtered-out kernels; intended for use with KernelFilter.
- Timemory — Modular connector for timing, memory usage, hardware counters, and related metrics, with optional control of, or name forwarding to, VTune, CUDA profilers, TAU, NVTX, Caliper, and LIKWID. Timemory components may also be used as a basis for custom plug-ins with stdout, text, and JSON output.
-
PAPI — Connector for PAPI hardware-counter collection (
KokkosTools_ENABLE_PAPI). -
SystemTap — Connector for SystemTap-based probing (
KokkosTools_ENABLE_SYSTEMTAP). -
Variorum — Connector for Variorum power and energy interfaces (
KokkosTools_ENABLE_VARIORUM). - Score-P — Connector for Score-P instrumentation and analysis (documented on the wiki).
-
Apex — Autotuning framework with Kokkos support; available via submodule (
KokkosTools_ENABLE_APEX). Supports tuning of Kokkos execution parameters such as team size. - Apollo — Complements Apex with ML-guided tuning of performance parameters (documented on the wiki).
-
Caliper — Performance-analysis framework with Kokkos support (
KokkosTools_ENABLE_CALIPER).
- LDMS connector — Integrates with the Lightweight Distributed Metric Service (LDMS) for HPC system monitoring (documented on the wiki).
- Energy profiler — Utility for energy-oriented monitoring of Kokkos applications.
Kokkos Tools combines connectors developed by the Kokkos team with contributions from the broader community. Contributions are encouraged in the following areas:
- Improvements to existing tools (connectors)
- New tools (connectors)
- Documentation
- Experience reports from production Kokkos applications (successes and limitations)
For items 1 and 2, open a GitHub issue and submit a pull request against develop.
For items 3 and 4, contact vlkale@sandia.gov and crtrott@sandia.gov, raise the topic on the Kokkos Team Slack when available, or open a documentation pull request (for example to README.md or Build.md). With contributor permission, representative case studies may be included in tutorials and presentations.
Additional guidance: General Development and Submitting a Pull Request.
- NERSC 2024 Advanced Kokkos Tutorial (slides and recording): https://www.nersc.gov/users/training/past-training-events/2024/portability-series-kokkos-apr2024/
- Overview slides: https://github.com/kokkos/kokkos-tutorials/blob/main/Profiling/Kokkos-Profiling.pdf
- In-depth presentation: https://www.youtube.com/watch?v=MH6zFYGw0HU
- Tutorial materials: https://github.com/kokkos/kokkos-tutorials
Additional tooling support for Kokkos includes:
- HPCToolkit for Kokkos — John Mellor-Crummey (johnmc@rice.edu)
- TAU support for Kokkos — Sameer Shende (sameer@cs.uoregon.edu)
- Automated testing of Kokkos programs — Vivek Kale (vlkale@sandia.gov)
- Examples: https://github.com/DavidPoliakoff/kokkos-tools-examples
- Project overview: https://kokkos.org
- Related discussion (nsys/ncu): https://github.com/NVIDIA/TensorRT-LLM/issues/183
SAND2017-3786