[rocprofiler-sdk] Add SPM support flag to counter metrics#4139
Open
SrirakshaNag wants to merge 3 commits intodevelopfrom
Open
[rocprofiler-sdk] Add SPM support flag to counter metrics#4139SrirakshaNag wants to merge 3 commits intodevelopfrom
SrirakshaNag wants to merge 3 commits intodevelopfrom
Conversation
jrmadsen
requested changes
Mar 17, 2026
| { | ||
| auto agents = rocprofiler::agent::get_agents(); | ||
|
|
||
| const auto it = std::find_if(agents.begin(), agents.end(), [&](const auto* agent) { |
Contributor
There was a problem hiding this comment.
Suggested change
| const auto it = std::find_if(agents.begin(), agents.end(), [&](const auto* agent) { | |
| const auto itr = std::find_if(agents.begin(), agents.end(), [&](const auto* agent) { |
Use itr for consistency with other code.
Comment on lines
+47
to
+52
| bool valid() const | ||
| { | ||
| return create_packets_fn != nullptr && delete_packets_fn != nullptr && | ||
| spm_start_fn != nullptr && spm_stop_fn != nullptr && spm_decode_fn != nullptr && | ||
| spm_query_fn != nullptr && is_supported_fn != nullptr && handle != nullptr; | ||
| } |
Contributor
There was a problem hiding this comment.
Move implementation to .cpp file
| { | ||
| /** @brief Wrapper to aqlprofile functions for SPM | ||
| */ | ||
| class Dlsym |
Contributor
There was a problem hiding this comment.
rename this class to interface or something. In #2706, we will probably just have this point to internal functions (no dlsym).
Comment on lines
+33
to
+63
| class Dlsym | ||
| { | ||
| public: | ||
| using CreateFn = decltype(aqlprofile_spm_create_packets); | ||
| using DeleteFn = decltype(aqlprofile_spm_delete_packets); | ||
| using StartFn = decltype(aqlprofile_spm_start); | ||
| using StopFn = decltype(aqlprofile_spm_stop); | ||
| using DecodeFn = decltype(aqlprofile_spm_decode_stream_v1); | ||
| using QueryFn = decltype(aqlprofile_spm_decode_query); | ||
| using SupportFn = decltype(aqlprofile_spm_is_event_supported); | ||
|
|
||
| Dlsym(); | ||
| ~Dlsym(); | ||
|
|
||
| bool valid() const | ||
| { | ||
| return create_packets_fn != nullptr && delete_packets_fn != nullptr && | ||
| spm_start_fn != nullptr && spm_stop_fn != nullptr && spm_decode_fn != nullptr && | ||
| spm_query_fn != nullptr && is_supported_fn != nullptr && handle != nullptr; | ||
| } | ||
|
|
||
| CreateFn* create_packets_fn = nullptr; | ||
| DeleteFn* delete_packets_fn = nullptr; | ||
| StartFn* spm_start_fn = nullptr; | ||
| StopFn* spm_stop_fn = nullptr; | ||
| DecodeFn* spm_decode_fn = nullptr; | ||
| QueryFn* spm_query_fn = nullptr; | ||
| SupportFn* is_supported_fn = nullptr; | ||
| void* handle = nullptr; | ||
| }; | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| class Dlsym | |
| { | |
| public: | |
| using CreateFn = decltype(aqlprofile_spm_create_packets); | |
| using DeleteFn = decltype(aqlprofile_spm_delete_packets); | |
| using StartFn = decltype(aqlprofile_spm_start); | |
| using StopFn = decltype(aqlprofile_spm_stop); | |
| using DecodeFn = decltype(aqlprofile_spm_decode_stream_v1); | |
| using QueryFn = decltype(aqlprofile_spm_decode_query); | |
| using SupportFn = decltype(aqlprofile_spm_is_event_supported); | |
| Dlsym(); | |
| ~Dlsym(); | |
| bool valid() const | |
| { | |
| return create_packets_fn != nullptr && delete_packets_fn != nullptr && | |
| spm_start_fn != nullptr && spm_stop_fn != nullptr && spm_decode_fn != nullptr && | |
| spm_query_fn != nullptr && is_supported_fn != nullptr && handle != nullptr; | |
| } | |
| CreateFn* create_packets_fn = nullptr; | |
| DeleteFn* delete_packets_fn = nullptr; | |
| StartFn* spm_start_fn = nullptr; | |
| StopFn* spm_stop_fn = nullptr; | |
| DecodeFn* spm_decode_fn = nullptr; | |
| QueryFn* spm_query_fn = nullptr; | |
| SupportFn* is_supported_fn = nullptr; | |
| void* handle = nullptr; | |
| }; | |
| struct spm_interface | |
| { | |
| using spm_create_packets_fn_t = decltype(aqlprofile_spm_create_packets); | |
| // change names below similar to above | |
| using DeleteFn = decltype(aqlprofile_spm_delete_packets); | |
| using StartFn = decltype(aqlprofile_spm_start); | |
| using StopFn = decltype(aqlprofile_spm_stop); | |
| using DecodeFn = decltype(aqlprofile_spm_decode_stream_v1); | |
| using QueryFn = decltype(aqlprofile_spm_decode_query); | |
| using SupportFn = decltype(aqlprofile_spm_is_event_supported); | |
| spm_create_packets_fn_t* spm_create_packets = nullptr; | |
| DeleteFn* spm_delete_packets = nullptr; | |
| StartFn* spm_start = nullptr; | |
| StopFn* spm_stop = nullptr; | |
| DecodeFn* spm_decode_stream_v1 = nullptr; | |
| QueryFn* spm_decode_query = nullptr; | |
| SupportFn* spm_is_event_supported = nullptr; | |
| }; | |
| std::optional<spm_interface> | |
| construct_spm_interface(void* handle = nullptr); |
|
|
||
| Dlsym::~Dlsym() | ||
| { | ||
| if(handle) dlclose(handle); |
Contributor
There was a problem hiding this comment.
You are using RTLD_NOLOAD, you should not dlclose
|
|
||
| Dlsym::~Dlsym() | ||
| { | ||
| if(handle) dlclose(handle); |
Contributor
There was a problem hiding this comment.
You are using RTLD_NOLOAD, you should not dlclose
Comment on lines
+41
to
+57
| handle = dlopen("libhsa-amd-aqlprofile64.so", RTLD_NOLOAD | RTLD_LAZY); | ||
| if(!handle) handle = dlopen("libhsa-amd-aqlprofile64.so.1", RTLD_NOLOAD | RTLD_LAZY); | ||
|
|
||
| if(!handle) | ||
| { | ||
| ROCP_CI_LOG(WARNING) << fmt::format("aqlprofile cannot be opened"); | ||
| return; | ||
| } | ||
|
|
||
| create_packets_fn = (CreateFn*) dlsym(handle, "aqlprofile_spm_create_packets"); | ||
| delete_packets_fn = (DeleteFn*) dlsym(handle, "aqlprofile_spm_delete_packets"); | ||
| spm_start_fn = (StartFn*) dlsym(handle, "aqlprofile_spm_start"); | ||
| spm_stop_fn = (StopFn*) dlsym(handle, "aqlprofile_spm_stop"); | ||
| spm_decode_fn = (DecodeFn*) dlsym(handle, "aqlprofile_spm_decode_stream_v1"); | ||
| spm_query_fn = (QueryFn*) dlsym(handle, "aqlprofile_spm_decode_query"); | ||
| is_supported_fn = (SupportFn*) dlsym(handle, "aqlprofile_spm_is_event_supported"); | ||
| } |
Contributor
There was a problem hiding this comment.
If the library is expected to be loaded, you can just dlsym(RTLD_DEFAULT, ...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Technical Details
JIRA ID
Test Plan
Test Result
Submission Checklist