Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ae74d14
feat(control): integrate time windows into the control session
marantic-amd Jul 30, 2026
70f10b0
rename(control): is_active_excluding_trigger -> is_active_without
marantic-amd Jul 23, 2026
b1df55d
fix(control): key trigger actions by scope, not name alone
marantic-amd Jul 27, 2026
d037fd6
fix(control): make TRACE_DELAY gate GPU context startup
marantic-amd Jul 27, 2026
d0fb862
fix(control): Address review findings
marantic-amd Aug 11, 2026
172096c
test(openmp): assert sampling duration from trace, not log output
marantic-amd Aug 13, 2026
c80a8f8
refactor(control): address review findings on constraint and session
marantic-amd Aug 13, 2026
6d579db
fix(sampling): stop delivering timer signals while paused
marantic-amd Aug 13, 2026
cadc480
test(transpose): limit trace-delay gating test to binary_rewrite
marantic-amd Aug 13, 2026
3eb04a9
fix(test): guard perfetto imports and satisfy misc-const-correctness
marantic-amd Aug 17, 2026
f0f3527
refactor(config): move trace-window config parsing out of constraint.hpp
marantic-amd Aug 20, 2026
5fec34a
fix(control): guard clock interrupt/reset from self-instrumentation
marantic-amd Aug 20, 2026
27a29b0
fix(control): address clang-tidy findings across control/config
marantic-amd Aug 24, 2026
6fc3d93
refactor(control): bundle time_window's delay/duration into time_wind…
marantic-amd Aug 27, 2026
fd46ed2
fix compile error
mradosav-amd Aug 28, 2026
d4c4451
fix(control): address remaining clang-tidy findings in PR2
marantic-amd Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions projects/rocprofiler-systems/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ replaces Perfetto as the primary trace output.
`ROCPROFSYS_CONFIG_FILE` is preserved, and the one given on the command line is
appended to it.

- Pausing sampling now stops the underlying per-thread timers instead of only
discarding the samples they produce. Previously a paused sampler kept delivering
timer signals, so the profiled application's sleeps were still interrupted
throughout a window in which no data was being collected.

### Fixed

- `ROCPROFSYS_TRACE_DELAY`/`ROCPROFSYS_TRACE_DURATION` now actually gate GPU context
startup, producing a real gap in cached GPU/RocPD data. Previously they only
suppressed downstream category emission. For GPU-only tracing with no marker
domain or trace region configured, the configured delay had no effect at all on
when GPU data collection actually began.

### Removed

- Removed the `ROCPROFSYS_BUILD_SQLITE3` CMake option and the in-tree SQLite3/rocpd
Expand Down
45 changes: 32 additions & 13 deletions projects/rocprofiler-systems/docs/reference/development-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,45 @@ a new internal thread is created to handle the new samplers.
Time-window constraint model
========================================

With the recent introduction of tracing delay and duration, the
`constraint namespace <https://github.com/ROCm/rocm-systems/blob/develop/projects/rocprofiler-systems/source/lib/core/constraint.hpp>`_
was introduced to improve the management of delays and duration limits for
data collection. The ``spec`` class accepts a clock identifier, a delay value, a duration value, and an
integer indicating how many times to repeat the delay and duration cycle. It is therefore
possible to perform tasks such as periodically enabling tracing for brief periods
of time in between long periods without data collection while the application runs. The
syntax follows the format ``clock_identifier:delay:capture_duration:cycles``, so a value of
``10:1:3`` for the last three parameters represents the following sequence of operations:
The time-window constraint model manages delays and duration limits for data collection.
Each window entry specifies a delay before collection begins, a duration for how long
collection is active, and an optional repeat count. The syntax for ``ROCPROFSYS_TRACE_PERIODS``
entries follows the format ``delay:duration`` or ``delay:duration:repeat``, so a value of
``10:1:3`` represents the following sequence of operations:

* Ten seconds where no data is collected, then one second where it is
* Ten seconds where no data is collected, then one second where it is
* Ten seconds where no data is collected, then one second where it is
* Stop

As another example, ``ROCPROFSYS_TRACE_PERIODS = realtime:10:1:5 process_cputime:10:2:20`` translates
to this sequence:
Clock selection
---------------

* Five cycles of: no data collection for ten seconds of real-time followed by one second of data collection
* Twenty cycles of: no data collection for ten seconds of process CPU time followed by two CPU-time seconds of data collection
``ROCPROFSYS_TRACE_PERIOD_CLOCK_ID`` controls what the delay and duration values mean.
It accepts exactly two values:

``realtime`` (default)
Delays and durations are measured in wall-clock time using a monotonic
steady clock. A ten-second delay waits for ten real seconds regardless of
how many CPU cores are active or how busy they are.

