Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
nishraptor committed Sep 20, 2023
2 parents 51ec26f + f978a3c commit e8ba91c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 14 deletions.
32 changes: 25 additions & 7 deletions src/runtime_src/core/common/api/xrt_xclbin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "core/common/system.h"
#include "core/common/device.h"
#include "core/common/message.h"
#include "core/common/module_loader.h"
#include "core/common/query_requests.h"
#include "core/common/xclbin_parser.h"
#include "core/common/xclbin_swemu.h"
Expand All @@ -36,6 +37,8 @@
#include "xclbin_int.h"

#include <boost/algorithm/string.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>

#include <array>
#include <fstream>
Expand Down Expand Up @@ -75,15 +78,9 @@ static const std::array<axlf_section_kind, max_sections> kinds = {
IP_METADATA
};

XRT_CORE_UNUSED

static std::vector<char>
read_xclbin(const std::string& fnm)
read_file(const std::string& fnm)
{
if (fnm.empty())
throw std::runtime_error("No xclbin specified");

// load the file
std::ifstream stream(fnm, std::ios::binary);
if (!stream)
throw std::runtime_error("Failed to open file '" + fnm + "' for reading");
Expand All @@ -97,6 +94,27 @@ read_xclbin(const std::string& fnm)
return header;
}

static std::vector<char>
read_xclbin(const std::string& fnm)
{
if (fnm.empty())
throw std::runtime_error("No xclbin specified");

namespace bfs = boost::filesystem;
if (bfs::exists(fnm) && bfs::is_regular_file(fnm))
return read_file(fnm);

std::string path;
try {
path = xrt_core::environment::xclbin_path(fnm);
}
catch (const std::exception&) {
throw std::runtime_error("Failed to find xclbin '" + fnm);
}

return read_file(path);
}

