Skip to content
Damien L-G edited this page Oct 24, 2023 · 51 revisions

Kokkos Tools

Kokkos Tools provide a light weight set of profiling and debug utilities, which interface with instrumentation hooks built directly into the Kokkos runtime. Compared to 3rd party tools, these tools can provide much cleaner, context specific information: in particular, the tools allow kernel-centric analysis and they use labels provided to Kokkos objects (kernel launches and views).

Under most circumstances, the profiling hooks are compiled into Kokkos executables by default. That means the tools work for your existing Kokkos application programs, assuming that the version for the profiling hooks is compatible with the tools version. No recompilation or changes to your build procedures are required.

Note: Kokkos_ENABLE_LIBDL must be on to load profiling hooks dynamically. It should be on by default, however.

General Usage

To use one of the tools, you have to compile it, which will generate a dynamic library. Before executing the Kokkos application, you then have to set the environment variable KOKKOS_TOOLS_LIBS to point to the dynamic library e.g. in Bash:

export KOKKOS_TOOLS_LIBS=${HOME}/kokkos-tools/src/tools/memory-events/kp_memory_event.so

and then run your application normally, e.g., in Bash:

myKokkosApp.exe;

Alternative to the environment variable, one can pass a parameterized flag to a Kokkos program executable --kokkos-tools-library, e.g., in Bash:

myApp.exe --kokkos-tools-library=${HOME}/kokkos-tools/src/tools/memory-events/kp_memory_event.so 

Many of the tools of Kokkos Tools will produce an output file which uses the hostname as well as the process id as part of the filename.

Explicit Instrumentation

One can explicitly add instrumentation to a library or an application. Currently, the only hooks intended for explicit programmer use are the region-related and section-related hooks. These use a push/pop model to mark coarser regions in your code.

void foo() {
   Kokkos::Profiling::pushRegion("foo");
   bar();
   stool();
   Kokkos::Profiling::popRegion();
}

Tools

Utilities

  • KernelFilter:

    A tool which is used in conjunction with analysis tools, to restrict them to a subset of the application.

Memory Analysis

  • MemoryHighWater:

    Outputs high water mark of memory usage of the application.

  • MemoryUsage:

    Generates a per Memory Space timeline of memory utilization.

  • MemoryEvents:

    Tool to track memory events such as allocation and deallocation. It also provides the information of the MemoryUsage tool.

Kernel Inspection

3rd Party Profiling Tool Hooks

Vendor-provided

  • nvprofConnector Provides Kernel Names to nvprof, so that analysis can be performed on a per kernel base. This will soon be called the nvtxconnector.

  • rocmConnector Provides Kernel Names to Rocm, so that analysis can be performed on a per kernel base.

  • VTuneConnector:

    Provides Kernel Names to VTune, so that analysis can be performed on a per kernel base.

  • VTuneFocusedConnector:

    Like VTuneConnector but turns profiling off outside of kernels. Should be used in conjunction with the KernelFilter tool.

Open-source

  • Timemory:

    Modular connector for accumulating timing, memory usage, hardware counters, and other various metrics. Supports controlling VTune, CUDA profilers, and TAU + kernel name forwarding to VTune, NVTX, TAU, Caliper, and LIKWID.

    If you need to write your own plug-in, this provides a straight-forward API to writing the plug-in.

    Defining a timemory component will enable your plug-in to output to stdout, text, and JSON, accumulate statistics, and utilize various portable function calls for common needs w.r.t. timers, resource usage, etc.

Automated Tuning

  • Apex: This is a tool for automated tuning of a large variety of programming models and languages. It is available as a submodule in the Kokkos Tools git repository. It has a hook for Kokkos and sophisticated mechanisms to tune parameters of Kokkos functions' parameters, e.g., the team size in a Kokkos parallel_for. See Apex for more information.

Automated Analysis

  • Caliper: This is a tool for automated tuning of a large variety of programming models and languages. It is available as a git submodule in the Kokkos Tools git repository. It has a hook for Kokkos and sophisticated mechanisms to tune parameters of Kokkos functions' parameters. See Caliper for more information.

Profile Data Sampling

  • Sampler for LDMS: This is a tool for sampling of data from the Lightweight Data Monitoring System developed at Sandia National Laboratories. It is a Kokkos Tools connector that invokes functions of LDMS to extract profiling data samples from a Kokkos application program.

Contributing

The Kokkos Tools developers welcome contributions from developers and users of Kokkos alike. We welcome contributions, particularly in the form of:

  1. Developing and improving on existing tools in the set of Kokkos Tools (each tool is a connector)
  2. Creating and contributing a new tool (connector) to add to the set of tools
  3. Improving documentation for Kokkos Tools
  4. Providing experiences of your Kokkos program use cases when using Kokkos Tools, telling about a success stories and/or failures with respect to Kokkos Tools.

The Kokkos Tools developers have (1) general guidelines and overview of development in Kokkos Tools and (2) specific guidelines and tips for contributing via each of the four ways listed. The wiki page for the general guidelines is here and the wiki pages for specific guidelines are referenced in the paragraphs below.

For items 1 and 2, one contributes by first identifying the problem by creating a Github Issue in the Kokkos Tools repo at github.com/kokkos/kokkos-tools/issues/ and then provides a suggested solution to the Github Issue via a PR against the develop branch of the Kokkos Tools repo.

For 3 and 4, please email [email protected] and [email protected] or, if you can, provide suggestions to the slack channel. For 3, you can also submit a PR for the files involving documentation in the Kokkos Tools repo, e.g., README.md, Build.md. For 4, if appropriate, the Kokkos Tools developers will showcase them in Kokkos Tools tutorials and other presentations, with your permission.

SAND2017-3786 W

Clone this wiki locally