Files
TheRock/rocm-systems/projects/rocprofiler-systems/source/lib/rocprof-sys/library/runtime.hpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

126 lines
4.0 KiB
C++

// Copyright (c) Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT
#pragma once
#include "api.hpp"
#include "common/defines.h"
#include "core/common.hpp"
#include "core/state.hpp"
#include "core/timemory.hpp"
#include "library/causal/components/causal_gotcha.hpp"
#include "library/components/exit_gotcha.hpp"
#include "library/components/fork_gotcha.hpp"
#include "library/components/kill_gotcha.hpp"
#include "library/components/mpi_gotcha.hpp"
#include "library/components/numa_gotcha.hpp"
#include "library/components/pthread_gotcha.hpp"
#include "library/components/vaapi_gotcha.hpp"
#include "library/thread_data.hpp"
#include <cstdint>
#include <timemory/backends/threading.hpp>
#include <timemory/macros/language.hpp>
#include <memory>
#include <set>
#include <string>
#include <string_view>
#include <unordered_set>
namespace rocprofsys
{
// started during preinit phase
using preinit_bundle_t =
tim::lightweight_tuple<exit_gotcha_t, fork_gotcha_t, mpi_gotcha_t, kill_gotcha_t>;
// started during init phase
using init_bundle_t = tim::lightweight_tuple<causal::component::causal_gotcha,
pthread_gotcha, component::numa_gotcha>;
// bundle of components around rocprofsys_init and rocprofsys_finalize
using main_bundle_t =
tim::lightweight_tuple<comp::wall_clock, comp::peak_rss, comp::page_rss,
comp::cpu_clock, comp::cpu_util>;
// bundle of components around each thread
#if defined(TIMEMORY_RUSAGE_THREAD) && TIMEMORY_RUSAGE_THREAD > 0
using thread_bundle_t = tim::lightweight_tuple<comp::wall_clock, comp::thread_cpu_clock,
comp::thread_cpu_util, comp::peak_rss>;
#else
using thread_bundle_t = tim::lightweight_tuple<comp::wall_clock, comp::thread_cpu_clock,
comp::thread_cpu_util>;
#endif
std::unique_ptr<main_bundle_t>&
get_main_bundle();
std::unique_ptr<init_bundle_t>&
get_init_bundle();
std::unique_ptr<preinit_bundle_t>&
get_preinit_bundle();
std::atomic<std::uint64_t>&
get_cpu_cid() TIMEMORY_HOT;
unique_ptr_t<std::vector<std::uint64_t>>&
get_cpu_cid_stack(std::int64_t _tid = threading::get_id(),
std::int64_t _parent = 0) TIMEMORY_HOT;
using cpu_cid_data_t = std::tuple<std::uint64_t, std::uint64_t, std::uint32_t>;
using cpu_cid_pair_t = std::tuple<std::uint64_t, std::uint32_t>;
using cpu_cid_parent_map_t = std::unordered_map<std::uint64_t, cpu_cid_pair_t>;
unique_ptr_t<cpu_cid_parent_map_t>&
get_cpu_cid_parents(std::int64_t _tid = threading::get_id()) TIMEMORY_HOT;
cpu_cid_data_t
create_cpu_cid_entry(std::int64_t _tid = threading::get_id()) TIMEMORY_HOT;
cpu_cid_pair_t
get_cpu_cid_entry(std::uint64_t _cid,
std::int64_t _tid = threading::get_id()) TIMEMORY_HOT;
tim::mutex_t&
get_cpu_cid_stack_lock(std::int64_t _tid = threading::get_id()) TIMEMORY_HOT;
// query current value
bool
sampling_enabled_on_child_threads();
// use this to disable sampling in a region (e.g. right before thread creation)
bool
push_enable_sampling_on_child_threads(bool _v);
// use this to restore previous setting
bool
pop_enable_sampling_on_child_threads();
// make sure every newly created thead starts with this value
void
set_sampling_on_all_future_threads(bool _v);
struct scoped_child_sampling
{
scoped_child_sampling(bool _v) { push_enable_sampling_on_child_threads(_v); }
~scoped_child_sampling() { pop_enable_sampling_on_child_threads(); }
};
pid_t
get_root_process_id();
bool
is_root_process();
bool
is_child_process();
} // namespace rocprofsys
#define ROCPROFSYS_SCOPED_SAMPLING_ON_CHILD_THREADS(VALUE) \
::rocprofsys::scoped_child_sampling ROCPROFSYS_VARIABLE(_scoped_child_sampling_, \
__LINE__) \
{ \
VALUE \
}