Skip to content

Commit 3887073

Browse files
authored
[XDP] Rearrange APIs to make more accessible across implementations (#9149)
1 parent 76270ed commit 3887073

File tree

7 files changed

+296
-388
lines changed

7 files changed

+296
-388
lines changed

src/runtime_src/xdp/profile/plugin/aie_base/aie_base_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#define AIE_BASE_UTIL_DOT_H
66

77
#include <cstdint>
8+
#include <string>
9+
#include <set>
810
#include "xdp/profile/database/static_info/aie_constructs.h"
911
#include "xdp/profile/plugin/aie_base/generations/aie_generations.h"
1012

src/runtime_src/xdp/profile/plugin/aie_trace/client/aie_trace.cpp

Lines changed: 4 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -567,134 +567,6 @@ namespace xdp {
567567
return comboEvents;
568568
}
569569

570-
/****************************************************************************
571-
* Configure group events (core modules only)
572-
***************************************************************************/
573-
void AieTrace_WinImpl::configGroupEvents(const XAie_LocType loc, const XAie_ModuleType mod,
574-
const module_type type, const std::string metricSet)
575-
{
576-
// Only needed for core module and metric sets that include DMA events
577-
if (!aie::isDmaSet(metricSet) || (type != module_type::core))
578-
return;
579-
580-
// Set masks for group events
581-
XAie_EventGroupControl(&aieDevInst, loc, mod, XAIE_EVENT_GROUP_CORE_PROGRAM_FLOW_CORE,
582-
GROUP_CORE_FUNCTIONS_MASK);
583-
XAie_EventGroupControl(&aieDevInst, loc, mod, XAIE_EVENT_GROUP_CORE_STALL_CORE,
584-
GROUP_CORE_STALL_MASK);
585-
XAie_EventGroupControl(&aieDevInst, loc, mod, XAIE_EVENT_GROUP_STREAM_SWITCH_CORE,
586-
GROUP_STREAM_SWITCH_RUNNING_MASK);
587-
}
588-
589-
/****************************************************************************
590-
* Configure event selection (memory tiles only)
591-
***************************************************************************/
592-
void AieTrace_WinImpl::configEventSelections(const XAie_LocType loc, const module_type type,
593-
const std::string metricSet, const uint8_t channel0,
594-
const uint8_t channel1, aie_cfg_base& config)
595-
{
596-
if (type != module_type::mem_tile)
597-
return;
598-
599-
XAie_DmaDirection dmaDir = aie::isInputSet(type, metricSet) ? DMA_S2MM : DMA_MM2S;
600-
601-
if (aie::isDebugVerbosity()) {
602-
std::string typeName = (dmaDir == DMA_S2MM) ? "S2MM" : "MM2S";
603-
std::string msg = "Configuring memory tile event selections to DMA "
604-
+ typeName + " channels " + std::to_string(channel0)
605-
+ " and " + std::to_string(channel1);
606-
xrt_core::message::send(severity_level::debug, "XRT", msg);
607-
}
608-
609-
XAie_EventSelectDmaChannel(&aieDevInst, loc, 0, dmaDir, channel0);
610-
XAie_EventSelectDmaChannel(&aieDevInst, loc, 1, dmaDir, channel1);
611-
612-
// Record for runtime config file
613-
config.port_trace_ids[0] = channel0;
614-
config.port_trace_ids[1] = channel1;
615-
if (aie::isInputSet(type, metricSet)) {
616-
config.port_trace_is_master[0] = true;
617-
config.port_trace_is_master[1] = true;
618-
config.s2mm_channels[0] = channel0;
619-
if (channel0 != channel1)
620-
config.s2mm_channels[1] = channel1;
621-
}
622-
else {
623-
config.port_trace_is_master[0] = false;
624-
config.port_trace_is_master[1] = false;
625-
config.mm2s_channels[0] = channel0;
626-
if (channel0 != channel1)
627-
config.mm2s_channels[1] = channel1;
628-
}
629-
}
630-
631-
/****************************************************************************
632-
* Configure edge detection events
633-
***************************************************************************/
634-
void AieTrace_WinImpl::configEdgeEvents(const tile_type& tile, const module_type type,
635-
const std::string metricSet, const XAie_Events event,
636-
const uint8_t channel)
637-
{
638-
if ((event != XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM_TILE)
639-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM_TILE)
640-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM)
641-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM))
642-
return;
643-
644-
// Catch memory tiles
645-
if (type == module_type::mem_tile) {
646-
// Event is DMA_S2MM_Sel0_stream_starvation or DMA_MM2S_Sel0_stalled_lock
647-
uint16_t eventNum = aie::isInputSet(type, metricSet)
648-
? EVENT_MEM_TILE_DMA_S2MM_SEL0_STREAM_STARVATION
649-
: EVENT_MEM_TILE_DMA_MM2S_SEL0_STALLED_LOCK;
650-
651-
// Register Edge_Detection_event_control
652-
// 26 Event 1 triggered on falling edge
653-
// 25 Event 1 triggered on rising edge
654-
// 23:16 Input event for edge event 1
655-
// 10 Event 0 triggered on falling edge
656-
// 9 Event 0 triggered on rising edge
657-
// 7:0 Input event for edge event 0
658-
uint32_t edgeEventsValue = (1 << 26) + (eventNum << 16) + (1 << 9) + eventNum;
659-
660-
xrt_core::message::send(severity_level::debug, "XRT",
661-
"Configuring memory tile edge events to detect rise and fall of event "
662-
+ std::to_string(eventNum));
663-
664-
auto tileOffset = _XAie_GetTileAddr(&aieDevInst, tile.row, tile.col);
665-
XAie_Write32(&aieDevInst, tileOffset + AIE_OFFSET_EDGE_CONTROL_MEM_TILE,
666-
edgeEventsValue);
667-
return;
668-
}
669-
670-
// Below is AIE tile support
671-
672-
// Event is DMA_MM2S_stalled_lock or DMA_S2MM_stream_starvation
673-
// Event is DMA_S2MM_Sel0_stream_starvation or DMA_MM2S_Sel0_stalled_lock
674-
uint16_t eventNum = aie::isInputSet(type, metricSet)
675-
? ((channel == 0) ? EVENT_MEM_DMA_MM2S_0_STALLED_LOCK
676-
: EVENT_MEM_DMA_MM2S_1_STALLED_LOCK)
677-
: ((channel == 0) ? EVENT_MEM_DMA_S2MM_0_STREAM_STARVATION
678-
: EVENT_MEM_DMA_S2MM_1_STREAM_STARVATION);
679-
680-
// Register Edge_Detection_event_control
681-
// 26 Event 1 triggered on falling edge
682-
// 25 Event 1 triggered on rising edge
683-
// 23:16 Input event for edge event 1
684-
// 10 Event 0 triggered on falling edge
685-
// 9 Event 0 triggered on rising edge
686-
// 7:0 Input event for edge event 0
687-
uint32_t edgeEventsValue = (1 << 26) + (eventNum << 16) + (1 << 9) + eventNum;
688-
689-
xrt_core::message::send(severity_level::debug, "XRT",
690-
"Configuring AIE tile edge events to detect rise and fall of event "
691-
+ std::to_string(eventNum));
692-
693-
auto tileOffset = _XAie_GetTileAddr(&aieDevInst, tile.row, tile.col);
694-
XAie_Write32(&aieDevInst, tileOffset + AIE_OFFSET_EDGE_CONTROL_MEM,
695-
edgeEventsValue);
696-
}
697-
698570
/****************************************************************************
699571
* Configure requested tiles with trace metrics and settings
700572
***************************************************************************/
@@ -858,7 +730,7 @@ namespace xdp {
858730

859731
// Configure combo & group events (e.g., to monitor DMA channels)
860732
auto comboEvents = configComboEvents(loc, mod, type, metricSet, cfgTile->core_trace_config);
861-
configGroupEvents(loc, mod, type, metricSet);
733+
aie::trace::configGroupEvents(&aieDevInst, loc, mod, type, metricSet);
862734

863735
// Set overall start/end for trace capture
864736
// NOTE: This needs to be done first.
@@ -1027,8 +899,8 @@ namespace xdp {
1027899

1028900
// Specify Sel0/Sel1 for memory tile events 21-44
1029901
if (type == module_type::mem_tile) {
1030-
configEventSelections(loc, type, metricSet, channel0, channel1,
1031-
cfgTile->memory_tile_trace_config);
902+
aie::trace::configEventSelections(&aieDevInst, loc, type, metricSet, channel0, channel1,
903+
cfgTile->memory_tile_trace_config);
1032904
}
1033905
else {
1034906
// Record if these are channel-specific events
@@ -1075,7 +947,7 @@ namespace xdp {
1075947
numMemoryTraceEvents++;
1076948

1077949
// Configure edge events (as needed)
1078-
configEdgeEvents(tile, type, metricSet, memoryEvents[i], channel0);
950+
aie::trace::configEdgeEvents(&aieDevInst, tile, type, metricSet, memoryEvents[i], channel0);
1079951

1080952
// Update config file
1081953
uint16_t phyEvent = 0;

src/runtime_src/xdp/profile/plugin/aie_trace/client/aie_trace.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ namespace xdp {
4646
std::vector<XAie_Events> configComboEvents(const XAie_LocType loc, const XAie_ModuleType mod,
4747
const module_type type, const std::string metricSet,
4848
aie_cfg_base& config);
49-
void configGroupEvents(const XAie_LocType loc, const XAie_ModuleType mod,
50-
const module_type type, const std::string metricSet);
51-
void configEventSelections(const XAie_LocType loc, const module_type type,
52-
const std::string metricSet, const uint8_t channel0,
53-
const uint8_t channel1, aie_cfg_base& config);
54-
void configEdgeEvents(const tile_type& tile, const module_type type,
55-
const std::string metricSet, const XAie_Events event,
56-
const uint8_t channel = 0);
5749

5850
private:
5951
typedef XAie_Events EventType;

src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.cpp

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -268,135 +268,6 @@ namespace xdp::aie::trace {
268268
return comboEvents;
269269
}
270270

271-
/****************************************************************************
272-
* Configure group events (core modules only)
273-
***************************************************************************/
274-
void configGroupEvents(XAie_DevInst* aieDevInst, const XAie_LocType loc,
275-
const XAie_ModuleType mod, const module_type type,
276-
const std::string metricSet)
277-
{
278-
// Only needed for core module and metric sets that include DMA events
279-
if (!xdp::aie::isDmaSet(metricSet) || (type != module_type::core))
280-
return;
281-
282-
// Set masks for group events
283-
XAie_EventGroupControl(aieDevInst, loc, mod, XAIE_EVENT_GROUP_CORE_PROGRAM_FLOW_CORE,
284-
GROUP_CORE_FUNCTIONS_MASK);
285-
XAie_EventGroupControl(aieDevInst, loc, mod, XAIE_EVENT_GROUP_CORE_STALL_CORE,
286-
GROUP_CORE_STALL_MASK);
287-
XAie_EventGroupControl(aieDevInst, loc, mod, XAIE_EVENT_GROUP_STREAM_SWITCH_CORE,
288-
GROUP_STREAM_SWITCH_RUNNING_MASK);
289-
}
290-
291-
/****************************************************************************
292-
* Configure event selection (memory tiles only)
293-
***************************************************************************/
294-
void configEventSelections(XAie_DevInst* aieDevInst, const XAie_LocType loc,
295-
const module_type type, const std::string metricSet,
296-
const uint8_t channel0, const uint8_t channel1,
297-
aie_cfg_base& config)
298-
{
299-
if (type != module_type::mem_tile)
300-
return;
301-
302-
XAie_DmaDirection dmaDir = isInputSet(type, metricSet) ? DMA_S2MM : DMA_MM2S;
303-
304-
if (aie::isDebugVerbosity()) {
305-
std::string typeName = (dmaDir == DMA_S2MM) ? "S2MM" : "MM2S";
306-
std::string msg = "Configuring memory tile event selections to DMA "
307-
+ typeName + " channels " + std::to_string(channel0)
308-
+ " and " + std::to_string(channel1);
309-
xrt_core::message::send(severity_level::debug, "XRT", msg);
310-
}
311-
312-
XAie_EventSelectDmaChannel(aieDevInst, loc, 0, dmaDir, channel0);
313-
XAie_EventSelectDmaChannel(aieDevInst, loc, 1, dmaDir, channel1);
314-
315-
// Record for runtime config file
316-
config.port_trace_ids[0] = channel0;
317-
config.port_trace_ids[1] = channel1;
318-
if (aie::isInputSet(type, metricSet)) {
319-
config.port_trace_is_master[0] = true;
320-
config.port_trace_is_master[1] = true;
321-
config.s2mm_channels[0] = channel0;
322-
if (channel0 != channel1)
323-
config.s2mm_channels[1] = channel1;
324-
}
325-
else {
326-
config.port_trace_is_master[0] = false;
327-
config.port_trace_is_master[1] = false;
328-
config.mm2s_channels[0] = channel0;
329-
if (channel0 != channel1)
330-
config.mm2s_channels[1] = channel1;
331-
}
332-
}
333-
334-
/****************************************************************************
335-
* Configure edge detection events
336-
***************************************************************************/
337-
void configEdgeEvents(XAie_DevInst* aieDevInst, const tile_type& tile,
338-
const module_type type, const std::string metricSet,
339-
const XAie_Events event, const uint8_t channel)
340-
{
341-
if ((event != XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM_TILE)
342-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM_TILE)
343-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM)
344-
&& (event != XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM))
345-
return;
346-
347-
// Catch memory tiles
348-
if (type == module_type::mem_tile) {
349-
// Event is DMA_S2MM_Sel0_stream_starvation or DMA_MM2S_Sel0_stalled_lock
350-
uint16_t eventNum = isInputSet(type, metricSet)
351-
? EVENT_MEM_TILE_DMA_S2MM_SEL0_STREAM_STARVATION
352-
: EVENT_MEM_TILE_DMA_MM2S_SEL0_STALLED_LOCK;
353-
354-
// Register Edge_Detection_event_control
355-
// 26 Event 1 triggered on falling edge
356-
// 25 Event 1 triggered on rising edge
357-
// 23:16 Input event for edge event 1
358-
// 10 Event 0 triggered on falling edge
359-
// 9 Event 0 triggered on rising edge
360-
// 7:0 Input event for edge event 0
361-
uint32_t edgeEventsValue = (1 << 26) + (eventNum << 16) + (1 << 9) + eventNum;
362-
363-
xrt_core::message::send(severity_level::debug, "XRT",
364-
"Configuring memory tile edge events to detect rise and fall of event "
365-
+ std::to_string(eventNum));
366-
367-
auto tileOffset = XAie_GetTileAddr(aieDevInst, tile.row, tile.col);
368-
XAie_Write32(aieDevInst, tileOffset + AIE_OFFSET_EDGE_CONTROL_MEM_TILE,
369-
edgeEventsValue);
370-
return;
371-
}
372-
373-
// Below is AIE tile support
374-
375-
// Event is DMA_MM2S_stalled_lock or DMA_S2MM_stream_starvation
376-
uint16_t eventNum = isInputSet(type, metricSet)
377-
? ((channel == 0) ? EVENT_MEM_DMA_MM2S_0_STALLED_LOCK
378-
: EVENT_MEM_DMA_MM2S_1_STALLED_LOCK)
379-
: ((channel == 0) ? EVENT_MEM_DMA_S2MM_0_STREAM_STARVATION
380-
: EVENT_MEM_DMA_S2MM_1_STREAM_STARVATION);
381-
382-
// Register Edge_Detection_event_control
383-
// 26 Event 1 triggered on falling edge
384-
// 25 Event 1 triggered on rising edge
385-
// 23:16 Input event for edge event 1
386-
// 10 Event 0 triggered on falling edge
387-
// 9 Event 0 triggered on rising edge
388-
// 7:0 Input event for edge event 0
389-
uint32_t edgeEventsValue = (1 << 26) + (eventNum << 16) + (1 << 9) + eventNum;
390-
391-
xrt_core::message::send(severity_level::debug, "XRT",
392-
"Configuring AIE tile edge events to detect rise and fall of event "
393-
+ std::to_string(eventNum));
394-
395-
auto tileOffset = XAie_GetTileAddr(aieDevInst, tile.row, tile.col);
396-
XAie_Write32(aieDevInst, tileOffset + AIE_OFFSET_EDGE_CONTROL_MEM,
397-
edgeEventsValue);
398-
}
399-
400271
/****************************************************************************
401272
* Configure delay for trace start event
402273
***************************************************************************/

src/runtime_src/xdp/profile/plugin/aie_trace/util/aie_trace_config.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,46 +55,6 @@ namespace xdp::aie::trace {
5555
const module_type type, const std::string metricSet,
5656
aie_cfg_base& config);
5757

58-
/**
59-
* @brief Configure group events (core modules only)
60-
* @param aieDevInst AIE device instance
61-
* @param loc Location of tile
62-
* @param mod Module type (used by driver)
63-
* @param type Module/tile type
64-
* @param metricSet Name of requested metric set
65-
*/
66-
void configGroupEvents(XAie_DevInst* aieDevInst, const XAie_LocType loc,
67-
const XAie_ModuleType mod, const module_type type,
68-
const std::string metricSet);
69-
70-
/**
71-
* @brief Configure event selections for DMA channels
72-
* @param aieDevInst AIE device instance
73-
* @param loc Location of tile
74-
* @param type Module/tile type
75-
* @param metricSet Name of requested metric set
76-
* @param channel0 First specified channel number
77-
* @param channel1 Second specified channel number
78-
* @param config Class used to document configuration
79-
*/
80-
void configEventSelections(XAie_DevInst* aieDevInst, const XAie_LocType loc,
81-
const module_type type, const std::string metricSet,
82-
const uint8_t channel0, const uint8_t channel1,
83-
aie_cfg_base& config);
84-
85-
/**
86-
* @brief Configure edge detection events
87-
* @param aieDevInst AIE device instance
88-
* @param tile Tile metadata
89-
* @param type Module/tile type
90-
* @param metricSet Name of requested metric set
91-
* @param event Requested event ID
92-
* @param channel Channel number to use for edge events
93-
*/
94-
void configEdgeEvents(XAie_DevInst* aieDevInst, const tile_type& tile,
95-
const module_type type, const std::string metricSet,
96-
const XAie_Events event, const uint8_t channel = 0);
97-
9858
/**
9959
* @brief Configure start of event trace using time delay
10060
* @param core Core module in FAL/resource manager

0 commit comments

Comments
 (0)