diff --git a/app/celer-sim/celer-sim.cc b/app/celer-sim/celer-sim.cc index 03aaf80b0b..c9da404745 100644 --- a/app/celer-sim/celer-sim.cc +++ b/app/celer-sim/celer-sim.cc @@ -48,9 +48,7 @@ # include "RunnerInputIO.json.hh" #endif -#if CELERITAS_USE_PERFETTO -# include "corecel/sys/PerfettoSession.hh" -#endif +#include "corecel/sys/TracingSession.hh" using namespace std::literals::string_view_literals; @@ -80,10 +78,9 @@ int get_openmp_thread() void run(std::istream* is, std::shared_ptr output) { CELER_EXPECT(is); -#if CELERITAS_USE_PERFETTO - PerfettoSession tracing_session("celer-sim.perfetto-trace"); + TracingSession tracing_session("celer-sim.perfetto-trace"); tracing_session.start(); -#endif + ScopedProfiling profile_this{"celer-sim"}; ScopedMem record_mem("celer-sim.run"); diff --git a/src/corecel/CMakeLists.txt b/src/corecel/CMakeLists.txt index 38ad8e7a07..dfec9313fc 100644 --- a/src/corecel/CMakeLists.txt +++ b/src/corecel/CMakeLists.txt @@ -96,7 +96,7 @@ if(CELERITAS_USE_Perfetto) list(APPEND PRIVATE_DEPS Celeritas::Perfetto) list(APPEND SOURCES sys/Counter.perfetto.cc - sys/PerfettoSession.cc + sys/TracingSession.perfetto.cc sys/ScopedProfiling.perfetto.cc ) endif() diff --git a/src/corecel/sys/PerfettoSession.hh b/src/corecel/sys/TracingSession.hh similarity index 71% rename from src/corecel/sys/PerfettoSession.hh rename to src/corecel/sys/TracingSession.hh index 9f65b0f9b8..a17a411f33 100644 --- a/src/corecel/sys/PerfettoSession.hh +++ b/src/corecel/sys/TracingSession.hh @@ -3,7 +3,7 @@ // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: (Apache-2.0 OR MIT) //---------------------------------------------------------------------------// -//! \file corecel/sys/PerfettoSession.hh +//! \file corecel/sys/TracingSession.hh //! \brief RAII class for managing a perfetto session and its resources. //---------------------------------------------------------------------------// #pragma once @@ -14,8 +14,6 @@ #include "celeritas_config.h" #include "corecel/Macros.hh" -#include "PerfettoSession.hh" - namespace perfetto { class TracingSession; @@ -30,23 +28,36 @@ enum class ProfilingBackend : uint32_t System }; -class PerfettoSession +#if CELERITAS_USE_PERFETTO +class TracingSession { public: - explicit PerfettoSession(); - PerfettoSession(std::string_view); - ~PerfettoSession(); + TracingSession(); + explicit TracingSession(std::string_view); + ~TracingSession(); + void start(); //!@{ //! Prevent copying and moving for RAII class - CELER_DEFAULT_MOVE_DELETE_COPY(PerfettoSession); + CELER_DEFAULT_MOVE_DELETE_COPY(TracingSession); //!@} - void start(); private: bool started_{false}; std::unique_ptr session_; int fd_{-1}; }; +#else + +//! noop +class TracingSession +{ + public: + TracingSession() = default; + explicit TracingSession(std::string_view) {} + + void start() {}; +}; +#endif } // namespace celeritas diff --git a/src/corecel/sys/PerfettoSession.cc b/src/corecel/sys/TracingSession.perfetto.cc similarity index 92% rename from src/corecel/sys/PerfettoSession.cc rename to src/corecel/sys/TracingSession.perfetto.cc index 2f57921fec..76c7357b54 100644 --- a/src/corecel/sys/PerfettoSession.cc +++ b/src/corecel/sys/TracingSession.perfetto.cc @@ -3,10 +3,10 @@ // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: (Apache-2.0 OR MIT) //---------------------------------------------------------------------------// -//! \file corecel/sys/PerfettoSession.cc +//! \file corecel/sys/TracingSession.perfetto.cc //! \brief RAII class for managing a perfetto session and its resources. //---------------------------------------------------------------------------// -#include "PerfettoSession.hh" +#include "TracingSession.hh" #include #include @@ -63,7 +63,7 @@ perfetto::TraceConfig configure_session() namespace celeritas { -PerfettoSession::PerfettoSession() +TracingSession::TracingSession() : session_{initialize_session(ProfilingBackend::System)} { if (use_profiling()) @@ -72,7 +72,7 @@ PerfettoSession::PerfettoSession() } } -PerfettoSession::PerfettoSession(std::string_view filename) +TracingSession::TracingSession(std::string_view filename) : session_{initialize_session(ProfilingBackend::InProcess)}, fd_{[&] { return use_profiling() ? open(filename.data(), O_RDWR | O_CREAT | O_TRUNC, 0660) @@ -85,7 +85,7 @@ PerfettoSession::PerfettoSession(std::string_view filename) } } -PerfettoSession::~PerfettoSession() +TracingSession::~TracingSession() { if (use_profiling()) { @@ -99,7 +99,7 @@ PerfettoSession::~PerfettoSession() } } } -void PerfettoSession::start() +void TracingSession::start() { if (use_profiling()) {