Skip to content

Commit 77d5484

Browse files
authored
Fix issue with reading AIE counter and GMIO metadata when PL device trace offload is enabled : CR 1083019 (#4455)
1 parent 7c93966 commit 77d5484

File tree

3 files changed

+59
-36
lines changed

3 files changed

+59
-36
lines changed

src/runtime_src/xdp/profile/database/static_info_database.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ namespace xdp {
184184
};
185185

186186
struct DeviceInfo {
187-
bool isReady;
188-
189187
double clockRateMHz;
190188
struct PlatformInfo platformInfo;
191189

@@ -215,6 +213,9 @@ namespace xdp {
215213

216214
bool hasFloatingAIM = false;
217215
bool hasFloatingASM = false;
216+
bool isReady = false;
217+
bool isAIEcounterRead = false;
218+
bool isGMIORead = false;
218219

219220
uint32_t numTracePLIO = 0;
220221

@@ -294,6 +295,34 @@ namespace xdp {
294295
return deviceInfo[deviceId]->isReady;
295296
}
296297

298+
bool isAIECounterRead(uint64_t deviceId)
299+
{
300+
if(deviceInfo.find(deviceId) == deviceInfo.end())
301+
return false;
302+
return deviceInfo[deviceId]->isAIEcounterRead;
303+
}
304+
305+
void setIsAIECounterRead(uint64_t deviceId, bool val)
306+
{
307+
if(deviceInfo.find(deviceId) == deviceInfo.end())
308+
return;
309+
deviceInfo[deviceId]->isAIEcounterRead = val;
310+
}
311+
312+
void setIsGMIORead(uint64_t deviceId, bool val)
313+
{
314+
if(deviceInfo.find(deviceId) == deviceInfo.end())
315+
return;
316+
deviceInfo[deviceId]->isGMIORead = val;
317+
}
318+
319+
bool isGMIORead(uint64_t deviceId)
320+
{
321+
if(deviceInfo.find(deviceId) == deviceInfo.end())
322+
return false;
323+
return deviceInfo[deviceId]->isGMIORead;
324+
}
325+
297326
double getClockRateMHz(uint64_t deviceId)
298327
{
299328
if(deviceInfo.find(deviceId) == deviceInfo.end())

src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,25 @@ namespace xdp {
130130
(db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName));
131131
}
132132
}
133+
}
133134
#ifdef XRT_ENABLE_AIE
134-
{
135-
// Update the AIE specific portion of the device
136-
std::shared_ptr<xrt_core::device> device =
137-
xrt_core::get_userpf_device(handle) ;
138-
auto counters = xrt_core::edge::aie::get_profile_counters(device.get());
139-
if (xrt_core::config::get_aie_profile() && counters.empty()) {
140-
std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available.");
141-
xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ;
142-
}
143-
for (auto& counter : counters) {
144-
(db->getStaticInfo()).addAIECounter(deviceId,
145-
counter.id,
146-
counter.column,
147-
counter.row,
148-
counter.counterNumber,
149-
counter.startEvent,
150-
counter.endEvent,
151-
counter.resetEvent,
152-
counter.clockFreqMhz,
153-
counter.module,
154-
counter.name) ;
155-
}
135+
if(!(db->getStaticInfo()).isAIECounterRead(deviceId)) {
136+
// Update the AIE specific portion of the device
137+
// When new xclbin is loaded, the xclbin specific datastructure is already recreated
138+
std::shared_ptr<xrt_core::device> device = xrt_core::get_userpf_device(handle);
139+
auto counters = xrt_core::edge::aie::get_profile_counters(device.get());
140+
if (xrt_core::config::get_aie_profile() && counters.empty()) {
141+
std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available.");
142+
xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ;
156143
}
157-
#endif
144+
for (auto& counter : counters) {
145+
(db->getStaticInfo()).addAIECounter(deviceId, counter.id, counter.column,
146+
counter.row, counter.counterNumber, counter.startEvent, counter.endEvent,
147+
counter.resetEvent, counter.clockFreqMhz, counter.module, counter.name);
148+
}
149+
(db->getStaticInfo()).setIsAIECounterRead(deviceId, true);
158150
}
151+
#endif
159152

160153
// Open the writer for this device
161154
struct xclDeviceInfo2 info;

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,20 @@ namespace xdp {
9999
(db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName));
100100
}
101101
}
102+
}
102103
#ifdef XRT_ENABLE_AIE
103-
{
104-
// Update the AIE specific portion of the device
105-
std::shared_ptr<xrt_core::device> device =
106-
xrt_core::get_userpf_device(handle) ;
107-
if (device != nullptr) {
108-
for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) {
109-
(db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ;
110-
}
111-
}
112-
}
113-
#endif
104+
if(!(db->getStaticInfo()).isGMIORead(deviceId)) {
105+
// Update the AIE specific portion of the device
106+
// When new xclbin is loaded, the xclbin specific datastructure is already recreated
107+
std::shared_ptr<xrt_core::device> device = xrt_core::get_userpf_device(handle) ;
108+
if (device != nullptr) {
109+
for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) {
110+
(db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ;
111+
}
112+
}
113+
(db->getStaticInfo()).setIsGMIORead(deviceId, true);
114114
}
115+
#endif
115116

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

0 commit comments

Comments
 (0)