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

[XDP] First cut implementation of AIE Debug feature for all devices #8701

Merged
merged 63 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
84e8de8
initial debug plugin changes
Oct 15, 2024
f4efa88
header fixes
Oct 15, 2024
7ea81b3
fixed compilation issues
Oct 18, 2024
47f393c
AIE Debug Plugin Edge implementation
predutta Nov 16, 2024
c6153a5
AIE Debug Plugin Edge implementation with necesssary hooks
predutta Nov 16, 2024
97cc763
Resolving hw_emu related linking issues
predutta Nov 18, 2024
df3afdc
Fixing Seg fault and populating register issues
predutta Nov 19, 2024
ca49669
Adding capability to specify register names
predutta Nov 21, 2024
7eb5310
Adding python script to populate register name to value map for writer
predutta Nov 21, 2024
b5422ad
adding writer
predutta Dec 2, 2024
ee3df7a
Adding code for writer and some refactoring
predutta Dec 9, 2024
3ae4300
Removing AIE4 and adding TODO comments
predutta Dec 10, 2024
bd9aaaa
initial improvements
Dec 14, 2024
459fa94
merge of master
Dec 14, 2024
f7e801c
cleaned up generations subdir
Dec 14, 2024
5a3e559
compile fixes
Dec 14, 2024
50ab298
more compile corrections
Dec 16, 2024
198dcff
Fixing mismatched data type in edge/poll()
Dec 18, 2024
a8e947b
removed debug messages and default is all
Dec 19, 2024
720f17b
streamlined code
Dec 19, 2024
000e76e
temp debug messages
Dec 19, 2024
1febfe0
fixed bug
Dec 19, 2024
e80308b
debugging
Dec 19, 2024
a62d531
fixed bug
Dec 19, 2024
1d3fb94
moved code around
Dec 20, 2024
5491a41
fixes with Prerona
Dec 20, 2024
20a170e
bug fix
Dec 20, 2024
cc2096e
const char now string
Dec 20, 2024
b9de87c
bug fixes in database & writer
Dec 20, 2024
29a5f61
fixed order bug
Dec 21, 2024
1d797c6
Added register interpreter class
Jan 3, 2025
29c199c
Merge branch 'Xilinx:master' into brAieDebugPlugin
predutta Jan 6, 2025
12e3710
Adding choice in ini file for detailed register interpretation
predutta Jan 6, 2025
85017b1
Populating maps for each hw_gen tile type
Jan 7, 2025
7e44a7b
Updated writer_metadata code
Jan 8, 2025
604162d
added first cut ve2 files
Jan 8, 2025
dabe825
corrected a few bugs
Jan 8, 2025
4d58363
Added support for register detailed interpretation
Jan 10, 2025
f5ecbfc
Updated metadata to include all registers
Jan 10, 2025
4a0ae01
Updated metadata file
Jan 10, 2025
f6ddca5
Adding writer capabilities for detailed interpretation
predutta Jan 13, 2025
f9e83bf
Fix minor bugs
Jan 14, 2025
ca88286
fixing bug
predutta Jan 14, 2025
b1a1f26
merge with master
Jan 15, 2025
4b6630c
updated headers and register sets
Jan 15, 2025
68bf579
Minor bug fixes
Jan 16, 2025
e89bd1f
removed a lot of uuuuunnecessary regs
Jan 16, 2025
a06d419
Fixing bugs in aie_debug/writer
Jan 17, 2025
a2aae7d
Resolve conflicts
Jan 17, 2025
f9ee9c9
client improvements
Jan 17, 2025
6aa7c46
Successful client build
vipangul Jan 17, 2025
bd255c3
updated writer
Jan 17, 2025
46f5004
writer and bit width updates
Jan 17, 2025
d20ffa5
removed driver include and native x86 builds for debug plugin
Jan 17, 2025
b4f1ca9
PASS: Client build
vipangul Jan 17, 2025
6699fd8
Merge branch 'brAieDebugPlugin' of https://github.com/pgschuey/XRT in…
vipangul Jan 17, 2025
d72319d
added back driver include
Jan 17, 2025
37d4872
updated comments in cmake files
Jan 17, 2025
3ef6c75
Merge branch 'brAieDebugPlugin' of https://github.com/pgschuey/XRT in…
vipangul Jan 17, 2025
8cab2ab
cleanup of branch
Jan 20, 2025
2ec3902
DCO Remediation Commit for Snigdha Gupta <[email protected]
Jan 20, 2025
f44d5fb
build AIE debug for VE2
Jan 21, 2025
bdd2a3e
Merge branch 'master' of https://github.com/Xilinx/XRT into brAieDebu…
Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/runtime_src/core/common/config_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -769,32 +769,31 @@ get_device_offline_timer()
return value;
}

