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

VITIS-14240 Driver Version Detection via APIs #8709

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion src/runtime_src/core/common/info_platform.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2021-2022 Xilinx, Inc
// Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#define XRT_CORE_COMMON_SOURCE
#include "info_platform.h"
#include "query_requests.h"
Expand Down Expand Up @@ -209,6 +209,8 @@ add_status_info(const xrt_core::device* device, ptree_type& pt)
case xrt_core::query::device_class::type::ryzen:
{
add_performance_info(device, pt_status);
const auto total_cols = xrt_core::device_query_default<xq::total_cols>(device, 0);
pt.add("total_columns", total_cols);
break;
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/runtime_src/core/include/xrt/xrt_device.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020-2022 Xilinx, Inc. All rights reserved.
// Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
#ifndef _XRT_DEVICE_H_
#define _XRT_DEVICE_H_

Expand Down Expand Up @@ -40,45 +40,45 @@ namespace info {
* device. The type of the device properties is compile time defined
* with param traits.
*
* @var bdf
* @var bdf (deprecated)
* BDF for device (std::string)
* @var interface_uuid
* @var interface_uuid (deprecated)
* Interface UUID when device is programmed with 2RP shell (`xrt::uuid`)
* @var kdma
* @var kdma (deprecated)
* Number of KDMA engines (std::uint32_t)
* @var max_clock_frequency_mhz
* @var max_clock_frequency_mhz (deprecated)
* Max clock frequency (unsigned long)
* @var m2m
* @var m2m (deprecated)
* True if device contains m2m (bool)
* @var name
* @var name (deprecated)
* Name (VBNV) of device (std::string)
* @var nodma
* @var nodma (deprecated)
* True if device is a NoDMA device (bool)
* @var offline
* @var offline (deprecated)
* True if device is offline and in process of being reset (bool)
* @var electrical
* @var electrical (deprecated)
* Electrical and power sensors present on the device (std::string)
* @var thermal
* @var thermal (deprecated)
* Thermal sensors present on the device (std::string)
* @var mechanical
* @var mechanical (deprecated)
* Mechanical sensors on and surrounding the device (std::string)
* @var memory
* @var memory (deprecated)
* Memory information present on the device (std::string)
* @var platform
* Platforms flashed on the device (std::string)
* @var pcie_info
* @var pcie_info (deprecated)
* Pcie information of the device (std::string)
* @var host
* Host information (std::string)
* @var aie
* @var aie (deprecated)
* AIE core information of the device (std::string)
* @var aie_shim
* @var aie_shim (deprecated)
* AIE shim information of the device (std::string)
* @var dynamic_regions
* @var dynamic_regions (deprecated)
* Information about xclbin on the device (std::string)
* @var vmr
* @var vmr (deprecated)
* Information about vmr on the device (std::string)
* @var aie_mem
* @var aie_mem (deprecated)
* AIE memory information of the device (std::string)
*/
enum class device : unsigned int {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.

// ------ I N C L U D E F I L E S -------------------------------------------
// System - Include Files
Expand Down Expand Up @@ -51,16 +51,8 @@ ReportRyzenPlatform::writeReport(const xrt_core::device* /*_pDevice*/,

const boost::property_tree::ptree& pt_status = pt_platform.get_child("status");
_output << boost::format(" %-23s: %s \n") % "Power Mode" % pt_status.get<std::string>("power_mode");
_output << boost::format(" %-23s: %s \n") % "Total Columns" % pt_status.get<std::string>("total_columns");

const boost::property_tree::ptree& clocks = pt_platform.get_child("clocks", empty_ptree);
if (!clocks.empty()) {
_output << std::endl << "Clocks" << std::endl;
for (const auto& kc : clocks) {
const boost::property_tree::ptree& pt_clock = kc.second;
std::string clock_name_type = pt_clock.get<std::string>("id");
_output << boost::format(" %-23s: %3s MHz\n") % clock_name_type % pt_clock.get<std::string>("freq_mhz");
}
}

auto watts = pt_platform.get<std::string>("electrical.power_consumption_watts", "N/A");
if (watts != "N/A")
Expand Down
49 changes: 8 additions & 41 deletions tests/xrt/query/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2021 Xilinx, Inc. All rights reserved.
// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <stdexcept>
#include <string>
Expand All @@ -15,24 +15,21 @@
static void
usage()
{
std::cout << "usage: %s [options] -k <bitstream>\n\n";
std::cout << " -k <bitstream>\n";
std::cout << "usage: %s [options]\n\n";
std::cout << " -d <bdf | device_index>\n";
std::cout << " [-j all] # dump all json queries\n";
std::cout << " [-j] # dump all json queries\n";
std::cout << " -h\n\n";
std::cout << "";
std::cout << "* Bitstream is required\n";
}

static int
run(int argc, char** argv)
{
if (argc < 3) {
if (argc < 2) {
usage();
return 1;
}

std::string xclbin_fnm;
std::string device_index = "0";
bool json_queries = false;

Expand All @@ -55,49 +52,19 @@ run(int argc, char** argv)
}

// Switch arguments
if (cur == "-k")
xclbin_fnm = arg;
else if (cur == "-d")
if (cur == "-d")
device_index = arg;
else
throw std::runtime_error("Unknown option value " + cur + " " + arg);
}

if (xclbin_fnm.empty())
throw std::runtime_error("No xclbin specified");

auto device = xrt::device(device_index);
auto xclbin = xrt::xclbin{xclbin_fnm};
auto uuid = device.load_xclbin(xclbin);

if (uuid != xclbin.get_uuid())
throw std::runtime_error("Unexpected uuid error");

std::cout << "device name: " << device.get_info<xrt::info::device::name>() << "\n";
std::cout << "device bdf: " << device.get_info<xrt::info::device::bdf>() << "\n";
std::cout << "device kdma: " << device.get_info<xrt::info::device::kdma>() << "\n";
std::cout << "device max freq: " << device.get_info<xrt::info::device::max_clock_frequency_mhz>() << "\n";
std::cout << "device m2m: " << std::boolalpha << device.get_info<xrt::info::device::m2m>() << std::dec << "\n";
std::cout << "device nodma: " << std::boolalpha << device.get_info<xrt::info::device::nodma>() << std::dec << "\n";
std::cout << "device interface uuid: " << device.get_info<xrt::info::device::interface_uuid>().to_string() << "\n";

if (json_queries) {
std::cout << "device electrical json info ====================================\n";
std::cout << device.get_info<xrt::info::device::electrical>();
std::cout << "device thermal json info =======================================\n";
std::cout << device.get_info<xrt::info::device::thermal>();
std::cout << "device mechanical json info ====================================\n";
std::cout << device.get_info<xrt::info::device::mechanical>();
std::cout << "device memory json info ========================================\n";
std::cout << device.get_info<xrt::info::device::memory>();
std::cout << "device platform json info ======================================\n";
std::cout << device.get_info<xrt::info::device::platform>();
std::cout << "device pcie json info ==========================================\n";
std::cout << device.get_info<xrt::info::device::pcie_info>();
std::cout << "device dynamic regions json info ===============================\n";
std::cout << device.get_info<xrt::info::device::dynamic_regions>();
std::cout << "device host json info ==========================================\n";
std::cout << device.get_info<xrt::info::device::host>();
std::cout << "device platform json info ==========================================\n";
std::cout << device.get_info<xrt::info::device::platform>();
}

// Equality implemented in 2.14
Expand Down
Loading