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

Removing json file dependecy for the aie test #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/runtime_src/core/include/experimental/xrt_xclbin.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,14 @@ class xclbin : public detail::pimpl<xclbin_impl>
const axlf*
get_axlf() const;

/**
* It is a wrapper to access the private function get_axlf_section()
* to get the AIE_METADATA
*/
std::pair<const char*, size_t> getAIE_Metadata_Wrapper(xrt::xclbin xclbin_obj){
return xclbin_obj.get_axlf_section(AIE_METADATA);
}

/**
* get_axlf_section() - Retrieve specified xclbin section
*
Expand Down
47 changes: 34 additions & 13 deletions src/runtime_src/core/tools/common/tests/TestAiePl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace XBU = XBUtilities;

// XRT includes
#include "experimental/xrt_system.h"
#include "experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_kernel.h"
Expand Down Expand Up @@ -40,8 +41,8 @@ TestAiePl::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, std::string aie_control, std::string dma_lock) {
xf::plctrl::plController m_pl_ctrl(aie_control.c_str(), dma_lock.c_str());
bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, std::string dma_lock, boost::property_tree::ptree aie_meta) {
xf::plctrl::plController m_pl_ctrl(dma_lock.c_str(), aie_meta);

unsigned int num_iter = 2;
unsigned int num_sample = 16;
Expand Down Expand Up @@ -143,9 +144,9 @@ bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, std::string aie_
return match;
}

bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, std::string aie_control, std::string dma_lock) {
bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, std::string dma_lock, boost::property_tree::ptree aie_meta) {
// instance of plController
xf::plctrl::plController_aie2 m_pl_ctrl(aie_control.c_str(), dma_lock.c_str());
xf::plctrl::plController_aie2 m_pl_ctrl(dma_lock.c_str(), aie_meta);

unsigned int num_iter = 1;
unsigned int num_sample = 32;
Expand Down Expand Up @@ -227,24 +228,44 @@ bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, std::string aie_
return match;
}

bool getAIE_Metadata(std::string test_path, boost::property_tree::ptree& aie_meta){
bool res = true;

//default is pl_controller_aie.xclbin
std::string b_file = "pl_controller_aie.xclbin";
auto binaryFile = std::filesystem::path(test_path) / b_file;
std::ifstream infile(binaryFile.string());
if (!infile.good()) {
b_file = "vck5000_pcie_pl_controller.xclbin.xclbin";
auto binaryFile = std::filesystem::path(test_path) / b_file;
std::ifstream infile(binaryFile.string());
if (!infile.good()) {
return false;
}
}

//create an xclbin obj
auto xclbin_obj = xrt::xclbin(binaryFile);
auto metadata = xclbin_obj.getAIE_Metadata_Wrapper(xclbin_obj);
std::istringstream metadataStream(metadata.first);
boost::property_tree::read_json(metadataStream, aie_meta);
return res;
}

void
TestAiePl::runTest(std::shared_ptr<xrt_core::device> dev, boost::property_tree::ptree& ptree)
{
xrt::device device(dev);

const std::string test_path = findPlatformPath(dev, ptree);
const std::string aie_control_file = "aie_control_config.json";
auto aie_control = std::filesystem::path(test_path) / aie_control_file;
boost::property_tree::ptree aie_meta;

std::ifstream aiefile(aie_control.string());
if (!aiefile.good()) {
logger(ptree, "Details", boost::str(boost::format("The given file could not be found: %s") % aie_control.string()));
if (!getAIE_Metadata(test_path, aie_meta)) {
logger(ptree, "Details", boost::str(boost::format("The AIE_METADATA could not be found: %s")));
ptree.put("status", test_token_skipped);
return;
}

boost::property_tree::ptree aie_meta;
read_json(aie_control.string(), aie_meta);
auto driver_info_node = aie_meta.get_child("aie_metadata.driver_config");
auto hw_gen_node = driver_info_node.get_child("hw_gen");
auto hw_gen = std::stoul(hw_gen_node.data());
Expand Down Expand Up @@ -276,10 +297,10 @@ TestAiePl::runTest(std::shared_ptr<xrt_core::device> dev, boost::property_tree::
// Check for AIE Hardware Generation
switch (hw_gen) {
case 1:
match = run_pl_controller_aie1(device, uuid, aie_control.string(), dma_lock.string());
match = run_pl_controller_aie1(device, uuid, dma_lock.string(), aie_meta);
break;
case 2:
match = run_pl_controller_aie2(device, uuid, aie_control.string(), dma_lock.string());
match = run_pl_controller_aie2(device, uuid, dma_lock.string(), aie_meta);
break;
default:
logger(ptree, "Error", "Unsupported AIE Hardware");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

namespace xf {
namespace plctrl {
plController::plController(const std::string& aie_info_path,
const std::string& dma_info_path)
: m_aie_info_path(aie_info_path),
m_dma_info_path(dma_info_path),
plController::plController(const std::string& dma_info_path, boost::property_tree::ptree& aie_meta_info)
: m_dma_info_path(dma_info_path),
m_aie_meta_info(aie_meta_info),
m_outputSize(0),
m_ping_pong(false)
{
Expand Down Expand Up @@ -170,11 +169,7 @@ void
plController::get_rtp()
{
boost::property_tree::ptree aie_meta;
std::ifstream jsonFile(m_aie_info_path);
if (!jsonFile.good())
throw std::runtime_error("get_rtp():ERROR:No aie info file specified");

boost::property_tree::json_parser::read_json(m_aie_info_path, aie_meta);
aie_meta = m_aie_meta_info;

for (auto& rtp_node : aie_meta.get_child("aie_metadata.RTPs")) {
rtp_type rtp = {};
Expand Down Expand Up @@ -210,13 +205,7 @@ std::vector<tile_type>
plController::get_tiles(const std::string& graph_name)
{
boost::property_tree::ptree aie_meta;

std::ifstream jsonFile(m_aie_info_path);
if (!jsonFile.good())
throw std::runtime_error(
"ERROR (get_tiles):No aie info file specified");

boost::property_tree::json_parser::read_json(m_aie_info_path, aie_meta);
aie_meta = m_aie_meta_info;
std::vector<tile_type> tiles;

for (auto& graph : aie_meta.get_child("aie_metadata.graphs")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class plController
/* Constructor
*/
plController() = delete;
plController(const std::string& aie_info_path, const std::string& dma_info_path);
plController(const std::string& dma_info_path, boost::property_tree::ptree& aie_meta_info);

