Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d3a9b15
Add OMPT to ROCpd
kcossett-amd Sep 16, 2025
e70f59b
Use correct category
kcossett-amd Sep 16, 2025
9926233
Added wrapper functions for future control
kcossett-amd Sep 17, 2025
cdd3212
Formatting
kcossett-amd Sep 17, 2025
9cc79af
Fix naming
kcossett-amd Sep 17, 2025
2cb7b97
Comment change
kcossett-amd Sep 17, 2025
ffba5db
Remove ompt_get_cb_args
kcossett-amd Sep 17, 2025
94e22f8
Switched to using region_sample for OMPT
kcossett-amd Sep 18, 2025
fa74e17
Remove relic function
kcossett-amd Sep 18, 2025
6f12f01
Remove get_use_rocpd that was used in this pr (one still remains)
kcossett-amd Sep 19, 2025
d2308b1
Rename ompt_get_args_string and reuse in tool_tracing_callback_stop
kcossett-amd Sep 19, 2025
9c13e25
Make lock init and destroy cb instant
kcossett-amd Sep 21, 2025
ace8715
[Prototype] ROCPD Name fix
kcossett-amd Sep 21, 2025
f326946
[Prototype] ROCPD Name fix P1
kcossett-amd Sep 22, 2025
8b3a93b
[Prototype] ROCPD Name fix P2
kcossett-amd Sep 22, 2025
76365db
ROCPD Name fix
kcossett-amd Sep 23, 2025
88eaefe
Var name changes
kcossett-amd Sep 24, 2025
2fe7792
Rewrite cb overwrite to single function
kcossett-amd Sep 24, 2025
37408bb
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Sep 24, 2025
a1d6a0e
[Important] Use parallel_data as key for parallel callback map
kcossett-amd Sep 24, 2025
944928b
Fix workflow failure
kcossett-amd Sep 24, 2025
5e70ad4
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Sep 24, 2025
7046ea5
Make cpp USE_ROCM consistent with hpp and use default constructor if …
kcossett-amd Sep 24, 2025
1c02b33
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Sep 24, 2025
4cca350
Add missing ROCPROFILER_VERSION check
kcossett-amd Sep 25, 2025
00070cd
Improve readability
kcossett-amd Sep 29, 2025
1372fe3
Make ompt storage maps thread local
kcossett-amd Sep 29, 2025
ef4b82d
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Sep 29, 2025
f61f3ef
Part 1: Variable name fix, memory cleanup, and fixed asserts
kcossett-amd Oct 5, 2025
ef77830
Part 2: Add comments
kcossett-amd Oct 5, 2025
d5b0088
Part 3: Add CI_THROW
kcossett-amd Oct 5, 2025
f3d620d
Part 4: Formatting
kcossett-amd Oct 6, 2025
0dafa85
Part 5: Move #include to cpp
kcossett-amd Oct 6, 2025
1a99122
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Oct 6, 2025
9de089f
Merge branch 'develop' into users/kcossett-amd/rocpd-ompt
kcossett-amd Oct 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ metadata_registry::get_string_list() const
return result;
}

#if ROCPROFSYS_USE_ROCM
#if ROCPROFSYS_USE_ROCM > 0

void
metadata_registry::add_code_object(
Expand Down Expand Up @@ -278,6 +278,96 @@ metadata_registry::get_kernel_symbol_list() const
return result;
}

