Skip to content

Commit

Permalink
VITIS-11750 Rename exe from xbutil to xrt-smi (Xilinx#8191)
Browse files Browse the repository at this point in the history
* VITIS-11750 Create a wrapper (e.g. npu-smi) on top of xbutil

Signed-off-by: Ryan Chane <[email protected]>

* VITIS-11750 Rename npu-smi to xrt-smi

Signed-off-by: Ryan Chane <[email protected]>

* VITIS-11750 Rename exe from xbutil to xrt-smi and fix related issues

Signed-off-by: Ryan Chane <[email protected]>

* VITIS-11750 Remove outdated legacy option check

Signed-off-by: Ryan Chane <[email protected]>

---------

Signed-off-by: Ryan Chane <[email protected]>
  • Loading branch information
rchane authored Jun 10, 2024
1 parent 8964124 commit 700a7e0
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/CMake/nativeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ message("----XRT_INSTALL_DIR=${XRT_INSTALL_DIR}")
message("----XRT_BUILD_INSTALL_DIR=${XRT_BUILD_INSTALL_DIR}")
#enable_testing()

add_test(NAME xbutil2
COMMAND ${XRT_BINARY_DIR}/runtime_src/core/tools/xbutil2/xbutil2 examine
add_test(NAME xrt-smi
COMMAND ${XRT_BINARY_DIR}/runtime_src/core/tools/xbutil2/xrt-smi examine
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set_tests_properties(xbutil2 PROPERTIES ENVIRONMENT
set_tests_properties(xrt-smi PROPERTIES ENVIRONMENT
"XILINX_XRT=${XRT_BUILD_INSTALL_DIR}")

add_test(NAME xbmgmt2
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/tools/common/XBMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main_(int argc, char** argv,
const SubCmdsCollection &_subCmds,
const boost::property_tree::ptree& configurations)
{
bool isUserDomain = boost::iequals(_executable, "xbutil");
bool isUserDomain = boost::iequals(_executable, "xrt-smi");

// Global options
bool bVerbose = false;
Expand Down
9 changes: 4 additions & 5 deletions src/runtime_src/core/tools/xbutil2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ file(GLOB XBUTIL_V2_SUBCMD_FILES
# Merge the files into one collection
set(XBUTIL_V2_SRCS ${XBUTIL_V2_BASE_FILES} ${XBUTIL_V2_SUBCMD_FILES})

# Determine the name of the executable
set(XBUTIL2_NAME "xrt-smi")
# Determine any helper scripts
if(WIN32)
set(XBUTIL2_NAME "xbutil") # Yes, on windows the file name will be xbutil
set(XRT_HELPER_SCRIPTS "xbutil" "xbutil.bat")
set(XRT_HELPER_SCRIPTS "xrt-smi" "xrt-smi.bat")
else()
set(XBUTIL2_NAME "xbutil2")
set(XRT_HELPER_SCRIPTS "xbutil")
set(XRT_HELPER_SCRIPTS "xbutil" "xrt-smi")
endif()

add_executable(${XBUTIL2_NAME} ${XBUTIL_V2_SRCS})
Expand Down
24 changes: 9 additions & 15 deletions src/runtime_src/core/tools/xbutil2/xbutil
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@ if [[ "`uname`" == windows32* ]] || [[ "`uname`" == CYGWIN* ]] ; then
fi

# Working variables
XRT_PROG=xbutil2
XRT_PROG=xrt-smi
echo "----------------------------------------------------------------------"
echo " WARNING:
xbutil has been renamed to xrt-smi
Please migrate to using xrt-smi instead of xbutil.
Commands, options, arguments and their descriptions can also be
reported via the --help option."
echo "----------------------------------------------------------------------"

# -- Examine the options
XRTWARP_PROG_ARGS_size=0
XRTWRAP_PROG_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
# Indicates that the legacy was specified
-legacy|--legacy)
echo "----------------------------------------------------------------------"
echo "Error: Obsoleted option
The --legacy option is no longer supported.
For legacy migration, please refer to the XRT github.io utility
migration guide.
Commands, options, arguments and their descriptions can also be
reported via the --help option."
echo "----------------------------------------------------------------------"
exit 1
;;
# Copy the options the remaining options
*)
XRTWRAP_PROG_ARGS[$XRTWARP_PROG_ARGS_size]="$1"
Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/tools/xbutil2/xbutil-bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ _xbutil_completion()
_command_word_xbutil_completion "${options}"
}

complete -F _xbutil_completion xbutil
echo Autocomplete enabled for the xbutil command
complete -F _xbutil_completion xrt-smi
echo Autocomplete enabled for the xrt-smi command

# ex: filetype=sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ alias __xbutil_completion_csh tcsh $XILINX_XRT/share/completions/xbutil-csh-comp
#
# The options that bypass the script parsing are as follows:
# -u, --user, -o, --output, -p, --path
complete xbutil 'n/-u/f/' 'n/--user/f/' 'n/-o/f/' 'n/--output/f/' 'n/-p/f/' 'n/--path/f/' 'p/*/`__xbutil_completion_csh`/'
echo Autocomplete enabled for the xbutil command
complete xrt-smi 'n/-u/f/' 'n/--user/f/' 'n/-o/f/' 'n/--output/f/' 'n/-p/f/' 'n/--path/f/' 'p/*/`__xbutil_completion_csh`/'
echo Autocomplete enabled for the xrt-smi command
2 changes: 1 addition & 1 deletion src/runtime_src/core/tools/xbutil2/xbutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main( int argc, char** argv )
{
// -- Build the supported subcommands
SubCmdsCollection subCommands;
const std::string executable = "xbutil";
const std::string executable = "xrt-smi";

boost::property_tree::ptree configTree;
std::istringstream command_config_stream(command_config);
Expand Down
51 changes: 51 additions & 0 deletions src/runtime_src/core/tools/xbutil2/xrt-smi
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
#

# -- Detect a Windows environment and automatically switch to the .bat file
if [[ "`uname`" == windows32* ]] || [[ "`uname`" == CYGWIN* ]] ; then
trap "" INT
"$0.bat" "$@"
exit $?
fi

# Working variables
XRT_PROG=xrt-smi

# -- Examine the options
XRTWARP_PROG_ARGS_size=0
XRTWRAP_PROG_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
# Copy the options the remaining options
*)
XRTWRAP_PROG_ARGS[$XRTWARP_PROG_ARGS_size]="$1"
XRTWARP_PROG_ARGS_size=$(($XRTWARP_PROG_ARGS_size + 1))
shift
;;
esac
done

# -- Find loader directory
XRT_LOADER_DIR="`dirname \"$0\"`"

# For edge platforms loader is not required as tools are in standard location(/usr).
# So calling unwrapped tool from this script itself.
if [[ $XRT_LOADER_DIR =~ "/usr" ]]; then
"${XRT_LOADER_DIR}/unwrapped/${XRT_PROG}" "${XRTWRAP_PROG_ARGS[@]}"
exit 0
fi

# Call loader for dc platforms
XRT_LOADER="${XRT_LOADER_DIR}/unwrapped/loader"
if [ ! -f "$XRT_LOADER" ]; then
echo "ERROR: Could not find 64-bit loader executable."
echo "ERROR: ${XRT_LOADER} does not exist."
exit 1
fi

"${XRT_LOADER}" -exec ${XRT_PROG} "${XRTWRAP_PROG_ARGS[@]}"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setlocal

REM Working variables
set XRT_PROG=xbutil
set XRT_PROG=xrt-smi

REM -- Examine the options
set XRTWRAP_PROG_ARGS=
Expand Down

0 comments on commit 700a7e0

Please sign in to comment.