``cputime``
Delays and durations are measured in process CPU time
(``CLOCK_PROCESS_CPUTIME_ID``). A ten-second delay waits until the process
has consumed ten CPU-seconds in total across all threads. This is useful
when you want to skip a fixed amount of computation rather than a fixed
elapsed time — for example, to profile only after a workload's warm-up
phase, measured in CPU work rather than calendar seconds.

Be aware that rocprof-sys instrumentation itself contributes to the
CPU-time counter, so the effective delay will be slightly shorter than the
configured value in heavily instrumented code.

Example — profile only the steady-state CPU work, skipping the first ten
CPU-seconds and capturing the next two, repeated twenty times::

ROCPROFSYS_TRACE_PERIOD_CLOCK_ID=cputime
ROCPROFSYS_TRACE_PERIODS=10:2:20

Eventually, the goal is to migrate all subsets of data collection which currently support
more rudimentary models of time window constraints, such as process sampling and causal profiling,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(core_sources
${CMAKE_CURRENT_LIST_DIR}/argparse.cpp
${CMAKE_CURRENT_LIST_DIR}/categories.cpp
${CMAKE_CURRENT_LIST_DIR}/config.cpp
${CMAKE_CURRENT_LIST_DIR}/constraint.cpp
${CMAKE_CURRENT_LIST_DIR}/cpu.cpp
${CMAKE_CURRENT_LIST_DIR}/dynamic_library.cpp
${CMAKE_CURRENT_LIST_DIR}/exception.cpp
Expand All @@ -34,7 +33,6 @@ set(core_headers
${CMAKE_CURRENT_LIST_DIR}/common_types.hpp
${CMAKE_CURRENT_LIST_DIR}/concepts.hpp
${CMAKE_CURRENT_LIST_DIR}/config.hpp
${CMAKE_CURRENT_LIST_DIR}/constraint.hpp
${CMAKE_CURRENT_LIST_DIR}/cpu.hpp
${CMAKE_CURRENT_LIST_DIR}/demangler.hpp
${CMAKE_CURRENT_LIST_DIR}/dynamic_library.hpp
Expand Down Expand Up @@ -63,6 +61,7 @@ add_library(
target_sources(rocprofiler-systems-core-library PRIVATE ${core_sources} ${core_headers})
add_subdirectory(binary)
add_subdirectory(components)
add_subdirectory(config)
add_subdirectory(containers)
add_subdirectory(control)
add_subdirectory(perfetto)
Expand Down
42 changes: 0 additions & 42 deletions projects/rocprofiler-systems/source/lib/core/categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "core/categories.hpp"
#include "core/common.hpp"
#include "core/config.hpp"
#include "core/constraint.hpp"
#include "core/state.hpp"
#include "core/timemory.hpp"
#include "core/utility.hpp"

Expand Down Expand Up @@ -72,46 +70,6 @@ setup()
{
// disable specified categories
disable_categories();

auto _trace_specs = constraint::get_trace_specs();

if(!_trace_specs.empty())
{
auto _trace_stages = constraint::get_trace_stages();

_trace_stages.init = [](const constraint::spec& _spec) {
if(_spec.delay > 1.0e-3) disable_categories(config::get_enabled_categories());
return state::process::get() < state::process::Finalized;
};

_trace_stages.start = [](const constraint::spec&) {
enable_categories(config::get_enabled_categories());
return state::process::get() < state::process::Finalized;
};

_trace_stages.stop = [](const constraint::spec&) {
// only disable categories if not finalized since this might run in background
// during finalization and disable output of data in those categories
if(state::process::get() < state::process::Finalized)
disable_categories(config::get_enabled_categories());
return state::process::get() < state::process::Finalized;
};

auto _promise = std::promise<void>();
std::thread{ [_trace_specs, _trace_stages](std::promise<void>* _prom) {
// ensure all categories are disabled before proceeding
// if a delay is requested
if(_trace_specs.front().delay > 1.0e-3)
disable_categories(config::get_enabled_categories());
_prom->set_value();
for(const auto& itr : _trace_specs)
itr(_trace_stages);
},
&_promise }
.detach();

_promise.get_future().wait_for(std::chrono::seconds{ 1 });
}
}

void
Expand Down
42 changes: 19 additions & 23 deletions projects/rocprofiler-systems/source/lib/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "common/environment.hpp"
#include "common/path.hpp"
#include "common/static_object.hpp"
#include "constraint.hpp"
#include "gpu.hpp"
#include "logger/logger.hpp"
#include "mproc.hpp"
Expand Down Expand Up @@ -399,8 +398,8 @@ install_strict_config_value_callbacks(const std::shared_ptr<settings>& _config)
// for ENV_NAME -- std::string{} can be constructed from either.
#define ROCPROFSYS_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \
[&]() { \
auto _env_name = std::string{ ENV_NAME }; \
auto _ret = _config->insert<TYPE, TYPE>( \
auto _env_name = std::string{ ENV_NAME }; \
const auto _ret = _config->insert<TYPE, TYPE>( \
_env_name, get_setting_name(_env_name), DESCRIPTION, TYPE{ INITIAL_VALUE }, \
std::set<std::string>{ "custom", "rocprofsys", "librocprof-sys", \
__VA_ARGS__ }); \
Expand Down Expand Up @@ -839,29 +838,26 @@ configure_settings(bool _init)
"roctxRangeStart/roctxRangeStop markers.",
std::string{}, "trace", "profile", "perfetto", "rocpd", "timemory", "rocm");

auto _clock_choices = std::vector<std::string>{};
for(const auto& itr : constraint::get_valid_clock_ids())
{
_clock_choices.emplace_back(
fmt::format("({}|{}|{})", itr.name, itr.value, itr.raw_name));
}

ROCPROFSYS_CONFIG_SETTING(std::string, env_vars::TRACE_PERIODS,
"Similar to specify trace delay and/or duration except in "
"the form <DELAY>:<DURATION>, <DELAY>:<DURATION>:<REPEAT>, "
"and/or <DELAY>:<DURATION>:<REPEAT>:<CLOCK_ID>",
std::string{}, "trace", "profile", "perfetto", "timemory");
ROCPROFSYS_CONFIG_SETTING(
std::string, env_vars::TRACE_PERIODS,
"Space- or semicolon-separated list of trace windows. Each entry has the form "
"<DELAY>:<DURATION> or <DELAY>:<DURATION>:<REPEAT>. The clock used for all "
"entries is controlled by ROCPROFSYS_TRACE_PERIOD_CLOCK_ID.",
std::string{}, "trace", "profile", "perfetto", "timemory");

ROCPROFSYS_CONFIG_SETTING(
std::string, env_vars::TRACE_PERIOD_CLOCK_ID,
"Set the default clock ID for ROCPROFSYS_TRACE_DELAY, ROCPROFSYS_TRACE_DURATION, "
"and/or ROCPROFSYS_TRACE_PERIODS. E.g. \"realtime\" == the delay/duration is "
"governed by the elapsed realtime, \"cputime\" == the delay/duration is governed "
"by the elapsed CPU-time within the process, etc. Note: when using CPU-based "
"timing, it is recommened to scale the value by the number of threads and be "
"aware that rocprof-sys may contribute to advancing the process CPU-time",
"CLOCK_REALTIME", "trace", "profile", "perfetto", "timemory")
->set_choices(_clock_choices);
"Clock used to measure delay and duration for ROCPROFSYS_TRACE_DELAY, "
"ROCPROFSYS_TRACE_DURATION, and ROCPROFSYS_TRACE_PERIODS.\n"
" realtime (default) : wall-clock time. A 10-second delay waits for\n"
" 10 real seconds regardless of how many CPU cores are active.\n"
" cputime : process CPU time (CLOCK_PROCESS_CPUTIME_ID). A 10-second\n"
" delay waits until the process has consumed 10 CPU-seconds in total\n"
" across all threads. Useful when you want to skip a fixed amount of\n"
" computation rather than a fixed elapsed time. Note: rocprof-sys\n"
" instrumentation itself contributes to the CPU-time counter.",
"realtime", "trace", "profile", "perfetto", "timemory")
->set_choices({ "realtime", "cputime" });

ROCPROFSYS_CONFIG_SETTING(
double, env_vars::SAMPLING_FREQ,
Expand Down
6 changes: 0 additions & 6 deletions projects/rocprofiler-systems/source/lib/core/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,6 @@ get_perfetto_backend();
std::string
get_perfetto_output_filename();

double
get_trace_delay();

double
get_trace_duration();

std::string
get_trace_region();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

set(config_headers ${CMAKE_CURRENT_LIST_DIR}/trace_period_config.hpp)

target_sources(rocprofiler-systems-core-library PRIVATE ${config_headers})

if(ROCPROFSYS_BUILD_TESTING)
add_subdirectory(tests)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

add_library(trace-period-config-tests OBJECT test_trace_period_config.cpp)

target_link_libraries(
trace-period-config-tests
PRIVATE
rocprofiler-systems-googletest-library
rocprofiler-systems-core-library
rocprofiler-systems-logger
rocprofiler-systems-headers
rocprofiler-systems-timemory
)

target_include_directories(
trace-period-config-tests
PRIVATE ${PROJECT_SOURCE_DIR}/source/lib ${CMAKE_BINARY_DIR}/source/lib/
)
Loading
Loading