|
| 1 | +.. meta:: |
| 2 | + :description: Defined concepts commonly used in AQLprofile |
| 3 | + :keywords: AQLprofile, ROCm |
| 4 | + |
| 5 | +AQLprofile glossary |
| 6 | +=================== |
| 7 | + |
| 8 | +Learn the definitions of concepts commonly used in AQLprofile. |
| 9 | + |
| 10 | +Agents |
| 11 | +------ |
| 12 | + |
| 13 | +Agents represent computational devices (CPUs, GPUs) in the Heterogeneous |
| 14 | +System Architecture (HSA) runtime. In AQLprofile, agents are discovered |
| 15 | +via HSA APIs and encapsulated in the ``AgentInfo`` structure. Each agent |
| 16 | +contains metadata including device type, name, compute unit count, and |
| 17 | +memory pools. |
| 18 | + |
| 19 | +Agents are enumerated using HSA API ``hsa_iterate_agents``, and their |
| 20 | +properties are queried via another HSA API, ``hsa_agent_get_info``. |
| 21 | +Agents are used to target specific GPUs for profiling, and to allocate |
| 22 | +resources such as command buffers and memory pools. |
| 23 | + |
| 24 | +Counters and events |
| 25 | +------------------- |
| 26 | + |
| 27 | +Performance counters are special circuits on the hardware that count |
| 28 | +specific GPU events (for example, cycles, instructions, cache hits). Events |
| 29 | +specify which counters to collect, identified by block name, block |
| 30 | +index, and counter ID. |
| 31 | + |
| 32 | +- Events are described using ``hsa_ven_amd_aqlprofile_event_t`` |
| 33 | + structures. |
| 34 | +- Events are grouped into profiles and collected during profiling |
| 35 | + sessions. |
| 36 | + |
| 37 | +.. code:: cpp |
| 38 | +
|
| 39 | + const hsa_ven_amd_aqlprofile_event_t events_arr1[] = { |
| 40 | + {HSA_VEN_AMD_AQLPROFILE_BLOCK_NAME_SQ, 0, 2 /*CYCLES*/}, |
| 41 | + {HSA_VEN_AMD_AQLPROFILE_BLOCK_NAME_SQ, 0, 3 /*BUSY_CYCLES*/}, |
| 42 | + // ... |
| 43 | + }; |
| 44 | +
|
| 45 | +Counter blocks |
| 46 | +-------------- |
| 47 | + |
| 48 | +Counter blocks correspond to hardware units on the GPU (for example, SQ, TCC, |
| 49 | +TCP). Each block exposes a set of counters/events. |
| 50 | + |
| 51 | +- Block names (for example, ``HSA_VEN_AMD_AQLPROFILE_BLOCK_NAME_SQ``) map to |
| 52 | + specific hardware blocks. |
| 53 | +- Events specify both the block and the counter within that block. |
| 54 | + |
| 55 | +Command buffers |
| 56 | +--------------- |
| 57 | + |
| 58 | +Command buffers are memory regions that store AQL packets and PM4 |
| 59 | +commands, which control GPU profiling operations. They're allocated per |
| 60 | +agent, and must meet alignment and size requirements dictated by the |
| 61 | +hardware. |
| 62 | + |
| 63 | +Command packets |
| 64 | +--------------- |
| 65 | + |
| 66 | +Command packets are AQL or PM4 packets that encode profiling commands |
| 67 | +for the GPU. They're constructed and written into command buffers. |
| 68 | + |
| 69 | +They're built using AQLprofile APIs or helper functions and submitted to |
| 70 | +the GPU via HSA queues. |
| 71 | + |
| 72 | +.. code:: cpp |
| 73 | +
|
| 74 | + bool Queue::Submit(hsa_ext_amd_aql_pm4_packet_t* packet) { |
| 75 | + // Write packet to queue and signal doorbell |
| 76 | + } |
| 77 | +
|
| 78 | +Output buffer |
| 79 | +------------- |
| 80 | + |
| 81 | +Output buffers are memory regions that store outputs such as counter |
| 82 | +values and thread trace tokens. They're allocated using HSA memory pools |
| 83 | +associated with the agent. |
| 84 | + |
| 85 | +Profile object |
| 86 | +-------------- |
| 87 | + |
| 88 | +The profile object encapsulates all information required to perform a |
| 89 | +profiling session. It's represented by the |
| 90 | +``hsa_ven_amd_aqlprofile_profile_t`` struct, which includes the agent, |
| 91 | +event type, list of events, command buffer, and additional parameters. |
| 92 | + |
| 93 | +Profile objects are constructed by specifying the agent, event type |
| 94 | +(PMC, SQTT), events to collect, and associated buffers. They're passed |
| 95 | +to AQLprofile APIs to start, stop, and read profiling data. |
| 96 | + |
| 97 | +.. code:: cpp |
| 98 | +
|
| 99 | + hsa_ven_amd_aqlprofile_profile_t *profile = |
| 100 | + new hsa_ven_amd_aqlprofile_profile_t{ |
| 101 | + agent_info->dev_id, |
| 102 | + HSA_VEN_AMD_AQLPROFILE_EVENT_TYPE_PMC, |
| 103 | + events, |
| 104 | + num_events, |
| 105 | + NULL, |
| 106 | + 0, |
| 107 | + 0, |
| 108 | + 0}; |
| 109 | +
|
0 commit comments