// Configurations under AIE_debug_settings section
inline std::string
get_aie_debug_settings_core_registers()
{
static std::string value = detail::get_string_value("AIE_debug_settings.core_registers", "");
static std::string value = detail::get_string_value("AIE_debug_settings.core_registers", "all");
return value;
}

inline std::string
get_aie_debug_settings_memory_registers()
{
static std::string value = detail::get_string_value("AIE_debug_settings.memory_registers", "");
static std::string value = detail::get_string_value("AIE_debug_settings.memory_registers", "all");
return value;
}

inline std::string
get_aie_debug_settings_interface_registers()
{
static std::string value = detail::get_string_value("AIE_debug_settings.interface_registers", "");
static std::string value = detail::get_string_value("AIE_debug_settings.interface_registers", "all");
return value;
}

inline std::string
get_aie_debug_settings_memory_tile_registers()
{
static std::string value = detail::get_string_value("AIE_debug_settings.memory_tile_registers", "");
static std::string value = detail::get_string_value("AIE_debug_settings.memory_tile_registers", "all");
return value;
}

Expand Down
3 changes: 3 additions & 0 deletions src/runtime_src/core/edge/hw_emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ file(GLOB XDP_PLUGIN_HW_EM_FILES
"${XDP_PLUGIN_DIR}/aie_status.cpp"
"${XDP_PLUGIN_DIR}/aie_profile.h"
"${XDP_PLUGIN_DIR}/aie_profile.cpp"
"${XDP_PLUGIN_DIR}/aie_debug.h"
"${XDP_PLUGIN_DIR}/aie_debug.cpp"

)

if (DEFINED XRT_AIE_BUILD)
Expand Down
72 changes: 72 additions & 0 deletions src/runtime_src/core/edge/user/plugin/xdp/aie_debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

#include "aie_debug.h"
#include "core/common/module_loader.h"
#include "core/common/dlfcn.h"
#include <iostream>

namespace xdp {
namespace aie {
namespace debug {
void load()
{
//#ifdef XRT_ENABLE_AIE
static xrt_core::module_loader xdp_aie_loader("xdp_aie_debug_plugin",
register_callbacks,
warning_callbacks);
//#endif
}
std::function<void (void*)> update_device_cb;
std::function<void (void*)> end_poll_cb;

void register_callbacks(void* handle)
{
using ftype = void (*)(void*); // Device handle

update_device_cb = reinterpret_cast<ftype>(xrt_core::dlsym(handle, "updateAIEDebugDevice"));
if (xrt_core::dlerror() != nullptr)
update_device_cb = nullptr;

end_poll_cb = reinterpret_cast<ftype>(xrt_core::dlsym(handle, "endAIEDebugRead"));
if (xrt_core::dlerror() != nullptr)
end_poll_cb = nullptr;
}

void warning_callbacks()
{
// No warnings for AIE debug plugin
}

} // end namespace debug

namespace dbg {
void update_device(void* handle)
{
if (debug::update_device_cb != nullptr) {
debug::update_device_cb(handle) ;
}
}

void end_poll(void* handle)
{
if (debug::end_poll_cb != nullptr) {
debug::end_poll_cb(handle) ;
}
}
} // end namespace dbg
} // end namespace aie
} // end namespace xdp
37 changes: 37 additions & 0 deletions src/runtime_src/core/edge/user/plugin/xdp/aie_debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

#ifndef AIE_DEBUG_DOT_H
#define AIE_DEBUG_DOT_H

namespace xdp {
namespace aie {

namespace debug {
void load();
void register_callbacks(void* handle);
void warning_callbacks();
} // end namespace debug

namespace dbg {
void update_device(void* handle);
void end_poll(void* handle);
} // end namespace dbg

} // end namespace aie
} // end namespace xdp

#endif
5 changes: 5 additions & 0 deletions src/runtime_src/core/edge/user/plugin/xdp/plugin_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "aie_status.h"
#include "aie_profile.h"
#include "aie_debug.h"

#ifndef __HWEM__
#include "aie_trace.h"
Expand Down Expand Up @@ -56,6 +57,8 @@ bool load()

if (xrt_core::config::get_aie_profile())
xdp::aie::profile::load();
if (xrt_core::config::get_aie_debug())
xdp::aie::debug::load();

