Skip to content

Commit

Permalink
Fix issue with reading AIE counter and GMIO metadata when PL device t…
Browse files Browse the repository at this point in the history
…race offload is enabled : CR 1083019 (#4455)
  • Loading branch information
IshitaGhosh authored Nov 13, 2020
1 parent 7c93966 commit 77d5484
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 36 deletions.
33 changes: 31 additions & 2 deletions src/runtime_src/xdp/profile/database/static_info_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ namespace xdp {
};

struct DeviceInfo {
bool isReady;

double clockRateMHz;
struct PlatformInfo platformInfo;

Expand Down Expand Up @@ -215,6 +213,9 @@ namespace xdp {

bool hasFloatingAIM = false;
bool hasFloatingASM = false;
bool isReady = false;
bool isAIEcounterRead = false;
bool isGMIORead = false;

uint32_t numTracePLIO = 0;

Expand Down Expand Up @@ -294,6 +295,34 @@ namespace xdp {
return deviceInfo[deviceId]->isReady;
}

bool isAIECounterRead(uint64_t deviceId)
{
if(deviceInfo.find(deviceId) == deviceInfo.end())
return false;
return deviceInfo[deviceId]->isAIEcounterRead;
}

void setIsAIECounterRead(uint64_t deviceId, bool val)
{
if(deviceInfo.find(deviceId) == deviceInfo.end())
return;
deviceInfo[deviceId]->isAIEcounterRead = val;
}

void setIsGMIORead(uint64_t deviceId, bool val)
{
if(deviceInfo.find(deviceId) == deviceInfo.end())
return;
deviceInfo[deviceId]->isGMIORead = val;
}

bool isGMIORead(uint64_t deviceId)
{
if(deviceInfo.find(deviceId) == deviceInfo.end())
return false;
return deviceInfo[deviceId]->isGMIORead;
}

double getClockRateMHz(uint64_t deviceId)
{
if(deviceInfo.find(deviceId) == deviceInfo.end())
Expand Down
39 changes: 16 additions & 23 deletions src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,25 @@ namespace xdp {
(db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName));
}
}
}
#ifdef XRT_ENABLE_AIE
{
// Update the AIE specific portion of the device
std::shared_ptr<xrt_core::device> device =
xrt_core::get_userpf_device(handle) ;
auto counters = xrt_core::edge::aie::get_profile_counters(device.get());
if (xrt_core::config::get_aie_profile() && counters.empty()) {
std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available.");
xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ;
}
for (auto& counter : counters) {
(db->getStaticInfo()).addAIECounter(deviceId,
counter.id,
counter.column,
counter.row,
counter.counterNumber,
counter.startEvent,
counter.endEvent,
counter.resetEvent,
counter.clockFreqMhz,
counter.module,
counter.name) ;
}
if(!(db->getStaticInfo()).isAIECounterRead(deviceId)) {
// Update the AIE specific portion of the device
// When new xclbin is loaded, the xclbin specific datastructure is already recreated
std::shared_ptr<xrt_core::device> device = xrt_core::get_userpf_device(handle);
auto counters = xrt_core::edge::aie::get_profile_counters(device.get());
if (xrt_core::config::get_aie_profile() && counters.empty()) {
std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available.");
xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ;
}
#endif
for (auto& counter : counters) {
(db->getStaticInfo()).addAIECounter(deviceId, counter.id, counter.column,
counter.row, counter.counterNumber, counter.startEvent, counter.endEvent,
counter.resetEvent, counter.clockFreqMhz, counter.module, counter.name);
}
(db->getStaticInfo()).setIsAIECounterRead(deviceId, true);
}
#endif

// Open the writer for this device
struct xclDeviceInfo2 info;
Expand Down
23 changes: 12 additions & 11 deletions src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,20 @@ namespace xdp {
(db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName));
}
}
}
#ifdef XRT_ENABLE_AIE
{
// Update the AIE specific portion of the device
std::shared_ptr<xrt_core::device> device =
xrt_core::get_userpf_device(handle) ;
if (device != nullptr) {
for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) {
(db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ;
}
}
}
#endif
if(!(db->getStaticInfo()).isGMIORead(deviceId)) {
// Update the AIE specific portion of the device
// When new xclbin is loaded, the xclbin specific datastructure is already recreated
std::shared_ptr<xrt_core::device> device = xrt_core::get_userpf_device(handle) ;
if (device != nullptr) {
for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) {
(db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ;
}
}
(db->getStaticInfo()).setIsGMIORead(deviceId, true);
}
#endif

uint64_t numAIETraceOutput = (db->getStaticInfo()).getNumAIETraceStream(deviceId);
if(0 == numAIETraceOutput) {
Expand Down

0 comments on commit 77d5484

Please sign in to comment.