Skip to content

Commit

Permalink
[XDP] Fix for profiling plugins to work on independent compilation de…
Browse files Browse the repository at this point in the history
…signs (Xilinx#8424)
  • Loading branch information
vipangul authored Sep 18, 2024
1 parent 9c5d447 commit 0cf086c
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/runtime_src/xdp/profile/database/static_info/aie_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,16 @@ namespace xdp::aie {
return infoPt;
}

void displayColShiftInfo(uint8_t colShift)
{
static bool displayed = false;
if (colShift>0 && !displayed) {
std::stringstream msg;
msg << "Partition start column shift of " << +colShift << " was found."
<< " Tile locations are adjusted by this column shift.";
xrt_core::message::send(severity_level::info, "XRT", msg.str());
displayed = true;
}
}

} // namespace xdp::aie
3 changes: 3 additions & 0 deletions src/runtime_src/xdp/profile/database/static_info/aie_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ namespace xdp::aie {
boost::property_tree::ptree
getAIEPartitionInfoClient(void* hwCtxImpl);

XDP_CORE_EXPORT
void displayColShiftInfo(uint8_t colShift);

} // namespace xdp::aie

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ AIEControlConfigFiletype::getAIETileRowOffset() const {
return xdp::aie::getAIETileRowOffset(aie_meta, "aie_metadata.driver_config.aie_tile_row_start");
}

std::vector<uint8_t>
AIEControlConfigFiletype::getPartitionOverlayStartCols() const {
return std::vector<uint8_t>{0};
}