if (xrt_core::config::get_noc_profile())
xdp::noc::profile::load();
Expand Down Expand Up @@ -103,6 +106,8 @@ bool load()

if (xrt_core::config::get_aie_profile())
xdp::aie::profile::load();
if (xrt_core::config::get_aie_debug())
xdp::aie::debug::load();
#endif
return true ;
}
Expand Down
16 changes: 10 additions & 6 deletions src/runtime_src/core/edge/user/plugin/xdp/shim_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "aie_profile.h"
#include "aie_status.h"
#include "hal_device_offload.h"
#include "aie_debug.h"

#ifdef __HWEM__
#include "hw_emu_device_offload.h"
Expand All @@ -45,14 +46,15 @@ inline
void update_device(void* handle)
{
#ifndef __HWEM__
hal::update_device(handle);
aie::update_device(handle);
hal::update_device(handle); //PL device offload
aie::update_device(handle); //trace
//aie::dbg::update_device(handle); //debug
#else
hal::hw_emu::update_device(handle);
hal::hw_emu::update_device(handle); //PL device offload
#endif

aie::ctr::update_device(handle);
aie::sts::update_device(handle);
aie::dbg::update_device(handle); //debug
aie::ctr::update_device(handle); //counters=profiling
aie::sts::update_device(handle); //status
}

// The flush_device callback should be called just before a new xclbin
Expand Down Expand Up @@ -84,8 +86,10 @@ void finish_flush_device(void* handle)
{
#ifndef __HWEM__
aie::finish_flush_device(handle);
//aie::dbg::end_poll(handle);
#endif
aie::ctr::end_poll(handle);
aie::dbg::end_poll(handle);
}

} // end namespace xdp
Expand Down
23 changes: 22 additions & 1 deletion src/runtime_src/xdp/profile/database/dynamic_event_database.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <iostream>

