Skip to content

Commit

Permalink
initial support for execution trace (#8136)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgschuey authored May 3, 2024
1 parent 2937c1b commit 8e5c564
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class AieTraceMetadata {
"all_stalls", "all_dma", "all_stalls_dma",
"all_stalls_s2mm", "all_stalls_mm2s",
"s2mm_channels", "mm2s_channels",
"s2mm_channels_stalls", "mm2s_channels_stalls"} },
"s2mm_channels_stalls", "mm2s_channels_stalls",
"execution"} },
{ module_type::mem_tile, {"input_channels", "input_channels_stalls",
"output_channels", "output_channels_stalls",
"s2mm_channels", "s2mm_channels_stalls",
Expand Down
17 changes: 17 additions & 0 deletions src/runtime_src/xdp/profile/plugin/aie_trace/client/aie_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,23 @@ namespace xdp {
cfgTile->active_core = tile.active_core;
cfgTile->active_memory = tile.active_memory;

// Catch core execution trace
if ((type == module_type::core) && (metricSet == "execution")) {
// Set start/end events, use execution packets, and start trace module
XAie_TraceStopEvent(&aieDevInst, loc, XAIE_CORE_MOD, coreTraceEndEvent);

// Driver requires at least one, non-zero trace event
XAie_TraceEvent(&aieDevInst, loc, XAIE_CORE_MOD, XAIE_EVENT_TRUE_CORE, 0);

XAie_Packet pkt = {0, 0};
XAie_TraceModeConfig(&aieDevInst, loc, XAIE_CORE_MOD, XAIE_TRACE_INST_EXEC);
XAie_TracePktConfig(&aieDevInst, loc, XAIE_CORE_MOD, pkt);

XAie_TraceStartEvent(&aieDevInst, loc, XAIE_CORE_MOD, coreTraceStartEvent);
(db->getStaticInfo()).addAIECfgTile(deviceId, cfgTile);
continue;
}

// Get vector of pre-defined metrics for this set
// NOTE: These are local copies to add tile-specific events
EventVector coreEvents;
Expand Down
36 changes: 29 additions & 7 deletions src/runtime_src/xdp/profile/plugin/aie_trace/edge/aie_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ namespace xdp {
auto typeInt = static_cast<int>(type);
auto& xaieTile = aieDevice->tile(col, row);
auto loc = XAie_TileLoc(col, row);

if ((type == module_type::core) && !aie::trace::isDmaSet(metricSet)) {
// If we're not looking at DMA events, then don't display the DMA
// If core is not active (i.e., DMA-only tile), then ignore this tile
Expand All @@ -341,6 +341,12 @@ namespace xdp {
: ((type == module_type::shim) ? "interface" : "AIE");
tileName.append(" tile (" + std::to_string(col) + "," + std::to_string(row) + ")");

if (aie::isInfoVerbosity()) {
std::stringstream infoMsg;
infoMsg << "Configuring " << tileName << " for trace using metric set " << metricSet;
xrt_core::message::send(severity_level::info, "XRT", infoMsg.str());
}

xaiefal::XAieMod core;
xaiefal::XAieMod memory;
xaiefal::XAieMod shim;
Expand Down Expand Up @@ -369,6 +375,28 @@ namespace xdp {
cfgTile->active_core = tile.active_core;
cfgTile->active_memory = tile.active_memory;

// Catch core execution trace
if ((type == module_type::core) && (metricSet == "execution")) {
// Set start/end events, use execution packets, and start trace module
auto coreTrace = core.traceControl();
if (coreTrace->setCntrEvent(coreTraceStartEvent, coreTraceEndEvent) != XAIE_OK)
continue;
coreTrace->reserve();

// Driver requires at least one, non-zero trace event
uint8_t slot;
coreTrace->reserveTraceSlot(slot);
coreTrace->setTraceEvent(slot, XAIE_EVENT_TRUE_CORE);

coreTrace->setMode(XAIE_TRACE_INST_EXEC);
XAie_Packet pkt = {0, 0};
coreTrace->setPkt(pkt);
coreTrace->start();

(db->getStaticInfo()).addAIECfgTile(deviceId, cfgTile);
continue;
}

// Get vector of pre-defined metrics for this set
// NOTE: these are local copies as we are adding tile/counter-specific events
EventVector coreEvents;
Expand All @@ -385,12 +413,6 @@ namespace xdp {
interfaceEvents = interfaceTileEventSets[metricSet];
}

if (aie::isInfoVerbosity()) {
std::stringstream infoMsg;
infoMsg << "Configuring " << tileName << " for trace using metric set " << metricSet;
xrt_core::message::send(severity_level::info, "XRT", infoMsg.str());
}

// Check Resource Availability
if (!tileHasFreeRsc(aieDevice, loc, type, metricSet)) {
xrt_core::message::send(severity_level::warning, "XRT",
Expand Down

0 comments on commit 8e5c564

Please sign in to comment.