static std::vector<char>
copy_axlf(const axlf* top)
{
Expand Down
12 changes: 9 additions & 3 deletions src/runtime_src/core/include/experimental/xrt_xclbin.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,16 @@ class xclbin : public detail::pimpl<xclbin_impl>
/**
* xclbin() - Constructor from an xclbin filename
*
* @param filename
* Path to the xclbin file
*
* Throws if file not found.
* @param filename : A path relative or absolute to an xclbin file
*
* If the specified path is an absolute path then the function
* returns this path or throws if file does not exist. If the path
* is relative, or just a plain file name, then the function check
* first in current directory, then in the platform specific xclbin
* repository.
*
* Throws if file could not be found.
*/
XCL_DRIVER_DLLESPEC
explicit
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/include/xgq_cmd_vmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ enum xgq_cmd_log_page_type {
XGQ_CMD_LOG_SYSTEM_DTB = 0x7,
XGQ_CMD_LOG_PLM_LOG = 0x8,
XGQ_CMD_LOG_APU_LOG = 0x9,

XGQ_CMD_LOG_SHELL_INTERFACE_UUID = 0xa,
};

/**
Expand Down
20 changes: 20 additions & 0 deletions src/runtime_src/core/pcie/driver/linux/xocl/subdev/xgq_vmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ struct xocl_xgq_vmr {
size_t xgq_vmr_system_dtb_size;
char *xgq_vmr_plm_log;
size_t xgq_vmr_plm_log_size;
char *xgq_vmr_shell_int_uuid;
size_t xgq_vmr_shell_int_uuid_size;
u16 pwr_scaling_threshold_limit;
u8 temp_scaling_threshold_limit;
u16 pwr_scaling_limit;
Expand Down Expand Up @@ -1200,6 +1202,15 @@ static int xgq_refresh_system_dtb(struct xocl_xgq_vmr *xgq)
&xgq->xgq_vmr_system_dtb_size, XGQ_CMD_LOG_SYSTEM_DTB, 0, 0);
}

static int xgq_refresh_shell_int_uuid(struct xocl_xgq_vmr *xgq)
{
if (xgq->xgq_vmr_shell_int_uuid)
vfree(xgq->xgq_vmr_shell_int_uuid);

return xgq_log_page_fw(xgq->xgq_pdev, &xgq->xgq_vmr_shell_int_uuid,
&xgq->xgq_vmr_shell_int_uuid_size, XGQ_CMD_LOG_SHELL_INTERFACE_UUID, 0, 0);
}

static int xgq_vmr_apu_log(struct xocl_xgq_vmr *xgq, char **fw, size_t *fw_size,
loff_t off, size_t req_size)
{
Expand Down Expand Up @@ -3289,6 +3300,8 @@ static int xgq_vmr_remove(struct platform_device *pdev)
vfree(xgq->xgq_vmr_system_dtb);
if (xgq->xgq_vmr_plm_log)
vfree(xgq->xgq_vmr_plm_log);
if (xgq->xgq_vmr_shell_int_uuid)
vfree(xgq->xgq_vmr_shell_int_uuid);

xgq_stop_services(xgq);
fini_worker(&xgq->xgq_complete_worker);
Expand Down Expand Up @@ -3368,6 +3381,11 @@ static int vmr_services_probe(struct platform_device *pdev)
return 0;
}

/* try refresh shell interface uuid, only newer shell has this info */
ret = xgq_refresh_shell_int_uuid(xgq);
if (ret)
XGQ_WARN(xgq, "shell interface uuid is not available, ret: %d", ret);

/* try to download APU PDI, user can check APU status later */
ret = xgq_download_apu_firmware(pdev);
if (ret)
Expand Down Expand Up @@ -3418,6 +3436,8 @@ static int xgq_vmr_probe(struct platform_device *pdev)
xgq->xgq_vmr_system_dtb_size = 0;
xgq->xgq_vmr_plm_log = NULL;
xgq->xgq_vmr_plm_log_size = 0;
xgq->xgq_vmr_shell_int_uuid = NULL;
xgq->xgq_vmr_shell_int_uuid_size = 0;

mutex_init(&xgq->xgq_lock);
mutex_init(&xgq->clk_scaling_lock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ namespace xdp {
XAIE_EVENT_DMA_S2MM_SEL0_FINISHED_TASK_MEM_TILE, XAIE_EVENT_DMA_S2MM_SEL1_FINISHED_TASK_MEM_TILE}},
{"input_channels_stalls",
{XAIE_EVENT_DMA_S2MM_SEL0_START_TASK_MEM_TILE, XAIE_EVENT_DMA_S2MM_SEL0_FINISHED_BD_MEM_TILE,
XAIE_EVENT_DMA_S2MM_SEL0_FINISHED_TASK_MEM_TILE, XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM_TILE,
XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM_TILE, XAIE_EVENT_DMA_S2MM_SEL0_STREAM_STARVATION_MEM_TILE,
XAIE_EVENT_DMA_S2MM_SEL0_FINISHED_TASK_MEM_TILE, XAIE_EVENT_DMA_S2MM_SEL0_STALLED_LOCK_ACQUIRE_MEM_TILE,
XAIE_EVENT_EDGE_DETECTION_EVENT_0_MEM_TILE, XAIE_EVENT_EDGE_DETECTION_EVENT_1_MEM_TILE,
XAIE_EVENT_DMA_S2MM_SEL0_MEMORY_BACKPRESSURE_MEM_TILE}},
{"output_channels",
{XAIE_EVENT_DMA_MM2S_SEL0_START_TASK_MEM_TILE, XAIE_EVENT_DMA_MM2S_SEL1_START_TASK_MEM_TILE,
Expand Down
2 changes: 1 addition & 1 deletion tests/xrt/import_bo/expimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ parent(const std::string& device_id, const std::string& xclbin_fnm, xrt::bo::fla
xrt::device device{device_id};
auto uuid = device.load_xclbin(xclbin_fnm);
xrt::kernel hello(device, uuid, "hello");
xrt::bo bo(device, 1024, flags, hello.group_id(0)); // 1K buffer is somewhat arbitrary
xrt::bo bo(device, 1024*4, flags, hello.group_id(0)); // 1K buffer is somewhat arbitrary
auto bo_data = bo.map<char*>();

// clear device data
Expand Down

0 comments on commit e8ba91c

Please sign in to comment.