OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
KokkosPerfCounters.hpp File Reference

OPENSWMM_PERF=1 launch/fence/deep_copy counters for the Kokkos surface solver, riding the in-process Kokkos::Tools callbacks. More...

#include <Kokkos_Core.hpp>
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include "../../core/PerfTimers.hpp"
Include dependency graph for KokkosPerfCounters.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::twoD::gpu::kperf::KernelEntry
 
struct  openswmm::twoD::gpu::kperf::Counters
 

Namespaces

namespace  openswmm
 
namespace  openswmm::twoD
 
namespace  openswmm::twoD::gpu
 
namespace  openswmm::twoD::gpu::kperf
 
namespace  openswmm::twoD::gpu::kperf::detail
 

Typedefs

using openswmm::twoD::gpu::kperf::detail::clock = std::chrono::steady_clock
 

Functions

void openswmm::twoD::gpu::kperf::detail::begin_dispatch (const char *name, std::uint32_t, std::uint64_t *kID)
 
void openswmm::twoD::gpu::kperf::detail::end_dispatch (std::uint64_t kID)
 
void openswmm::twoD::gpu::kperf::detail::begin_fence (const char *, std::uint32_t, std::uint64_t *handle)
 
void openswmm::twoD::gpu::kperf::detail::end_fence (std::uint64_t)
 
void openswmm::twoD::gpu::kperf::detail::begin_deep_copy (Kokkos_Profiling_SpaceHandle dst, const char *, const void *, Kokkos_Profiling_SpaceHandle src, const char *, const void *, std::uint64_t size)
 
void openswmm::twoD::gpu::kperf::install ()
 
void openswmm::twoD::gpu::kperf::reset ()
 
void openswmm::twoD::gpu::kperf::count_advance ()
 
void openswmm::twoD::gpu::kperf::dump ()
 

Variables

Counters openswmm::twoD::gpu::kperf::g
 
std::vector< clock::time_point > openswmm::twoD::gpu::kperf::detail::dispatch_t0
 
std::vector< clock::time_point > openswmm::twoD::gpu::kperf::detail::fence_t0
 

Detailed Description

OPENSWMM_PERF=1 launch/fence/deep_copy counters for the Kokkos surface solver, riding the in-process Kokkos::Tools callbacks.

Phase A2 of plans/CPU_GPU_PERF_REVIEW_PLAN_2026-09-02.md. The counters answer three questions the wall clock cannot: how many kernel launches an advance() costs, how long the host blocks in fences, and how many bytes cross host<->device per advance. They hook Kokkos::Tools::Experimental::set_*_callback rather than the ~25 dispatch sites so every launch — including implicit fences and the deep_copies inside devCopy/devRefresh — is counted without a line of code in the hot path.

Registration is skipped when an external tool is loaded (KOKKOS_TOOLS_LIBS / KOKKOS_PROFILE_LIBRARY): Kokkos holds ONE callback set, and stealing it would blind nsys/kernel-logger, which attribute by the same kernel labels (plan Phase A3). Use one or the other per run.

Per-kernel s= is HOST-SIDE wall between the begin/end dispatch callbacks: on the OpenMP backend that is the kernel's execution time (dispatch blocks); on CUDA/HIP it is launch overhead only — device time lives in the fence/nsys numbers.

Counters are plain (non-atomic) longs: the engine drives the solver from one thread, and Kokkos dispatch callbacks fire on the calling thread. Zero cost when OPENSWMM_PERF is unset (nothing is registered at all).

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n Apache-2.0