void
metadata_registry::overwrite_callback_names(
std::initializer_list<
std::pair<rocprofiler_callback_tracing_kind_t, callback_rename_map_t>>
rename_table)
{
if(rename_table.size() == 0) return;

using callback_kind_t = rocprofiler_callback_tracing_kind_t;
using operation_names_t = std::vector<std::string_view>;

auto category_names = std::vector<std::string_view>{};
auto modified_ops = std::map<callback_kind_t, operation_names_t>{};

auto extract_operations = [&](callback_kind_t cat) -> operation_names_t {
auto items = m_callback_tracing_info.items();
const auto* target_category = items[static_cast<size_t>(cat)];

auto operations_data = target_category->items();
operation_names_t operation_names;
operation_names.reserve(operations_data.size());

for(const auto& [op_idx, op_name] : operations_data)
operation_names.push_back(*op_name);

return operation_names;
};

// Store category names
category_names.resize(ROCPROFILER_CALLBACK_TRACING_LAST);
for(callback_kind_t i = ROCPROFILER_CALLBACK_TRACING_NONE;
i < ROCPROFILER_CALLBACK_TRACING_LAST;
i = static_cast<callback_kind_t>(static_cast<int>(i) + 1))
{
category_names[i] = m_callback_tracing_info.at(i);
}

// Process list
for(const auto& category_info : rename_table)
{
auto callback_kind = category_info.first;
// Store operations of all following categories
// as they will be deleted
for(callback_kind_t i =
static_cast<callback_kind_t>(static_cast<int>(callback_kind) + 1);
i < ROCPROFILER_CALLBACK_TRACING_LAST;
i = static_cast<callback_kind_t>(static_cast<int>(i) + 1))
{
if(modified_ops.find(i) != modified_ops.end()) break;
modified_ops[i] = extract_operations(i);
}

ROCPROFSYS_CI_THROW(modified_ops.find(callback_kind) != modified_ops.end(),
"Overwriting a previously overwritten entry is forbidden");

ROCPROFSYS_CI_THROW(!modified_ops.empty() &&
callback_kind >= modified_ops.begin()->first,
"Category must have a larger enum value than all previously "
"modified_ops categories");

// Overwrite desired category
auto operation_names = extract_operations(callback_kind);
for(const auto& [index, new_value] : category_info.second)
{
ROCPROFSYS_CI_THROW(index < 0 ||
static_cast<size_t>(index) >= operation_names.size(),
"Index is invalid");
operation_names[index] = new_value;
}
modified_ops[callback_kind] = std::move(operation_names);
}
if(modified_ops.empty()) return;

// Emplace the changed category operations
for(callback_kind_t i = modified_ops.begin()->first;
i < ROCPROFILER_CALLBACK_TRACING_LAST;
i = static_cast<callback_kind_t>(static_cast<int>(i) + 1))
{
auto renaming_entry = modified_ops.find(i);
const auto& operations_vec = renaming_entry->second;
m_callback_tracing_info.emplace(i, category_names.at(i).data());
for(size_t op_idx = 0; op_idx < operations_vec.size(); ++op_idx)
{
m_callback_tracing_info.emplace(
i, static_cast<rocprofiler_tracing_operation_t>(op_idx),
operations_vec[op_idx].data());
}
}
}

rocprofiler::sdk::buffer_name_info_t<const char*>
metadata_registry::get_buffer_name_info() const
{
Expand All @@ -292,5 +382,20 @@ metadata_registry::get_callback_tracing_info() const

#endif

metadata_registry::metadata_registry()
{
#if ROCPROFSYS_USE_ROCM > 0
overwrite_callback_names({
# if(ROCPROFILER_VERSION >= 600)
{ ROCPROFILER_CALLBACK_TRACING_OMPT,
{ { ROCPROFILER_OMPT_ID_thread_begin, "omp_thread" },
{ ROCPROFILER_OMPT_ID_thread_end, "omp_thread" },
{ ROCPROFILER_OMPT_ID_parallel_begin, "omp_parallel" },
{ ROCPROFILER_OMPT_ID_parallel_end, "omp_parallel" } } }
# endif
});
#endif
}

} // namespace trace_cache
} // namespace rocprofsys
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "common/synchronized.hpp"
#include "core/agent.hpp"
#include "core/categories.hpp"
#include "core/debug.hpp"

#include <cassert>
#include <cstdint>
Expand All @@ -35,6 +36,8 @@
# include <rocprofiler-sdk/callback_tracing.h>
# include <rocprofiler-sdk/cxx/name_info.hpp>
#endif
#include <initializer_list>
#include <map>
#include <set>
#include <sstream>
#include <stdint.h>
Expand Down Expand Up @@ -215,7 +218,7 @@ struct metadata_registry

private:
friend class cache_manager;
metadata_registry() = default;
metadata_registry();
common::synchronized<info::process> m_process;
common::synchronized<
std::unordered_set<info::pmc, info::pmc_info_hash, info::pmc_info_equal>>
Expand All @@ -240,6 +243,14 @@ struct metadata_registry
rocprofiler::sdk::callback_name_info_t<const char*> m_callback_tracing_info{
rocprofiler::sdk::get_callback_tracing_names<const char*>()
};

using callback_rename_map_t =
std::map<rocprofiler_tracing_operation_t, std::string_view>;

void overwrite_callback_names(
std::initializer_list<
std::pair<rocprofiler_callback_tracing_kind_t, callback_rename_map_t>>
rename_table);
#endif
};

Expand Down
Loading
Loading