Skip to content

Commit

Permalink
Flush Perfetto TrackEvents (#1630)
Browse files Browse the repository at this point in the history
* update perfetto container, flush trackevents

* dummy definition
  • Loading branch information
esseivaju authored Feb 20, 2025
1 parent f7b34fb commit b63e1b9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/celer-sim/celer-sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ std::shared_ptr<OutputRegistry> run(std::istream* is)
id_cast<StreamId>(get_openmp_thread()),
id_cast<EventId>(event)),
capture_exception);
tracing_session.flush();
if (run_input->transporter_result)
{
result.events[event] = std::move(event_result);
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/interactive/CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"CELERITAS_USE_SWIG": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_Perfetto": {"type": "BOOL", "value": "ON"},
"PERFETTO_ROOT": {"type": "PATH", "value": "$env{PERFETTO_ROOT}/sdk"},
"PERFETTO_ROOT": {"type": "PATH", "value": "$env{PERFETTO_ROOT}"},
"CMAKE_CXX_STANDARD": {"type": "STRING", "value": "17"},
"CMAKE_CXX_COMPILER": {"type": "PATH", "value": "$env{CXX}" },
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
Expand Down
13 changes: 7 additions & 6 deletions scripts/docker/interactive/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM almalinux:latest

ARG PERFETTO_REP=https://android.googlesource.com/platform/external/perfetto
ARG PERFETTO_VERSION_TAG=v45.0
ARG PERFETTO_VERSION_TAG=v49.0
ENV DEVEL_ROOT=/opt/devel
ENV PERFETTO_ROOT=${DEVEL_ROOT}/perfetto
ENV PERFETTO_TOOLS=${PERFETTO_ROOT}/out/linux
Expand All @@ -21,12 +21,12 @@ RUN mkdir -p "${DEVEL_ROOT}"
RUN git clone -b${PERFETTO_VERSION_TAG} ${PERFETTO_REP} ${PERFETTO_ROOT} \
&& cd ${PERFETTO_ROOT} \
&& tools/install-build-deps \
&& tools/gn gen --args='is_debug=false' ${PERFETTO_TOOLS} \
&& tools/gn gen --args='is_debug=false is_hermetic_clang=false' ${PERFETTO_TOOLS} \
&& tools/ninja -C ${PERFETTO_TOOLS} tracebox traced traced_probes perfetto

# setup spack
ARG SPACK_REP=https://github.com/spack/spack.git
ARG SPACK_VERSION_TAG=v0.22.0
ARG SPACK_VERSION_TAG=develop
ARG SPACK_ENV_SPEC=${DEVEL_ROOT}/spack.yaml
ENV SPACK_ROOT=${DEVEL_ROOT}/spack
ENV SPACK_EXE=${SPACK_ROOT}/bin/spack
Expand Down Expand Up @@ -66,14 +66,15 @@ RUN eval $(${SPACK_EXE} env activate --sh ${CELERITAS_ENV_NAME}) \
# compile geomodel
ENV GEOMODEL_ROOT=${DEVEL_ROOT}/GeoModel
RUN dnf install -y eigen3-devel hdf5-devel sqlite-devel \
&& git clone -bceleritas https://github.com/celeritas-project/GeoModel.git ${GEOMODEL_ROOT}

RUN eval $(${SPACK_EXE} env activate --sh ${CELERITAS_ENV_NAME}) \
&& git clone -bceleritas https://github.com/celeritas-project/GeoModel.git ${GEOMODEL_ROOT} \
&& eval $(${SPACK_EXE} env activate --sh ${CELERITAS_ENV_NAME}) \
&& mkdir -p ${GEOMODEL_ROOT}/build && cd ${GEOMODEL_ROOT}/build \
&& git submodule update --init \
&& cmake -DGEOMODEL_BUILD_ATLASEXTENSIONS=ON -DGEOMODEL_BUILD_FULLSIMLIGHT=ON -DGEOMODEL_USE_HEPMC3=ON .. \
&& make -j$(nproc)

ENV LANG=en_US.UTF-8

# setup entrypoint and utilities
COPY setup_shell.sh /etc/profile.d/setup_shell.sh
COPY run-perfetto.sh /usr/local/bin/run-perfetto
Expand Down
4 changes: 0 additions & 4 deletions scripts/docker/interactive/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ spack:
- "[email protected]:"
- hepmc3
- nlohmann-json
- "[email protected]:"
- "[email protected]: +gdml"
view: true
concretizer:
unify: true
packages:
root:
# Note: ~gsl and ~math are removed because dd4hep requires them
variants: ~aqua ~davix ~examples ~opengl ~x ~tbb
all:
compiler: [clang]
variants: cxxstd=17
15 changes: 15 additions & 0 deletions src/corecel/sys/TracingSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ TracingSession::~TracingSession()
{
if (started_)
{
this->flush();
session_->StopBlocking();
}
if (fd_ != system_fd_)
Expand All @@ -151,6 +152,20 @@ void TracingSession::start() noexcept
}
}

//---------------------------------------------------------------------------//
/*!
* Flush track events associated with the calling thread for the profiling
* session. In multi-threaded applications, this should be called from each
* worker thread to ensure that their track events are correctly written.
*/
void TracingSession::flush() noexcept
{
if (session_ && started_)
{
perfetto::TrackEvent::Flush();
}
}

//---------------------------------------------------------------------------//
/*!
* Define the deleter where the TracingSession definition is accessible.
Expand Down
4 changes: 4 additions & 0 deletions src/corecel/sys/TracingSession.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class TracingSession
// Start the profiling session
void start() noexcept;

// Flush the track events associated with the calling thread
void flush() noexcept;

CELER_DELETE_COPY_MOVE(TracingSession);

private:
Expand Down Expand Up @@ -85,6 +88,7 @@ inline void TracingSession::start() noexcept
CELER_DISCARD(started_);
CELER_DISCARD(fd_);
}
inline void TracingSession::flush() noexcept {}
inline void TracingSession::Deleter::operator()(perfetto::TracingSession*)
{
CELER_ASSERT_UNREACHABLE();
Expand Down

0 comments on commit b63e1b9

Please sign in to comment.