Skip to content
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

Initial support for tracing DMA events in AIE tile memory modules #7859

Merged
merged 16 commits into from
Jan 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@ enum class module_type {
uint32_t broadcast_mask_west = BROADCAST_MASK_DEFAULT;
uint32_t broadcast_mask_east = BROADCAST_MASK_DEFAULT;
uint32_t internal_events_broadcast[NUM_BROADCAST_EVENTS] = {};
bool port_trace_is_master[NUM_SWITCH_MONITOR_PORTS];
int8_t port_trace_ids[NUM_SWITCH_MONITOR_PORTS];
std::vector<aie_cfg_counter> pc;

aie_cfg_base(uint32_t count) : pc(count) {};
aie_cfg_base(uint32_t count) : pc(count) {
for (uint32_t i=0; i < NUM_SWITCH_MONITOR_PORTS; ++i) {
port_trace_is_master[i] = false;
port_trace_ids[i] = -1;
}
};
};

/*
Expand All @@ -226,7 +233,6 @@ enum class module_type {
{
public:
uint32_t trace_mode = 1;
std::string port_trace = "null";
aie_cfg_core() : aie_cfg_base(4)
{
group_event_config = {
Expand Down Expand Up @@ -261,16 +267,9 @@ enum class module_type {
class aie_cfg_peripheral_tile : public aie_cfg_base
{
public:
bool port_trace_is_master[NUM_SWITCH_MONITOR_PORTS];
int8_t port_trace_ids[NUM_SWITCH_MONITOR_PORTS];
int8_t s2mm_channels[NUM_CHANNEL_SELECTS] = {-1, -1};
int8_t mm2s_channels[NUM_CHANNEL_SELECTS] = {-1, -1};
aie_cfg_peripheral_tile() : aie_cfg_base(4) {
for (uint32_t i=0; i < NUM_SWITCH_MONITOR_PORTS; ++i) {
port_trace_is_master[i] = false;
port_trace_ids[i] = -1;
}
}
aie_cfg_peripheral_tile() : aie_cfg_base(4) {}
};

/*
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/xdp/profile/device/aieTraceS2MM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void AIETraceS2MM::init(uint64_t bo_size, int64_t bufaddr, bool circular)
uint32_t regValue = 0;
read(TS2MM_AP_CTRL, BYTES_PER_WORD, &regValue);
std::stringstream msg;
msg << "AIE TraceS2MM AP control register after first start: 0x" << std::hex << regValue;
msg << "AIE TraceS2MM AP control register after second start: 0x" << std::hex << regValue;
xrt_core::message::send(severity_level::debug, "XRT", msg.str());
}
// End of temporary code
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/xdp/profile/device/traceS2MM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void TraceS2MM::init(uint64_t bo_size, int64_t bufaddr, bool circular)
uint32_t regValue = 0;
read(TS2MM_AP_CTRL, BYTES_PER_WORD, &regValue);
std::stringstream msg;
msg << "AIE TraceS2MM AP control register after first start: 0x" << std::hex << regValue;
msg << "AIE TraceS2MM AP control register after second start: 0x" << std::hex << regValue;
xrt_core::message::send(severity_level::debug, "XRT", msg.str());
}
// End of temporary code
Expand Down
22 changes: 17 additions & 5 deletions src/runtime_src/xdp/profile/device/tracedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,34 @@ constexpr unsigned int BYTES_128BIT = 16;
constexpr uint32_t NUM_TRACE_EVENTS = 8;
constexpr uint32_t NUM_OUTPUT_TRACE_EVENTS = 9;
constexpr uint32_t NUM_BROADCAST_EVENTS = 16;
constexpr uint32_t EVENT_CORE_ACTIVE = 28;
constexpr uint32_t EVENT_CORE_DISABLED = 29;
constexpr uint16_t EVENT_MEM_TILE_DMA_MM2S_SEL0_STALLED_LOCK = 35;
constexpr uint16_t EVENT_MEM_TILE_DMA_S2MM_SEL0_STREAM_STARVATION = 37;
constexpr uint32_t BROADCAST_MASK_DEFAULT = 65535;
constexpr uint32_t NUM_TRACE_PCS = 4;
constexpr uint32_t NUM_MEM_TRACE_PCS = 2;
constexpr uint32_t NUM_COMBO_EVENT_CONTROL = 3;
constexpr uint32_t NUM_COMBO_EVENT_INPUT = 4;
constexpr uint32_t NUM_SWITCH_MONITOR_PORTS = 8;
constexpr uint32_t NUM_CHANNEL_SELECTS = 2;

constexpr uint32_t BROADCAST_MASK_DEFAULT = 65535;
constexpr uint32_t CORE_BROADCAST_EVENT_BASE = 107;
constexpr uint32_t ES1_TRACE_COUNTER = 1020;
constexpr uint32_t ES2_TRACE_COUNTER = 0x3FF00;

constexpr uint32_t EVENT_CORE_ACTIVE = 28;
constexpr uint32_t EVENT_CORE_DISABLED = 29;
constexpr uint16_t EVENT_MEM_DMA_MM2S_0_STALLED_LOCK = 33;
constexpr uint16_t EVENT_MEM_DMA_MM2S_1_STALLED_LOCK = 34;
constexpr uint16_t EVENT_MEM_DMA_S2MM_0_STREAM_STARVATION = 35;
constexpr uint16_t EVENT_MEM_DMA_S2MM_1_STREAM_STARVATION = 36;
constexpr uint16_t EVENT_MEM_TILE_DMA_MM2S_SEL0_STALLED_LOCK = 35;
constexpr uint16_t EVENT_MEM_TILE_DMA_S2MM_SEL0_STREAM_STARVATION = 37;

constexpr uint32_t GROUP_CORE_STALL_MASK = 0x0000000F;
constexpr uint32_t GROUP_CORE_FUNCTIONS_MASK = 0x0000000C;
constexpr uint32_t GROUP_STREAM_SWITCH_RUNNING_MASK = 0x00002222;

constexpr uint64_t AIE_OFFSET_EDGE_CONTROL_MEM_TILE = 0x94408;
constexpr uint64_t AIE_OFFSET_EDGE_CONTROL_MEM = 0x14408;

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ namespace xdp {
&& shimTileMetricsSettings.empty() && shimGraphMetricsSettings.empty()) {
isValidMetrics = false;
} else {
getConfigMetricsForTiles(aieTileMetricsSettings, aieGraphMetricsSettings, module_type::core);
// Use DMA type here to include both core-active tiles and DMA-only tiles
getConfigMetricsForTiles(aieTileMetricsSettings, aieGraphMetricsSettings, module_type::dma);
getConfigMetricsForTiles(memTileMetricsSettings, memGraphMetricsSettings, module_type::mem_tile);
getConfigMetricsForInterfaceTiles(shimTileMetricsSettings, shimGraphMetricsSettings);
setTraceStartControl(compilerOptions.graph_iterator_event);
Expand Down Expand Up @@ -314,8 +315,8 @@ namespace xdp {

std::set<tile_type> allValidTiles;
auto validTilesVec = metadataReader->getTiles("all", type, "all");
std::unique_copy(validTilesVec.begin(), validTilesVec.end(), std::inserter(allValidTiles, allValidTiles.end()),
tileCompare);
std::unique_copy(validTilesVec.begin(), validTilesVec.end(),
std::inserter(allValidTiles, allValidTiles.end()), tileCompare);

// STEP 1 : Parse per-graph and/or per-kernel settings

Expand Down Expand Up @@ -606,6 +607,8 @@ namespace xdp {

// Set default, check validity, and remove "off" tiles
bool showWarning = true;
bool showWarning2 = true;
bool showWarning3 = true;
std::vector<tile_type> offTiles;
auto defaultSet = defaultSets[type];
auto coreSets = metricSets[module_type::core];
Expand Down Expand Up @@ -635,15 +638,30 @@ namespace xdp {
}
tileMetric.second = defaultSet;
}

// Check for deprecated metric set names
if (tileMetric.second == "functions_partial_stalls") {
if (showWarning2) {
xrt_core::message::send(severity_level::warning, "XRT",
"The metric set functions_partial_stalls is being renamed to partial_stalls. "
"Please use the new set name starting in 2024.2.");
showWarning2 = false;
}
}
if (tileMetric.second == "functions_all_stalls") {
if (showWarning3) {
xrt_core::message::send(severity_level::warning, "XRT",
"The metric set functions_all_stalls is being renamed to all_stalls. "
"Please use the new set name starting in 2024.2.");
showWarning3 = false;
}
}
}

// Remove all the "off" tiles
for (auto &t : offTiles) {
configMetrics.erase(t);
}

// If needed, turn on debug fal messages
// xaiefal::Logger::get().setLogLevel(xaiefal::LogLevel::DEBUG);
}

// Resolve metrics for interface tiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,16 @@ class AieTraceMetadata {

std::map<module_type, std::string> defaultSets {
{ module_type::core, "functions"},
{ module_type::dma, "functions"},
{ module_type::mem_tile, "input_channels"},
{ module_type::shim, "input_ports"}
};

std::map <module_type, std::vector<std::string>> metricSets {
{ module_type::core, {"functions", "functions_partial_stalls",
"functions_all_stalls", "all"} },
"functions_all_stalls", "partial_stalls",
"all_stalls", "all_dma", "all_stalls_dma",
"s2mm_channels_stalls", "mm2s_channels_stalls"} },
{ module_type::mem_tile, {"input_channels", "input_channels_stalls",
"output_channels", "output_channels_stalls",
"s2mm_channels", "s2mm_channels_stalls",
Expand Down
Loading