Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/runtime_src/core/include/xrt/xrt_aie.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class buffer : public detail::pimpl<buffer_impl>
*
* This constructor initializes a buffer object with the specified device, xclbin UUID, and string identifier. This throws an exception if no GMIO/External buffer exists with given name
*/
[[deprecated("deprecated, please use buffer(hw_context, name) instead")]]
buffer(const xrt::device& device, const xrt::uuid& uuid, const std::string& name);

/**
Expand Down
3 changes: 3 additions & 0 deletions src/runtime_src/core/include/xrt/xrt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class device
* @return
* UUID of argument xclbin
*/
[[deprecated("deprecated, please use hw_context() instead")]]
XCL_DRIVER_DLLESPEC
uuid
load_xclbin(const axlf* xclbin);
Expand All @@ -358,6 +359,7 @@ class device
* the xclbin. Using this function allows one time
* allocation of data that needs to be kept in memory.
*/
[[deprecated("deprecated, please use hw_context() instead")]]
XCL_DRIVER_DLLESPEC
uuid
load_xclbin(const std::string& xclbin_fnm);
Expand All @@ -374,6 +376,7 @@ class device
* caller. The xrt::xclbin object must contain the complete axlf
* structure.
*/
[[deprecated("deprecated, please use hw_context() instead")]]
XCL_DRIVER_DLLESPEC
uuid
load_xclbin(const xrt::xclbin& xclbin);
Expand Down
1 change: 1 addition & 0 deletions src/runtime_src/core/include/xrt/xrt_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class graph
* @param am
* Open the graph with specified access (default primary)
*/
[[deprecated("deprecated, please use graph(hw_context, name) instead")]]
graph(const xrt::device& device, const xrt::uuid& xclbin_id, const std::string& name,
access_mode am = access_mode::primary);

Expand Down
34 changes: 19 additions & 15 deletions src/runtime_src/core/tools/common/tests/TestAiePl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace XBU = XBUtilities;

// XRT includes
#include "xrt/experimental/xrt_system.h"
#include "xrt/experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"

#include <boost/format.hpp>
Expand All @@ -42,7 +44,7 @@ TestAiePl::run(const std::shared_ptr<xrt_core::device>& dev)
return ptree;
}

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

unsigned int num_iter = 2;
Expand Down Expand Up @@ -83,17 +85,17 @@ bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, boost::property_
unsigned int mem_size_bytes = 0;

auto sender_receiver_k1 =
xrt::kernel(device, uuid, "sender_receiver:{sender_receiver_1}");
xrt::kernel(hw_ctx, "sender_receiver:{sender_receiver_1}");
auto controller_k1 =
xrt::kernel(device, uuid, "pl_controller_kernel:{controller_1}");
xrt::kernel(hw_ctx, "pl_controller_kernel:{controller_1}");

// output memory
mem_size_bytes = num_sample * num_iter * sizeof(uint32_t);
auto out_bo1 = xrt::bo(device, mem_size_bytes, sender_receiver_k1.group_id(output_buffer_idx));
auto out_bo1 = xrt::bo(hw_ctx, mem_size_bytes, sender_receiver_k1.group_id(output_buffer_idx));
auto host_out1 = out_bo1.map<int*>();

// input memory
auto in_bo1 = xrt::bo(device, mem_size_bytes, sender_receiver_k1.group_id(input_buffer_idx));
auto in_bo1 = xrt::bo(hw_ctx, mem_size_bytes, sender_receiver_k1.group_id(input_buffer_idx));
auto host_in1 = in_bo1.map<int*>();


Expand All @@ -104,7 +106,7 @@ bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, boost::property_
in_bo1.sync(XCL_BO_SYNC_BO_TO_DEVICE, mem_size_bytes, /*OFFSET=*/0);

