Kokkos

View inspection

Linaro DDT provides a pretty printer to inspect C++ Kokkos::View variables when using Kokkos version 5.x with the CUDA device backend. The pretty printer is used automatically to present Kokkos::View data in a more understandable format.

The format includes the underlying data type of the view and the extent of each dimension. Dynamic extents will be resolved at runtime. For example, Linaro DDT will display Kokkos::View<double[10][3]> for a view that is declared as Kokkos::View<double*[3]> v("v", 10) in the source code.

You can inspect individual Kokkos::View elements using the special at(indices...) method provided by the pretty printer, which mirrors the behavior of the Kokkos::View::operator(). For example, you can add the expression v.at(1,1) in the Evaluate window to print the same element that you would access with v(1,1) in the source code.

The at(indices...) method can also be used in tracepoint variables to log individual view element values or in the condition expression of conditional breakpoints.

There is partial support of the Multi-Dimensional Array Viewer (MDA). You can use the MDA to inspect all elements of a Kokkos::View. For example, to inspect above view enter v.at($i,$j) as the Array Expression, then configure the Ranges and press Evaluate. Visualizing elements of a Kokkos::View is currently not supported. See Known issues and limitations for a full list of known MDA limitations.

Dual View inspection

Linaro DDT allows inspecting a C++ Kokkos::DualView by expanding its attributes, which are Kokkos::View objects using the above pretty printer. A Kokkos::DualView has the following attributes d_view (view instance on the device), h_view (view instance on the host) and modified_flags (tracks host and device modification state).

For example, to inspect a device view element you can use dual_view.d_view.at(indices...). To inspect the host or device modification flag use dual_view.modified_flags.at(0) or dual_view.modified_flags.at(1) respectively.

Known issues and limitations

This section provides information about known issues and limitations of debugging Kokkos codes.

  • Pretty printing of a Kokkos::View is only supported for LayoutLeft and LayoutRight. Other built-in layouts, such as LayoutStride, and experimental layouts are not supported. For unsupported views Linaro DDT will show the internal structure of a view. If a layout is not explicitly specified in the view type definition, then Linaro DDT will assume LayoutLeft (the default for the CUDA execution space).

  • Element inspection of a Kokkos::View using the Kokkos::Unmanaged memory trait is not implemented.

  • The reason that at(indices...) is required to access Kokkos::View elements, instead of operator(), is due to an internal limitation.

  • A Kokkos::View can only be inspected when the execution is stopped in its execution space. For example, a view defined in the CUDA execution space can only be inspected when stopped in a kernel executing on the CUDA device backend, but not when stopped in host code.

  • The dimensions of a running Kokkos CUDA kernel might be larger than the range specified for the Kokkos kernel in the source code.

  • Incomplete debug information may result in the following symptoms:

    • A Kokkos::View declared using auto will likely not be pretty printed correctly. Element inspection will not function correctly.

    • Views of a Kokkos::DualView with static extents will only be pretty printed using its dynamic extents. Element inspection will not function correctly.

    • The underlying data type of a Kokkos::View might be displayed as an internal Kokkos typedef/alias, for example Kokkos::View<data_type>.

    • Inspecting a Kokkos::View while stopped in host code will show its internal structure (NVIDIA HPC Compiler only).

  • Multi-Dimensional Array Viewer (MDA):

    • Ranges must be configured manually, and are not auto-detected based on Kokkos::View extents.

    • Visualizing a Kokkos::View is not supported.

    • Exporting a Kokkos::View in HDF5 format is not supported.

    • Exporting a Kokkos::View in CSV format can take a long time when the number of exported elements exceeds 1000.