-
Notifications
You must be signed in to change notification settings - Fork 20.6k
hexagon: support for op-trace (fine-grain tracing of HVX/HMX/DMA events) #24592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
092420d
hex-optrace: add support for optrace and instrument matmul and flash-…
max-krasnyansky fd73301
hex-trace: improve trace event and prefetto generator
max-krasnyansky cad3e5f
hex-trace: add new script dedicated to handling traces, specifically …
max-krasnyansky 88e48c8
hex-trace: add --head/--tail options to profile and trace tools
max-krasnyansky 0619380
hex-trace: fix whitespaces
max-krasnyansky bb2bb37
hex-trace: fix flake8 warnings
max-krasnyansky 85b25be
hex-trace: fix flake8 warnings
max-krasnyansky 06e9c16
hmx-fa: restore q_tiles clearing
max-krasnyansky 05edb1d
hex-profile: remove circular dep in includes
max-krasnyansky 6b9f9d2
hex-trace: simplify trace sizing check
max-krasnyansky cdc7664
hex-profile: sort events in the summary by name
max-krasnyansky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #ifndef HEX_PROFILE_H | ||
| #define HEX_PROFILE_H | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <qurt.h> | ||
|
|
||
| #include "hex-utils.h" | ||
| #include "htp-ops.h" | ||
|
|
||
| #define HTP_TRACE_EVT_START 0 | ||
| #define HTP_TRACE_EVT_STOP 1 | ||
|
|
||
| #ifndef HEX_NUM_PMU_COUNTERS | ||
| #define HEX_NUM_PMU_COUNTERS 8 | ||
| #endif | ||
|
|
||
| static inline void hex_get_pmu(uint32_t counters[]) { | ||
| #if __HVX_ARCH__ >= 79 | ||
| asm volatile("%0 = upmucnt0" : "=r"(counters[0])); | ||
| asm volatile("%0 = upmucnt1" : "=r"(counters[1])); | ||
| asm volatile("%0 = upmucnt2" : "=r"(counters[2])); | ||
| asm volatile("%0 = upmucnt3" : "=r"(counters[3])); | ||
| asm volatile("%0 = upmucnt4" : "=r"(counters[4])); | ||
| asm volatile("%0 = upmucnt5" : "=r"(counters[5])); | ||
| asm volatile("%0 = upmucnt6" : "=r"(counters[6])); | ||
| asm volatile("%0 = upmucnt7" : "=r"(counters[7])); | ||
| #else | ||
| counters[0] = qurt_pmu_get(QURT_PMUCNT0); | ||
| counters[1] = qurt_pmu_get(QURT_PMUCNT1); | ||
| counters[2] = qurt_pmu_get(QURT_PMUCNT2); | ||
| counters[3] = qurt_pmu_get(QURT_PMUCNT3); | ||
| counters[4] = qurt_pmu_get(QURT_PMUCNT4); | ||
| counters[5] = qurt_pmu_get(QURT_PMUCNT5); | ||
| counters[6] = qurt_pmu_get(QURT_PMUCNT6); | ||
| counters[7] = qurt_pmu_get(QURT_PMUCNT7); | ||
| #endif | ||
| } | ||
|
|
||
| struct htp_thread_trace { | ||
| uint32_t count; | ||
| uint32_t max_events; | ||
| struct htp_trace_desc * events; | ||
| }; | ||
|
|
||
| static inline void htp_trace_event(struct htp_thread_trace * tr, uint16_t id, uint16_t info, uint32_t type) { | ||
| if (tr && tr->events && tr->count < tr->max_events) { | ||
| uint32_t idx = tr->count; | ||
| tr->events[idx].id = id; | ||
| tr->events[idx].info = info | (type == HTP_TRACE_EVT_STOP ? 0x8000 : 0); | ||
| tr->events[idx].cycles = (uint32_t) hex_get_cycles(); | ||
| tr->count++; | ||
| } | ||
| } | ||
|
|
||
| static inline void htp_trace_event_start(struct htp_thread_trace * tr, uint16_t id, uint16_t info) { | ||
| htp_trace_event(tr, id, info, HTP_TRACE_EVT_START); | ||
| } | ||
|
|
||
| static inline void htp_trace_event_stop(struct htp_thread_trace * tr, uint16_t id, uint16_t info) { | ||
| htp_trace_event(tr, id, info, HTP_TRACE_EVT_STOP); | ||
| } | ||
|
|
||
| #endif /* HEX_PROFILE_H */ |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this is not likely to overflow it's common curtesy to use
snprintf. :)I see there are a few other
sprintfs inhexagonalready...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thanks for reviewing.
I'm going to merge but will follow up shortly. I have another big MUL_MAT update that is almost ready and it uses/extends this tracing stuff a bit so I'll just replace all
sprintfs()in there.