uint32_t num_pm = m_pl_ctrl.get_microcode_size(); /// sizeof(int32_t);
auto pm_bo = xrt::bo(device, (num_pm + 1) * sizeof(uint32_t),
auto pm_bo = xrt::bo(hw_ctx, (num_pm + 1) * sizeof(uint32_t),
controller_k1.group_id(pm_buffer_idx));
auto host_pm = pm_bo.map<uint32_t*>();

Expand Down Expand Up @@ -145,7 +147,7 @@ bool run_pl_controller_aie1(xrt::device device, xrt::uuid uuid, boost::property_
return match;
}

bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, boost::property_tree::ptree& aie_meta) {
bool run_pl_controller_aie2(xrt::hw_context hw_ctx, boost::property_tree::ptree& aie_meta) {
// instance of plController
xf::plctrl::plController_aie2 m_pl_ctrl(aie_meta);

Expand All @@ -170,16 +172,16 @@ bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, boost::property_
uint32_t mem_size_bytes = 0;

// XRT auto get group_id
auto sender_receiver_k1 = xrt::kernel(device, uuid, "sender_receiver:{sender_receiver_1}");
auto controller_k1 = xrt::kernel(device, uuid, "pl_controller_top:{controller_1}");
auto sender_receiver_k1 = xrt::kernel(hw_ctx, "sender_receiver:{sender_receiver_1}");
auto controller_k1 = xrt::kernel(hw_ctx, "pl_controller_top:{controller_1}");

// output memory
mem_size_bytes = num_sample * num_iter * sizeof(uint32_t);
auto out_bo1 = xrt::bo(device, mem_size_bytes, sender_receiver_k1.group_id(output_buffer_idx));
auto out_bo1 = xrt::bo(hw_ctx, mem_size_bytes, sender_receiver_k1.group_id(output_buffer_idx));
auto host_out1 = out_bo1.map<uint32_t*>();

// input memory
auto in_bo1 = xrt::bo(device, mem_size_bytes, sender_receiver_k1.group_id(input_buffer_idx));
auto in_bo1 = xrt::bo(hw_ctx, mem_size_bytes, sender_receiver_k1.group_id(input_buffer_idx));
auto host_in1 = in_bo1.map<uint32_t*>();

// initialize input memory
Expand All @@ -190,7 +192,7 @@ bool run_pl_controller_aie2(xrt::device device, xrt::uuid uuid, boost::property_
in_bo1.sync(XCL_BO_SYNC_BO_TO_DEVICE, mem_size_bytes, /*OFFSET=*/0);

uint32_t num_pm = m_pl_ctrl.get_microcode_size(); /// sizeof(uint32_t);
auto pm_bo = xrt::bo(device, (num_pm + 1) * sizeof(uint32_t),
auto pm_bo = xrt::bo(hw_ctx, (num_pm + 1) * sizeof(uint32_t),
controller_k1.group_id(pm_buffer_idx));
auto host_pm = pm_bo.map<uint32_t*>();

Expand Down Expand Up @@ -251,7 +253,9 @@ TestAiePl::runTest(const std::shared_ptr<xrt_core::device>& dev, boost::property
}
ptree.put("xclbin_directory", std::filesystem::path(test_path));

const auto uuid = device.load_xclbin(binaryFile.string());
auto xclbin = xrt::xclbin(binaryFile.string());
auto uuid = device.register_xclbin(xclbin);
xrt::hw_context hw_ctx(device, uuid);

boost::property_tree::ptree aie_meta;
auto metadata_pair = dev->get_axlf_section(AIE_METADATA);
Expand Down Expand Up @@ -279,11 +283,11 @@ TestAiePl::runTest(const std::shared_ptr<xrt_core::device>& dev, boost::property
case 1: {
std::string dma_lock_file = "dma_lock_report.json";
auto dma_lock = std::filesystem::path(test_path) / dma_lock_file;
match = run_pl_controller_aie1(device, uuid, aie_meta, dma_lock.string());
match = run_pl_controller_aie1(hw_ctx, aie_meta, dma_lock.string());
break;
}
case 2:
match = run_pl_controller_aie2(device, uuid, aie_meta);
match = run_pl_controller_aie2(hw_ctx, aie_meta);
break;
default:
XBValidateUtils::logger(ptree, "Error", "Unsupported AIE Hardware");
Expand Down
14 changes: 10 additions & 4 deletions src/runtime_src/core/tools/common/tests/TestAiePs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "tools/common/XBUtilitiesCore.h"
#include "xrt/experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"
namespace XBU = XBUtilities;

Expand Down Expand Up @@ -54,7 +56,9 @@ TestAiePs::runTest(const std::shared_ptr<xrt_core::device>& dev, boost::property
ptree.put("status", XBValidateUtils::test_token_skipped);
return;
}
device.load_xclbin(path);
auto dep_xclbin = xrt::xclbin(path);
auto dep_uuid = device.register_xclbin(dep_xclbin);
xrt::hw_context dep_hw_ctx(device, dep_uuid);
}

const std::string b_file = XBValidateUtils::findXclbinPath(dev, ptree);
Expand All @@ -70,9 +74,11 @@ TestAiePs::runTest(const std::shared_ptr<xrt_core::device>& dev, boost::property
const int input_size_allocated = ((input_size_in_bytes / 4096) + ((input_size_in_bytes % 4096) > 0)) * 4096;
const int output_size_allocated = ((output_size_in_bytes / 4096) + ((output_size_in_bytes % 4096) > 0)) * 4096;

auto uuid = device.load_xclbin(b_file);
auto aie_kernel = xrt::kernel(device,uuid, "aie_kernel");
auto out_bo= xrt::bo(device, output_size_allocated, aie_kernel.group_id(2));
auto xclbin = xrt::xclbin(b_file);
auto uuid = device.register_xclbin(xclbin);
xrt::hw_context hw_ctx(device, uuid);
auto aie_kernel = xrt::kernel(hw_ctx, "aie_kernel");
auto out_bo= xrt::bo(hw_ctx, output_size_allocated, aie_kernel.group_id(2));
auto out_bomapped = out_bo.map<float*>();
memset(out_bomapped, 0, output_size_in_bytes);

Expand Down
28 changes: 16 additions & 12 deletions src/runtime_src/core/tools/common/tests/TestBandwidthKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ namespace XBU = XBUtilities;
#include <boost/property_tree/json_parser.hpp>
#include <filesystem>
#include <math.h>
#include "xrt/experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"

#ifdef _WIN32
Expand Down Expand Up @@ -78,7 +80,7 @@ marshal_build_metadata(std::string test_path, unsigned int* num_kernel, unsigned
}

static std::vector<xrt::kernel>
create_kernel_objects(xrt::device device, xrt::uuid xclbin_uuid, int num_kernel)
create_kernel_objects(xrt::hw_context hw_ctx, int num_kernel)
{
std::string krnl_name = "bandwidth";
std::vector<xrt::kernel> krnls(num_kernel);
Expand All @@ -90,7 +92,7 @@ create_kernel_objects(xrt::device device, xrt::uuid xclbin_uuid, int num_kernel)
// compute unit.
// For such case, this kernel object can only access the specific
// Compute unit
krnls[i] = xrt::kernel(device, xclbin_uuid, krnl_name_full.c_str());
krnls[i] = xrt::kernel(hw_ctx, krnl_name_full.c_str());
}
return krnls;
}
Expand Down Expand Up @@ -145,7 +147,7 @@ calculate_throughput(std::chrono::time_point<std::chrono::high_resolution_clock>
}

static std::pair<double, std::vector<double>>
test_bandwidth_ddr(xrt::device device, std::vector<xrt::kernel> krnls, int num_kernel_ddr)
test_bandwidth_ddr(xrt::hw_context hw_ctx, std::vector<xrt::kernel> krnls, int num_kernel_ddr)
{
double max_throughput = 0;
double mbpersec = 0;
Expand All @@ -166,8 +168,8 @@ test_bandwidth_ddr(xrt::device device, std::vector<xrt::kernel> krnls, int num_k

// Creating Buffers
for (int i = 0; i < num_kernel_ddr; i++) {
input_buffer[i] = xrt::bo(device, vector_size_bytes, krnls[i].group_id(0));
output_buffer[i] = xrt::bo(device, vector_size_bytes, krnls[i].group_id(1));
input_buffer[i] = xrt::bo(hw_ctx, vector_size_bytes, krnls[i].group_id(0));
output_buffer[i] = xrt::bo(hw_ctx, vector_size_bytes, krnls[i].group_id(1));
}

for (int i = 0; i < num_kernel_ddr; i++) {
Expand Down Expand Up @@ -214,7 +216,7 @@ test_bandwidth_ddr(xrt::device device, std::vector<xrt::kernel> krnls, int num_k
}

static double
test_bandwidth_hbm(xrt::device device, std::vector<xrt::kernel> krnls, int num_kernel)
test_bandwidth_hbm(xrt::hw_context hw_ctx, std::vector<xrt::kernel> krnls, int num_kernel)
{
double max_throughput = 0;
double mbpersec = 0;
Expand All @@ -232,8 +234,8 @@ test_bandwidth_hbm(xrt::device device, std::vector<xrt::kernel> krnls, int num_k
xrt::bo input_buffer, output_buffer;

// Creating Buffers
input_buffer = xrt::bo(device, vector_size_bytes, krnls[num_kernel - 1].group_id(0));
output_buffer = xrt::bo(device, vector_size_bytes, krnls[num_kernel - 1].group_id(1));
input_buffer = xrt::bo(hw_ctx, vector_size_bytes, krnls[num_kernel - 1].group_id(0));
output_buffer = xrt::bo(hw_ctx, vector_size_bytes, krnls[num_kernel - 1].group_id(1));

input_buffer.write(input_host.data());
input_buffer.sync(XCL_BO_SYNC_BO_TO_DEVICE);
Expand Down Expand Up @@ -299,13 +301,15 @@ TestBandwidthKernel::runTest(const std::shared_ptr<xrt_core::device>& dev, boost
ptree.put("status", XBValidateUtils::test_token_skipped);
return;
}
auto xclbin_uuid = device.load_xclbin(b_file);
auto xclbin = xrt::xclbin(b_file);
auto uuid = device.register_xclbin(xclbin);
xrt::hw_context hw_ctx(device, uuid);

std::vector<xrt::kernel> krnls = create_kernel_objects(device, xclbin_uuid, num_kernel);
std::vector<xrt::kernel> krnls = create_kernel_objects(hw_ctx, num_kernel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]

  std::vector<xrt::kernel> krnls = create_kernel_objects(hw_ctx, num_kernel);
                                                                 ^


try {
if (num_kernel_ddr) {
auto throughputs = test_bandwidth_ddr(device, krnls, num_kernel_ddr);
auto throughputs = test_bandwidth_ddr(hw_ctx, krnls, num_kernel_ddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]

      auto  throughputs = test_bandwidth_ddr(hw_ctx, krnls, num_kernel_ddr);
                                                            ^

double max_throughput = throughputs.first;
std::vector <double> throughput_per_kernel = throughputs.second;
XBValidateUtils::logger(ptree, "Details", boost::str(boost::format("Throughput (Type: DDR) (Bank count: %d) : %.1f MB/s") % num_kernel_ddr % max_throughput));
Expand All @@ -315,7 +319,7 @@ TestBandwidthKernel::runTest(const std::shared_ptr<xrt_core::device>& dev, boost
}
}
if (chk_hbm_mem) {
double max_throughput = test_bandwidth_hbm(device, krnls, num_kernel);
double max_throughput = test_bandwidth_hbm(hw_ctx, krnls, num_kernel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]

      double max_throughput = test_bandwidth_hbm(hw_ctx, krnls, num_kernel);
                                                                ^

XBValidateUtils::logger(ptree, "Details", boost::str(boost::format("Throughput (Type: HBM) (Bank count: 1) : %.1f MB/s") % max_throughput));
}
} catch (const std::runtime_error& e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ namespace XBU = XBUtilities;
#include <boost/property_tree/json_parser.hpp>
#include <filesystem>
#include <math.h>
#include "xrt/experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"

#ifdef _WIN32
Expand Down Expand Up @@ -97,13 +99,15 @@ TestHostMemBandwidthKernel::runTest(const std::shared_ptr<xrt_core::device>& dev
}

std::string krnl_name = "bandwidth";
xrt::uuid xclbin_uuid;
xrt::xclbin xclbin;
if (retVal == EOPNOTSUPP) {
krnl_name = "slavebridge";
xclbin_uuid = device.load_xclbin(old_binary_file.string());
xclbin = xrt::xclbin(old_binary_file.string());
} else {
xclbin_uuid = device.load_xclbin(b_file);
xclbin = xrt::xclbin(b_file);
}
auto uuid = device.register_xclbin(xclbin);
xrt::hw_context hw_ctx(device, uuid);
std::vector<xrt::kernel> krnls(num_kernel);

for (int i = 0; i < num_kernel; i++) {
Expand All @@ -119,7 +123,7 @@ TestHostMemBandwidthKernel::runTest(const std::shared_ptr<xrt_core::device>& dev
// compute unit.
// For such case, this kernel object can only access the specific
// Compute unit
krnls[i] = xrt::kernel(device, xclbin_uuid, krnl_name_full.c_str());
krnls[i] = xrt::kernel(hw_ctx, krnl_name_full.c_str());
}

double max_throughput = 0;
Expand Down
16 changes: 10 additions & 6 deletions src/runtime_src/core/tools/common/tests/TestPsIops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace XBU = XBUtilities;
#include <sstream>

#include "ps_iops_util/xilutil.hpp"
#include "xrt/experimental/xrt_xclbin.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"

#ifdef _WIN32
Expand Down Expand Up @@ -97,18 +99,18 @@ runThread(std::vector<xrt::run>& cmds, unsigned int total, arg_t& arg)
}

static void
runTestThread(const xrt::device& device, const xrt::kernel& hello_world,
runTestThread(const xrt::hw_context& hw_ctx, const xrt::kernel& hello_world,
arg_t& arg)
{
std::vector<xrt::run> cmds;
std::vector<xrt::bo> bos;

for (int i = 0; i < arg.queueLength; i++) {
auto run = xrt::run(hello_world);
auto bo0 = xrt::bo(device, DATA_SIZE, hello_world.group_id(0));
auto bo0 = xrt::bo(hw_ctx, DATA_SIZE, hello_world.group_id(0));
run.set_arg(0, bo0);
bos.push_back(std::move(bo0));
auto bo1 = xrt::bo(device, DATA_SIZE, hello_world.group_id(1));
auto bo1 = xrt::bo(hw_ctx, DATA_SIZE, hello_world.group_id(1));
run.set_arg(1, bo1);
bos.push_back(std::move(bo1));
run.set_arg(2, COUNT);
Expand All @@ -129,16 +131,18 @@ TestPsIops::testMultiThreads(const std::string& dev, const std::string& xclbin_f
std::vector<arg_t> arg(threadNumber);

xrt::device device(dev);
auto uuid = device.load_xclbin(xclbin_fn);
auto hello_world = xrt::kernel(device, uuid.get(), krnl.name);
auto xclbin = xrt::xclbin(xclbin_fn);
auto uuid = device.register_xclbin(xclbin);
xrt::hw_context hw_ctx(device, uuid);
auto hello_world = xrt::kernel(hw_ctx, krnl.name);

barrier.init(threadNumber + 1);

for (int i = 0; i < threadNumber; i++) {
arg[i].thread_id = i;
arg[i].queueLength = queueLength;
arg[i].total = total;
threads[i] = std::thread([&](int i){ runTestThread(device, hello_world, arg[i]); }, i);
threads[i] = std::thread([&](int i){ runTestThread(hw_ctx, hello_world, arg[i]); }, i);
}

/* Wait threads to prepare to start */
Expand Down
Loading
Loading