void enqueue_set_aie_iteration(const std::string& graphName, int num_iter);

Expand Down Expand Up @@ -94,8 +94,8 @@ class plController
std::vector<uint32_t> m_opcodeBuffer;
std::vector<uint32_t> m_metadata;

std::string m_aie_info_path;
std::string m_dma_info_path;
boost::property_tree::ptree m_aie_meta_info;
uint32_t m_outputSize;
bool m_ping_pong;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ void dynBuffer::add(uint32_t* data, int blk_size) {
m_usedSize += blk_size;
}

plController_aie2::plController_aie2(const std::string& aie_info_path, const std::string& dma_info_path)
: m_aie_info_path(aie_info_path),
m_dma_info_path(dma_info_path),
plController_aie2::plController_aie2(const std::string& dma_info_path, boost::property_tree::ptree& aie_meta_info)
: m_dma_info_path(dma_info_path),
m_aie_meta_info(aie_meta_info),
m_outputSize(0),
m_set_num_iter(false)
{
Expand Down Expand Up @@ -179,12 +179,7 @@ void plController_aie2::enqueue_write(int addr, int val) {
// re-use this code from "core/edge/common/aie_parser.cpp"
void plController_aie2::get_rtp() {
boost::property_tree::ptree aie_meta;
std::ifstream jsonFile(m_aie_info_path);
if (!jsonFile.good())
throw std::runtime_error("get_rtp():ERROR:No aie info file specified");

boost::property_tree::json_parser::read_json(m_aie_info_path, aie_meta);

aie_meta = m_aie_meta_info;
for (auto& rtp_node : aie_meta.get_child("aie_metadata.RTPs")) {
rtp_type rtp;

Expand Down Expand Up @@ -216,11 +211,7 @@ void plController_aie2::get_rtp() {

std::vector<tile_type> plController_aie2::get_tiles(const std::string& graph_name) {
boost::property_tree::ptree aie_meta;
std::ifstream jsonFile(m_aie_info_path);
if (!jsonFile.good())
throw std::runtime_error("get_tiles():ERROR:No aie info file specified");

boost::property_tree::json_parser::read_json(m_aie_info_path, aie_meta);
aie_meta = m_aie_meta_info;
std::vector<tile_type> tiles;

for (auto& graph : aie_meta.get_child("aie_metadata.graphs")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class plController_aie2 {
/* Constructor
*/
plController_aie2() = delete;
plController_aie2(const std::string& aie_info_path, const std::string& dma_info_path);
plController_aie2(const std::string& dma_info_path, boost::property_tree::ptree& aie_meta_info);

void enqueue_set_aie_iteration(const std::string& graphName, int num_iter);

Expand Down Expand Up @@ -95,8 +95,8 @@ class plController_aie2 {
std::unordered_map<std::string, rtp_type> m_rtps;
dynBuffer m_opcodeBuffer;

std::string m_aie_info_path = "aie_control_config.json";
std::string m_dma_info_path = "dma_lock_report.json";
boost::property_tree::ptree m_aie_meta_info;

uint32_t m_outputSize = 0;
bool m_set_num_iter = false;
Expand Down
Loading