namespace xdp {

VPDynamicDatabase::VPDynamicDatabase(VPDatabase* d) :
db(d), eventId(1)
{
Expand Down Expand Up @@ -291,6 +291,27 @@ namespace xdp {
return device_db->moveAIESamples();
}

void VPDynamicDatabase::addAIEDebugSample(uint64_t deviceId, uint8_t col,
uint8_t row, uint32_t value, uint64_t offset, std::string name)
{
auto device_db = getDeviceDB(deviceId);
device_db->addAIEDebugSample(col, row, value, offset, name);
}

std::vector<xdp::aie::AIEDebugDataType>
VPDynamicDatabase::getAIEDebugSamples(uint64_t deviceId)
{
auto device_db = getDeviceDB(deviceId);
return device_db->getAIEDebugSamples();
}

std::vector<xdp::aie::AIEDebugDataType>
VPDynamicDatabase::moveAIEDebugSamples(uint64_t deviceId)
{
auto device_db = getDeviceDB(deviceId);
return device_db->moveAIEDebugSamples();
}

void VPDynamicDatabase::addAIETimerSample(uint64_t deviceId, unsigned long timestamp1,
unsigned long timestamp2, const std::vector<uint64_t>& values)
{
Expand Down
10 changes: 7 additions & 3 deletions src/runtime_src/xdp/profile/database/dynamic_event_database.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace xdp {
XDP_CORE_EXPORT void addDependency(uint64_t id, uint64_t dependency) ;
XDP_CORE_EXPORT std::map<uint64_t, std::vector<uint64_t>> getDependencyMap() ;

// Add and get AIE Trace Data Buffer
// Add and get AIE Trace Data Buffer
XDP_CORE_EXPORT void addAIETraceData(uint64_t deviceId, uint64_t strmIndex, void* buffer, uint64_t bufferSz, bool copy);
XDP_CORE_EXPORT aie::TraceDataType* getAIETraceData(uint64_t deviceId, uint64_t strmIndex);

Expand All @@ -173,7 +173,11 @@ namespace xdp {
XDP_CORE_EXPORT std::vector<counters::Sample> getPowerSamples(uint64_t deviceId) ;

XDP_CORE_EXPORT void addAIESample(uint64_t deviceId, double timestamp,
const std::vector<uint64_t>& values) ;
const std::vector<uint64_t>& values);
XDP_CORE_EXPORT void addAIEDebugSample(uint64_t deviceId, uint8_t col,
uint8_t row, uint32_t value, uint64_t offset, std::string name);
XDP_CORE_EXPORT std::vector<xdp::aie::AIEDebugDataType> moveAIEDebugSamples(uint64_t deviceId);
XDP_CORE_EXPORT std::vector<xdp::aie::AIEDebugDataType> getAIEDebugSamples(uint64_t deviceId);
XDP_CORE_EXPORT std::vector<counters::Sample> getAIESamples(uint64_t deviceId) ;
XDP_CORE_EXPORT std::vector<counters::Sample> moveAIESamples(uint64_t deviceId);
XDP_CORE_EXPORT void addAIETimerSample(uint64_t deviceId, unsigned long timestamp1,
Expand All @@ -188,7 +192,7 @@ namespace xdp {
XDP_CORE_EXPORT void setPLDeadlockInfo(uint64_t deviceId, const std::string& str);
XDP_CORE_EXPORT std::string getPLDeadlockInfo();
} ;

}

#endif
15 changes: 14 additions & 1 deletion src/runtime_src/xdp/profile/database/dynamic_info/aie_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace xdp {

SampleContainer samples;
DoubleSampleContainer timerSamples;
AIEDebugContainer aieDebugSamples;

std::mutex traceLock; // Protects "traceData" vector

Expand All @@ -54,10 +55,14 @@ namespace xdp {
void addAIESample(double timestamp, const std::vector<uint64_t>& values);

inline
void addAIETimerSample(unsigned long timestamp1, unsigned long timestamp2,
void addAIETimerSample(unsigned long timestamp1, unsigned long timestamp2,
const std::vector<uint64_t>& values)
{ timerSamples.addSample({timestamp1, timestamp2, values}); }

inline
void addAIEDebugSample(uint8_t col, uint8_t row, uint32_t value, uint64_t offset, std::string name)
{ aieDebugSamples.addAIEDebugData({col, row, value, offset, name}); }

inline
std::vector<counters::Sample> getAIESamples()
{ return samples.getSamples(); }
Expand All @@ -69,6 +74,14 @@ namespace xdp {
inline
std::vector<counters::DoubleSample> getAIETimerSamples()
{ return timerSamples.getSamples(); }

inline
std::vector<xdp::aie::AIEDebugDataType> getAIEDebugSamples()
{ return aieDebugSamples.getAIEDebugData(); }

inline
std::vector<xdp::aie::AIEDebugDataType> moveAIEDebugSamples()
{ return aieDebugSamples.moveAIEDebugData(); }
};

} // end namespace xdp
Expand Down
14 changes: 13 additions & 1 deletion src/runtime_src/xdp/profile/database/dynamic_info/device_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ namespace xdp {
void addAIESample(double timestamp, const std::vector<uint64_t>& values)
{ aie_db.addAIESample(timestamp, values); }

void addAIETimerSample(unsigned long timestamp1, unsigned long timestamp2,
void addAIETimerSample(unsigned long timestamp1, unsigned long timestamp2,
const std::vector<uint64_t>& values)
{ aie_db.addAIETimerSample(timestamp1, timestamp2, values); }

inline
void addAIEDebugSample(uint8_t col, uint8_t row, uint32_t value, uint64_t offset, std::string name)
{ aie_db.addAIEDebugSample(col, row, value, offset, name); }

inline std::vector<counters::Sample> getAIESamples()
{ return aie_db.getAIESamples(); }

Expand All @@ -126,6 +130,14 @@ namespace xdp {
inline std::string& getPLDeadlockInfo()
{ return pl_db.getDeadlockInfo(); }

inline
std::vector<xdp::aie::AIEDebugDataType> getAIEDebugSamples()
{ return aie_db.getAIEDebugSamples(); }

inline std::vector<xdp::aie::AIEDebugDataType> moveAIEDebugSamples()
{ return aie_db.moveAIEDebugSamples(); }


};

} // end namespace xdp
Expand Down
27 changes: 27 additions & 0 deletions src/runtime_src/xdp/profile/database/dynamic_info/samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ namespace xdp {
}

};

class AIEDebugContainer
{
private:
std::vector<xdp::aie::AIEDebugDataType> samples;
std::mutex containerLock; // Protects the "samples" vector

public:
AIEDebugContainer() = default;
~AIEDebugContainer() = default;

inline void addAIEDebugData(const xdp::aie::AIEDebugDataType& s)
{
std::lock_guard<std::mutex> lock(containerLock);
samples.push_back(s);
}
inline std::vector<xdp::aie::AIEDebugDataType> getAIEDebugData()
{
std::lock_guard<std::mutex> lock(containerLock);
return samples;
}
inline std::vector<xdp::aie::AIEDebugDataType> moveAIEDebugData()
{
std::lock_guard<std::mutex> lock(containerLock);
return std::move(samples);
}
};
} // end namespace xdp

#endif
Loading
Loading