Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -254,6 +254,88 @@ rocpd_post_processing::get_memory_allocate_callback() const
};
};
}

postprocessing_callback
rocpd_post_processing::get_ompt_callback() const
{
[[maybe_unused]] auto parse_args = []([[maybe_unused]] const std::string& arg_str) {
# if ROCPROFSYS_USE_ROCM > 0
rocprofiler_sdk::function_args_t args;
const std::string delimiter = ";;";

auto split = [](const std::string& str, const std::string& _delimiter) {
std::vector<std::string> tokens;
size_t start = 0;
size_t end = str.find(_delimiter);

while(end != std::string::npos)
{
tokens.push_back(str.substr(start, end - start));
start = end + _delimiter.length();
end = str.find(_delimiter, start);
}

return tokens;
};

auto tokens = split(arg_str, delimiter);

// Ensure the number of tokens is a multiple of 4
if(tokens.size() % 4 != 0)
{
throw std::invalid_argument("Malformed argument string.");
}

for(auto it = tokens.begin(); it != tokens.end(); it += 4)
{
rocprofiler_sdk::argument_info arg = { static_cast<uint32_t>(std::stoi(*it)),
*(it + 1), *(it + 2), *(it + 3) };
args.push_back(arg);
}

return args;
# endif
};

return [&]([[maybe_unused]] const storage_parsed_type_base& parsed) {
# if ROCPROFSYS_USE_ROCM > 0
auto _ors = static_cast<const struct ompt_region_sample&>(parsed);
auto& data_processor = get_data_processor();
auto& n_info = node_info::get_instance();
auto process = m_metadata.get_process_info();
auto thread_primary_key =
data_processor.map_thread_id_to_primary_key(_ors.thread_id);

auto callback_tracing_info = m_metadata.get_callback_tracing_info();
auto _name = _ors.name;
auto name_primary_key = data_processor.insert_string(_name.c_str());

auto category_primary_key =
data_processor.insert_string(trait::name<category::rocm_ompt_api>::value);

size_t stack_id = _ors.correlation_id_internal;
size_t parent_stack_id = _ors.correlation_id_ancestor;
size_t correlation_id = 0;

auto event_primary_key =
data_processor.insert_event(category_primary_key, stack_id, parent_stack_id,
correlation_id, _ors.call_stack.c_str());

auto args = parse_args(_ors.args_str);
for(const auto& arg : args)
{
data_processor.insert_args(event_primary_key, arg.arg_number,
arg.arg_type.c_str(), arg.arg_name.c_str(),
arg.arg_value.c_str());
}

data_processor.insert_region(n_info.id, process.pid, thread_primary_key,
_ors.start_timestamp, _ors.end_timestamp,
name_primary_key, event_primary_key);
# endif
};
}

#endif

postprocessing_callback
Expand Down Expand Up @@ -654,6 +736,7 @@ rocpd_post_processing::register_parser_callback([[maybe_unused]] storage_parser&
# if(ROCPROFILER_VERSION >= 600)
parser.register_type_callback(entry_type::memory_alloc,
get_memory_allocate_callback());
parser.register_type_callback(entry_type::ompt, get_ompt_callback());
# endif
parser.register_type_callback(entry_type::in_time_sample,
get_in_time_sample_callback());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class rocpd_post_processing
postprocessing_callback get_memory_copy_callback() const;
#if(ROCPROFILER_VERSION >= 600)
postprocessing_callback get_memory_allocate_callback() const;
postprocessing_callback get_ompt_callback() const;
#endif
postprocessing_callback get_region_callback() const;
postprocessing_callback get_in_time_sample_callback() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,45 @@ struct memory_allocate_sample : storage_parsed_type_base
// Stream handle
size_t stream_handle;
};

struct ompt_region_sample : storage_parsed_type_base
{
ompt_region_sample() = default;
ompt_region_sample(std::string _name, uint64_t _thread_id, int32_t _operation,
uint64_t _correlation_id_internal,
uint64_t _correlation_id_ancestor, uint64_t _start_timestamp,
uint64_t _end_timestamp, std::string _args_str,
std::string _call_stack)
: name(std::move(_name))
, thread_id(_thread_id)
, operation(_operation)
, correlation_id_internal(_correlation_id_internal)
, correlation_id_ancestor(_correlation_id_ancestor)
, start_timestamp(_start_timestamp)
, end_timestamp(_end_timestamp)
, args_str(std::move(_args_str))
, call_stack(std::move(_call_stack))
{}

// Identification fields
std::string name;
uint64_t thread_id;
int32_t operation;

// Correlation fields
uint64_t correlation_id_internal;
uint64_t correlation_id_ancestor;

// Timing fields
uint64_t start_timestamp;
uint64_t end_timestamp;

// Callback arguments
std::string args_str;

// Additional fields
std::string call_stack;
};
#endif

struct region_sample : storage_parsed_type_base
Expand Down Expand Up @@ -231,9 +270,10 @@ enum class entry_type : uint32_t
memory_copy = 0x0004,
#if(ROCPROFSYS_USE_ROCM && ROCPROFILER_VERSION >= 600)
memory_alloc = 0x0005,
ompt = 0x0006,
#endif
amd_smi_sample = 0x0006,
cpu_freq_sample = 0x0007,
amd_smi_sample = 0x0007,
cpu_freq_sample = 0x0008,
fragmented_space = 0xFFFF
};
} // namespace trace_cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ storage_parser::consume_storage()
invoke_callbacks(header.type, _memory_allocate_sample);
break;
}
case entry_type::ompt:
{
ompt_region_sample _ompt_region_sample;
parse_data(sample.data(), _ompt_region_sample.name,
_ompt_region_sample.thread_id, _ompt_region_sample.operation,
_ompt_region_sample.correlation_id_internal,
_ompt_region_sample.correlation_id_ancestor,
_ompt_region_sample.start_timestamp,
_ompt_region_sample.end_timestamp,
_ompt_region_sample.args_str, _ompt_region_sample.call_stack);

invoke_callbacks(header.type, _ompt_region_sample);
break;
}
#endif
case entry_type::region:
{
Expand Down
Loading
Loading