std::vector<std::string>
AIEControlConfigFiletype::getValidGraphs() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class AIEControlConfigFiletype : public xdp::aie::BaseFiletypeImpl {

uint8_t getAIETileRowOffset() const override;

std::vector<uint8_t>
getPartitionOverlayStartCols() const override;

std::vector<std::string>
getValidGraphs() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#define XDP_CORE_SOURCE

#include "aie_trace_config_filetype.h"
#include "xdp/profile/database/static_info/aie_util.h"
#include "core/common/message.h"
#include "xdp/profile/database/static_info/aie_util.h"
#include "xdp/profile/plugin/vp_base/utility.h"

#include <boost/algorithm/string.hpp>
#include <boost/property_tree/json_parser.hpp>
Expand All @@ -31,6 +32,22 @@ using severity_level = xrt_core::message::severity_level;
AIETraceConfigFiletype::AIETraceConfigFiletype(boost::property_tree::ptree& aie_project)
: AIEControlConfigFiletype(aie_project) {}

std::vector<uint8_t>
AIETraceConfigFiletype::getPartitionOverlayStartCols() const {
auto partitionOverlays = aie_meta.get_child_optional("aie_metadata.driver_config.partition_overlay_start_cols");
if (!partitionOverlays) {
return std::vector<uint8_t>{0};
}

std::vector<uint8_t> allStartColShifts;
for (auto const &shift : partitionOverlays.get()) {
uint8_t colShift = xdp::aie::convertStringToUint8(shift.second.data());
allStartColShifts.push_back(colShift);
}

return allStartColShifts.size() > 0 ? allStartColShifts : std::vector<uint8_t>{0};
}

std::vector<std::string>
AIETraceConfigFiletype::getValidKernels() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class AIETraceConfigFiletype : public AIEControlConfigFiletype {
AIETraceConfigFiletype(boost::property_tree::ptree& aie_project);
~AIETraceConfigFiletype() = default;

std::vector<uint8_t>
getPartitionOverlayStartCols() const override;

std::vector<std::string>
getValidKernels() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class BaseFiletypeImpl {

virtual uint8_t getAIETileRowOffset() const = 0;

virtual std::vector<uint8_t>
getPartitionOverlayStartCols() const = 0;

virtual std::vector<std::string>
getValidGraphs() const = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class AieProfileMetadata {
hwContext = std::move(c);
}

inline std::vector<uint8_t> getPartitionOverlayStartCols() const {
return metadataReader->getPartitionOverlayStartCols();
}
bool aieMetadataEmpty() { return metadataReader==nullptr; }

void getConfigMetricsForintfTilesLatencyConfig(xdp::module_type module,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ namespace xdp {
auto stats = aieDevice->getRscStat(XAIEDEV_DEFAULT_GROUP_AVAIL);
auto configChannel0 = metadata->getConfigChannel0();
auto configChannel1 = metadata->getConfigChannel1();
uint8_t startColShift = metadata->getPartitionOverlayStartCols().front();
aie::displayColShiftInfo(startColShift);

for (int module = 0; module < metadata->getNumModules(); ++module) {
auto configMetrics = metadata->getConfigMetrics(module);
Expand All @@ -454,7 +456,7 @@ namespace xdp {
for (auto& tileMetric : configMetrics) {
auto& metricSet = tileMetric.second;
auto tile = tileMetric.first;
auto col = tile.col;
auto col = tile.col + startColShift;
auto row = tile.row;
auto subtype = tile.subtype;
auto type = aie::getModuleType(row, metadata->getAIETileRowOffset());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,26 @@ namespace xdp {
mGraphCoreTilesMap[graph] = metadataReader->getEventTiles(graph, module_type::core);
}

//Note: AIE Status is not released product on client. Whenever client support is needed,
// required dynamic column start shift should come from XRT and not compiler metadata
uint8_t startColShift = metadataReader->getPartitionOverlayStartCols().front();
aie::displayColShiftInfo(startColShift);

if (startColShift > 0) {
for(auto& [graph, tileVec] : mGraphCoreTilesMap) {
for(auto& tile : tileVec)
tile.col += startColShift;
}
}

// Report tiles (debug only)
if (xrt_core::config::get_verbosity() >= static_cast<uint32_t>(severity_level::debug)) {
std::stringstream msg;
msg << "Tiles used for AIE status:\n";
for (const auto& kv : mGraphCoreTilesMap) {
msg << kv.first << " : ";
for (const auto& tile : kv.second)
msg << "(" << tile.col << "," << tile.row << "), ";
msg << "(" << +tile.col << "," << +tile.row << "), ";
msg << "\n";
}
xrt_core::message::send(severity_level::debug, "XRT", msg.str());
Expand Down Expand Up @@ -357,7 +369,7 @@ namespace xdp {
for (const auto& tile : graphTilesVec) {
if (coreStuckCountMap[tile]) {
msg
<< "T(" << tile.col <<"," << tile.row << "):" << "<" << coreStuckCountMap[tile]
<< "T(" << +tile.col <<"," << +tile.row << "):" << "<" << coreStuckCountMap[tile]
<< ":0x" << std::hex << coreStatusMap[tile] << std::dec << "> ";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class AieTraceMetadata {
void setHwContext(xrt::hw_context c) {
hwContext = std::move(c);
}
inline std::vector<uint8_t> getPartitionOverlayStartCols() const {
return metadataReader->getPartitionOverlayStartCols();
}
bool aieMetadataEmpty() { return metadataReader==nullptr; }

bool isGMIOMetric(const std::string& metric) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ namespace xdp {
auto configChannel0 = metadata->getConfigChannel0();
auto configChannel1 = metadata->getConfigChannel1();

uint8_t startColShift = metadata->getPartitionOverlayStartCols().front();
aie::displayColShiftInfo(startColShift);

// Zero trace event tile counts
for (int m = 0; m < static_cast<int>(module_type::num_types); ++m) {
for (int n = 0; n <= NUM_TRACE_EVENTS; ++n)
Expand All @@ -314,7 +317,7 @@ namespace xdp {
for (auto& tileMetric : metadata->getConfigMetrics()) {
auto& metricSet = tileMetric.second;
auto tile = tileMetric.first;
auto col = tile.col;
auto col = tile.col + startColShift;
auto row = tile.row;
auto subtype = tile.subtype;
auto type = aie::getModuleType(row, metadata->getRowOffset());
Expand Down

0 comments on commit 0cf086c

Please sign in to comment.