diff --git a/src/CMake/components.cmake b/src/CMake/components.cmake new file mode 100644 index 00000000000..331ff2b1b1d --- /dev/null +++ b/src/CMake/components.cmake @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + +# Custom variables imported by this CMake stub which should be defined by parent CMake: +# LINUX_FLAVOR + +if (NOT WIN32) + if (${LINUX_FLAVOR} MATCHES "^(ubuntu|debian)") + set (XRT_DEV_COMPONENT_SUFFIX "dev") + elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos)") + set (XRT_DEV_COMPONENT_SUFFIX "devel") + endif() +endif(NOT WIN32) + +# Default component name for any install() command without the COMPONENT argument +# The default component is the xrt run-time component, if XRT_DEV_COMPONENT is +# set to something different then a development component will be created with +# link libraries and header which are then excluded from runtime component +set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "xrt") + +# Enable development package by specifying development component name +# If XRT_DEV_COMPONENT is same DEFAULT_COMPONENT then only that package +# is created with both development and run-time content. +#set (XRT_DEV_COMPONENT "xrt-dev") +set (XRT_COMPONENT "xrt") +set (XRT_DEV_COMPONENT "xrt") + +set (XRT_BASE_COMPONENT "base") +set (XRT_BASE_DEV_COMPONENT "base-${XRT_DEV_COMPONENT_SUFFIX}") + +# For NPU builds the defalt component is "npu". +if (XRT_NPU) + set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "npu") + set (XRT_COMPONENT "npu") + set (XRT_DEV_COMPONENT "npu") +endif(XRT_NPU) diff --git a/src/CMake/dkms-aws.cmake b/src/CMake/dkms-aws.cmake index b55c5806567..eb18fe3b29c 100644 --- a/src/CMake/dkms-aws.cmake +++ b/src/CMake/dkms-aws.cmake @@ -65,25 +65,32 @@ SET (XRT_DKMS_AWS_DRIVER_INCLUDES # includes relative to core SET (XRT_DKMS_AWS_CORE_INCLUDES - include/ert.h + include/xrt/detail/ert.h + include/xrt/detail/xclbin.h + include/xrt/deprecated/xclerr.h include/xclfeatures.h - include/xclbin.h - include/xclerr.h ) foreach (DKMS_FILE ${XRT_DKMS_AWS_DRIVER_SRCS}) get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install(FILES ${XRT_DKMS_AWS_DRIVER_SRC_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/aws/${DKMS_DIR} COMPONENT aws) + install(FILES ${XRT_DKMS_AWS_DRIVER_SRC_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/aws/${DKMS_DIR} + COMPONENT aws) endforeach() foreach (DKMS_FILE ${XRT_DKMS_AWS_DRIVER_INCLUDES}) get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install(FILES ${XRT_DKMS_AWS_DRIVER_INCLUDE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/${DKMS_DIR} COMPONENT aws) + install(FILES ${XRT_DKMS_AWS_DRIVER_INCLUDE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/${DKMS_DIR} + COMPONENT aws) endforeach() foreach (DKMS_FILE ${XRT_DKMS_AWS_CORE_INCLUDES}) - get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install(FILES ${XRT_DKMS_AWS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/${DKMS_DIR} COMPONENT aws) + install(FILES ${XRT_DKMS_AWS_CORE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_AWS_INSTALL_DRIVER_DIR}/include + COMPONENT aws) endforeach() -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/aws/${DKMS_FILE_NAME} DESTINATION ${XRT_DKMS_AWS_INSTALL_DIR} COMPONENT aws) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/aws/${DKMS_FILE_NAME} + DESTINATION ${XRT_DKMS_AWS_INSTALL_DIR} + COMPONENT aws) diff --git a/src/CMake/dkms-edge.cmake b/src/CMake/dkms-edge.cmake index 8a96603d38d..01e904ad8a7 100644 --- a/src/CMake/dkms-edge.cmake +++ b/src/CMake/dkms-edge.cmake @@ -98,16 +98,16 @@ SET (XRT_DKMS_DRIVER_SRCS # includes relative to core SET (XRT_DKMS_CORE_INCLUDES - include/ert.h + include/xrt/detail/ert.h + include/xrt/detail/xclbin.h + include/xrt/detail/xrt_error_code.h + include/xrt/detail/xrt_mem.h + include/xrt/deprecated/xclerr.h include/ps_kernel.h include/types.h include/xclfeatures.h - include/xclbin.h - include/xclerr.h include/xclerr_int.h include/xclhal2_mem.h - include/xrt_error_code.h - include/xrt_mem.h include/xgq_cmd_common.h include/xgq_cmd_ert.h include/xgq_cmd_vmr.h @@ -151,20 +151,19 @@ foreach (DKMS_FILE ${XRT_DKMS_DRIVER_SRCS}) endforeach() foreach (DKMS_FILE ${XRT_DKMS_CORE_INCLUDES}) - get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/${DKMS_DIR}) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/include) endforeach() foreach (DKMS_FILE ${XRT_DKMS_COMMON_XRT_DRV}) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/common/) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/common) endforeach() foreach (DKMS_FILE ${XRT_DKMS_COMMON_XRT_DRV_INCLUDES}) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/include/) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/include) endforeach() foreach (DKMS_FILE ${XRT_DKMS_CORE_EDGE_INCLUDES}) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/include/) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/zocl/include) endforeach() install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${DKMS_FILE_NAME} DESTINATION ${XRT_DKMS_INSTALL_DIR}) diff --git a/src/CMake/dkms.cmake b/src/CMake/dkms.cmake index 9b6a8f22499..711c4d07456 100644 --- a/src/CMake/dkms.cmake +++ b/src/CMake/dkms.cmake @@ -236,16 +236,16 @@ SET (XRT_DKMS_DRIVER_INCLUDES include/xocl_xgq.h ) -# includes relative to core +# includes relative to core copied flat to DKMS include SET (XRT_DKMS_CORE_INCLUDES - include/ert.h + include/xrt/detail/ert.h + include/xrt/detail/xclbin.h + include/xrt/detail/xrt_error_code.h + include/xrt/detail/xrt_mem.h + include/xrt/deprecated/xclerr.h include/ps_kernel.h include/xclfeatures.h - include/xclbin.h - include/xclerr.h include/xclerr_int.h - include/xrt_error_code.h - include/xrt_mem.h include/xgq_cmd_common.h include/xgq_cmd_ert.h include/xgq_cmd_vmr.h @@ -282,25 +282,36 @@ SET (XRT_DKMS_ABS_SRCS) foreach (DKMS_FILE ${XRT_DKMS_DRIVER_SRCS}) get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install (FILES ${XRT_DKMS_DRIVER_SRC_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/${DKMS_DIR}) + install (FILES ${XRT_DKMS_DRIVER_SRC_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/${DKMS_DIR} + COMPONENT ${XRT_COMPONENT}) endforeach() foreach (DKMS_FILE ${XRT_DKMS_DRIVER_INCLUDES}) get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install (FILES ${XRT_DKMS_DRIVER_INCLUDE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/${DKMS_DIR}) + install (FILES ${XRT_DKMS_DRIVER_INCLUDE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/${DKMS_DIR} + COMPONENT ${XRT_COMPONENT}) endforeach() foreach (DKMS_FILE ${XRT_DKMS_CORE_INCLUDES}) - get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/${DKMS_DIR}) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/include + COMPONENT ${XRT_COMPONENT}) endforeach() foreach (DKMS_FILE ${XRT_DKMS_COMMON_XRT_DRV}) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/common/) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/common + COMPONENT ${XRT_COMPONENT}) endforeach() foreach (DKMS_FILE ${XRT_DKMS_COMMON_XRT_DRV_INCLUDES}) - install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/include/) + install (FILES ${XRT_DKMS_CORE_DIR}/${DKMS_FILE} + DESTINATION ${XRT_DKMS_INSTALL_DRIVER_DIR}/include + COMPONENT ${XRT_COMPONENT}) endforeach() -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${DKMS_FILE_NAME} DESTINATION ${XRT_DKMS_INSTALL_DIR}) +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${DKMS_FILE_NAME} + DESTINATION ${XRT_DKMS_INSTALL_DIR} + COMPONENT ${XRT_COMPONENT}) diff --git a/src/CMake/nativeLnx.cmake b/src/CMake/nativeLnx.cmake index ecfcc19eb69..a2344b81ce1 100644 --- a/src/CMake/nativeLnx.cmake +++ b/src/CMake/nativeLnx.cmake @@ -85,20 +85,20 @@ if ( (${CMAKE_VERSION} VERSION_GREATER "3.16.0") set(XRT_STATIC_BUILD ON) endif() -# --- Boost --- -#set(Boost_DEBUG 1) +# XRT install components +include (CMake/components.cmake) -# --- Boost Libraries --- +# Boost Libraries include (CMake/boostUtil.cmake) include_directories(${Boost_INCLUDE_DIRS}) add_compile_options("-DBOOST_LOCALE_HIDE_AUTO_PTR") -# --- Curses --- +# Curses INCLUDE (FindCurses) find_package(Curses REQUIRED) -# --- XRT Variables --- +# XRT Variables include (CMake/xrtVariables.cmake) # Define RPATH for embedding in libraries and executables. This allows diff --git a/src/CMake/nativeWin.cmake b/src/CMake/nativeWin.cmake index ffa38df3956..fb6d23db505 100644 --- a/src/CMake/nativeWin.cmake +++ b/src/CMake/nativeWin.cmake @@ -24,10 +24,10 @@ ELSE(GIT_FOUND) MESSAGE(FATAL_ERROR "Looking for GIT - not found") endif(GIT_FOUND) -# --- Boost --- -#set(Boost_DEBUG 1) +# XRT install components +include(CMake/components.cmake) -INCLUDE (FindBoost) +include(FindBoost) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_LIBS ON) find_package(Boost @@ -73,10 +73,10 @@ if (MSVC) endif() -INCLUDE (FindGTest) +include(FindGTest) # --- XRT Variables --- -include (CMake/xrtVariables.cmake) +include(CMake/xrtVariables.cmake) # --- Release: eula --- file(GLOB XRT_EULA @@ -86,16 +86,16 @@ install (FILES ${XRT_SOURCE_DIR}/../LICENSE DESTINATION ${XRT_INSTALL_DIR}/licen message("-- XRT EA eula files ${XRT_SOURCE_DIR}/../LICENSE") # -- CPack -include (CMake/cpackWin.cmake) +include(CMake/cpackWin.cmake) # --- Create Version header and JSON file --- -include (CMake/version.cmake) +include(CMake/version.cmake) -message ("------------ xrt install dir: ${XRT_INSTALL_DIR}") +message("------------ xrt install dir: ${XRT_INSTALL_DIR}") add_subdirectory(runtime_src) # --- Find Package Support --- -include (CMake/findpackage.cmake) +include(CMake/findpackage.cmake) # --- Python bindings --- xrt_add_subdirectory(python) diff --git a/src/CMake/settings.cmake b/src/CMake/settings.cmake index b773aca4e42..b1f0ae35cae 100644 --- a/src/CMake/settings.cmake +++ b/src/CMake/settings.cmake @@ -9,6 +9,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) message("-- Host system processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}") message("-- Target system processor is ${CMAKE_SYSTEM_PROCESSOR}") +# Indicate that we are building XRT +add_compile_definitions("XRT_BUILD") + set(XRT_NATIVE_BUILD "yes") if (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) set(XRT_NATIVE_BUILD "no") diff --git a/src/CMake/version.cmake b/src/CMake/version.cmake index caa5dadd1cc..ffb05ba08c2 100644 --- a/src/CMake/version.cmake +++ b/src/CMake/version.cmake @@ -93,14 +93,26 @@ configure_file( ${PROJECT_BINARY_DIR}/gen/version.json ) -install(FILES ${PROJECT_BINARY_DIR}/gen/version.h DESTINATION ${XRT_INSTALL_INCLUDE_DIR}) +# xrt component install +install(FILES ${PROJECT_BINARY_DIR}/gen/version.h + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_DEV_COMPONENT}) + +# xrt component install +install(FILES ${PROJECT_BINARY_DIR}/gen/version.h + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_BASE_DEV_COMPONENT}) + if (${XRT_NATIVE_BUILD} STREQUAL "yes") -install(FILES ${PROJECT_BINARY_DIR}/gen/version.json DESTINATION ${XRT_INSTALL_DIR}) + install(FILES ${PROJECT_BINARY_DIR}/gen/version.json + DESTINATION ${XRT_INSTALL_DIR} + COMPONENT ${XRT_COMPONENT}) endif() # This is not required on MPSoC platform. To avoid yocto error, do NOT intall if ((${XRT_NATIVE_BUILD} STREQUAL "yes") AND (NOT WIN32)) # Copied over from dkms.cmake. TODO: cleanup set (XRT_DKMS_INSTALL_DIR "/usr/src/xrt-${XRT_VERSION_STRING}") - install(FILES ${PROJECT_BINARY_DIR}/gen/version.h DESTINATION ${XRT_DKMS_INSTALL_DIR}/driver/include) + install(FILES ${PROJECT_BINARY_DIR}/gen/version.h + DESTINATION ${XRT_DKMS_INSTALL_DIR}/driver/include) endif() diff --git a/src/include/1_2/CL/cl2xrt.hpp b/src/include/1_2/CL/cl2xrt.hpp index bb435e8bd2d..9f13fb4cee1 100644 --- a/src/include/1_2/CL/cl2xrt.hpp +++ b/src/include/1_2/CL/cl2xrt.hpp @@ -16,9 +16,9 @@ #ifndef XRT_CL2XRT_HPP #define XRT_CL2XRT_HPP -#include "experimental/xrt_bo.h" -#include "experimental/xrt_device.h" -#include "experimental/xrt_kernel.h" +#include "xrt/xrt_bo.h" +#include "xrt/xrt_device.h" +#include "xrt/xrt_kernel.h" #include diff --git a/src/python/pybind11/src/pyxrt.cpp b/src/python/pybind11/src/pyxrt.cpp index 8f586f0cfbb..f5f0dece423 100644 --- a/src/python/pybind11/src/pyxrt.cpp +++ b/src/python/pybind11/src/pyxrt.cpp @@ -14,9 +14,9 @@ #include "xrt/xrt_kernel.h" #include "xrt/xrt_bo.h" #include "xrt/xrt_graph.h" -#include "experimental/xrt_message.h" -#include "experimental/xrt_system.h" -#include "experimental/xrt_xclbin.h" +#include "xrt/experimental/xrt_message.h" +#include "xrt/experimental/xrt_system.h" +#include "xrt/experimental/xrt_xclbin.h" // Pybind11 includes #include diff --git a/src/runtime_src/core/common/api/aie/xrt_graph.cpp b/src/runtime_src/core/common/api/aie/xrt_graph.cpp index 91074563007..47caad15fd0 100644 --- a/src/runtime_src/core/common/api/aie/xrt_graph.cpp +++ b/src/runtime_src/core/common/api/aie/xrt_graph.cpp @@ -12,9 +12,9 @@ #include "core/include/xrt/xrt_graph.h" #include "core/include/xrt/xrt_aie.h" #include "core/include/xrt/xrt_bo.h" +#include "core/include/xrt/xrt_device.h" #include "core/include/xcl_graph.h" -#include "core/include/experimental/xrt_device.h" #include "core/common/api/device_int.h" #include "core/common/api/native_profile.h" #include "core/common/device.h" diff --git a/src/runtime_src/core/common/api/bo.h b/src/runtime_src/core/common/api/bo.h index 31faefade96..387fec483a1 100644 --- a/src/runtime_src/core/common/api/bo.h +++ b/src/runtime_src/core/common/api/bo.h @@ -6,8 +6,8 @@ // This file defines implementation extensions to the XRT BO APIs. #include "core/include/xrt/xrt_bo.h" +#include "core/include/xrt/detail/ert.h" #include "core/common/config.h" -#include "core/include/ert.h" namespace xrt_core { namespace bo { diff --git a/src/runtime_src/core/common/api/command.h b/src/runtime_src/core/common/api/command.h index fe869b299fa..1f6c7227bb6 100644 --- a/src/runtime_src/core/common/api/command.h +++ b/src/runtime_src/core/common/api/command.h @@ -7,8 +7,8 @@ #include "core/common/device.h" #include "core/common/shim/hwctx_handle.h" #include "core/common/shim/buffer_handle.h" -#include "xrt.h" -#include "ert.h" +#include "core/include/xrt/detail/ert.h" +#include "core/include/xrt/deprecated/xrt.h" /** * class command - Command API expected by sws and kds command monitor diff --git a/src/runtime_src/core/common/api/context_mgr.h b/src/runtime_src/core/common/api/context_mgr.h index 61dfd0dbf00..b18a2a26408 100644 --- a/src/runtime_src/core/common/api/context_mgr.h +++ b/src/runtime_src/core/common/api/context_mgr.h @@ -1,9 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved. // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. - +#include "core/include/xrt/xrt_hw_context.h" #include "core/include/xrt/xrt_uuid.h" -#include "core/include/experimental/xrt_hw_context.h" #include "core/common/cuidx_type.h" #include diff --git a/src/runtime_src/core/common/api/elf_int.h b/src/runtime_src/core/common/api/elf_int.h index 700244c2ba7..98cd04c839b 100644 --- a/src/runtime_src/core/common/api/elf_int.h +++ b/src/runtime_src/core/common/api/elf_int.h @@ -4,7 +4,7 @@ #define _XRT_COMMON_ELF_INT_H_ // This file defines implementation extensions to the XRT ELF APIs. -#include "core/include/experimental/xrt_elf.h" +#include "core/include/xrt/experimental/xrt_elf.h" #include #include #include diff --git a/src/runtime_src/core/common/api/error_int.h b/src/runtime_src/core/common/api/error_int.h index 8f610b8cb7c..5ba64ef1ffc 100644 --- a/src/runtime_src/core/common/api/error_int.h +++ b/src/runtime_src/core/common/api/error_int.h @@ -19,7 +19,7 @@ #define _XRT_COMMON_ERROR_INT_H_ // This file defines implementation extensions to the XRT Error APIs. -#include "core/include/experimental/xrt_error.h" +#include "core/include/xrt/experimental/xrt_error.h" #include "core/common/config.h" #include diff --git a/src/runtime_src/core/common/api/fence_int.h b/src/runtime_src/core/common/api/fence_int.h index 08b4aedd51a..8d3a263cff4 100644 --- a/src/runtime_src/core/common/api/fence_int.h +++ b/src/runtime_src/core/common/api/fence_int.h @@ -5,7 +5,7 @@ #define _XRT_COMMON_FENCE_INT_H_ // This file defines implementation extensions to the XRT Kernel APIs. -#include "core/include/experimental/xrt_fence.h" +#include "core/include/xrt/experimental/xrt_fence.h" #include "core/common/shim/fence_handle.h" namespace xrt_core::fence_int { diff --git a/src/runtime_src/core/common/api/hw_context_int.h b/src/runtime_src/core/common/api/hw_context_int.h index 1215de1288d..245e7cffd08 100644 --- a/src/runtime_src/core/common/api/hw_context_int.h +++ b/src/runtime_src/core/common/api/hw_context_int.h @@ -4,8 +4,9 @@ #define XRT_COMMON_API_HW_CONTEXT_INT_H #include "core/common/config.h" + // This file defines implementation extensions to the XRT XCLBIN APIs. -#include "core/include/experimental/xrt_hw_context.h" +#include "core/include/xrt/xrt_hw_context.h" #include diff --git a/src/runtime_src/core/common/api/hw_queue.cpp b/src/runtime_src/core/common/api/hw_queue.cpp index 9c4f0d11eb5..fe26c44d608 100644 --- a/src/runtime_src/core/common/api/hw_queue.cpp +++ b/src/runtime_src/core/common/api/hw_queue.cpp @@ -13,11 +13,11 @@ #include "core/common/debug.h" #include "core/common/device.h" #include "core/common/thread.h" -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" #include "core/include/xrt_hwqueue.h" #include "xrt/xrt_hw_context.h" -#include "experimental/xrt_fence.h" +#include "xrt/experimental/xrt_fence.h" #include #include diff --git a/src/runtime_src/core/common/api/hw_queue.h b/src/runtime_src/core/common/api/hw_queue.h index 89566cf126a..dbae9108a86 100644 --- a/src/runtime_src/core/common/api/hw_queue.h +++ b/src/runtime_src/core/common/api/hw_queue.h @@ -6,12 +6,6 @@ #include "core/common/config.h" #include "xrt/detail/pimpl.h" -#include "experimental/xrt_fence.h" -#include "experimental/xrt_kernel.h" - -#include "core/common/shim/buffer_handle.h" - -#include #include #include @@ -22,6 +16,7 @@ class hw_context; namespace xrt_core { +class buffer_handle; class command; class device; class fence; diff --git a/src/runtime_src/core/common/api/ip_int.h b/src/runtime_src/core/common/api/ip_int.h index 37cd7619163..61f6d23639d 100644 --- a/src/runtime_src/core/common/api/ip_int.h +++ b/src/runtime_src/core/common/api/ip_int.h @@ -6,7 +6,7 @@ // This file defines implementation extensions to the XRT BO APIs. #include "core/common/config.h" -#include "core/include/experimental/xrt_ip.h" +#include "core/include/xrt/experimental/xrt_ip.h" namespace xrt_core::ip_int { diff --git a/src/runtime_src/core/common/api/kernel_int.h b/src/runtime_src/core/common/api/kernel_int.h index 202957fe76b..2947d518745 100644 --- a/src/runtime_src/core/common/api/kernel_int.h +++ b/src/runtime_src/core/common/api/kernel_int.h @@ -8,12 +8,12 @@ #define _XRT_COMMON_KERNEL_INT_H_ // This file defines implementation extensions to the XRT Kernel APIs. -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/experimental/xrt_kernel.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/config.h" #include "core/common/xclbin_parser.h" #include "core/common/shim/buffer_handle.h" -#include "core/include/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/core/common/api/module_int.h b/src/runtime_src/core/common/api/module_int.h index 75e95e723c4..8b5a2b189c0 100644 --- a/src/runtime_src/core/common/api/module_int.h +++ b/src/runtime_src/core/common/api/module_int.h @@ -7,8 +7,8 @@ #define _XRT_COMMON_MODULE_INT_H_ // This file defines implementation extensions to the XRT Kernel APIs. -#include "core/include/experimental/xrt_bo.h" -#include "core/include/experimental/xrt_module.h" +#include "core/include/xrt/xrt_bo.h" +#include "core/include/xrt/experimental/xrt_module.h" #include diff --git a/src/runtime_src/core/common/api/xclbin_int.h b/src/runtime_src/core/common/api/xclbin_int.h index 26e8dd4ca4c..a6038a5a7cb 100644 --- a/src/runtime_src/core/common/api/xclbin_int.h +++ b/src/runtime_src/core/common/api/xclbin_int.h @@ -6,7 +6,7 @@ #define _XRT_COMMON_XCLBIN_INT_H_ // This file defines implementation extensions to the XRT XCLBIN APIs. -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/config.h" #include "core/common/xclbin_parser.h" diff --git a/src/runtime_src/core/common/api/xrt_bo.cpp b/src/runtime_src/core/common/api/xrt_bo.cpp index a1fbd66538c..19231ea9a1d 100755 --- a/src/runtime_src/core/common/api/xrt_bo.cpp +++ b/src/runtime_src/core/common/api/xrt_bo.cpp @@ -10,7 +10,8 @@ #include "core/include/xrt/xrt_bo.h" #include "core/include/xrt/xrt_aie.h" #include "core/include/xrt/xrt_hw_context.h" -#include "core/include/experimental/xrt_ext.h" +#include "core/include/xrt/detail/xrt_mem.h" +#include "core/include/xrt/experimental/xrt_ext.h" #include "native_profile.h" #include "bo.h" @@ -19,7 +20,6 @@ #include "handle.h" #include "hw_context_int.h" #include "kernel_int.h" -#include "xrt_mem.h" #include "core/common/api/bo_int.h" #include "core/common/device.h" #include "core/common/memalign.h" diff --git a/src/runtime_src/core/common/api/xrt_elf.cpp b/src/runtime_src/core/common/api/xrt_elf.cpp index bb522c32e74..0960165aeef 100644 --- a/src/runtime_src/core/common/api/xrt_elf.cpp +++ b/src/runtime_src/core/common/api/xrt_elf.cpp @@ -3,7 +3,7 @@ #define XCL_DRIVER_DLL_EXPORT // exporting xrt_elf.h #define XRT_API_SOURCE // exporting xrt_elf.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "experimental/xrt_elf.h" +#include "xrt/experimental/xrt_elf.h" #include "xrt/xrt_uuid.h" #include "elf_int.h" diff --git a/src/runtime_src/core/common/api/xrt_error.cpp b/src/runtime_src/core/common/api/xrt_error.cpp index 1d95354185a..2b10e63e0ac 100644 --- a/src/runtime_src/core/common/api/xrt_error.cpp +++ b/src/runtime_src/core/common/api/xrt_error.cpp @@ -19,7 +19,7 @@ // core/include/experimental/xrt_error.h #define XCL_DRIVER_DLL_EXPORT // exporting xrt_xclbin.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_error.h" +#include "core/include/xrt/experimental/xrt_error.h" #include "native_profile.h" #include "device_int.h" diff --git a/src/runtime_src/core/common/api/xrt_fence.cpp b/src/runtime_src/core/common/api/xrt_fence.cpp index ef6577f478f..5c0892e13c8 100644 --- a/src/runtime_src/core/common/api/xrt_fence.cpp +++ b/src/runtime_src/core/common/api/xrt_fence.cpp @@ -3,7 +3,7 @@ #define XRT_API_SOURCE // exporting xrt_hwcontext.h #define XCL_DRIVER_DLL_EXPORT // exporting xrt_xclbin.h #define XRT_CORE_COMMON_SOURCE // in same dll as coreutil -#include "core/include/experimental/xrt_fence.h" +#include "core/include/xrt/experimental/xrt_fence.h" #include "core/common/api/fence_int.h" #include "core/common/shim/fence_handle.h" #include "core/common/shim/shared_handle.h" diff --git a/src/runtime_src/core/common/api/xrt_ini.cpp b/src/runtime_src/core/common/api/xrt_ini.cpp index f07f0bb7e69..23f6ea7dbe3 100644 --- a/src/runtime_src/core/common/api/xrt_ini.cpp +++ b/src/runtime_src/core/common/api/xrt_ini.cpp @@ -19,7 +19,7 @@ // core/include/experimental/xrt_ini.h #define XCL_DRIVER_DLL_EXPORT // exporting xrt_ini.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_ini.h" +#include "core/include/xrt/experimental/xrt_ini.h" #include "core/common/config_reader.h" #include "core/common/error.h" diff --git a/src/runtime_src/core/common/api/xrt_ip.cpp b/src/runtime_src/core/common/api/xrt_ip.cpp index 4911541001f..363104451e5 100644 --- a/src/runtime_src/core/common/api/xrt_ip.cpp +++ b/src/runtime_src/core/common/api/xrt_ip.cpp @@ -7,8 +7,8 @@ #define XCL_DRIVER_DLL_EXPORT // exporting xrt_ip.h #define XRT_CORE_COMMON_SOURCE // in same dll as coreutil #define XRT_API_SOURCE // in same dll as coreutil -#include "core/include/experimental/xrt_ip.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_ip.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/api/hw_context_int.h" #include "core/common/api/ip_int.h" diff --git a/src/runtime_src/core/common/api/xrt_kernel.cpp b/src/runtime_src/core/common/api/xrt_kernel.cpp index 50362b2b803..cd72df3fe35 100644 --- a/src/runtime_src/core/common/api/xrt_kernel.cpp +++ b/src/runtime_src/core/common/api/xrt_kernel.cpp @@ -8,17 +8,17 @@ #define XCL_DRIVER_DLL_EXPORT // exporting xrt_kernel.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common #include "core/include/xrt/xrt_kernel.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/experimental/xrt_kernel.h" #include "core/common/shim/buffer_handle.h" #include "core/common/shim/hwctx_handle.h" #include "core/include/xrt/xrt_hw_context.h" -#include "core/include/experimental/xrt_ext.h" -#include "core/include/experimental/xrt_mailbox.h" -#include "core/include/experimental/xrt_module.h" -#include "core/include/experimental/xrt_xclbin.h" -#include "core/include/ert.h" +#include "core/include/xrt/experimental/xrt_ext.h" +#include "core/include/xrt/experimental/xrt_mailbox.h" +#include "core/include/xrt/experimental/xrt_module.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" +#include "core/include/xrt/detail/ert.h" #include "core/include/ert_fa.h" #include "bo.h" diff --git a/src/runtime_src/core/common/api/xrt_message.cpp b/src/runtime_src/core/common/api/xrt_message.cpp index 5aa40870072..d1758692b63 100644 --- a/src/runtime_src/core/common/api/xrt_message.cpp +++ b/src/runtime_src/core/common/api/xrt_message.cpp @@ -5,7 +5,7 @@ // core/include/experimental/xrt_message.h #define XCL_DRIVER_DLL_EXPORT // exporting xrt_ini.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_message.h" +#include "core/include/xrt/experimental/xrt_message.h" #include "core/common/config_reader.h" #include "core/common/message.h" diff --git a/src/runtime_src/core/common/api/xrt_module.cpp b/src/runtime_src/core/common/api/xrt_module.cpp index f85e4274c14..5c78d4641f1 100644 --- a/src/runtime_src/core/common/api/xrt_module.cpp +++ b/src/runtime_src/core/common/api/xrt_module.cpp @@ -5,16 +5,17 @@ #define XRT_CORE_COMMON_SOURCE // in same dll as core_common #include "core/common/config_reader.h" #include "core/common/message.h" -#include "experimental/xrt_module.h" -#include "experimental/xrt_elf.h" -#include "experimental/xrt_ext.h" +#include "xrt/experimental/xrt_module.h" +#include "xrt/experimental/xrt_elf.h" +#include "xrt/experimental/xrt_ext.h" #include "xrt/xrt_bo.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_uuid.h" +#include "xrt/detail/ert.h" + #include "elf_int.h" -#include "ert.h" #include "module_int.h" #include "core/common/debug.h" diff --git a/src/runtime_src/core/common/api/xrt_profile.cpp b/src/runtime_src/core/common/api/xrt_profile.cpp index 0b7fad6fa05..3040d6d2ef9 100644 --- a/src/runtime_src/core/common/api/xrt_profile.cpp +++ b/src/runtime_src/core/common/api/xrt_profile.cpp @@ -21,7 +21,7 @@ #define XCL_DRIVER_DLL_EXPORT #define XRT_CORE_COMMON_SOURCE -#include "core/include/experimental/xrt_profile.h" +#include "core/include/xrt/experimental/xrt_profile.h" #include "core/common/dlfcn.h" #include "core/common/error.h" diff --git a/src/runtime_src/core/common/api/xrt_queue.cpp b/src/runtime_src/core/common/api/xrt_queue.cpp index 07f2dfd42e2..1461367d0d8 100644 --- a/src/runtime_src/core/common/api/xrt_queue.cpp +++ b/src/runtime_src/core/common/api/xrt_queue.cpp @@ -6,7 +6,7 @@ // core/include/experimental/xrt_queue.h #define XRT_API_SOURCE // exporting xrt_queue.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_queue.h" +#include "core/include/xrt/experimental/xrt_queue.h" #include #include diff --git a/src/runtime_src/core/common/api/xrt_system.cpp b/src/runtime_src/core/common/api/xrt_system.cpp index 81623d3240c..a925fb20c38 100644 --- a/src/runtime_src/core/common/api/xrt_system.cpp +++ b/src/runtime_src/core/common/api/xrt_system.cpp @@ -5,7 +5,7 @@ // core/include/experimental/xrt_system.h #define XCL_DRIVER_DLL_EXPORT // exporting xrt_ini.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_system.h" +#include "core/include/xrt/experimental/xrt_system.h" #include "core/common/system.h" diff --git a/src/runtime_src/core/common/api/xrt_version.cpp b/src/runtime_src/core/common/api/xrt_version.cpp index dcb1d3c8ade..45296d6de3a 100644 --- a/src/runtime_src/core/common/api/xrt_version.cpp +++ b/src/runtime_src/core/common/api/xrt_version.cpp @@ -5,7 +5,7 @@ // core/include/experimental/xrt_version.h #define XRT_API_SOURCE // exporting xrt_version.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_version.h" +#include "core/include/xrt/experimental/xrt_version.h" #include "version.h" #ifdef major diff --git a/src/runtime_src/core/common/api/xrt_xclbin.cpp b/src/runtime_src/core/common/api/xrt_xclbin.cpp index 2828a2c52f2..8f9d60f8914 100644 --- a/src/runtime_src/core/common/api/xrt_xclbin.cpp +++ b/src/runtime_src/core/common/api/xrt_xclbin.cpp @@ -6,7 +6,7 @@ // core/include/experimental/xrt_xclbin.h #define XRT_API_SOURCE // exporting xrt_version.h #define XRT_CORE_COMMON_SOURCE // in same dll as core_common -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/system.h" #include "core/common/device.h" @@ -16,7 +16,7 @@ #include "core/common/xclbin_parser.h" #include "core/common/xclbin_swemu.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "handle.h" #include "native_profile.h" @@ -34,7 +34,7 @@ #include #ifdef _WIN32 -# include "windows/uuid.h" +# include "xrt/detail/windows/uuid.h" # pragma warning( disable : 4244 4267 4996) #else # include diff --git a/src/runtime_src/core/common/bo_cache.h b/src/runtime_src/core/common/bo_cache.h index 40edc3a4cf1..079b467cf44 100644 --- a/src/runtime_src/core/common/bo_cache.h +++ b/src/runtime_src/core/common/bo_cache.h @@ -8,7 +8,7 @@ #include "core/common/system.h" #include "core/common/device.h" #include "core/common/shim/buffer_handle.h" -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" #include #include diff --git a/src/runtime_src/core/common/debug_ip.cpp b/src/runtime_src/core/common/debug_ip.cpp index 850c793fc0f..9c2fdd7fead 100644 --- a/src/runtime_src/core/common/debug_ip.cpp +++ b/src/runtime_src/core/common/debug_ip.cpp @@ -20,7 +20,7 @@ #include "debug_ip.h" #include "core/common/device.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/include/xdp/add.h" #include "core/include/xdp/aim.h" #include "core/include/xdp/am.h" diff --git a/src/runtime_src/core/common/device.cpp b/src/runtime_src/core/common/device.cpp index 9dd3306f0e2..87bc78822e2 100644 --- a/src/runtime_src/core/common/device.cpp +++ b/src/runtime_src/core/common/device.cpp @@ -13,11 +13,11 @@ #include "xclbin_parser.h" #include "xclbin_swemu.h" -#include "core/include/ert.h" -#include "core/include/xrt.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/ert.h" +#include "core/include/xrt/detail/xclbin.h" +#include "core/include/xrt/deprecated/xrt.h" #include "core/include/xrt/xrt_uuid.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/api/hw_queue.h" #include "core/common/api/xclbin_int.h" diff --git a/src/runtime_src/core/common/device.h b/src/runtime_src/core/common/device.h index 9f45ee7bfbb..0ea94367a4b 100644 --- a/src/runtime_src/core/common/device.h +++ b/src/runtime_src/core/common/device.h @@ -16,7 +16,7 @@ #include "core/common/shim/hwctx_handle.h" #include "core/common/usage_metrics.h" #include "core/include/xrt.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/core/common/info_memory.cpp b/src/runtime_src/core/common/info_memory.cpp index ccc0053c9d7..e458cf5b0ee 100644 --- a/src/runtime_src/core/common/info_memory.cpp +++ b/src/runtime_src/core/common/info_memory.cpp @@ -7,7 +7,7 @@ #include "ps_kernel.h" #include "query_requests.h" #include "utils.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include diff --git a/src/runtime_src/core/common/info_platform.cpp b/src/runtime_src/core/common/info_platform.cpp index 7a99c4a37f4..275b30627ac 100644 --- a/src/runtime_src/core/common/info_platform.cpp +++ b/src/runtime_src/core/common/info_platform.cpp @@ -6,7 +6,7 @@ #include "query_requests.h" #include "sensor.h" #include "utils.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include diff --git a/src/runtime_src/core/common/info_platform.h b/src/runtime_src/core/common/info_platform.h index b0551ff9733..b5d496051fd 100644 --- a/src/runtime_src/core/common/info_platform.h +++ b/src/runtime_src/core/common/info_platform.h @@ -19,7 +19,7 @@ // Local - Include Files #include "device.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" namespace xrt_core { namespace platform { diff --git a/src/runtime_src/core/common/ishim.h b/src/runtime_src/core/common/ishim.h index f69db78cea2..981c917f8b1 100755 --- a/src/runtime_src/core/common/ishim.h +++ b/src/runtime_src/core/common/ishim.h @@ -20,8 +20,8 @@ #include "xrt/xrt_graph.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_uuid.h" -#include "experimental/xrt_fence.h" -#include "experimental/xrt-next.h" +#include "xrt/experimental/xrt_fence.h" +#include "xrt/experimental/xrt-next.h" #include #include diff --git a/src/runtime_src/core/common/message.h b/src/runtime_src/core/common/message.h index 272e9f49061..d7047a442eb 100644 --- a/src/runtime_src/core/common/message.h +++ b/src/runtime_src/core/common/message.h @@ -19,7 +19,7 @@ #include "core/common/config.h" #include "core/common/config_reader.h" #include "core/include/xrt.h" -#include "core/include/experimental/xrt_message.h" +#include "core/include/xrt/experimental/xrt_message.h" #include #include #include diff --git a/src/runtime_src/core/common/runner/runner.cpp b/src/runtime_src/core/common/runner/runner.cpp index 4383dec02b2..46e689a7e52 100644 --- a/src/runtime_src/core/common/runner/runner.cpp +++ b/src/runtime_src/core/common/runner/runner.cpp @@ -16,12 +16,12 @@ #include "core/include/xrt/xrt_device.h" #include "core/include/xrt/xrt_hw_context.h" #include "core/include/xrt/xrt_kernel.h" -#include "core/include/experimental/xrt_elf.h" -#include "core/include/experimental/xrt_ext.h" -#include "core/include/experimental/xrt_kernel.h" -#include "core/include/experimental/xrt_module.h" -#include "core/include/experimental/xrt_queue.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_elf.h" +#include "core/include/xrt/experimental/xrt_ext.h" +#include "core/include/xrt/experimental/xrt_kernel.h" +#include "core/include/xrt/experimental/xrt_module.h" +#include "core/include/xrt/experimental/xrt_queue.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #ifdef _WIN32 # pragma warning (push) diff --git a/src/runtime_src/core/common/scheduler.cpp b/src/runtime_src/core/common/scheduler.cpp index 3283f6a590c..799467bf4fb 100644 --- a/src/runtime_src/core/common/scheduler.cpp +++ b/src/runtime_src/core/common/scheduler.cpp @@ -20,8 +20,8 @@ #include "config_reader.h" #include "xclbin_parser.h" #include "message.h" -#include "ert.h" -#include "types.h" +#include "core/include/types.h" +#include "core/include/xrt/detail/ert.h" #include #include diff --git a/src/runtime_src/core/common/scheduler.h b/src/runtime_src/core/common/scheduler.h index cf31643ce9a..2542de95e75 100644 --- a/src/runtime_src/core/common/scheduler.h +++ b/src/runtime_src/core/common/scheduler.h @@ -18,7 +18,7 @@ #define core_common_scheduler_h_ #include "core/include/xrt.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" // This is interim, must be consolidated with runtime_src/xrt/scheduler // when XRT C++ code is refactored. diff --git a/src/runtime_src/core/common/shim/fence_handle.h b/src/runtime_src/core/common/shim/fence_handle.h index 13c4fc7eefc..1d91255dca9 100644 --- a/src/runtime_src/core/common/shim/fence_handle.h +++ b/src/runtime_src/core/common/shim/fence_handle.h @@ -3,11 +3,11 @@ #ifndef XRT_CORE_FENCE_HANDLE_H #define XRT_CORE_FENCE_HANDLE_H +#include "xrt/experimental/xrt_fence.h" + #include "core/common/shim/shared_handle.h" #include "core/common/error.h" -#include "experimental/xrt_fence.h" - #include #include diff --git a/src/runtime_src/core/common/uuid.h b/src/runtime_src/core/common/uuid.h index c9bc256d7ad..edb51d29856 100644 --- a/src/runtime_src/core/common/uuid.h +++ b/src/runtime_src/core/common/uuid.h @@ -17,7 +17,7 @@ #ifndef xrt_core_uuid_h_ #define xrt_core_uuid_h_ -#include "core/include/experimental/xrt_uuid.h" +#include "xrt/xrt_uuid.h" namespace xrt_core { diff --git a/src/runtime_src/core/common/xclbin_parser.h b/src/runtime_src/core/common/xclbin_parser.h index c9ac18826c0..78e6d083844 100644 --- a/src/runtime_src/core/common/xclbin_parser.h +++ b/src/runtime_src/core/common/xclbin_parser.h @@ -18,7 +18,7 @@ #include "config.h" #include "cuidx_type.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/include/xrt/xrt_uuid.h" #include diff --git a/src/runtime_src/core/common/xclbin_swemu.h b/src/runtime_src/core/common/xclbin_swemu.h index 8822506ba1f..24ce05e7830 100644 --- a/src/runtime_src/core/common/xclbin_swemu.h +++ b/src/runtime_src/core/common/xclbin_swemu.h @@ -14,7 +14,7 @@ * under the License. */ #include "core/common/device.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include diff --git a/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/halapi.cxx b/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/halapi.cxx index b6940165a0b..f755c3777ad 100755 --- a/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/halapi.cxx +++ b/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/halapi.cxx @@ -6,6 +6,7 @@ #include "core/common/system.h" #include "core/common/device.h" #include "core/include/xdp/app_debug.h" +#include "core/include/deprecated/xcl_app_debug.h" #include "xcl_graph.h" namespace { diff --git a/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/shim.h b/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/shim.h index a42dc9eba8f..454372e5a03 100755 --- a/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/shim.h +++ b/src/runtime_src/core/edge/sw_emu/generic_pcie_hal2/shim.h @@ -21,7 +21,7 @@ #include "core/common/shim/buffer_handle.h" #include "core/common/shim/hwctx_handle.h" #include "core/common/shim/shared_handle.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/include/xdp/common.h" #include "core/include/xdp/counters.h" #include "core/include/xdp/trace.h" diff --git a/src/runtime_src/core/edge/user/hwctx_object.cpp b/src/runtime_src/core/edge/user/hwctx_object.cpp index a0baac45262..c3bf2ac2783 100644 --- a/src/runtime_src/core/edge/user/hwctx_object.cpp +++ b/src/runtime_src/core/edge/user/hwctx_object.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. #include "hwctx_object.h" +#include "core/edge/common/aie_parser.h" #include "core/edge/user/aie/profile_object.h" #ifdef XRT_ENABLE_AIE #include "core/edge/user/aie/graph_object.h" @@ -17,11 +18,11 @@ namespace zynqaie { // hwctx_object:: hwctx_object(ZYNQ::shim* shim, slot_id slot_idx, xrt::uuid uuid, xrt::hw_context::access_mode mode) - : m_shim(shim) - , m_uuid(std::move(uuid)) - , m_slot_idx(slot_idx) - , m_mode(mode) - , m_info(xrt_core::edge::aie::get_partition_info(xrt_core::get_userpf_device(m_shim).get(), m_uuid)) + : m_shim(shim) + , m_uuid(std::move(uuid)) + , m_slot_idx(slot_idx) + , m_mode(mode) + , m_info(xrt_core::edge::aie::get_partition_info(xrt_core::get_userpf_device(m_shim).get(), m_uuid)) {} #ifdef XRT_ENABLE_AIE @@ -130,6 +131,7 @@ hwctx_object::open_aie_buffer_handle(const char* name) void hwctx_object::reset_array() const { +#ifdef XRT_ENABLE_AIE if (!m_aie_array) throw xrt_core::error(-EINVAL, "No AIE present in hw_context to reset"); @@ -138,6 +140,9 @@ hwctx_object::reset_array() const m_aie_array->open_context(device.get(), xrt::aie::access_mode::primary); m_aie_array->reset(device.get(), m_slot_idx, m_info.partition_id); +#else + throw xrt_core::error(std::errc::not_supported, __func__); +#endif } } diff --git a/src/runtime_src/core/edge/user/shim.cpp b/src/runtime_src/core/edge/user/shim.cpp index 5e4e525ff0b..6e749d224fe 100644 --- a/src/runtime_src/core/edge/user/shim.cpp +++ b/src/runtime_src/core/edge/user/shim.cpp @@ -12,6 +12,7 @@ #include "core/include/xdp/lapc.h" #include "core/include/xdp/spc.h" #include "core/include/xrt/xrt_uuid.h" +#include "core/include/deprecated/xcl_app_debug.h" #include "core/edge/common/aie_parser.h" @@ -738,7 +739,7 @@ xclLoadAxlf(const axlf *buffer) .za_dtbo_path = const_cast(dtbo_path.c_str()), .za_dtbo_path_len = static_cast(dtbo_path.length()), .hw_gen = hw_gen, - .partition_id = partition_id, + .partition_id = static_cast(partition_id), }; axlf_obj.kds_cfg.polling = xrt_core::config::get_ert_polling(); diff --git a/src/runtime_src/core/include/CMakeLists.txt b/src/runtime_src/core/include/CMakeLists.txt index fb2e51e20a3..5cc5e23438f 100644 --- a/src/runtime_src/core/include/CMakeLists.txt +++ b/src/runtime_src/core/include/CMakeLists.txt @@ -1,35 +1,32 @@ # SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. -set(XRT_HEADER_SRC +# These headers must be installed to legacy include dir for legacy xrt +# package as well as under xrt/ for base package and also xrt legacy +# The includes simply refer into include/xrt +set(XRT_CORE_HEADER_SRC ert.h - xstream.h - types.h - xcl_axi_checker_codes.h + xrt.h xclbin.h xclerr.h - xclfeatures.h - xclhal2.h - xrt.h - xcl_app_debug.h - xcl_macros.h - xcl_app_debug.h - xclperf.h - xclhal2_mem.h - xrt_mem.h xrt_error_code.h + xrt_mem.h + + # unknown where used xgq_cmd_common.h xgq_cmd_ert.h xgq_impl.h xgq_resp_parser.h) -install (FILES ${XRT_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR} COMPONENT ${XRT_DEV_COMPONENT}) -add_subdirectory(xrt) +# Legacy deprecated install +install (FILES ${XRT_CORE_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR} + COMPONENT ${XRT_DEV_COMPONENT}) + +# Legacy experimental add_subdirectory(experimental) -add_subdirectory(deprecated) -if(WIN32) -add_subdirectory(windows) -endif() -add_subdirectory(unittests) + +# Exported includes +add_subdirectory(xrt) + diff --git a/src/runtime_src/core/include/deprecated/CMakeLists.txt b/src/runtime_src/core/include/deprecated/CMakeLists.txt deleted file mode 100644 index 6899402cd06..00000000000 --- a/src/runtime_src/core/include/deprecated/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved -# -set(XRT_DEPRECATED_HEADER_SRC - xrt.h - xcl_app_debug.h - xcl_axi_checker_codes.h - xclperf.h) - -install (FILES ${XRT_DEPRECATED_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/deprecated COMPONENT ${XRT_DEV_COMPONENT}) - -message("-- XRT deprecated header files") -foreach (header ${XRT_DEPRECATED_HEADER_SRC}) - message("-- ${header}") -endforeach() diff --git a/src/runtime_src/core/include/ert.h b/src/runtime_src/core/include/ert.h index ac5858db474..fa74562313a 100644 --- a/src/runtime_src/core/include/ert.h +++ b/src/runtime_src/core/include/ert.h @@ -1,1176 +1,7 @@ -/* - * Copyright (C) 2019-2022, Xilinx Inc - * - * This file is dual licensed. It may be redistributed and/or modified - * under the terms of the Apache 2.0 License OR version 2 of the GNU - * General Public License. - * - * Apache License Verbiage - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * GPL license Verbiage: - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. You should have received a copy of the - * GNU General Public License along with this program; if not, write - * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. -/** - * DOC: XRT Embedded Runtime definition - * - * Header file *ert.h* defines data structures used by Emebdded Runtime (ERT) and - * XRT xclExecBuf() API. - */ - -#ifndef _ERT_H_ -#define _ERT_H_ - -#if defined(__linux__) && defined(__KERNEL__) -# include -#elif defined(__windows__) && defined(_KERNEL_MODE) -# include -#elif defined(__cplusplus) && !defined(_KERNEL_MODE) -# include -# include -#else -# include -# include -# include -#endif - -#ifdef _WIN32 -# pragma warning( push ) -# pragma warning( disable : 4200 4201 ) -#endif - -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" -#endif - -#define to_cfg_pkg(pkg) \ - ((struct ert_configure_cmd *)(pkg)) -#define to_start_krnl_pkg(pkg) \ - ((struct ert_start_kernel_cmd *)(pkg)) -#define to_copybo_pkg(pkg) \ - ((struct ert_start_copybo_cmd *)(pkg)) -#define to_cfg_sk_pkg(pkg) \ - ((struct ert_configure_sk_cmd *)(pkg)) -#define to_init_krnl_pkg(pkg) \ - ((struct ert_init_kernel_cmd *)(pkg)) -#define to_validate_pkg(pkg) \ - ((struct ert_validate_cmd *)(pkg)) -#define to_abort_pkg(pkg) \ - ((struct ert_abort_cmd *)(pkg)) - - -#define HOST_RW_PATTERN 0xF0F0F0F0 -#define DEVICE_RW_PATTERN 0x0F0F0F0F - -/** - * struct ert_packet: ERT generic packet format - * - * @state: [3-0] current state of a command - * @custom: [11-4] custom per specific commands - * @count: [22-12] number of words in payload (data) - * @opcode: [27-23] opcode identifying specific command - * @type: [31-28] type of command (currently 0) - * @data: count number of words representing packet payload - */ -struct ert_packet { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t custom:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-28] */ - }; - uint32_t header; - }; - uint32_t data[1]; /* count number of words */ -}; - -/** - * struct ert_start_kernel_cmd: ERT start kernel command format - * - * @state: [3-0] current state of a command - * @stat_enabled: [4] enabled driver to record timestamp for various - * states cmd has gone through. The stat data - * is appended after cmd data. - * @extra_cu_masks: [11-10] extra CU masks in addition to mandatory mask - * @count: [22-12] number of words following header for cmd data. Not - * include stat data. - * @opcode: [27-23] 0, opcode for start_kernel - * @type: [31-27] 0, type of start_kernel - * - * @cu_mask: first mandatory CU mask - * @data: count-1 number of words representing interpreted payload - * - * The packet payload is comprised of reserved id field, a mandatory CU mask, - * and extra_cu_masks per header field, followed by a CU register map of size - * (count - (1 + extra_cu_masks)) uint32_t words. - */ -struct ert_start_kernel_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t stat_enabled:1; /* [4] */ - uint32_t unused:5; /* [9-5] */ - uint32_t extra_cu_masks:2; /* [11-10] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - /* payload */ - uint32_t cu_mask; /* mandatory cu mask */ - uint32_t data[1]; /* count-1 number of words */ -}; - -/** - * struct ert_dpu_data - interpretation of data payload for ERT_START_DPU - * - * @instruction_buffer: address of instruction buffer - * @instruction_buffer_size: size of instruction buffer in bytes - * @chained: number of following ert_dpu_data elements - * - * The ert_dpu_data is prepended to data payload of ert_start_kernel_cmd - * after any extra cu masks. The payload count of the ert packet is - * incremented with the size (words) of ert_dpu_data elements - * preprended to the data payload. - * - * The data payload for ERT_START_DPU is interpreted as fixed instruction - * buffer address along with instruction count, followed by regular kernel - * arguments. - */ -struct ert_dpu_data { - uint64_t instruction_buffer; /* buffer address 2 words */ - uint32_t instruction_buffer_size; /* size of buffer in bytes */ - uint32_t chained; /* number of following ert_dpu_data elements */ -}; - -/** - * struct ert_npu_data - interpretation of data payload for ERT_START_NPU - * - * @instruction_buffer: address of instruction buffer - * @instruction_buffer_size: size of instruction buffer in bytes - * @instruction_prop_count: WORD length of property name value pairs - * - * The ert_npu_data is prepended to data payload of ert_start_kernel_cmd - * after any extra cu masks. The payload count of the ert packet is - * incremented with the size (words) of ert_npu_data elements - * preprended to the data payload. - * - * The data payload for ERT_START_NPU is interpreted as instruction - * buffer address, instruction count along with instruction property, - * followed by regular kernel arguments. - * - * When instruction_prop_count is non-zero, it indicates the length - * (in 32 bits WORD) of the instruction buffer properties after this - * fields. This count is reserved for future extension. One example - * propertiy is the number of actual columns this instruction used. - */ -struct ert_npu_data { - uint64_t instruction_buffer; /* buffer address 2 words */ - uint32_t instruction_buffer_size; /* size of buffer in bytes */ - uint32_t instruction_prop_count; /* WORD length of following properties nv pairs */ -}; - -/** - * struct ert_npu_preempt_data - interpretation of data payload for ERT_START_NPU_PREEMPT - * - * @instruction_buffer: address of instruction buffer - * @save_buffer: address of save instruction buffer - * @restore_buffer: address of restrore instruction buffer - * @instruction_buffer_size: size of instruction buffer in bytes - * @save_buffer_size: size of save instruction buffer in bytes - * @restore_buffer_size: size of restore instruction buffer in bytes - * @instruction_prop_count: number of property name value pairs - * - * The ert_npu_preempt_data is prepended to data payload of ert_start_kernel_cmd - * after any extra cu masks. The payload count of the ert packet is - * incremented with the size (words) of ert_npu_preempt_data elements - * preprended to the data payload. - * - * The data payload for ERT_START_NPU_PREEMPT is interpreted as instruction - * buffer, save instruction buffer, restore instruction buffer and their - * size, along with instruction property, followed by regular kernel arguments. - * - * When instruction_prop_count is non-zero, it indicates the length - * (in 32 bits WORD) of the instruction buffer properties after this - * fields. This count is reserved for future extension. One example - * propertiy is the number of actual columns this instruction used. - */ -struct ert_npu_preempt_data { - uint64_t instruction_buffer; /* buffer address 2 words */ - uint64_t save_buffer; /* buffer address 2 words */ - uint64_t restore_buffer; /* buffer address 2 words */ - uint32_t instruction_buffer_size; /* size of buffer in bytes */ - uint32_t save_buffer_size; /* size of buffer in bytes */ - uint32_t restore_buffer_size; /* size of buffer in bytes */ - uint32_t instruction_prop_count; /* DWORD length of following properties nv pairs */ -}; - -/** - * struct ert_cmd_chain_data - interpretation of data payload for ERT_CMD_CHAIN - * - * @command_count: number of commands in chain - * @submit_index: index of last successfully submitted command in chain - * @error_index: index of failing command if cmd status is not completed - * @data[]: address of each command in chain - * - * This is the payload of an *ert_packet* when the opcode is ERT_CMD_CHAIN - */ -struct ert_cmd_chain_data { - uint32_t command_count; - uint32_t submit_index; - uint32_t error_index; - uint32_t reserved[3]; - uint64_t data[]; -}; - -#ifndef U30_DEBUG -#define ert_write_return_code(cmd, value) \ -do { \ - struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ - int end_idx = skcmd->count - 1 - skcmd->extra_cu_masks; \ - skcmd->data[end_idx] = value; \ -} while (0) - -#define ert_read_return_code(cmd, ret) \ -do { \ - struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ - int end_idx = skcmd->count - 1 - skcmd->extra_cu_masks; \ - ret = skcmd->data[end_idx]; \ -} while (0) -#else -/* These are for debug legacy U30 firmware */ -#define ert_write_return_code(cmd, value) \ -do { \ - struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ - skcmd->cu_mask = value; \ -} while (0) - -#define ert_read_return_code(cmd, ret) \ -do { \ - struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ - ret = skcmd->cu_mask; \ -} while (0) -#endif - -/** - * struct ert_init_kernel_cmd: ERT initialize kernel command format - * this command initializes CUs by writing CU registers. CUs are - * represented by cu_mask and extra_cu_masks. - * - * @state: [3-0] current state of a command - * @update_rtp: [4] command is for runtime update of cu argument - * @extra_cu_masks: [11-10] extra CU masks in addition to mandatory mask - * @count: [22-12] number of words following header - * @opcode: [27-23] 0, opcode for init_kernel - * @type: [31-27] 0, type of init_kernel - * - * @cu_run_timeout the configured CU timeout value in Microseconds - * setting to 0 means CU should not timeout - * @cu_reset_timeout the configured CU reset timeout value in Microseconds - * when CU timeout, CU will be reset. this indicates - * CU reset should be completed within the timeout value. - * if cu_run_timeout is set to 0, this field is undefined. - * - * @cu_mask: first mandatory CU mask - * @data: count-9 number of words representing interpreted payload - * - * The packet payload is comprised of reserved id field, 8 reserved fields, - * a mandatory CU mask, and extra_cu_masks per header field, followed by a - * CU register map of size (count - (9 + extra_cu_masks)) uint32_t words. - */ -struct ert_init_kernel_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t update_rtp:1; /* [4] */ - uint32_t unused:5; /* [9-5] */ - uint32_t extra_cu_masks:2; /* [11-10] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - uint32_t cu_run_timeout; /* CU timeout value in Microseconds */ - uint32_t cu_reset_timeout; /* CU reset timeout value in Microseconds */ - uint32_t reserved[6]; /* reserved for future use */ - - /* payload */ - uint32_t cu_mask; /* mandatory cu mask */ - uint32_t data[1]; /* count-9 number of words */ -}; - -#define KDMA_BLOCK_SIZE 64 /* Limited by KDMA CU */ -struct ert_start_copybo_cmd { - uint32_t state:4; /* [3-0], must be ERT_CMD_STATE_NEW */ - uint32_t unused:6; /* [9-4] */ - uint32_t extra_cu_masks:2; /* [11-10], = 3 */ - uint32_t count:11; /* [22-12], = 16, exclude 'arg' */ - uint32_t opcode:5; /* [27-23], = ERT_START_COPYBO */ - uint32_t type:4; /* [31-27], = ERT_DEFAULT */ - uint32_t cu_mask[4]; /* mandatory cu masks */ - uint32_t reserved[4]; /* for scheduler use */ - uint32_t src_addr_lo; /* low 32 bit of src addr */ - uint32_t src_addr_hi; /* high 32 bit of src addr */ - uint32_t src_bo_hdl; /* src bo handle, cleared by driver */ - uint32_t dst_addr_lo; /* low 32 bit of dst addr */ - uint32_t dst_addr_hi; /* high 32 bit of dst addr */ - uint32_t dst_bo_hdl; /* dst bo handle, cleared by driver */ - uint32_t size; /* size in bytes low 32 bit*/ - uint32_t size_hi; /* size in bytes high 32 bit*/ - void *arg; /* pointer to aux data for KDS */ -}; - -/** - * struct ert_configure_cmd: ERT configure command format - * - * @state: [3-0] current state of a command - * @count: [22-12] number of words in payload (5 + num_cus) - * @opcode: [27-23] 1, opcode for configure - * @type: [31-27] 0, type of configure - * - * @slot_size: command queue slot size - * @num_cus: number of compute units in program - * @cu_shift: shift value to convert CU idx to CU addr - * @cu_base_addr: base address to add to CU addr for actual physical address - * - * @ert:1 enable embedded HW scheduler - * @polling:1 poll for command completion - * @cu_dma:1 enable CUDMA custom module for HW scheduler - * @cu_isr:1 enable CUISR custom module for HW scheduler - * @cq_int:1 enable interrupt from host to HW scheduler - * @cdma:1 enable CDMA kernel - * @unused:25 - * @dsa52:1 reserved for internal use - * - * @data: addresses of @num_cus CUs - */ -struct ert_configure_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t unused:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - /* payload */ - uint32_t slot_size; - uint32_t num_cus; - uint32_t cu_shift; - uint32_t cu_base_addr; - - /* features */ - uint32_t ert:1; - uint32_t polling:1; - uint32_t cu_dma:1; - uint32_t cu_isr:1; - uint32_t cq_int:1; - uint32_t cdma:1; - uint32_t dataflow:1; - /* WORKAROUND: allow xclRegWrite/xclRegRead access shared CU */ - uint32_t rw_shared:1; - uint32_t kds_30:1; - uint32_t dmsg:1; - uint32_t echo:1; - uint32_t intr:1; - uint32_t unusedf:19; - uint32_t dsa52:1; - - /* cu address map size is num_cus */ - uint32_t data[1]; -}; - -/* - * Note: We need to put maximum 128 soft kernel image - * in one config command (1024 DWs including header). - * So each one needs to be smaller than 8 DWs. - * - * This data struct is obsoleted. Only used in legacy ERT firmware. - * Use 'struct config_sk_image_uuid' instead on XGQ based ERT. - * - * @start_cuidx: start index of compute units of each image - * @num_cus: number of compute units of each image - * @sk_name: symbol name of soft kernel of each image - */ -struct config_sk_image { - uint32_t start_cuidx; - uint32_t num_cus; - uint32_t sk_name[5]; -}; - -/* - * Note: We need to put maximum 128 soft kernel image - * in one config command (1024 DWs including header). - * So each one needs to be smaller than 8 DWs. - * - * @start_cuidx: start index of compute units of each image - * @num_cus: number of compute units of each image - * @sk_name: symbol name of soft kernel of each image - * @sk_uuid: xclbin uuid that this soft kernel image belones to - */ -struct config_sk_image_uuid { - uint32_t start_cuidx; - uint32_t num_cus; - uint32_t sk_name[5]; - unsigned char sk_uuid[16]; - uint32_t slot_id; -}; - -/** - * struct ert_configure_sk_cmd: ERT configure soft kernel command format - * - * @state: [3-0] current state of a command - * @count: [22-12] number of words in payload - * @opcode: [27-23] 1, opcode for configure - * @type: [31-27] 0, type of configure - * - * @num_image: number of images -*/ -struct ert_configure_sk_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t unused:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - /* payload */ - uint32_t num_image; - struct config_sk_image image[1]; -}; - -/** - * struct ert_unconfigure_sk_cmd: ERT unconfigure soft kernel command format - * - * @state: [3-0] current state of a command - * @count: [22-12] number of words in payload - * @opcode: [27-23] 1, opcode for configure - * @type: [31-27] 0, type of configure - * - * @start_cuidx: start index of compute units - * @num_cus: number of compute units in program - */ -struct ert_unconfigure_sk_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t unused:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - /* payload */ - uint32_t start_cuidx; - uint32_t num_cus; -}; - -/** - * struct ert_abort_cmd: ERT abort command format. - * - * @exec_bo_handle: The bo handle of execbuf command to abort - */ -struct ert_abort_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t custom:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - - /* payload */ - uint64_t exec_bo_handle; -}; - -/** - * struct ert_validate_cmd: ERT BIST command format. - * - */ -struct ert_validate_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t custom:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - uint32_t timestamp; - uint32_t cq_read_single; - uint32_t cq_write_single; - uint32_t cu_read_single; - uint32_t cu_write_single; -}; - -/** - * struct ert_validate_cmd: ERT BIST command format. - * - */ -struct ert_access_valid_cmd { - union { - struct { - uint32_t state:4; /* [3-0] */ - uint32_t custom:8; /* [11-4] */ - uint32_t count:11; /* [22-12] */ - uint32_t opcode:5; /* [27-23] */ - uint32_t type:4; /* [31-27] */ - }; - uint32_t header; - }; - uint32_t h2h_access; - uint32_t h2d_access; - uint32_t d2h_access; - uint32_t d2d_access; - uint32_t d2cu_access; - uint32_t wr_count; - uint32_t wr_test; -}; - -/** - * ERT command state - * - * @ERT_CMD_STATE_NEW: Set by host before submitting a command to - * scheduler - * @ERT_CMD_STATE_QUEUED: Internal scheduler state - * @ERT_CMD_STATE_SUBMITTED: Internal scheduler state - * @ERT_CMD_STATE_RUNNING: Internal scheduler state - * @ERT_CMD_STATE_COMPLETED: Set by scheduler when command completes - * @ERT_CMD_STATE_ERROR: Set by scheduler if command failed - * @ERT_CMD_STATE_ABORT: Set by scheduler if command abort - * @ERT_CMD_STATE_TIMEOUT: Set by scheduler if command timeout and reset - * @ERT_CMD_STATE_NORESPONSE: Set by scheduler if command timeout and fail to - * reset - */ -enum ert_cmd_state { - ERT_CMD_STATE_NEW = 1, - ERT_CMD_STATE_QUEUED = 2, - ERT_CMD_STATE_RUNNING = 3, - ERT_CMD_STATE_COMPLETED = 4, - ERT_CMD_STATE_ERROR = 5, - ERT_CMD_STATE_ABORT = 6, - ERT_CMD_STATE_SUBMITTED = 7, - ERT_CMD_STATE_TIMEOUT = 8, - ERT_CMD_STATE_NORESPONSE = 9, - ERT_CMD_STATE_SKERROR = 10, //Check for error return code from Soft Kernel - ERT_CMD_STATE_SKCRASHED = 11, //Soft kernel has crashed - ERT_CMD_STATE_MAX, // Always the last one -}; - -struct cu_cmd_state_timestamps { - uint64_t skc_timestamps[ERT_CMD_STATE_MAX]; // In nano-second -}; - -/** - * Opcode types for commands - * - * @ERT_START_CU: start a workgroup on a CU - * @ERT_START_KERNEL: currently aliased to ERT_START_CU - * @ERT_CONFIGURE: configure command scheduler - * @ERT_EXEC_WRITE: execute a specified CU after writing - * @ERT_CU_STAT: get stats about CU execution - * @ERT_START_COPYBO: start KDMA CU or P2P, may be converted to ERT_START_CU - * before cmd reach to scheduler, short-term hack - * @ERT_SK_CONFIG: configure soft kernel - * @ERT_SK_START: start a soft kernel - * @ERT_SK_UNCONFIG: unconfigure a soft kernel - * @ERT_START_KEY_VAL: same as ERT_START_CU but with key-value pair flavor - * @ERT_START_DPU: instruction buffer command format - * @ERT_CMD_CHAIN: command chain - * @ERT_START_NPU: instruction buffer command format on NPU format - * @ERT_START_NPU_PREEMPT: instruction buffer command with preemption format on NPU - */ -enum ert_cmd_opcode { - ERT_START_CU = 0, - ERT_START_KERNEL = 0, - ERT_CONFIGURE = 2, - ERT_EXIT = 3, - ERT_ABORT = 4, - ERT_EXEC_WRITE = 5, - ERT_CU_STAT = 6, - ERT_START_COPYBO = 7, - ERT_SK_CONFIG = 8, - ERT_SK_START = 9, - ERT_SK_UNCONFIG = 10, - ERT_INIT_CU = 11, - ERT_START_FA = 12, - ERT_CLK_CALIB = 13, - ERT_MB_VALIDATE = 14, - ERT_START_KEY_VAL = 15, - ERT_ACCESS_TEST_C = 16, - ERT_ACCESS_TEST = 17, - ERT_START_DPU = 18, - ERT_CMD_CHAIN = 19, - ERT_START_NPU = 20, - ERT_START_NPU_PREEMPT = 21, -}; - -/** - * Command types - * - * @ERT_DEFAULT: default command type - * @ERT_KDS_LOCAL: command processed by KDS locally - * @ERT_CTRL: control command uses reserved command queue slot - * @ERT_CU: compute unit command - */ -enum ert_cmd_type { - ERT_DEFAULT = 0, - ERT_KDS_LOCAL = 1, - ERT_CTRL = 2, - ERT_CU = 3, - ERT_SCU = 4, -}; - -/** - * Soft kernel types - * - * @SOFTKERNEL_TYPE_EXEC: executable - */ -enum softkernel_type { - SOFTKERNEL_TYPE_EXEC = 0, -}; - -/* - * Base address GPIO per spec - * | Offset | Description - * ----------------------- - * | 0x00 | ERT_MGMT_PF_base_addr (Not sure where this should be use) - * | 0x08 | ERT_USER_PF_base_addr. The base address of ERT peripherals - */ -#if defined(ERT_BUILD_V20) -uint32_t ert_base_addr = 0; -# define ERT_BASE_ADDR 0x01F30008 -#endif - -#if defined(ERT_BUILD_V30) -uint32_t ert_base_addr = 0; -# define ERT_BASE_ADDR 0x01F30008 -#endif - -/** - * Address constants per spec - */ -#define ERT_WORD_SIZE 4 /* 4 bytes */ -#define ERT_CQ_SIZE 0x10000 /* 64K */ -#if defined(ERT_BUILD_U50) -# define ERT_CQ_BASE_ADDR 0x340000 -# define ERT_CSR_ADDR 0x360000 -#elif defined(ERT_BUILD_V20) -# define ERT_CQ_BASE_ADDR (0x000000 + ert_base_addr) -# define ERT_CSR_ADDR (0x010000 + ert_base_addr) -#elif defined(ERT_BUILD_V30) -# define ERT_CQ_BASE_ADDR 0x1F60000 -# define ERT_CSR_ADDR (0x010000 + ert_base_addr) -#else -# define ERT_CQ_BASE_ADDR 0x190000 -# define ERT_CSR_ADDR 0x180000 -#endif - -/** - * The STATUS REGISTER is for communicating completed CQ slot indices - * MicroBlaze write, host reads. MB(W) / HOST(COR) - */ -#define ERT_STATUS_REGISTER_ADDR (ERT_CSR_ADDR) -#define ERT_STATUS_REGISTER_ADDR0 (ERT_CSR_ADDR) -#define ERT_STATUS_REGISTER_ADDR1 (ERT_CSR_ADDR + 0x4) -#define ERT_STATUS_REGISTER_ADDR2 (ERT_CSR_ADDR + 0x8) -#define ERT_STATUS_REGISTER_ADDR3 (ERT_CSR_ADDR + 0xC) - -/** - * The CU DMA REGISTER is for communicating which CQ slot is to be started - * on a specific CU. MB selects a free CU on which the command can - * run, then writes the 1<state = ERT_CMD_STATE_NEW; - pkt->extra_cu_masks = 3; - pkt->count = 16; - pkt->opcode = ERT_START_COPYBO; - pkt->type = ERT_DEFAULT; - pkt->cu_mask[0] = 0; - pkt->cu_mask[1] = 0; - pkt->cu_mask[2] = 0; - pkt->cu_mask[3] = 0; - pkt->src_addr_lo = (uint32_t)src_offset; - pkt->src_addr_hi = (src_offset >> 32) & 0xFFFFFFFF; - pkt->src_bo_hdl = src_bo; - pkt->dst_addr_lo = (uint32_t)dst_offset; - pkt->dst_addr_hi = (dst_offset >> 32) & 0xFFFFFFFF; - pkt->dst_bo_hdl = dst_bo; - pkt->size = size; - pkt->size_hi = 0; /* set to 0 explicitly */ - pkt->arg = 0; -} -static inline uint64_t -ert_copybo_src_offset(struct ert_start_copybo_cmd *pkt) -{ - return (uint64_t)pkt->src_addr_hi << 32 | pkt->src_addr_lo; -} -static inline uint64_t -ert_copybo_dst_offset(struct ert_start_copybo_cmd *pkt) -{ - return (uint64_t)pkt->dst_addr_hi << 32 | pkt->dst_addr_lo; -} -static inline uint64_t -ert_copybo_size(struct ert_start_copybo_cmd *pkt) -{ - return pkt->size; -} - -static inline bool -ert_valid_opcode(struct ert_packet *pkt) -{ - struct ert_start_kernel_cmd *skcmd; - struct ert_init_kernel_cmd *ikcmd; - struct ert_start_copybo_cmd *sccmd; - struct ert_configure_cmd *ccmd; - struct ert_configure_sk_cmd *cscmd; - struct ert_cmd_chain_data *ccdata; - bool valid; - - switch (pkt->opcode) { - case ERT_START_CU: - skcmd = to_start_krnl_pkg(pkt); - /* 1 cu mask + 4 registers */ - valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 4); - break; - case ERT_START_DPU: - skcmd = to_start_krnl_pkg(pkt); - /* 1 mandatory cumask + extra_cu_masks + size (in words) of ert_dpu_data */ - valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_dpu_data) / sizeof(uint32_t)); - break; - case ERT_CMD_CHAIN: - ccdata = (struct ert_cmd_chain_data*) pkt->data; - /* header count must match number of commands in payload */ - valid = (pkt->count == (ccdata->command_count * sizeof(uint64_t) + sizeof(struct ert_cmd_chain_data)) / sizeof(uint32_t)); - break; - case ERT_START_NPU: - skcmd = to_start_krnl_pkg(pkt); - /* 1 mandatory cumask + extra_cu_masks + ert_npu_data */ - valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_npu_data) / sizeof(uint32_t)); - break; - case ERT_START_NPU_PREEMPT: - skcmd = to_start_krnl_pkg(pkt); - /* 1 mandatory cumask + extra_cu_masks + ert_npu_preempt_data */ - valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_npu_preempt_data) / sizeof(uint32_t)); - break; - case ERT_START_KEY_VAL: - skcmd = to_start_krnl_pkg(pkt); - /* 1 cu mask */ - valid = (skcmd->count >= skcmd->extra_cu_masks + 1); - break; - case ERT_EXEC_WRITE: - skcmd = to_start_krnl_pkg(pkt); - /* 1 cu mask + 6 registers */ - valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 6); - break; - case ERT_START_FA: - skcmd = to_start_krnl_pkg(pkt); - /* 1 cu mask */ - valid = (skcmd->count >= skcmd->extra_cu_masks + 1); - break; - case ERT_SK_START: - skcmd = to_start_krnl_pkg(pkt); - /* 1 cu mask + 1 control word */ - valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 1); - break; - case ERT_CONFIGURE: - ccmd = to_cfg_pkg(pkt); - /* 5 mandatory fields in struct */ - valid = (ccmd->count >= 5 + ccmd->num_cus); - break; - case ERT_START_COPYBO: - sccmd = to_copybo_pkg(pkt); - valid = (sccmd->count == 16); - break; - case ERT_INIT_CU: - ikcmd = to_init_krnl_pkg(pkt); - /* 9 mandatory words in struct + 4 control registers */ - valid = (ikcmd->count >= ikcmd->extra_cu_masks + 9 + 4); - break; - case ERT_SK_CONFIG: - cscmd = to_cfg_sk_pkg(pkt); - valid = (cscmd->count == sizeof(struct config_sk_image) * cscmd->num_image / 4 + 1); - break; - case ERT_CLK_CALIB: - case ERT_MB_VALIDATE: - case ERT_ACCESS_TEST_C: - case ERT_CU_STAT: /* TODO: Rules to validate? */ - case ERT_EXIT: - case ERT_ABORT: - valid = true; - break; - case ERT_SK_UNCONFIG: /* NOTE: obsolete */ - default: - valid = false; - } - - return valid; -} - -static inline uint64_t -get_ert_packet_size_bytes(struct ert_packet *pkt) -{ - // header plus payload - return sizeof(pkt->header) + pkt->count * sizeof(uint32_t); -} - -static inline struct ert_dpu_data* -get_ert_dpu_data(struct ert_start_kernel_cmd* pkt) -{ - if (pkt->opcode != ERT_START_DPU) - return NULL; - - // past extra cu_masks embedded in the packet data - return (struct ert_dpu_data*) (pkt->data + pkt->extra_cu_masks); -} - -static inline struct ert_dpu_data* -get_ert_dpu_data_next(struct ert_dpu_data* dpu_data) -{ - if (dpu_data->chained == 0) - return NULL; - - return dpu_data + 1; -} - -static inline struct ert_cmd_chain_data* -get_ert_cmd_chain_data(struct ert_packet* pkt) -{ - if (pkt->opcode != ERT_CMD_CHAIN) - return NULL; - - return (struct ert_cmd_chain_data*) pkt->data; -} - -static inline struct ert_npu_data* -get_ert_npu_data(struct ert_start_kernel_cmd* pkt) -{ - if (pkt->opcode != ERT_START_NPU) - return NULL; - - // past extra cu_masks embedded in the packet data - return (struct ert_npu_data*) (pkt->data + pkt->extra_cu_masks); -} - -static inline struct ert_npu_preempt_data* -get_ert_npu_preempt_data(struct ert_start_kernel_cmd* pkt) -{ - if (pkt->opcode != ERT_START_NPU_PREEMPT) - return NULL; - - // past extra cu_masks embedded in the packet data - return (struct ert_npu_preempt_data*) (pkt->data + pkt->extra_cu_masks); -} - -static inline uint32_t* -get_ert_regmap_begin(struct ert_start_kernel_cmd* pkt) -{ - switch (pkt->opcode) { - case ERT_START_DPU: - return pkt->data + pkt->extra_cu_masks - + (get_ert_dpu_data(pkt)->chained + 1) * sizeof(struct ert_dpu_data) / sizeof(uint32_t); - - case ERT_START_NPU: - return pkt->data + pkt->extra_cu_masks - + sizeof(struct ert_npu_data) / sizeof(uint32_t) - + get_ert_npu_data(pkt)->instruction_prop_count; - - case ERT_START_NPU_PREEMPT: - return pkt->data + pkt->extra_cu_masks - + sizeof(struct ert_npu_preempt_data) / sizeof(uint32_t) - + get_ert_npu_preempt_data(pkt)->instruction_prop_count; - - default: - // skip past embedded extra cu_masks - return pkt->data + pkt->extra_cu_masks; - } -} - -static inline uint32_t* -get_ert_regmap_end(struct ert_start_kernel_cmd* pkt) -{ - // pkt->count includes the mandatory cumask which precededs data array - return &pkt->cu_mask + pkt->count; -} - -static inline uint64_t -get_ert_regmap_size_bytes(struct ert_start_kernel_cmd* pkt) -{ - return (get_ert_regmap_end(pkt) - get_ert_regmap_begin(pkt)) * sizeof(uint32_t); -} - -#ifdef __linux__ -#define P2ROUNDUP(x, align) (-(-(x) & -(align))) -static inline struct cu_cmd_state_timestamps * -ert_start_kernel_timestamps(struct ert_start_kernel_cmd *pkt) -{ - uint64_t offset = pkt->count * sizeof(uint32_t) + sizeof(pkt->header); - /* Make sure the offset of timestamps are properly aligned. */ - return (struct cu_cmd_state_timestamps *) - ((char *)pkt + P2ROUNDUP(offset, sizeof(uint64_t))); -} - -/* Return 0 if this pkt doesn't support timestamp or disabled */ -static inline int -get_size_with_timestamps_or_zero(struct ert_packet *pkt) -{ - struct ert_start_kernel_cmd *skcmd; - int size = 0; - - switch (pkt->opcode) { - case ERT_START_CU: - case ERT_EXEC_WRITE: - case ERT_START_FA: - case ERT_SK_START: - skcmd = to_start_krnl_pkg(pkt); - if (skcmd->stat_enabled) { - size = (char *)ert_start_kernel_timestamps(skcmd) - (char *)pkt; - size += sizeof(struct cu_cmd_state_timestamps); - } - } - - return size; -} -#endif - -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - -#ifdef _WIN32 -# pragma warning( pop ) -#endif - -#endif +// The content of this file has moved. +// This file is no longer exported and is used internally +// within XRT for legacy reasons +#include "xrt/detail/ert.h" diff --git a/src/runtime_src/core/include/experimental/CMakeLists.txt b/src/runtime_src/core/include/experimental/CMakeLists.txt index d7d75ce648a..8560f27b1f7 100644 --- a/src/runtime_src/core/include/experimental/CMakeLists.txt +++ b/src/runtime_src/core/include/experimental/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. set(XRT_EXPERIMENTAL_HEADER_SRC xrt-next.h xrt_aie.h @@ -28,4 +28,7 @@ set(XRT_EXPERIMENTAL_HEADER_SRC xclbin_util.h xclbin-util.h) -install (FILES ${XRT_EXPERIMENTAL_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/experimental COMPONENT ${XRT_DEV_COMPONENT}) +# Legacy deprecated install +install (FILES ${XRT_EXPERIMENTAL_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/experimental + COMPONENT ${XRT_DEV_COMPONENT}) diff --git a/src/runtime_src/core/include/experimental/template.txt b/src/runtime_src/core/include/experimental/template.txt new file mode 100644 index 00000000000..dd16e02ca1e --- /dev/null +++ b/src/runtime_src/core/include/experimental/template.txt @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#include "xrt/experimental/zzz.h" diff --git a/src/runtime_src/core/include/experimental/xclbin-util.h b/src/runtime_src/core/include/experimental/xclbin-util.h index de915dc72e4..4476a8aba16 100644 --- a/src/runtime_src/core/include/experimental/xclbin-util.h +++ b/src/runtime_src/core/include/experimental/xclbin-util.h @@ -1,23 +1,4 @@ -/** - * Copyright (C) 2020 Xilinx, Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -#ifndef xclbin_util_h_deprecated -#define xclbin_util_h_deprecated - -#include "xclbin_util.h" - -#pragma message("xclbin-util.h is deprecated, please use xclbin_util.h") - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xclbin-util.h with xrt/experimental/xclbin_util.h") +#include "xrt/experimental/xclbin_util.h" diff --git a/src/runtime_src/core/include/experimental/xclbin_util.h b/src/runtime_src/core/include/experimental/xclbin_util.h index bba82bae58d..76e5810a60f 100644 --- a/src/runtime_src/core/include/experimental/xclbin_util.h +++ b/src/runtime_src/core/include/experimental/xclbin_util.h @@ -1,47 +1,4 @@ -/** - * Copyright (C) 2020 Xilinx, Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -/** - * This file contains publically exported xclbin utilities. - */ - -#ifndef xclbin_util_h_ -#define xclbin_util_h_ - -#include "xclbin.h" - -static inline const axlf* -xclbin_axlf_handle(const void *xclbin) -{ - const axlf* top = (const axlf*) xclbin; - return (strncmp(top->m_magic,"xclbin2",7)) ? NULL : top; -} - -/** - * xclbin_uuid() - Get the uuid of an xclbin - * - * @xclbin: Raw pointer the enture xclbin file content - * @out: A uuid to populate with the xclbin uuid - * Return: 0 on success, errcode otherwise - */ -static inline int -xclbin_uuid(const void *xclbin, xuid_t out) -{ - const axlf* top = xclbin_axlf_handle(xclbin); - return (top) ? uuid_copy(out, top->m_header.uuid) , 0 : -EINVAL; -} - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xclbin_util.h with xrt/experimental/xclbin_util.h") +#include "xrt/experimental/xclbin_util.h" diff --git a/src/runtime_src/core/include/experimental/xrt-next.h b/src/runtime_src/core/include/experimental/xrt-next.h index 6b0e5c5d094..d068b4b65fe 100644 --- a/src/runtime_src/core/include/experimental/xrt-next.h +++ b/src/runtime_src/core/include/experimental/xrt-next.h @@ -1,307 +1,4 @@ -/* - * Copyright (C) 2019-2020, Xilinx Inc - All rights reserved - * Xilinx Runtime (XRT) Experimental APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#ifndef _XRT_NEXT_APIS_H_ -#define _XRT_NEXT_APIS_H_ - -#include "../xrt.h" - -/* - * typedef xclInterruptNotifyHandle - * - * Implementation specific type representing an interrupt notify handle - * that is used by xclOpen/CloseIPInterruptNotify() - */ -#ifdef _WIN32 -typedef void* xclInterruptNotifyHandle; -# define XCL_NULL_INTC_HANDLE INVALID_HANDLE_VALUE -#else -typedef int xclInterruptNotifyHandle; -# define XCL_NULL_INTC_HANDLE -1 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Place holder for experimental APIs - */ - -/** - * xclP2pEnable() - enable or disable p2p - * - * @handle: Device handle - * @enable: false-disable, true-enable - * @force: true-force to reassign bus IO memory - * Return: 0 on success or appropriate error number - * - * Enable or Disable P2P feature. Warm reboot might be required. - */ -XCL_DRIVER_DLLESPEC -int -xclP2pEnable(xclDeviceHandle handle, bool enable, bool force); - -/* - * API to get number of live processes on the given device. - * This uses kdsstat information in sysfs. - */ -XCL_DRIVER_DLLESPEC -uint32_t -xclGetNumLiveProcesses(xclDeviceHandle handle); - -/** - * xclGetSysfsPath() - Helper function to build a sysfs node full path - * - * @handle: Device handle - * @subdev: Sub-device name - * @entry: Name of sysfs node - * @sysfsPath: Return string with full path for sysfs node - * @size: Length of the return string - * Return: 0 or standard error number - * - * (For debug and profile usage only for now) The sysfs information is - * not accessible above XRT layer now. However, debug/profile needs - * information from sysfs (for example debug_ip_layout) to properly - * initialize xdp code, so this helper API can be used - */ -XCL_DRIVER_DLLESPEC -int -xclGetSysfsPath(xclDeviceHandle handle, const char* subdev, - const char* entry, char* sysfsPath, size_t size); - -struct KernelTransferData -{ - char* cuPortName; - char* argName; - char* memoryName; - - uint64_t totalReadBytes; - uint64_t totalReadTranx; - uint64_t totalReadLatency; - uint64_t totalReadBusyCycles; - uint64_t minReadLatency; - uint64_t maxReadLatency; - - uint64_t totalWriteBytes; - uint64_t totalWriteTranx; - uint64_t totalWriteLatency; - uint64_t totalWriteBusyCycles; - uint64_t minWriteLatency; - uint64_t maxWriteLatency; -}; - -struct CuExecData -{ - char* cuName; - char* kernelName; - - uint64_t cuExecCount; - uint64_t cuExecCycles; - uint64_t cuBusyCycles; - uint64_t cuMaxExecCycles; - uint64_t cuMinExecCycles; - uint64_t cuMaxParallelIter; - uint64_t cuStallExtCycles; - uint64_t cuStallIntCycles; - uint64_t cuStallStrCycles; - -}; - -struct StreamTransferData -{ - char* masterPortName; - char* slavePortName; - - uint64_t strmNumTranx; - uint64_t strmBusyCycles; - uint64_t strmDataBytes; - uint64_t strmStallCycles; - uint64_t strmStarveCycles; -}; - -struct ProfileResults -{ - char* deviceName; - - uint64_t numAIM; - struct KernelTransferData *kernelTransferData; - - uint64_t numAM; - struct CuExecData *cuExecData; - - uint64_t numASM; - struct StreamTransferData *streamData; -}; - -/** - * int xclCreateProfileResults(xclDeviceHandle, ProfileResults**) - * - * - Creates and initializes buffer for storing the ProfileResults from - * the device. - * - To use this API, "profile_api" configuration needs to be set to - * "true" in xrt.ini. "profile_api=true" enables profiling (for - * profile counters on device) using XRT APIs (no OpenCL API) - * - * @xclDeviceHandle : Device handle - * @ProfileResults : Double pointer to hold the pointer to buffer created - * to store profiling results (on success). This argument - * remains unchanged if xclCreateProfileResults fails. - */ -XCL_DRIVER_DLLESPEC -int -xclCreateProfileResults(xclDeviceHandle, struct ProfileResults**); - -/** - * int xclGetProfileResults(xclDeviceHandle, ProfileResults*) - * - * - Read the profiling counters from the hardware and populate - * profiling data in the “ProfileResults” structure (created using - * xclCreateProfileResults). - * - To use this API, "profile_api" configuration needs to be set to - * "true" in xrt.ini. "profile_api=true" enables profiling (for - * profile counters on device) using XRT APIs (no OpenCL API) - * - * @xclDeviceHandle : Device handle - * @ProfileResults* : Pointer to buffer to store profiling results. - * This buffer should be created using previous - * call to "xclCreateProfileResults" - */ -XCL_DRIVER_DLLESPEC -int -xclGetProfileResults(xclDeviceHandle, struct ProfileResults*); - -/** - * int xclDestroyProfileResults(xclDeviceHandle, ProfileResults*) - * - * - Traverse the given ProfileResults structure and delete the - * allocated memory - * - To use this API, "profile_api" configuration needs to be set to - * "true" in xrt.ini. "profile_api=true" enables profiling (for - * profile counters on device) using XRT APIs (no OpenCL API) - * - * @xclDeviceHandle : Device handle - * @ProfileResults : Pointer to buffer to be deleted - */ -XCL_DRIVER_DLLESPEC -int -xclDestroyProfileResults(xclDeviceHandle, struct ProfileResults*); - -/** - * xclRegRead() - Read register in register space of an IP - * - * @handle: Device handle - * @ipIndex: IP index - * @offset: Offset in the register space - * @datap: Pointer to where result will be saved - * Return: 0 or appropriate error number - * - * Caller should own an exclusive context on the IP obtained via - * xclOpenContext() This API may be used to read from device registers. - * Offset is relative to the the register map exposed by the IP. - * Please note that the intent of this API is to support legacy RTL IPs. - * If you are creating a new IP please use one of the well defined - * execution models which are natively supported by XRT. - * If you have a new execution model that you would like to be natively - * supported by XRT please look into ert.h to define new command objects. - */ -XCL_DRIVER_DLLESPEC -int -xclRegRead(xclDeviceHandle handle, uint32_t ipIndex, uint32_t offset, uint32_t *datap); - -/** - * xclRegWRite() - Write to register in register space of an IP - * - * @handle: Device handle - * @ipIndex: IP index - * @offset: Offset in the register space - * @data: Data to be written - * Return: 0 or appropriate error number - * - * Caller should own an exclusive context on the CU obtained via - * xclOpenContext() This API may be used to write to device registers. - * Offset is relative to the the register map exposed by the CU. - * Please note that the intent of this API is to support legacy RTL IPs. - * If you are creating a new IP please use one of the well defined - * execution models which are natively supported by XRT. - * If you have a new execution model that you would like to be natively - * supported by XRT please look into ert.h to define new command objects. - */ -XCL_DRIVER_DLLESPEC -int -xclRegWrite(xclDeviceHandle handle, uint32_t ipIndex, uint32_t offset, uint32_t data); - -/** - * xclOpenIPInterruptNotify() - Open a fd for IP interrupt notify - * - * @handle: Device handle - * @ipIndex: IP index - * @flags: flags for the fd - * Return: Interrupt notify handle - * - * Caller should own an exclusive context on the IP obtained via - * xclOpenContext() - * - * Support for non managed IP. This is the proper way to support - * custom IPs which doesn't compliant with supported control protocol. - * - * This API would open a handle used for CU interrupt - * notification. The usage is similar to open a UIO device. Caller - * could use standard read/poll/select system call to wait for IP - * interrupts. Once this API was called, xclExecBuf() could not be - * used to schedule this specific IP. The expectation is the caller - * performing any necessary actions to make it work. - * - * Note: the IP irq would be disable after this is called. Caller - * could manually enable the interrupt by write(). - */ -XCL_DRIVER_DLLESPEC -xclInterruptNotifyHandle -xclOpenIPInterruptNotify(xclDeviceHandle handle, uint32_t ipIndex, unsigned int flags); - -/** - * xclCloseIPInterruptNotify() - Clost the interrupt notify fd - * - * @handle: Device handle - * @fd: fd handle - * Return: 0 or appropriate error number - * - * Caller should own an exclusive context on the IP obtained via xclOpenContext() - * This API would close the file descriptor used for IP interrupt notification. - * Once this API was called, xclExecBuf() could schedule this specific IP. - */ -XCL_DRIVER_DLLESPEC -int -xclCloseIPInterruptNotify(xclDeviceHandle handle, int fd); - -/** - * xclErrorClear() - Clear all asynchronous error records in driver - * - * @handle: Device handle - * Return: 0 or appropriate error number - * - * Note: this API needs root privilege - */ -XCL_DRIVER_DLLESPEC -int -xclErrorClear(xclDeviceHandle handle); - -#ifdef __cplusplus -} -#endif - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimenta/xrt-next.h with xrt/experimental/xrt-next.h") +#include "xrt/experimental/xrt-next.h" diff --git a/src/runtime_src/core/include/experimental/xrt_aie.h b/src/runtime_src/core/include/experimental/xrt_aie.h index 5199342ef8c..8742b726007 100644 --- a/src/runtime_src/core/include/experimental/xrt_aie.h +++ b/src/runtime_src/core/include/experimental/xrt_aie.h @@ -1,17 +1,4 @@ -/** - * Copyright (C) 2021 Xilinx, Inc - * ZNYQ XRT Library layered on top of ZYNQ zocl kernel driver - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_aie.h with xrt/xrt_aie.h") #include "xrt/xrt_aie.h" diff --git a/src/runtime_src/core/include/experimental/xrt_bo.h b/src/runtime_src/core/include/experimental/xrt_bo.h index ba38e3802b3..74be0281aa6 100644 --- a/src/runtime_src/core/include/experimental/xrt_bo.h +++ b/src/runtime_src/core/include/experimental/xrt_bo.h @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2021, Xilinx Inc - All rights reserved - * Xilinx Runtime (XRT) Experimental APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_bo.h with xrt/xrt_bo.h") #include "xrt/xrt_bo.h" diff --git a/src/runtime_src/core/include/experimental/xrt_device.h b/src/runtime_src/core/include/experimental/xrt_device.h index 9049cd8ae90..82e7d90f297 100644 --- a/src/runtime_src/core/include/experimental/xrt_device.h +++ b/src/runtime_src/core/include/experimental/xrt_device.h @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2021, Xilinx Inc - All rights reserved - * Xilinx Runtime (XRT) Experimental APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_device.h with xrt/xrt_device.h") #include "xrt/xrt_device.h" diff --git a/src/runtime_src/core/include/experimental/xrt_elf.h b/src/runtime_src/core/include/experimental/xrt_elf.h index 8cb2ad9ad78..24c172ea587 100644 --- a/src/runtime_src/core/include/experimental/xrt_elf.h +++ b/src/runtime_src/core/include/experimental/xrt_elf.h @@ -1,62 +1,4 @@ -// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -#ifndef XRT_ELF_H_ -#define XRT_ELF_H_ - -#include "xrt/detail/config.h" -#include "xrt/detail/pimpl.h" -#include "xrt/xrt_uuid.h" - -#ifdef __cplusplus -# include -# include -#endif - -#ifdef __cplusplus -namespace xrt { - -/*! - * @class elf - * - * @brief - * An elf contains instructions for functions to execute in some - * pre-configured hardware. The xrt::elf class provides APIs to mine - * the elf itself for relevant data. - * - * An xclbin is used to configure the hardware and an elf object is - * always associated with exactly one xclbin, meaning the instructions - * are for a specific hardware configuration. - */ -class elf_impl; -class elf : public detail::pimpl -{ -public: - elf() = default; - - XRT_API_EXPORT - explicit - elf(const std::string& fnm); - - /** - * elf() - Constructor from raw ELF data - * - * @param data - * Raw data of elf - * - */ - XRT_API_EXPORT - explicit - elf(std::istream& stream); - - XRT_API_EXPORT - xrt::uuid - get_cfg_uuid() const; -}; - -} // namespace xrt - -#else -# error xrt::elf is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_elf.h with xrt/experimental/xrt_elf.h") +#include "xrt/experimental/xrt_elf.h" diff --git a/src/runtime_src/core/include/experimental/xrt_error.h b/src/runtime_src/core/include/experimental/xrt_error.h index a964a906a7f..2775354d3ed 100644 --- a/src/runtime_src/core/include/experimental/xrt_error.h +++ b/src/runtime_src/core/include/experimental/xrt_error.h @@ -1,126 +1,4 @@ -/** - * Copyright (C) 2020 Xilinx, Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#ifndef xrt_error_h_ -#define xrt_error_h_ - -#include "xrt.h" -#include "xrt_error_code.h" -#include "xrt_device.h" - -#ifdef __cplusplus -# include -# include -# include -#endif - -#ifdef __cplusplus -namespace xrt { - -class error_impl; -class error -{ -public: - /** - * error() - Constructor for last asynchronous error of a class - * - * @device: Device to get last errors from - * @ecl: Error class to retrieve error from - */ - XCL_DRIVER_DLLESPEC - error(const xrt::device& device, xrtErrorClass ecl); - - /** - * error() - Constructor from error code and time stamp - * - * @ecl: Error code - * @timestamp: Time stamp - * - * Allow construction of error object from manually retrieved - * error code and timestamp - */ - XCL_DRIVER_DLLESPEC - error(xrtErrorCode ecl, xrtErrorTime timestamp); - - /** - * get_timestamp() - Get the timestamp for this error - * - * Return: Error timestamp - */ - XCL_DRIVER_DLLESPEC - xrtErrorTime - get_timestamp() const; - - /** - * get_error_code() - Get the error code for this error - * - * Return: Underlying xrt error code - */ - XCL_DRIVER_DLLESPEC - xrtErrorCode - get_error_code() const; - - /** - * to_string() - Convert error object into a formatted string - * - * Return: Formatted string for error - */ - XCL_DRIVER_DLLESPEC - std::string - to_string() const; - -private: - std::shared_ptr handle; -}; - -} // xrt - -#endif - -/** - * xrtErrorGetLast - Get the last error code and its timestamp of a given error class. - * - * @handle: Device handle. - * @class: Error Class for the last error to get. - * @error: Returned XRT error code. - * @timestamp: The timestamp when the error generated - * - * Return: 0 on success or appropriate XRT error code. - */ -XCL_DRIVER_DLLESPEC -int -xrtErrorGetLast(xrtDeviceHandle handle, enum xrtErrorClass ecl, xrtErrorCode* error, uint64_t* timestamp); - -/** - * xrtErrorGetString - Get the description string of a given error code. - * - * @handle: Device handle. - * @error: XRT error code. - * @out: Preallocated output buffer for the error string. - * @len: Length of output buffer. - * @out_len: Output of length of message, ignored if null. - * - * Return: 0 on success or appropriate XRT error code. - * - * Specifying out_len while passing nullptr for output buffer will - * return the message length, which can then be used to allocate the - * output buffer itself. - */ -XCL_DRIVER_DLLESPEC -int -xrtErrorGetString(xrtDeviceHandle, xrtErrorCode error, char* out, size_t len, size_t* out_len); - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_error.h with xrt/experimental/xrt_error.h") +#include "xrt/experimental/xrt_error.h" diff --git a/src/runtime_src/core/include/experimental/xrt_exception.h b/src/runtime_src/core/include/experimental/xrt_exception.h index 8f7c99ef19a..e1618de9edf 100644 --- a/src/runtime_src/core/include/experimental/xrt_exception.h +++ b/src/runtime_src/core/include/experimental/xrt_exception.h @@ -1,38 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_EXCEPTION_H_ -#define XRT_EXCEPTION_H_ - -#ifdef __cplusplus -# include -# include -#endif - -#ifdef __cplusplus - -namespace xrt { - -/** - * class exception -- XRT specific exceptions - * - * In most APIs errors are propagated as std::exception or - * mostly as std::system_error with error codes corresponding to - * POSIX error codes. - * - * Specific non standard system errors are defined as a specific - * xrt::exception, which in turn is derived from a std::exception. - */ -class exception : public std::exception -{ -public: - exception() - {} -}; - -} // namespace xrt - -#else -# error xrt_exception is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_exception.h with xrt/experimental/xrt_exception.h") +#include "xrt/experimental/xrt_exception.h" diff --git a/src/runtime_src/core/include/experimental/xrt_ext.h b/src/runtime_src/core/include/experimental/xrt_ext.h index 267ba0469e5..62ab159d348 100644 --- a/src/runtime_src/core/include/experimental/xrt_ext.h +++ b/src/runtime_src/core/include/experimental/xrt_ext.h @@ -1,265 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_EXT_H_ -#define XRT_EXT_H_ - -// XRT extensions to XRT coreutil -// These extensions are experimental - -#include "xrt/detail/config.h" -#include "xrt/detail/bitmask.h" -#include "xrt/xrt_bo.h" -#include "xrt/xrt_hw_context.h" -#include "xrt/xrt_kernel.h" -#include "experimental/xrt_module.h" - -#ifdef __cplusplus -# include -#endif - -#ifdef __cplusplus -namespace xrt::ext { - -/*! - * @class bo - * - * @brief Buffer object extension - * xrt::ext::bo is an extension of xrt::bo with additional functionality - * - * @details - * An extension buffer amends the contruction of an xrt::bo with - * additional simplified constructors for specifying access mode of - * host only buffers. - * - * Once constructed, the object must be assigned to an xrt::bo object - * before use. This is becayse XRT relies on templated kernel - * argument assignment and the templated assignment operator is not - * specialized for xrt::ext::bo. - * - * Ultimately the extension will be merged into class xrt::bo. - */ -class bo : public xrt::bo -{ -public: - - /** - * @enum access_mode - buffer object accessibility - * - * @var none - * No access is specified, same as read|write|local - * @var read - * The buffer is read by device, the cpu writes to the buffer - * @var write - * The buffer is written by device, the host reads from the buffer - * @var local - * Access is local to process and device on which it is allocated - * @var shared - * Access is shared between devices within process - * @var process - * Access is shared between processes and devices - * @var hybrid - * Access is shared between drivers (cross-adapter) - * - * The access mode is used to specify how the buffer is used by - * device and process. - * - * A buffer can be specified as local, meaning it is only used by - * the process and device on which it is allocated. A buffer can - * also be specified as shared, meaning it is shared between devices - * within the process. Finally a buffer can be specified as - * process, meaning it is shared between processes and devices. If - * neither local, shared, or process is specified, the default is - * local. Only one of local, shared, or process can be specified. - * - * A buffer can be opened for read, meaning the device will read the - * content written by host, or it can be opened for write, meaning - * the device will write to the buffer and the host will read. To - * specify that a buffer is used for both read and write, the access - * flags can be ORed. If neither read or write is specified, the - * default is read|write. - * - * The default access mode is read|write|local when no access mode - * is specified. - * - * Friend operators are provided for bitwise operations on access - * mode. It is invalid to combine local, shared, proces, and hybrid. - */ - enum class access_mode : uint64_t - { - none = 0, - - read = 1 << 0, - write = 1 << 1, - read_write = read | write, - - local = 0, - shared = 1 << 2, - process = 1 << 3, - hybrid = 1 << 4, - }; - - friend constexpr access_mode operator&(access_mode lhs, access_mode rhs) - { - return xrt::detail::operator&(lhs, rhs); - } - - friend constexpr access_mode operator|(access_mode lhs, access_mode rhs) - { - return xrt::detail::operator|(lhs, rhs); - } - - /** - * bo() - Constructor with user host buffer and access mode - * - * @param device - * The device on which to allocate this buffer - * @param userptr - * The host buffer which must be page aligned - * @param sz - * Size of buffer which must in multiple of page size - * @param access - * Specific access mode for the buffer (see `enum access_mode`) - * - * This constructor creates a host_only buffer object with - * specified access. - */ - XRT_API_EXPORT - bo(const xrt::device& device, void* userptr, size_t sz, access_mode access); - - /** - * bo() - Constructor with user host buffer and access mode - * - * @param device - * The device on which to allocate this buffer - * @param userptr - * The host buffer which must be page aligned - * @param sz - * Size of buffer which must in multiple of page size - * @param access - * Specific access mode for the buffer (see `enum access_mode`) - * - * This constructor creates a host_only buffer object with local - * access and read|write direction. - */ - XRT_API_EXPORT - bo(const xrt::device& device, void* userptr, size_t sz); - - /** - * bo() - Constructor for buffer object with specific access - * - * @param device - * The device on which to allocate this buffer - * @param sz - * Size of buffer - * @param access - * Specific access mode for the buffer (see `enum access_mode`) - * - * This constructor creates a host_only buffer object with - * specified access. - */ - XRT_API_EXPORT - bo(const xrt::device& device, size_t sz, access_mode access); - - /** - * bo() - Constructor for buffer object - * - * @param device - * The device on which to allocate this buffer - * @param sz - * Size of buffer - - * This constructor creates a host_only buffer object with local - * access and read|write direction. - */ - XRT_API_EXPORT - bo(const xrt::device& device, size_t sz); - - /** - * bo() - Constructor to import an exported buffer from another process - * - * @param device - * The device that imports this buffer - * @param pid - * Process id of exporting process - * @param ehdl - * Exported buffer handle, implementation specific type - * - * The exported buffer handle is obtained from exporting process by - * calling `export_buffer()` on the buffer to be exported. - */ - XRT_API_EXPORT - bo(const xrt::device& device, pid_type pid, xrt::bo::export_handle ehdl); - - /** - * bo() - Constructor for buffer object - * - * @param hwctx - * The hardware context that this buffer object uses for queue - * operations such as syncing and residency operations. - * @param sz - * Size of buffer - * @param access - * Specific access mode for the buffer (see `enum access_mode`) - * - * This constructor creates a host_only buffer object with specified - * access mode. The hardware context is used for syncing of data - * to from device and residency operations, which are all enqueued - * operations that are synchronized on fence objects. - */ - XRT_API_EXPORT - bo(const xrt::hw_context& hwctx, size_t sz, access_mode access); - - /** - * bo() - Constructor for buffer object - * - * @param hwctx - * The hardware context that this buffer object uses for queue - * operations such as syncing and residency operations. - * @param sz - * Size of buffer - * - * This constructor creates a host_only buffer object with local - * access and in|out direction. - */ - XRT_API_EXPORT - bo(const xrt::hw_context& hwctx, size_t sz); - - /// @cond - // Deprecated. Hardware context specific import is not supported - XRT_API_EXPORT - bo(const xrt::hw_context& hwctx, pid_type pid, xrt::bo::export_handle ehdl); - /// @endcond -}; - - -class kernel : public xrt::kernel -{ -public: - /** - * kernel() - Constructor from module - * - * @param hwctx - * The hardware context that this kernel is created in. - * @param module - * A module with elf binary instruction code which the - * kernel function will execute. - * @param name - * Name of kernel function to construct. - * - * The module contains an elf binary with instructions for maybe - * multiple functions. When the kernel is constructed, the - * corresponding function is located in the module. The - * instructions for the function are sent to the kernel mode driver - * in an ERT packet along with the kernel function arguments. - */ - XRT_API_EXPORT - kernel(const xrt::hw_context& ctx, const xrt::module& mod, const std::string& name); -}; - -} // xrt::ext - -#else -# error xrt::ext is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_ext.h with xrt/experimental/xrt_ext.h") +#include "xrt/experimental/xrt_ext.h" diff --git a/src/runtime_src/core/include/experimental/xrt_fence.h b/src/runtime_src/core/include/experimental/xrt_fence.h index 5ac082bba54..61db5f6e3ab 100644 --- a/src/runtime_src/core/include/experimental/xrt_fence.h +++ b/src/runtime_src/core/include/experimental/xrt_fence.h @@ -1,221 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_FENCE_H_ -#define XRT_FENCE_H_ - -#include "xrt/detail/config.h" -#include "xrt/xrt_device.h" - -// Until better place for pid_type -#include "xrt/xrt_bo.h" - -#ifdef __cplusplus -# include -# include -# include -#endif - -#ifdef __cplusplus -// Opaque handle to internal use -namespace xrt_core { -class fence_handle; -} - -namespace xrt { - -/*! - * @class fence - * - * @brief - * Fence object for synchronization of operations - * - * @details - * A fence object is used to synchronize operations between - * run objects. - * - * A fence object should be signaled by one run object and waited on - * by other run objects. The fence represents the expected next state - * of a run object, it is enqueued as a wait for one or more run - * objects, and it is signaled upon completion of the run on which is - * was enqueued. - * - * The fence object has state that represents the next value (fence - * id) of an enqueued operation and is has state that represents the - * corresponding value to wait for. Both the next and the expected - * value is incremented when the fence is signaled or waited upon, and - * therefore a fence should be copied if more than one operation is - * dependent on it. A fence should never be signaled by more than one - * run object. - * - * A fence object can be exported for use by another process. This - * allows setting up a pipeline of operations between processes. - */ -class fence_impl; -class fence : public detail::pimpl -{ -public: -#ifdef _WIN32 - using export_handle = uint64_t; -#else - using export_handle = int; -#endif - -public: - /** - * @enum access_mode - buffer object accessibility - * - * @var local - * Access is local to process and device on which it is allocated - * @var shared - * Access is shared between devices within process - * @var process - * Access is shared between processes and devices - * @var hybrid - * Access is shared between drivers (cross-adapater) - */ - enum class access_mode : uint8_t { local, shared, process, hybrid }; - - /** - * fence() - Default constructor - * - * Constructs an empty fence object that converts to false in - * boolean comparisons. - */ - fence() = default; - - /** - * fence() - Constructor for fence object with specific access - * - * @param device - * The device on which to allocate this fence - * @param access - * Specific access mode for the buffer (see `enum access_mode`) - * - * The fence object should be signaled by one run object and waited - * on by other run objects. The fence represents the expected next - * state of a run object, it is enqueued as a wait for one or - * more run objects, and it is signaled upon completion of the run - * on which is was enqueued. - * - * The fence object has state that represents the next value (fence - * id) of an enqueued operation and is has state that represents the - * corresponding value to wait for. Both the next and the expected - * value is incremented when the fence is signaled or waited upon, - * and therefore a fence should be copied if more than one operation - * is dependent on it. A fence should never be signaled by more - * than one run object. - */ - XRT_API_EXPORT - fence(const xrt::device& device, access_mode access); - - /** - * fence() - Constructor to import an exported fence - * - * @param pid - * Process id of exporting process - * @param ehdl - * Exported fence handle, implementation specific type - * - * The exported fence handle is obtained from exporting process by - * calling `export_fence()` on the fence to be exported. - */ - XRT_API_EXPORT - fence(const xrt::device& device, pid_type pid, export_handle ehdl); - - /** - * fence() - Copy constructor - * - * Creates a new fence object that is a copy of the other fence. - * There is no shared state between the two fence objects. - * - * The copy constructor is used when a fence is to be waited on by - * more than one consumer. Since the fence has state that increments - * at each wait submission, the fence should be copied if more than - * one consumer is to wait on it. - */ - XRT_API_EXPORT - fence(const fence& other); - - /** - * fence() - Move constructor - * - * Move constructor. The other fence object is left in an - * unspecified state. - */ - XRT_API_EXPORT - fence(fence&& other) noexcept; - - /** - * Move assignment operator - * - * The other fence object is left in an unspecified state. - */ - XRT_API_EXPORT - fence& - operator=(fence&& other) noexcept = default; - - ///@cond - // Constructor from internal implementation - XRT_API_EXPORT - fence(std::unique_ptr handle); - ///@endcond - - /** - * export_fence() - Export fence object to another process - * - * @return - * Exported fence handle, implementation specific type. This - * exported handle can be imported by another process - */ - XRT_API_EXPORT - export_handle - export_fence(); - - /** - * wait() - Wait for fence to be signaled - * - * @paramm timeout Timeout for wait. A value of 0, implies block - * until completes. - * @return std::cv_status::no_timeout when wait - * completes succesfully. std::cv_status::timeout when wait times - * out. - * - * Throws on error (to-be-defined) - - * Wait for fence to be signaled at its current value. This is - * CPU blocking operation. - */ - XRT_API_EXPORT - std::cv_status - wait(const std::chrono::milliseconds& timeout); - - /** - * get_access_mode() - Return the mode of access for the fence - * - * See access mode. Only process level fence objects can be - * exported. - */ - XRT_API_EXPORT - access_mode - get_access_mode() const; - - /** - * get_next_state() - Return the next state of the fence - * - * The next state is the value that the fence will be set to when it - * is signaled and it is the value that will be waited on when the - * fence is submitted for wait. The next state is incremented each - * time the fence is signaled or waited on. - */ - XRT_API_EXPORT - uint64_t - get_next_state() const; -}; - -} // namespace xrt - -#else -# error xrt::fence is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_fence.h with xrt/experimental/xrt_fence.h") +#include "xrt/experimental/xrt_fence.h" diff --git a/src/runtime_src/core/include/experimental/xrt_graph.h b/src/runtime_src/core/include/experimental/xrt_graph.h index a2de4fd79b2..57e49e9cf72 100644 --- a/src/runtime_src/core/include/experimental/xrt_graph.h +++ b/src/runtime_src/core/include/experimental/xrt_graph.h @@ -1,17 +1,4 @@ -/** - * Copyright (C) 2021 Xilinx, Inc - * ZNYQ XRT Library layered on top of ZYNQ zocl kernel driver - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_graph.h with xrt/xrt_graph.h") #include "xrt/xrt_graph.h" diff --git a/src/runtime_src/core/include/experimental/xrt_hw_context.h b/src/runtime_src/core/include/experimental/xrt_hw_context.h index dcd6ee243f8..f6d1cc3cd28 100644 --- a/src/runtime_src/core/include/experimental/xrt_hw_context.h +++ b/src/runtime_src/core/include/experimental/xrt_hw_context.h @@ -1,3 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_hw_context.h with xrt/xrt_hw_context.h") #include "xrt/xrt_hw_context.h" diff --git a/src/runtime_src/core/include/experimental/xrt_ini.h b/src/runtime_src/core/include/experimental/xrt_ini.h index d128d25dc58..bdf261c27b1 100644 --- a/src/runtime_src/core/include/experimental/xrt_ini.h +++ b/src/runtime_src/core/include/experimental/xrt_ini.h @@ -1,99 +1,4 @@ -/* - * Copyright (C) 2021-2022 Xilinx, Inc - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef _XRT_INI_H_ -#define _XRT_INI_H_ - -#include "xrt.h" - -#ifdef __cplusplus -# include -#endif - -#ifdef __cplusplus - -/*! - * @namespace xrt::ini - * - * @brief - * APIs for XRT configuration control. - * - * @details - * XRT can be configured through a json xrt.ini file co-located with - * the host executable. If present, XRT uses configuration options - * from the ini file when a given option is first accessed. Without an - * ini file, the configuration options take on default values. - * - * The APIs in this file allow host application to specify - * configuration options for XRT programatically. It is only possible - * for the host application to change configuration options before a - * given option is used by XRT the very first time. - */ -namespace xrt { namespace ini { - -/*! - * set() - Change xrt.ini string value for specified key - * - * @param key - * Key to change value for - * @param value - * New value for key - * - * Throws if key value cannot be changed. - */ -XCL_DRIVER_DLLESPEC -void -set(const std::string& key, const std::string& value); - -/*! - * set() - Change xrt.ini string value for specified key - * - * @param key - * Key to change value for - * @param value - * New value for key - * - * Throws if key value cannot be changed. - */ -inline void -set(const std::string& key, unsigned int value) -{ - set(key, std::to_string(value)); -} - - -}} // ini, xrt - -/// @cond -extern "C" { -#endif - -/** - * xrtIniSet() - Change xrt.ini string value for specified key - * - * @key: Key to change value for - * @value: New value for key - * Return: 0 on success, error if key value cannot be changed - */ -XCL_DRIVER_DLLESPEC -int -xrtIniStringSet(const char* key, const char* value); - -/** - * xrtIniUintSet() - Change xrt.ini unsigned int value for specified key - * - * @key: Key to change value for - * @value: New value for key - * Return: 0 on success, error if key value cannot be changed - */ -XCL_DRIVER_DLLESPEC -int -xrtIniUintSet(const char* key, unsigned int value); - -/// @endcond -#ifdef __cplusplus -} -#endif - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_ini.h with xrt/experimental/xrt_ini.h") +#include "xrt/experimental/xrt_ini.h" diff --git a/src/runtime_src/core/include/experimental/xrt_ip.h b/src/runtime_src/core/include/experimental/xrt_ip.h index c66e29a8b9f..565914751ce 100644 --- a/src/runtime_src/core/include/experimental/xrt_ip.h +++ b/src/runtime_src/core/include/experimental/xrt_ip.h @@ -1,201 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved. -// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_IP_H_ -#define XRT_IP_H_ - -#include "xrt.h" -#include "xrt/xrt_uuid.h" -#include "xrt/xrt_device.h" -#include "xrt/detail/pimpl.h" - -#include "experimental/xrt_hw_context.h" - -#ifdef __cplusplus -# include -# include -# include -#endif - -#ifdef __cplusplus - -namespace xrt { - -/*! - * @class ip - * - * @brief - * xrt::ip represent the custom IP - * - * @details The ip can be controlled through read- and write register - * only. If the IP supports interrupt notification, then xrt::ip - * objects supports enabling and control of underlying IP interrupt. - * - * In order to construct an ip object, the following requirements must be met: - * - * - The custom IP must appear in IP_LAYOUT section of xclbin. - * - The custom IP must have a base address such that it can be controlled - * through register access at offsets from base address. - * - The custom IP must have an address range so that write and read access - * to base address offset can be validated. - * - XRT supports exclusive access only for the custom IP, this is to other - * processes from accessing the same IP at the same time. - */ -class ip_impl; -class ip : public detail::pimpl -{ -public: - /*! - * @class interrupt - * - * @brief - * xrt::ip::interrupt represents an IP interrupt event. - * - * This class represents an IP interrupt event. The interrupt - * object is contructed via `xrt::ip::create_interrupt_notify()`. - * The object can be used to enable and disable IP interrupts - * and to wait for an interrupt to occur. - * - * Upon construction, the IP interrupt is automatically enabled. - */ - class interrupt_impl; - class interrupt : public detail::pimpl - { - public: - /// @cond - explicit - interrupt(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - /// @endcond - - /** - * enable() - Enable interrupt - * - * Enables the IP interrupt if not already enabled. The - * IP interrupt is automatically enabled when the interrupt - * object is created. - */ - XCL_DRIVER_DLLESPEC - void - enable(); - - /** - * disable() - Disable interrupt - * - * Disables the IP interrupt notification from IP. - */ - XCL_DRIVER_DLLESPEC - void - disable(); - - /** - * wait() - Wait for interrupt - * - * Wait for interrupt from IP. Upon return, interrupt is - * re-enabled. - */ - XCL_DRIVER_DLLESPEC - void - wait(); - - /** - * wait() - Wait for interrupt or timeout to occur - * - * @param timeout - * Timout in milliseconds. - * @return - * std::cv_status::timeout if the timeout specified expired, - * std::cv_status::no_timeout otherwise. - * - * Blocks the current thread until an interrupt is received from the IP, or - * until after the specified timeout duration - */ - XCL_DRIVER_DLLESPEC - std::cv_status - wait(const std::chrono::milliseconds& timeout) const; - }; - -public: - /** - * ip() - Construct empty ip object - */ - ip() - {} - - /** - * ip() - Constructor from a device and xclbin - * - * @param device - * Device programmed with the IP - * @param xclbin_id - * UUID of the xclbin with the IP - * @param name - * Name of IP to construct - * - * The IP is opened with exclusive access meaning that no other - * xrt::ip objects can use the same IP, nor will another process be - * able to use the IP while one process has been granted access. - * - * Constructor throws on error. - */ - XCL_DRIVER_DLLESPEC - ip(const xrt::device& device, const xrt::uuid& xclbin_id, const std::string& name); - - /// @cond - /// Experimental in 2022.2 - XCL_DRIVER_DLLESPEC - ip(const xrt::hw_context& ctx, const std::string& name); - /// @endcond - - /** - * write_register() - Write to the address range of an ip - * - * @param offset - * Offset in register space to write to - * @param data - * Data to write - * - * Throws std::out_or_range if offset is outside the - * ip address space - */ - XCL_DRIVER_DLLESPEC - void - write_register(uint32_t offset, uint32_t data); - - /** - * read_register() - Read data from ip address range - * - * @param offset - * Offset in register space to read from - * @return - * Value read from offset - * - * Throws std::out_or_range if offset is outside the - * ip address space - */ - XCL_DRIVER_DLLESPEC - uint32_t - read_register(uint32_t offset) const; - - /** - * create_interrupt_notify() - Create xrt::ip::interrupt object - * - * @return - * xrt::ip::interrupt object can be used to control IP interrupt. - * - * This function creates an xrt::ip::interrupt object that can be - * used to control and wait for IP interrupt. On successful - * return the IP has interrupt enabled. - * - * Throws if the custom IP doesn't support interrupts. - */ - XCL_DRIVER_DLLESPEC - interrupt - create_interrupt_notify(); -}; - -} // xrt -#endif - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_ip.h with xrt/experimental/xrt_ip.h") +#include "xrt/experimental/xrt_ip.h" diff --git a/src/runtime_src/core/include/experimental/xrt_kernel.h b/src/runtime_src/core/include/experimental/xrt_kernel.h index 54916a58d35..ae1d778a7bb 100644 --- a/src/runtime_src/core/include/experimental/xrt_kernel.h +++ b/src/runtime_src/core/include/experimental/xrt_kernel.h @@ -1,251 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2021 Xilinx, Inc. All rights reserved. // Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_EXPERIMENTAL_KERNEL_H -#define XRT_EXPERIMENTAL_KERNEL_H -#include "xrt/xrt_kernel.h" -#include "xrt/xrt_hw_context.h" - -#include "xrt/detail/config.h" - -#ifdef __cplusplus -# include "xrt/detail/pimpl.h" -# include -# include -#endif - -#ifdef __cplusplus -namespace xrt { - -/** - * class runlist - A class to manage a list of xrt::run objects - * - * @brief - * This class is used to manage a list of xrt::run objects such - * that they can be executed atomically in the order they are added - * to the list. - * - * @details - * Run objects are added to the list using the add() method. A runlist - * is submitted for execution using the execute() method. Once the - * list is executing, no more run objects can be added until execution - * of the current last run object has completed. The list can be reset - * using the reset() method, which will clear all run objects, or the - * list can be reused by calling execute() again maybe with additional - * run objects. - * - * There is no support for removing individual run objects from the - * list. - */ -class runlist_impl; -class runlist : public detail::pimpl -{ -public: - /** - * class command_error - exception for abnormal runlist execution - * - * Captures the failing run object and the state at which it failed. - */ - class command_error_impl; - class command_error : public detail::pimpl, public std::exception - { - public: - XRT_API_EXPORT - command_error(const xrt::run& run, ert_cmd_state state, const std::string& what); - - /** - * get_run() - run object that failed - */ - XRT_API_EXPORT - xrt::run - get_run() const; - - /** - * get_command_state() - command state upon completion - */ - XRT_API_EXPORT - ert_cmd_state - get_command_state() const; - - XRT_API_EXPORT - const char* - what() const noexcept override; - }; - -public: - /** - * runlist() - Construct empty runlist object - * - * Can be used as lvalue in assignment. - * - * It is undefined behavior to use a default constructed runlist - * for anything but assignment. - */ - runlist() = default; - - /** - * runlist - Constructor - * - * A runlist is associated with a specific hwctx. All run objects - * added to the list must be associated with kernel objects that are - * created in specified hwctx. - * - * Throws is invariant per run object hwctx requirement is violated. - */ - XRT_API_EXPORT - explicit - runlist(const xrt::hw_context& hwctx); - - /** - * runlist - Destructor - * - * The destructor of the runlist clears the association with the run - * objects, but does not check for runlist state or wait for run - * object completion. It is the caller's responsibility to ensure - * that the runlist is not executing when the destructor is called - * or beware that there may be run objects still executing. - */ - XRT_API_EXPORT - ~runlist(); - - /** - * add() - Add a run object to the list - * - * The run object is added to the end of the list. A run object can - * only be added to a runlist once and only a runlist which must be - * associated with the same hwctx as the kernel from which the run - * object was created. - * - * It is undefined behavior to add a run object to a runlist which - * is currently executing or to explicitly start (xrt::run::start()) - * a run object that is part of a runlist. - * - * It is the caller's responsibility to ensure that the runlist is - * not executing when this method is called. This can be done by - * calling the wait() method on the runlist object. - * - * The state of run objects in a runlist should be ignored. The - * `xrt::run::state()` function is not guaranteed to reflect the - * actual run object state and cannot be called for run objects that - * are part of a runlist. If any run object fails to complete - * successfully, `xrt::runlist::wait()` will throw an exception with - * the failed run object and it's fail state. - * - * Throws if the kernel from which the run object was created does - * not match the hwctx from which the runlist was created. - * - * Throws if the run object is already part of a runlist. - * - * Throws if runlist is executing. - */ - XRT_API_EXPORT - void - add(const xrt::run& run); - - /** - * execute() - Execute the runlist - * - * The runlist is submitted for execution. The run objects in the - * list are executed atomically in the order they were added to the - * list. - * - * Executing an empty runlist is a no-op. - * - * Throws if runlist is already executing. - */ - XRT_API_EXPORT - void - execute(); - - /** - * wait() - Wait for the runlist to complete - * - * @param timeout - * Timeout for wait. A value of 0, implies block until all run - * objects have completed successfully. - * @return - * std::cv_status::no_timeout if list has completed execution of - * all run objects, std::cv_status::timeout if the timeout expired - * prior to all run objects completing. - * - * Completion of a runlist execution means that all run objects have - * completed succesfully. If any run object in the list fails to - * complete successfully, the function throws - * `xrt::runlist::command_error` with the failed run object and - * state. - */ - XRT_API_EXPORT - std::cv_status - wait(const std::chrono::milliseconds& timeout) const; - - /** - * wait() - Wait for the runlist to complete - * - * This is a convenience method that calls wait() with a timeout of 0. - * - * The function blocks until all run objects have completed or - * throws if any run object fails to complete successfully. - */ - void - wait() const - { - wait(std::chrono::milliseconds(0)); - } - - /** - * state() - Check the current state of a runlist object - * - * @return - * Current state of this run object. - * - * The state values are defined in ``include/ert.h`` - * The state of an empty runlist is ERT_CMD_STATE_COMPLETED. - * - * This function is the preferred way to poll a runlist for - * for completion. - */ - XRT_API_EXPORT - ert_cmd_state - state() const; - - /** - * DEPRECATED, prefer `state()`. - * - * Poll the runlist for completion. - * - * @return 0 if command list is still running, any other value - * indicates completion. - * - * Completion of a runlist execution means that all run objects have - * completed succesfully. If any run object in the list fails to - * complete successfully, the function throws - * `xrt::runlist::command_error` with the failed run object and - * state. - */ - XRT_API_EXPORT - int - poll() const; - - /** - * reset() - Reset the runlist - * - * The runlist is reset to its initial state. All run objects are - * removed from the list. - * - * It is the caller's responsibility to ensure that the runlist is - * not executing when this method is called. This can be done by - * calling the wait() method on the runlist object. - * - * Throws if runlist is executing. - */ - XRT_API_EXPORT - void - reset(); -}; - -} // namespace xrt - -#endif // __cplusplus -#endif // XRT_EXPERIMENTAL_KERNEL_H - - +#pragma message("please replace experimental/xrt_kernel.h with xrt/experimental/xrt_kernel.h") +#include "xrt/experimental/xrt_kernel.h" diff --git a/src/runtime_src/core/include/experimental/xrt_mailbox.h b/src/runtime_src/core/include/experimental/xrt_mailbox.h index 3a716b6545e..fdcea8e8a29 100644 --- a/src/runtime_src/core/include/experimental/xrt_mailbox.h +++ b/src/runtime_src/core/include/experimental/xrt_mailbox.h @@ -1,205 +1,4 @@ -/* - * Copyright (C) 2021-2022 Xilinx, Inc - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef _XRT_MAILBOX_H_ -#define _XRT_MAILBOX_H_ - -#include "xrt.h" -#include "xrt/xrt_kernel.h" -#include "xrt/xrt_bo.h" -#include "xrt/detail/pimpl.h" - -#ifdef __cplusplus -# include -#endif - -#ifdef __cplusplus - -namespace xrt { - -/*! - * @class mailbox - * - * @brief - * xrt::mailbox provides access to the kernel mailbox if any - * - * @details - * The mailbox extends the API of an xrt::run with mailbox specific - * APIs to explicitly control mailbox aspects of a kernel. It is an - * error to construct a mailbox from a run object or kernel that - * doesn't support mailbox. - */ -class mailbox_impl; -class mailbox : public detail::pimpl -{ -public: - /** - * mailbox() - Construct mailbox from a \ref xrt::run object. - * - * It is an error to construct a mailbox from a run object that is - * not associated with a kernel supporting mailbox, or from a run - * object associated with multiple compute units. In other words a - * mailbox is 1-1 with a compute unit that is managed by the - * argument run object. - */ - XCL_DRIVER_DLLESPEC - explicit - mailbox(const run& run); - - /** - * read() - Read kernel arguments into mailbox copy - * - * This function is asynchronous, it requests the kernel to update - * the content of the mailbox when it is safe to do so. If the - * kernel is in auto restart mode, then the update is delayed until - * beginning of next iteration. If the kernel is idle, then the - * update is immediate. - * - * The mailbox is busy until the kernel has updated the content. - * It is an error to call ``read()`` while the mailbox is busy, - * throws std::system_error with std::errc::device_or_resource_busy. - * - * This function invalidates any argument data returned through - * ``get_arg`` function. - */ - XCL_DRIVER_DLLESPEC - void - read(); - - /** - * write() - Write the mailbox copy of kernel arguments to kernel - * - * This function is asynchronous, it requests the kernel to copy - * the content of the mailbox when it is safe to do so. If the - * kernel is in auto restart mode, then the copying is delayed until - * beginning of next iteration. If the kernel is idle, then the - * copying is immediate. - * - * The mailbox is busy until the kernel has copied the content. - * It is an error to call ``write()`` while the mailbox is busy, - * throws std::system_error with std::errc::device_or_resource_busy. - */ - XCL_DRIVER_DLLESPEC - void - write(); - - /** - * get_arg() - Returns the mailbox copy of an argument - * - * @param index - * Index of kernel argument to read - * @return - * The raw data and size in bytes of data - * - * The argument data returned is a direct reference to the mailbox - * copy of the data. It is valid only until the mailbox is updated - * again. - * - * The function is synchronous and blocks if the mailbox is busy, - * per pending ``read()`` or ``write()``. - * - * Subject to deprecation in favor of type safe version. - */ - XCL_DRIVER_DLLESPEC - std::pair - get_arg(int index) const; - - /** - * set_arg() - Set a specific kernel global argument in the mailbox - * - * @param index - * Index of kernel argument to set - * @param boh - * The global buffer argument value to set (lvalue). - * - * Use this API to queue up a new kernel argument value that can - * be written to the kernel using ``write()``. - * - * The function is synchronous and blocks if the mailbox is busy, - * per pending ``read()`` or ``write()``. - */ - void - set_arg(int index, xrt::bo& boh) - { - set_arg_at_index(index, boh); - } - - /** - * set_arg() - xrt::bo variant for const lvalue - */ - void - set_arg(int index, const xrt::bo& boh) - { - set_arg_at_index(index, boh); - } - - /** - * set_arg() - xrt::bo variant for rvalue - */ - void - set_arg(int index, xrt::bo&& boh) - { - set_arg_at_index(index, boh); - } - - /** - * set_arg() - Set a specific kernel scalar argument in the mailbox - * - * @param index - * Index of kernel argument to set - * @param arg - * The scalar argument value to set. - * - * Use this API to queue up a new kernel scalar arguments value that - * can be written to the kernel using ``write()``. - * - * The function is synchronous and blocks if the mailbox is busy, - * per pending ``read()`` or ``write()``. - */ - template - void - set_arg(int index, ArgType&& arg) - { - set_arg_at_index(index, &arg, sizeof(arg)); - } - - /** - * set_arg - set named argument in the mailbox - * - * @param argnm - * Name of kernel argument - * @param argvalue - * Argument value - * - * Throws if specified argument name doesn't match kernel - * specification. Throws if argument value is incompatible with - * specified argument - */ - template - void - set_arg(const std::string& argnm, ArgType&& argvalue) - { - auto index = get_arg_index(argnm); - set_arg(index, std::forward(argvalue)); - } - - -private: - XCL_DRIVER_DLLESPEC - int - get_arg_index(const std::string& argnm) const; - - XCL_DRIVER_DLLESPEC - void - set_arg_at_index(int index, const void* value, size_t bytes); - - XCL_DRIVER_DLLESPEC - void - set_arg_at_index(int index, const xrt::bo&); -}; - -} // xrt -#endif - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_mailbox.h with xrt/experimental/xrt_mailbox.h") +#include "xrt/experimental/xrt_mailbox.h" diff --git a/src/runtime_src/core/include/experimental/xrt_message.h b/src/runtime_src/core/include/experimental/xrt_message.h index b51ded4009e..0f558b7518d 100644 --- a/src/runtime_src/core/include/experimental/xrt_message.h +++ b/src/runtime_src/core/include/experimental/xrt_message.h @@ -1,140 +1,4 @@ -/* - * Copyright (C) 2021-2022 Xilinx, Inc - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef xrt_message_h_ -#define xrt_message_h_ - -#include "xrt.h" - -#ifdef __cplusplus -# include -# include -#endif - -#ifdef __cplusplus - -/*! - * @namespace xrt::message - * - * @brief - * APIs for XRT messaging. - * - * @details - * XRT internally uses a message system that supports dispatching of - * messages to null, console, file, or syslog under different verbosity - * levels. The sink and verbosity level is controlled statically - * through ``xrt.ini`` or at run-time using ``xrt::ini``. - * - * The APIs in this file allow host application to use the same - * message dispatch mechanism as XRT is configured to use. - */ -namespace xrt { namespace message { - -/*! - * @enum level - * - * @brief - * Verbosity level for messages - * - * @details - * Use logging APIs to control at what verbosity level the - * messages should be issued. The default verbosity can be changed in - * `xrt.ini` or programatically by using `xrt::ini::set`. - * - * @var emergency - * @var alert - * @var critical - * @var error - * @var warning - * @var notice - * @var info - * @var debug - */ -enum class level : unsigned short -{ - emergency = xrtLogMsgLevel::XRT_EMERGENCY, - alert = xrtLogMsgLevel::XRT_ALERT, - critical = xrtLogMsgLevel::XRT_CRITICAL, - error = xrtLogMsgLevel::XRT_ERROR, - warning = xrtLogMsgLevel::XRT_WARNING, - notice = xrtLogMsgLevel::XRT_NOTICE, - info = xrtLogMsgLevel::XRT_INFO, - debug = xrtLogMsgLevel::XRT_DEBUG -}; - -/// @cond -namespace detail { - -template -void -format(boost::format& fmt, ArgType&& arg) -{ - fmt % std::forward(arg); -} - -template -void -format(boost::format& fmt, ArgType&& arg, Args&&... args) -{ - fmt % std::forward(arg); - format(fmt, std::forward(args)...); -} - -// enabled() - check if specified level is enabled -XCL_DRIVER_DLLESPEC -bool -enabled(level lvl); - -} // detail -/// @endcond - -/** - * log() - Dispatch composed log message - * - * @param lvl - * Severity level, the message is ignored if configured level - * is less than specified level. - * @param tag - * The message tag to use. - * @param msg - * A formatted composed message - */ -XCL_DRIVER_DLLESPEC -void -log(level lvl, const std::string& tag, const std::string& msg); - -/** - * logf() - Compose and dispatch formatted log message - * - * @param lvl - * Severity level, the message is ignored if configured level - * is less than specified level. - * @param tag - * The message tag to use. - * @param format - * A format string similar to printf or boost::format - * @param args - * Message arguments for the placeholders used in the format string - * - * This log function uses boost::format to compose the message from - * specified format string and arguments. - */ -template -void -logf(level lvl, const std::string& tag, const char* format, Args&&... args) -{ - if (!detail::enabled(lvl)) - return; - - auto fmt = boost::format(format); - detail::format(fmt, std::forward(args)...); - log(lvl, tag, fmt.str()); -} - -}} - -#endif // __cplusplus - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_message.h with xrt/experimental/xrt_message.h") +#include "xrt/experimental/xrt_message.h" diff --git a/src/runtime_src/core/include/experimental/xrt_module.h b/src/runtime_src/core/include/experimental/xrt_module.h index 781e50afd70..a7e8e1eba76 100644 --- a/src/runtime_src/core/include/experimental/xrt_module.h +++ b/src/runtime_src/core/include/experimental/xrt_module.h @@ -1,124 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_MODULE_H_ -#define XRT_MODULE_H_ - -#include "xrt/detail/config.h" -#include "xrt/xrt_bo.h" -#include "xrt/xrt_hw_context.h" -#include "xrt/xrt_uuid.h" -#include "xrt/detail/pimpl.h" -#include "experimental/xrt_elf.h" - -#ifdef __cplusplus -# include -# include -#endif - -#ifdef __cplusplus -namespace xrt { - -/*! - * @class module - * - * @brief - * An xrt::module contains functions an application will execute in - * hardware. In Alveo the xclbin is the container that configures the - * hardware and provides the functions. In AIE the functions are a - * set of instructions that are run on configured hardware, the - * instructions are embedded in an elf file, which is parsed for meta - * data determining how the functions are invoked. - * - * An xrt::module is constructed from the object that contains the - * functions to execute. In the case of Alveo, the module is - * definitely constructed from an xrt::xclbin , in case of AIE the - * module is constructed from an xrt::elf or from a user pointer. - */ -class module_impl; -class module : public detail::pimpl -{ -public: - /** - */ - module() - {} - - /** - * module() - Constructor from elf - * - * @param elf - * An elf binary with functions to execute - * - * The elf binary contains instructions for functions to be executed - * in some hardware context. The elf binary has text segments with - * meta data to be mined for function arguments and type. - * - * The constructor retains ownership of the elf object. - */ - XRT_API_EXPORT - explicit - module(const xrt::elf& elf); - - /** - * module() - Constructor from user ptr - * - * @param userptr - * A pointer to an opaque representation of the instructions - * to execute on hardware configured by an xclbin with uuid - * @param sz - * Size in bytes of the userptr buffer - * @param uuid - * Unique id of the hardware configuration. Must match the - * xclbin uuid use to configure the hardware. - * - * The user pointer is an opaque representation of the instructions - * to execute on hardware configured by xclbin. - * - * The constructor copies the content of the userptr. - */ - XRT_API_EXPORT - module(void* userptr, size_t sz, const xrt::uuid& uuid); - - /** - * module() - Constructor associate module with hardware context - * - * @param parent - * Parent module with instruction buffer to move into hwctx - * @param hwctx - * Hardware context to associate with module - * - * Copy content of existing module into an allocation associated - * with the specified hardware context. - * - * Throws if module is not compatible with hardware context - */ - XRT_API_EXPORT - module(const xrt::module& parent, const xrt::hw_context& hwctx); - - /** - * get_cfg_uuid() - Get the uuid of the hardware configuration - * - * @return - * UUID of matching hardware configuration - * - * An module is associated with exactly one hardware configuration. - * This function returns the uuid that identifies the configuration. - */ - XRT_API_EXPORT - xrt::uuid - get_cfg_uuid() const; - - XRT_API_EXPORT - xrt::hw_context - get_hw_context() const; - -private: -}; - -} // namespace xrt - -#else -# error xrt::module is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_module.h with xrt/experimental/xrt_module.h") +#include "xrt/experimental/xrt_module.h" diff --git a/src/runtime_src/core/include/experimental/xrt_profile.h b/src/runtime_src/core/include/experimental/xrt_profile.h index 2ee89a60a00..fa9be31a2da 100644 --- a/src/runtime_src/core/include/experimental/xrt_profile.h +++ b/src/runtime_src/core/include/experimental/xrt_profile.h @@ -1,253 +1,4 @@ -/* - * Copyright (C) 2020-2022, Xilinx Inc - All rights reserved - * Xilinx Runtime (XRT) Experimental APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#ifndef _XRT_PROFILE_H_ -#define _XRT_PROFILE_H_ - -#include "xrt.h" - -#ifdef __cplusplus - -#include - -namespace xrt { namespace profile { - -/*! - * @class user_range - * - * @brief - * xrt::profile::user_range xrt::profile::user_range is used to track start and stop times - * between two user defined points in host program and add them to profiling output for - * visualization using post-processing tools. - * - * @details - * By turning on various trace options in the xrt.ini file, - * XRT applications will track events and generate files, which are turned into a - * timeline visualization and summary via post-processing tools. A user range is used - * to explicitly add events measured from start to stop from the host code to that - * timeline visualization and summary. - * Usage - - * 1. If a user_range is instantiated using the default constructor, no time is marked - * until the user calls start with two strings (label and tooltip) - * 2. The user must call start() and stop() to mark ranges of time they are interested in. - * If stop() is not called, then any range being tracked lasts until the user_range object is destructed - * 3. As a shortcut, the user can instantiate a user_range object passing two strings (label and tooltip). This starts monitoring the range immediately - * The user_range object can be reused any number of times, by calling start()/stop() pairs in the host code - * 4. Multiple sequential calls to start() ignore all but the first call - * 5. Multiple sequential calls to stop() ignore all but the first call - */ -class user_range -{ -private: - uint32_t id; - bool active; -public: - /** - * user_range() - Default Constructor for user range - * - * If this constructor is called, the object is created but the - * beginning of the range time is not marked. - */ - XCL_DRIVER_DLLESPEC - user_range(); - - /** - * user_range() - Constructor for user range with text - * - * @param label - * The string that appears embedded on the waveform for this range - * @param tooltip - * The string that appears on the waveform when hovering over the range - * - * Construct an object and start keeping track of time immediately - * upon construction. - */ - XCL_DRIVER_DLLESPEC - user_range(const char* label, const char* tooltip = nullptr); - - /** - * user_range() - Copy constructor - * - * Explicitly removed as ranges are actively keeping track of real time - * and cannot be copied. - */ - user_range(const user_range& rhs) = delete; - - /** - * user_range() - Move constructor - * - * Explicitly removed as ranges are actively keeping track of real time - * and cannot be moved. - */ - user_range(user_range&& rhs) = delete; - - /** - * operator=() - * - * Explicitly removed as ranges should not be assigned - */ - user_range& operator=(const user_range& rhs) = delete; - user_range& operator=(user_range&& rhs) = delete; - - /** - * ~user_range() - Destructor - * - * If the range is still active, mark this point as the end of the range - */ - XCL_DRIVER_DLLESPEC - ~user_range(); - - /** - * start() - Mark the start position of a user range - * - * @param label - * The string that appears embedded on the waveform for this range - * @param tooltip - * The string that appears on the waveform when hovering over the range - * - * If the range is still actively recording time, end the current - * range and start a new one. - */ - XCL_DRIVER_DLLESPEC - void - start(const char* label, const char* tooltip = nullptr); - - /** - * end() - Mark the end position of a user range - * - * If the range has already been ended, do nothing. Otherwise - * mark the end position of the range and stop tracking time. - */ - XCL_DRIVER_DLLESPEC - void - end(); -}; - -/*! - * @class user_event - * - * @brief - * xrt::profile::user_event mark a specific point in execution with a label for later visualization - * - * @details - * A user event can be generated from inside host code and optionally tagged with a label. - * These events are post-processed and represented on summary and trace waveforms as markers. - */ -class user_event -{ -public: - /** - * user_event() - Constructor - * - * Create an object, but do not mark any particular time - */ - XCL_DRIVER_DLLESPEC - user_event(); - - /** - * ~user_event() - Destructor - * - * Destroy the object, but do not mark any particular time - */ - XCL_DRIVER_DLLESPEC - ~user_event(); - - /** - * mark() - Mark the current moment in time with a marker on the waveform - * - * @param label - * An optional label that will be displayed on top of marker in waveform - * - */ - XCL_DRIVER_DLLESPEC - void - mark(const char* label = nullptr); - - /** - * mark_time_ns() - Mark a custom moment in time with a marker on the waveform - * - * @param time_ns - * Time duration in nanoseconds since appliction start. - * This must be compatible with xrt_core::time_ns() API. - * @param label - * An optional label that will be displayed on top of marker in waveform - * - */ - XCL_DRIVER_DLLESPEC - void - mark_time_ns(const std::chrono::nanoseconds& time_ns, const char* label = nullptr); -}; - -} // end namespace profile -} // end namespace xrt - -extern "C" { -#endif - -/** - * xrtURStart() - Mark the start time in the user code of a range - * - * @id: A user supplied id to match starts and ends of ranges - * @label: The text to display in the waveform for this particular range - * @tooltip: The text to display in the waveform when hovering over this range - * Return: none - * - */ -XCL_DRIVER_DLLESPEC -void -xrtURStart(unsigned int id, const char* label, const char* tooltip = nullptr); - -/** - * xrtUREnd() - Mark the end time in the user code of a range - * - * @id: A user supplied id to match starts and ends of ranges - * Return: none - * - */ -XCL_DRIVER_DLLESPEC -void -xrtUREnd(unsigned int id); - -/** - * xrtUEMark() - Mark the current time as when something happened - * - * @label: An optional label that is added to the marker in the waveform - * Return: none - * - */ -XCL_DRIVER_DLLESPEC -void -xrtUEMark(const char* label); - -/** - * xrtUEMarkTimeNs() - Mark a custom time as when something happened - * - * @time_ns: Time duration in nanoseconds since application start. - * This must be compatible with xrt_core::time_ns() API. - * @label: An optional label that is added to the marker in the waveform - * Return: none - * - */ -XCL_DRIVER_DLLESPEC -void -xrtUEMarkTimeNs(unsigned long long int time_ns, const char* label); - -#ifdef __cplusplus -} -#endif - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_profile.h with xrt/experimental/xrt_profile.h") +#include "xrt/experimental/xrt_profile.h" diff --git a/src/runtime_src/core/include/experimental/xrt_queue.h b/src/runtime_src/core/include/experimental/xrt_queue.h index 6dba9791797..b22acbac904 100644 --- a/src/runtime_src/core/include/experimental/xrt_queue.h +++ b/src/runtime_src/core/include/experimental/xrt_queue.h @@ -1,267 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2022 Xilinx, Inc. All rights reserved. -// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. -#ifndef XRT_QUEUE_H_ -#define XRT_QUEUE_H_ - -#include "xrt/detail/config.h" - -#ifdef __cplusplus -# include -# include -# include -#endif - -#ifdef __cplusplus - -namespace xrt { - -/** - * class queue -- producer / consumer queue for tasks - * - * Used for sequencing operations in order of enqueuing. - * - * A queue has exactly one consumer which is a separate thread created - * when the queue is constructed. - * - * When an opeation is enqueued on the queue an event is returned to - * the caller. This event can be enqueued in a different queue, which - * will then wait for the former to complete the operaiton associated - * with the event. - */ -class queue_impl; -class queue -{ - friend class queue_impl; - - // class task - type-erased callable operation - // - // A task wraps a caller's typed operation such that it - // can be inserted into a queue. - // - // Tasks should be synchronous operations. - class task - { - struct task_iholder - { - virtual ~task_iholder() {}; - virtual void execute() = 0; - }; - - // Wrap typed operation - template - struct task_holder : public task_iholder - { - Callable m_held; - - explicit - task_holder(Callable&& t) - : m_held(std::move(t)) - {} - - void execute() override - { - m_held(); - } - }; - - std::unique_ptr m_content; - - public: - task() = default; - task(task&& rhs) = default; - - // task() - task constructor for synchronous operation - // - // @c : callable object, a std::packaged_task - template - task(Callable&& c) - : m_content(new task_holder(std::forward(c))) - {} - - task& - operator=(task&& rhs) = default; - - operator bool() const - { - return m_content != nullptr; - } - - void - execute() - { - m_content->execute(); - } - }; // class queue::task - -public: - - /** - * class event - type-erased std::shared_future - * - * Wraps typed future return value returned when - * enqueueing an operation. - * - * Returned futures implicitly convert to an event and as such - * enqueue return values can be stored in an event container if - * necessary. - * - * The event object is not needed where the typed future can be - * used. - */ - class event - { - struct event_iholder - { - virtual ~event_iholder() {}; - virtual void wait() const = 0; - }; - - // Wrap typed future - template - struct event_holder : public event_iholder - { - std::shared_future m_held; - - explicit - event_holder(std::shared_future&& e) - : m_held(std::move(e)) - {} - - void wait() const override - { - m_held.wait(); - } - }; - - std::shared_ptr m_content; - - public: - event() = default; - event(event&& rhs) = default; - event(const event& rhs) = default; - - // event() - event constructor for std::shared_future - // - // @e : shared_future to type erase - template - event(std::shared_future e) - : m_content(std::make_shared>(std::move(e))) - {} - - event& - operator=(event&& rhs) = default; - - operator bool() const - { - return m_content!=nullptr; - } - - void - wait() const - { - if (m_content) - m_content->wait(); - } - }; - -private: - // Add task to queue - XRT_API_EXPORT - void - add_task(task&& ev); - -public: - /** - * queue() - Constructor for queue object - * - * The queue is constructed with one consumer thread. - */ - XRT_API_EXPORT - queue(); - - /** - * enqueue() - Enqueue a callable - * - * @param c - * Callable function, typically a lambda - * @return - * Future result of the function (std::future) - * - * A callable is an argument-less lambda function. The function is - * executed asynchronously by the queue consumer (worker thread) - * once all previous enqueued operations have completed. - * - * Upon completion the returned future becomes valid and will - * contain the return value of executing the lambda. - */ - template - auto - enqueue(Callable&& c) - { - using return_type = decltype(c()); - std::packaged_task task{[cc = std::move(c)] { return cc(); }}; - std::shared_future f{task.get_future()}; - add_task(std::move(task)); - return f; - } - - /** - * enqueue() - Enqueue the future of an enqueued operation - * - * @param sf - * The future result to wait on (std::shared_future) - * @return - * Future of the future (std::shared_future) - * - * Subsequent enqueued task blocks until the enqueued future is - * valid. - * - * This type of enqueued future is used for synchronization between - * multiple queues. - */ - template - auto - enqueue(std::shared_future sf) - { - return enqueue([evc = xrt::queue::event{std::move(sf)}] { evc.wait(); }); - } - - /** - * enqueue() - Enqueue an event (type erased future) - * - * @oaram ev - * Event to enqueue - * @param - * Future of event (std::shared_future) - * - * Subsequent enqueued task blocks until the enqueued event is - * valid. - * - * This type of enqueued event is used for synchronization between - * multiple queues. - */ - auto - enqueue(xrt::queue::event ev) - { - return enqueue([evc = std::move(ev)] { evc.wait(); }); - } - -public: - queue_impl* - get_impl() const - { - return m_impl.get(); - } - -private: - std::shared_ptr m_impl; -}; - -} // namespace xrt - -#else -# error xrt_enqueue is only implemented for C++ -#endif // __cplusplus - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_queue.h with xrt/experimental/xrt_queue.h") +#include "xrt/experimental/xrt_queue.h" diff --git a/src/runtime_src/core/include/experimental/xrt_system.h b/src/runtime_src/core/include/experimental/xrt_system.h index d94892283b7..e04dc6d1f41 100644 --- a/src/runtime_src/core/include/experimental/xrt_system.h +++ b/src/runtime_src/core/include/experimental/xrt_system.h @@ -1,35 +1,4 @@ -/* - * Copyright (C) 2021-2022 Xilinx, Inc - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef xrt_system_h_ -#define xrt_system_h_ - -#include "xrt.h" - -#ifdef __cplusplus - -/*! - * @namespace xrt::system - * - * @brief - * APIs for system level queries and control. - */ -namespace xrt { namespace system { - -/** - * enumerate_devices() - Enumerate devices found in the system - * - * @return - * Number of devices in the system recognized by XRT - */ -XCL_DRIVER_DLLESPEC -unsigned int -enumerate_devices(); - -}} - -#endif // __cplusplus - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_system.h with xrt/experimental/xrt_system.h") +#include "xrt/experimental/xrt_system.h" diff --git a/src/runtime_src/core/include/experimental/xrt_uuid.h b/src/runtime_src/core/include/experimental/xrt_uuid.h index 268853b33ac..e4a239a9488 100644 --- a/src/runtime_src/core/include/experimental/xrt_uuid.h +++ b/src/runtime_src/core/include/experimental/xrt_uuid.h @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2021, Xilinx Inc - All rights reserved - * Xilinx Runtime (XRT) Experimental APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_uuid.h with xrt/xrt_uuid.h") #include "xrt/xrt_uuid.h" diff --git a/src/runtime_src/core/include/experimental/xrt_version.h b/src/runtime_src/core/include/experimental/xrt_version.h index 163febfd868..9e45ff42a96 100644 --- a/src/runtime_src/core/include/experimental/xrt_version.h +++ b/src/runtime_src/core/include/experimental/xrt_version.h @@ -1,139 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. - -#ifndef xrt_version_h_ -#define xrt_version_h_ - -#include "xrt/detail/config.h" - -#ifdef __cplusplus - -/*! - * @namespace xrt::version - * - * @brief - * APIs for version queries - */ -namespace xrt::version { - -/** - * code() - Returns the version code for the library. - * - * The version code is a combination of major and minor version. - * The major version is shifted left by 16 bits and the minor version - * is added. - */ -XRT_API_EXPORT -unsigned int -code(); - -/** - * major() - Returns the major version for the library. - * - * The major version indicates ABI compatibility. The major version - * is incremented by 1 only if a release that breaks ABI compatibility. - */ -XRT_API_EXPORT -unsigned int -major(); - -/** - * minor() - Returns the minor version for the library. - * - * The minor version is incremented by 1 for each release within a - * major version. - */ -XRT_API_EXPORT -unsigned int -minor(); - -/** - * patch() - Returns the patch version for the library. - * - * The patch number defaults to 0 for local builds, but is otherwise - * controlled by CI and incremented by 1 for each build. - * - * The patch number is reset to 0 when the minor version is - * incremented. - */ -XRT_API_EXPORT -unsigned int -patch(); - -/** - * build() - Returns the build number for the library. - * - * The build number is the total number of commits to XRT - * on current branch. - */ -XRT_API_EXPORT -unsigned int -build(); - -/** - * feature() - Returns the feature number for the library. - * - * The feature number is the total number of commits to XRT - * main branch. For branches off of XRT's main branch, the - * feature number is the total number of commits at the time - * the branch diverged from XRT's main branch. - */ -XRT_API_EXPORT -unsigned int -feature(); - -} // namespace xrt::version - -/// @cond -extern "C" { -#endif - -/** - * See xrt::version::code() - */ -XRT_API_EXPORT -unsigned int -xrtVersionCode(); - -/** - * See xrt::version::major() - */ -XRT_API_EXPORT -unsigned int -xrtVersionMajor(); - -/** - * See xrt::version::minor() - */ -XRT_API_EXPORT -unsigned int -xrtVersionMinor(); - -/** - * See xrt::version::patch() - */ -XRT_API_EXPORT -unsigned int -xrtVersionPatch(); - -/** - * See xrt::version::build() - */ -XRT_API_EXPORT -unsigned int -xrtVersionBuild(); - -/** - * See xrt::version::feature() - */ -XRT_API_EXPORT -unsigned int -xrtVersionFeature(); - -/// @endcond -#ifdef __cplusplus -} -#endif - - -#endif +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_version.h with xrt/experimental/xrt_version.h") +#include "xrt/experimental/xrt_version.h" diff --git a/src/runtime_src/core/include/experimental/xrt_xclbin.h b/src/runtime_src/core/include/experimental/xrt_xclbin.h index a14a14ad025..d55580ac477 100644 --- a/src/runtime_src/core/include/experimental/xrt_xclbin.h +++ b/src/runtime_src/core/include/experimental/xrt_xclbin.h @@ -1,1117 +1,4 @@ -/* - * Copyright (C) 2020-2022 Xilinx, Inc. All rights reserved. - * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef XRT_XCLBIN_H_ -#define XRT_XCLBIN_H_ - -#include "xrt/detail/config.h" - -#include "xrt.h" -#include "xclbin.h" -#include "xrt/xrt_uuid.h" -#include "xrt/detail/pimpl.h" - -#ifdef __cplusplus -# include -# include -# include -# include -#endif - -/** - * typedef xrtXclbinHandle - opaque xclbin handle - */ -typedef void* xrtXclbinHandle; // NOLINT - -#ifdef __cplusplus -namespace xrt { - -/*! - * @class xclbin - * - * @brief - * xrt::xclbin represents an xclbin and provides APIs to access meta data. - * - * @details - * The xclbin object is constructed by the user from a file. - * - * When the xclbin object is constructed from a complete xclbin, then it - * can be used by xrt::device to program the xclbin onto the device. - * - * **First-class objects and class navigation** - * - * All meta data is rooted at xrt::xclbin. - * - * \image{inline} html xclbin_navigation.png "xclbin navigation" - * - * From the xclbin object - * xrt::xclbin::kernel or xrt::xclbin::ip objects can be constructed. - * - * The xrt:xclbin::kernel is a concept modelled only in the xclbin XML - * metadata, it corresponds to a function that can be executed by one - * or more compute units modelled by xrt::xclbin::ip objects. An - * xrt::xclbin::ip object corresponds to an entry in the xclbin - * IP_LAYOUT section, so the xrt::xclbin::kernel object is just a - * grouping of one or more of these. - * - * In some cases the kernel concept is not needed, thus - * xrt::xclbin::ip objects corresponding to entries in the xclbin - * IP_LAYOUT sections can be accessed directly. - * - * An xrt::xclbin::arg object corresponds to one or more entries in - * the xclbin CONNECTIVITY section decorated with additional meta data - * (offset, size, type, etc) from the XML section if available. An - * argument object represents a specific kernel or ip argument. If - * the argument is a global buffer, then it may connect to one or more - * memory objects. - * - * Finally the xrt::xclbin::mem object corresponds to an entry in the - * MEM_TOPOLOGY section of the xclbin. - */ -class xclbin_impl; -class xclbin : public detail::pimpl -{ -public: - /*! - * @enum target_type - * - * @brief - * Type of xclbin - * - * @details - * See `xclbin.h` - */ - enum class target_type { hw, sw_emu, hw_emu }; - -public: - /*! - * @class mem - * - * @brief - * xrt::xclbin::mem represents a physical device memory bank - * - * @details - * A memory object is constructed from an entry in the MEM_TOPOLOGY - * section of an xclbin. - */ - class mem_impl; - class mem : public detail::pimpl - { - public: - /** - * @enum memory_type - type of memory - * - * @details - * See `xclbin.h` - */ - enum class memory_type : uint8_t { - ddr3 = MEM_DDR3, - ddr4 = MEM_DDR4, - dram = MEM_DRAM, - streaming = MEM_STREAMING, - preallocated_global = MEM_PREALLOCATED_GLOB, - are = MEM_ARE, //Aurora - hbm = MEM_HBM, - bram = MEM_BRAM, - uram = MEM_URAM, - streaming_connection = MEM_STREAMING_CONNECTION, - host = MEM_HOST - }; - - public: - mem() = default; - - explicit - mem(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - /** - * get_tag() - Get tag name - * - * @return - * Memory tag name - */ - XRT_API_EXPORT - std::string - get_tag() const; - - /** - * get_base_address() - Get the base address of the memory bank - * - * @return - * Base address of the memory bank, or -1 for invalid base address - */ - XRT_API_EXPORT - uint64_t - get_base_address() const; - - /** - * get_size_kb() - Get the size of the memory in KB - * - * @return - * Size of memory in KB, or -1 for invalid size - */ - XRT_API_EXPORT - uint64_t - get_size_kb() const; - - /** - * get_used() - Get used status of the memory - * - * @return - * True of this memory bank is used by kernels in the xclbin - * or false otherwise. - * - * A value of false indicates that no buffer can be allocated - * in this memory bank. - */ - XRT_API_EXPORT - bool - get_used() const; - - /** - * get_type() - Get the type of the memory - * - * @return - * Memory type - * - */ - XRT_API_EXPORT - memory_type - get_type() const; - - /** - * get_index() - Get the index of the memory - * - * @return - * Index of the memory within the memory topology - * - * The returned index can be used when allocating buffers using - * \ref xrt::bo provided the memory bank is connected / used. - */ - XRT_API_EXPORT - int32_t - get_index() const; - }; - - /*! - * @class arg - * - * @brief - * class arg - xrt::xclbin::arg represents a compute unit argument - * - * @details - * The argument object constructed from the xclbin connectivity - * section. An argument is connected to a memory bank or a memory - * group, which dictates where in device memory a global buffer - * used with this kernel argument must be allocated. - */ - class arg_impl; - class arg : public detail::pimpl - { - public: - arg() = default; - - explicit - arg(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - /** - * get_name() - Get argument name - * - * @return - * Name of argument. - * - */ - XRT_API_EXPORT - std::string - get_name() const; - - /** - * get_mems() - Get list of device memories from xclbin. - * - * @return - * A list of xrt::xclbin::mem objects to which this argument - * is connected. - */ - XRT_API_EXPORT - std::vector - get_mems() const; - - /** - * get_port() - Get port name of this argument - * - * @return - * Port name - */ - XRT_API_EXPORT - std::string - get_port() const; - - /** - * get_size() - Argument size in bytes - * - * @return - * Argument size - */ - XRT_API_EXPORT - uint64_t - get_size() const; - - /** - * get_offset() - Argument offset - * - * @return - * Argument offset - */ - XRT_API_EXPORT - uint64_t - get_offset() const; - - /** - * get_host_type() - Get the argument host type - * - * @return - * Argument host type - */ - XRT_API_EXPORT - std::string - get_host_type() const; - - /** - * get_index() - Get the index of this argument - * - * @return - * Argument index - */ - XRT_API_EXPORT - size_t - get_index() const; - }; - - /*! - * @class ip - * - * @brief - * xrt::xclbin::ip represents a IP in an xclbin. - * - * @details - * The ip corresponds to an entry in the IP_LAYOUT section of the - * xclbin. - */ - class ip_impl; - class ip : public detail::pimpl - { - public: - /** - * @enum control_type - - * - * @details - * See `xclbin.h` - */ - enum class control_type : uint8_t { hs = 0, chain = 1, none = 2, fa = 5 }; - - /** - * @enum ip_type - * - * @details - * See `xclbin.h` - */ - enum class ip_type : uint8_t { pl = IP_KERNEL, ps = IP_PS_KERNEL }; - - public: - ip() = default; - - explicit - ip(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - /** - * get_name() - Get name of IP - * - * @return - * IP name. - */ - XRT_API_EXPORT - std::string - get_name() const; - - /** - * get_type() - Get the IP type - * - * @return - * IP type - */ - XRT_API_EXPORT - ip_type - get_type() const; - - /** - * get_control_type() - Get the IP control protocol - * - * @return - * Control type - */ - XRT_API_EXPORT - control_type - get_control_type() const; - - /** - * get_num_args() - Number of arguments - * - * @return - * Number of arguments for this IP per CONNECTIVITY section - */ - XRT_API_EXPORT - size_t - get_num_args() const; - - /** - * get_args() - Get list of IP arguments - * - * @return - * A list sorted of xclbin::arg sorted by argument indices - * - * An argument may have multiple memory connections - */ - XRT_API_EXPORT - std::vector - get_args() const; - - /** - * get_arg() - Get argument at index. - * - * @param index - * Index of argument - * @return - * The argument a specified index - * - * The argument may have multiple memory connections - */ - XRT_API_EXPORT - arg - get_arg(int32_t index) const; - - /** - * get_base_address() - Get the base address of the cu - * - * @return - * The base address of the IP - */ - XRT_API_EXPORT - uint64_t - get_base_address() const; - - /** - * get_size() - Get the address range size of this IP. - * - * @return - * The size of this IP - * - * The address range is a property of the kernel and - * as such only valid for for kernel compute units. - * - * For IPs that are not associated with a kernel, the - * size return is 0. - */ - XRT_API_EXPORT - size_t - get_size() const; - }; - - /*! - * class kernel - * - * @brief - * xrt::xclbin::kernel represents a kernel in an xclbin. - * - * @details - * The kernel corresponds to an entry in the XML meta data section - * of the xclbin combined with meta data from other xclbin sections. - * The kernel object is implicitly constructed from the xclbin - * object via APIs. - */ - class kernel_impl; - class kernel : public detail::pimpl - { - public: - /** - * @enum kernel_type - * - * The kernel type is extracted from the XML kernel meta data section - */ - enum class kernel_type : uint8_t { none = 0, pl = 1, ps = 2, dpu = 3}; - - public: - kernel() = default; - - explicit - kernel(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - /** - * get_name() - Get kernel name - * - * @return - * The name of the kernel - */ - XRT_API_EXPORT - std::string - get_name() const; - - /** - * get_type() - Get kernel type - * - * @return - * The type of the kernel - */ - XRT_API_EXPORT - kernel_type - get_type() const; - - /** - * get_cus() - Get list of cu from kernel. - * - * @return - * A list of xrt::xclbin::ip objects corresponding the compute units - * for this kernel object. - */ - XRT_API_EXPORT - std::vector - get_cus() const; - - /** - * get_cus() - Get list of compute units that matches name - * - * @param name - * Name to match against, prefixed with kernel name - * @return - * A list of xrt::xclbin::ip objects that are compute units - * of this kernel object and matches the specified name. - * - * The kernel name can optionally specify which kernel instance(s) to - * match "kernel:{cu1,cu2,...} syntax. - */ - XRT_API_EXPORT - std::vector - get_cus(const std::string& name) const; - - /** - * get_cu() - Get compute unit by name - * - * @return - * The xct::xclbin::ip object matching the specified name, or error if - * not present. - */ - XRT_API_EXPORT - ip - get_cu(const std::string& name) const; - - /** - * get_num_args() - Number of arguments - * - * @return - * Number of arguments for this kernel. - */ - XRT_API_EXPORT - size_t - get_num_args() const; - - /** - * get_args() - Get list of kernel arguments - * - * @return - * A list sorted of xclbin::arg sorted by argument indices - * - * An argument may have multiple memory connections - */ - XRT_API_EXPORT - std::vector - get_args() const; - - /** - * get_arg() - Get kernel argument at index. - * - * @return - * The xrt::xclbin::arg object at specified argument index. - * - * The memory connections of an argument is the union of the - * connections for each compute unit for that particular argument. - * In other words, for each connection of the argument returned - * by ``get_arg()`` there is at least one compute unit that has - * that connection. - */ - XRT_API_EXPORT - arg - get_arg(int32_t index) const; - }; - - /// @cond - /** undocumented access to aie metadata, subject to change **/ - class aie_partition_impl; - class aie_partition : detail::pimpl - { - public: - explicit - aie_partition(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - XRT_API_EXPORT - uint64_t - get_inference_fingerprint() const; - - XRT_API_EXPORT - uint64_t - get_pre_post_fingerprint() const; - - XRT_API_EXPORT - uint32_t - get_operations_per_cycle() const; - }; - /// @endcond - -public: - /** - * xclbin() - Construct empty xclbin object - */ - xclbin() = default; - - /// @cond - /** - * xclbin() - Construct from handle - */ - explicit - xclbin(std::shared_ptr handle) - : detail::pimpl(handle) - {} - /// @endcond - - /** - * xclbin() - Constructor from an xclbin filename - * - * - * @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. - */ - XRT_API_EXPORT - explicit - xclbin(const std::string& filename); - - /** - * xclbin() - Constructor from raw data - * - * @param data - * Raw data of xclbin - * - * The raw data of the xclbin can be deleted after calling the - * constructor. - */ - XRT_API_EXPORT - explicit - xclbin(const std::vector& data); - - /** - * xclbin() - Constructor from raw data - * - * @param top - * Raw data of xclbin file as axlf* - * - * The argument axlf is copied by the constructor. - */ - XRT_API_EXPORT - explicit - xclbin(const axlf* top); - - /** - * get_kernels() - Get list of kernels from xclbin. - * - * @return - * A list of xrt::xclbin::kernel from xclbin. - * - * Kernels are extracted from embedded XML metadata in the xclbin. - * A kernel groups one or more compute units. A kernel has arguments - * from which offset, type, etc can be retrived. - */ - XRT_API_EXPORT - std::vector - get_kernels() const; - - /** - * get_kernel() - Get a kernel by name from xclbin - * - * @param name - * Name of kernel to get. - * @return - * The matching kernel from the xclbin or error - * if no matching kernel is found. - * - * A matching kernel is extracted from embedded XML metadata in the - * xclbin. A kernel groups one or more compute units. A kernel has - * arguments from which offset, type, etc can be retrived. - */ - XRT_API_EXPORT - kernel - get_kernel(const std::string& name) const; - - /** - * get_ips() - Get a list of IPs from the xclbin - * - * @return - * A list of xrt::xclbin::ip objects from xclbin. - * - * The returned xrt::xclbin::ip objects are extracted from the - * IP_LAYOUT section of the xclbin. - */ - XRT_API_EXPORT - std::vector - get_ips() const; - - /** - * get_ips() - Get list of ips that matches name - * - * @param name - * Name to match against, prefixed with kernel name - * @return - * A list of xrt::xclbin::ip objects that are compute units - * of this kernel object and matches the specified name. - * - * The kernel name can optionally specify which kernel instance(s) to - * match "kernel:{ip1,ip2,...} syntax. - */ - XRT_API_EXPORT - std::vector - get_ips(const std::string& name) const; - - /** - * get_ip() - Get a specific IP from the xclbin - * - * @return - * A list of xrt::xclbin::ip objects from xclbin. - * - * The returned xrt::xclbin::ip object is extracted from the - * IP_LAYOUT section of the xclbin. - */ - XRT_API_EXPORT - ip - get_ip(const std::string& name) const; - - /** - * get_mems() - Get list of memory objects - * - * @return - * A list of xrt::xclbin::mem objects from xclbin - * - * The returned xrt::xclbin::mem objects are extracted from - * the xclbin. - */ - XRT_API_EXPORT - std::vector - get_mems() const; - - /// @cond - XRT_API_EXPORT - std::vector - get_aie_partitions() const; - /// @endcond - - /** - * get_xsa_name() - Get Xilinx Support Archive (XSA) name of xclbin - * - * @return - * Name of XSA (vbnv name). - * - * An exception is thrown if the data is missing. - */ - XRT_API_EXPORT - std::string - get_xsa_name() const; - - /** - * get_fpga_device_name() - Get FPGA device name - * - * @return - * Name of fpga device per XML metadata. - */ - XRT_API_EXPORT - std::string - get_fpga_device_name() const; - - /** - * get_uuid() - Get the uuid of the xclbin - * - * @return - * UUID of xclbin - * - * An exception is thrown if the data is missing. - */ - XRT_API_EXPORT - uuid - get_uuid() const; - - /** - * get_interface_uuid() - Get the interface uuid of the xclbin - * - * @return - * Interface uuid of the xclbin - * - * An exception is thrown if the data is missing. - */ - XRT_API_EXPORT - uuid - get_interface_uuid() const; - - /** - * get_target_type() - Get the type of this xclbin - * - * @return - * Target type, which can be hw, sw_emu, or hw_emu - */ - XRT_API_EXPORT - target_type - get_target_type() const; - - /// @cond - /** - * get_axlf() - Get the axlf data of the xclbin - * - * @return - * The axlf data of the xclbin object - * - * An exception is thrown if the data is missing. - */ - XRT_API_EXPORT - const axlf* - get_axlf() const; - - /** - * get_axlf_section() - Retrieve specified xclbin section - * - * @param section - * The section to retrieve - * @return - * The specified section if available cast to specified type. - * Note, that this is an unsafe cast, behavior is undefined if the - * specified SectionType is invalid. - * - * The SectionType template parameter is an axlf type from xclbin.h - * and it much match the type of the section data retrieved. - * - * Throws if requested section does not exist in the xclbin. - */ - template - SectionType - get_axlf_section(axlf_section_kind section) const - { - return reinterpret_cast(get_axlf_section(section).first); - } - /// @endcond - -private: - XRT_API_EXPORT - std::pair - get_axlf_section(axlf_section_kind section) const; -}; - -/** - * xclbin_repository - Repository of xclbins - * - * A repository of xclbins is a collection of xclbins that can be - * searched for a specific xclbin through iteration. - * - * The location of a repository is specified by a directory or it - * can be implementations and platform specific. - */ -class xclbin_repository_impl; -class xclbin_repository : public detail::pimpl -{ -public: - /** - * xclbin_repository - Default constructor - * - * Create repository from builtin platform specific repository - * path or paths. - */ - XRT_API_EXPORT - xclbin_repository(); - - /** - * xclbin_repository - - * - * Create repository from specified path. - * - * The specified directory can be an absolute path to a directory or - * it can be a relative path to a directory rooted at the current - * working directory. - */ - XRT_API_EXPORT - explicit - xclbin_repository(const std::string& dir); - - /** - * iterator - Iterator over xclbins in repository - * - * The iterator is a forward iterator that iterates over the - * xclbins in the repository. The iterator dereferences to an - * xrt::xclbin object by value. - */ - class iterator_impl; - class iterator : public detail::pimpl - { - public: - using iterator_category = std::forward_iterator_tag; - using difference_type = std::ptrdiff_t; - using value_type = xclbin; - using pointer = value_type; - using reference = value_type; - - public: - /** - * iterator - Converting default constructor from implmentation - */ - iterator(std::shared_ptr handle) - : detail::pimpl(std::move(handle)) - {} - - /** - * iterator - Copy constructor - * - * Create a copy of an iterator - */ - XRT_API_EXPORT - iterator(const iterator&); - - /** - * Advance iterator to next xclbin - */ - XRT_API_EXPORT - iterator& - operator++(); - - /** - * Advance iterator to next xclbin return old iterator - * - * This is a relatively expensive operation that duplicates - * the internal representation of the original iterator. - */ - XRT_API_EXPORT - iterator - operator++(int); - - /** - * Compare iterators - */ - XRT_API_EXPORT - bool - operator==(const iterator& rhs) const; - - /** - * Compare iterators - */ - bool - operator!=(const iterator& rhs) const - { - return !(*this == rhs); - } - - /** - * Dereference iterator - * - * Returns xrt::xclbin object by value. The xclbin object - * is constructed on the fly. - */ - XRT_API_EXPORT - value_type - operator*() const; - - /** - * Dereference iterator - * - * Returns xrt::xclbin object by value. The xclbin object - * is constructed on the fly. - */ - XRT_API_EXPORT - value_type - operator->() const; - - /** - * Get path to xclbin file path in repository for this iterator - */ - XRT_API_EXPORT - std::string - path() const; - }; - - /** - * begin() - Get iterator to first xclbin in repository - */ - XRT_API_EXPORT - iterator - begin() const; - - /** - * end() - Get iterator to end of xclbin repository - */ - XRT_API_EXPORT - iterator - end() const; - - /** - * load() - Load xclbin from repository - */ - XRT_API_EXPORT - xclbin - load(const std::string& name) const; -}; - -} // namespace xrt - -/// @cond -extern "C" { -#endif - -/** - * xrtXclbinAllocFilename() - Allocate a xclbin using xclbin filename - * - * @filename: path to the xclbin file - * Return: xrtXclbinHandle on success or NULL with errno set - */ -XRT_API_EXPORT -xrtXclbinHandle -xrtXclbinAllocFilename(const char* filename); - - -/** - * xrtXclbinAllocAxlf() - Allocate a xclbin using an axlf - * - * @top_axlf: an axlf - * Return: xrtXclbinHandle on success or NULL with errno set - */ -XRT_API_EXPORT -xrtXclbinHandle -xrtXclbinAllocAxlf(const struct axlf* top_axlf); - -/** - * xrtXclbinAllocRawData() - Allocate a xclbin using raw data - * - * @data: raw data buffer of xclbin - * @size: size (in bytes) of raw data buffer of xclbin - * Return: xrtXclbinHandle on success or NULL with errno set - */ -XRT_API_EXPORT -xrtXclbinHandle -xrtXclbinAllocRawData(const char* data, int size); - -/** - * xrtXclbinFreeHandle() - Deallocate the xclbin handle - * - * @xhdl: xclbin handle - * Return: 0 on success, -1 on error - */ -XRT_API_EXPORT -int -xrtXclbinFreeHandle(xrtXclbinHandle xhdl); - -/** - * xrtXclbinGetXSAName() - Get Xilinx Support Archive (XSA) Name of xclbin handle - * - * @xhdl: Xclbin handle - * @name: Return name of XSA. - * If the value is nullptr, the content of this value will not be populated. - * Otherwise, the the content of this value will be populated. - * @size: size (in bytes) of @name. - * @ret_size: Return size (in bytes) of XSA name. - * If the value is nullptr, the content of this value will not be populated. - * Otherwise, the the content of this value will be populated. - * Return: 0 on success or appropriate error number - */ -XRT_API_EXPORT -int -xrtXclbinGetXSAName(xrtXclbinHandle xhdl, char* name, int size, int* ret_size); - -/** - * xrtXclbinGetUUID() - Get UUID of xclbin handle - * - * @xhdl: Xclbin handle - * @ret_uuid: Return xclbin id in this uuid_t struct - * Return: 0 on success or appropriate error number - */ -XRT_API_EXPORT -int -xrtXclbinGetUUID(xrtXclbinHandle xhdl, xuid_t ret_uuid); - -/** - * xrtXclbinGetNumKernels() - Get number of PL kernels in xclbin - * - * @xhdl: Xclbin handle obtained from an xrtXclbinAlloc function - * Return: The number of PL kernels in the xclbin - * - * Kernels are extracted from embedded XML metadata in the xclbin. - * A kernel groups one or more compute units. A kernel has arguments - * from which offset, type, etc can be retrived. - */ -XRT_API_EXPORT -size_t -xrtXclbinGetNumKernels(xrtXclbinHandle xhdl); - -/** - * xrtXclbinGetNumKernelComputeUnits() - Get number of CUs in xclbin - * - * @xhdl: Xclbin handle obtained from an xrtXclbinAlloc function - * Return: The number of compute units - * - * Compute units are associated with kernels. This function returns - * the total number of compute units as the sum of compute units over - * all kernels. - */ -XRT_API_EXPORT -size_t -xrtXclbinGetNumKernelComputeUnits(xrtXclbinHandle xhdl); - -/** - * xrtXclbinGetData() - Get the raw data of the xclbin handle - * - * @xhdl: Xclbin handle - * @data: Return raw data. - * If the value is nullptr, the content of this value will not be populated. - * Otherwise, the the content of this value will be populated. - * @size: Size (in bytes) of @data - * @ret_size: Return size (in bytes) of XSA name. - * If the value is nullptr, the content of this value will not be populated. - * Otherwise, the the content of this value will be populated. - * Return: 0 on success or appropriate error number - */ -XRT_API_EXPORT -int -xrtXclbinGetData(xrtXclbinHandle xhdl, char* data, int size, int* ret_size); - -/* - * xrtGetXclbinUUID() - Get UUID of xclbin image running on device - * - * @dhdl: Device handle - * @out: Return xclbin id in this uuid_t struct - * Return: 0 on success or appropriate error number - */ -XRT_API_EXPORT -int -xrtXclbinUUID(xclDeviceHandle dhdl, xuid_t out); - -/// @endcond -#ifdef __cplusplus -} -#endif - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#pragma message("please replace experimental/xrt_xclbin.h with xrt/experimental/xrt_xclbin.h") +#include "xrt/experimental/xrt_xclbin.h" diff --git a/src/runtime_src/core/include/types.h b/src/runtime_src/core/include/types.h index 91929d5af06..544d574677f 100644 --- a/src/runtime_src/core/include/types.h +++ b/src/runtime_src/core/include/types.h @@ -18,8 +18,8 @@ #define core_include_types_h_ #if defined(_WIN32) -# include "windows/types.h" -# include "windows/uuid.h" +# include "xrt/detail/windows/types.h" +# include "xrt/detail/windows/uuid.h" #endif #endif diff --git a/src/runtime_src/core/include/unittests/xrt_c_compilation/main.c b/src/runtime_src/core/include/unittests/xrt_c_compilation/main.c index b9fb5ce3f94..79735210154 100644 --- a/src/runtime_src/core/include/unittests/xrt_c_compilation/main.c +++ b/src/runtime_src/core/include/unittests/xrt_c_compilation/main.c @@ -6,13 +6,12 @@ /* * Test C compilation with xrt header files */ -#include "core/include/xrt.h" #include "core/include/xrt/xrt_aie.h" #include "core/include/xrt/xrt_bo.h" #include "core/include/xrt/xrt_device.h" #include "core/include/xrt/xrt_kernel.h" #include "core/include/xrt/xrt_uuid.h" #include "core/include/xrt/xrt_graph.h" -#include "core/include/experimental/xrt_error.h" -#include "core/include/experimental/xrt_ini.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_error.h" +#include "core/include/xrt/experimental/xrt_ini.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" diff --git a/src/runtime_src/core/include/windows/CMakeLists.txt b/src/runtime_src/core/include/windows/CMakeLists.txt deleted file mode 100644 index 489a9b9c92a..00000000000 --- a/src/runtime_src/core/include/windows/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# -set(XRT_WINDOWS_HEADER_SRC - types.h - uuid.h) - -install (FILES ${XRT_WINDOWS_HEADER_SRC} DESTINATION ${XRT_INSTALL_DIR}/include/windows) - -message("-- XRT OS native header files") -foreach (header ${XRT_WINDOWS_HEADER_SRC}) - message("-- ${header}") -endforeach() diff --git a/src/runtime_src/core/include/xclbin.h b/src/runtime_src/core/include/xclbin.h index b4658086555..4fabad61f52 100644 --- a/src/runtime_src/core/include/xclbin.h +++ b/src/runtime_src/core/include/xclbin.h @@ -1,695 +1,6 @@ -/** - * Copyright (C) 2015-2024, Advanced Micro Devices, Inc. All rights Reserved. - * - * This file is dual licensed. It may be redistributed and/or modified - * under the terms of the Apache 2.0 License OR version 2 of the GNU - * General Public License. - * - * Apache License Verbiage - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * GPL license Verbiage: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. -#ifndef _XCLBIN_H_ -#define _XCLBIN_H_ - -#if defined(__linux__) -# if defined(__KERNEL__) -# include -# include -# include -# elif defined(__cplusplus) -# include -# include -# include -# include -# else -# include -# include -# include -# endif -#elif defined(_WIN32) -# if defined(_KERNEL_MODE) -# include -# include -# elif defined(__cplusplus) -# include -# include -# include -# include -# else -# include -# include -# include -# endif -#endif - -#if defined(__linux__) && defined(__KERNEL__) -# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) -typedef uuid_t xuid_t; -# elif defined(RHEL_RELEASE_CODE) -# if RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7,4) -typedef uuid_t xuid_t; -# else -typedef uuid_le xuid_t; -# endif -# else -typedef uuid_le xuid_t; -# endif -#elif defined(__linux__) && !defined(__KERNEL__) -typedef uuid_t xuid_t; -#elif defined(_WIN32) && defined(_KERNEL_MODE) -typedef GUID xuid_t; -#endif - -// ----------------- Custom Assert Macro ------------------------- -// The xclbin.h header file is used both by the driver and host -// applications/libraries. For C++ static_assert() would be used, but -// for the the drivers (e.g., linux) a more custom solution is needed -// e.g., BUILD_BUG_ON_ZERO()). Instead of creating a wrapper around the -// various OS builds, a custom assert (based on the linux assert) is used. - -#ifdef __cplusplus - // Used C++ static assert - #define XCLBIN_STATIC_ASSERT(e,m) \ - static_assert (e, m) -#else - // Use our "custom" kernel compilation assert - #define XLCBIN_ASSERT_CONCAT_(a, b) a##b - #define XLCBIN_ASSERT_CONCAT(a, b) XLCBIN_ASSERT_CONCAT_(a, b) - - // Create an artifitial assertion via a bad divide by zero assertion. - #define XCLBIN_STATIC_ASSERT(e,m) \ - enum { XLCBIN_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) } -#endif - -// *** Helper macro *** -// Reports a size of structure via an error -#define SIZE_OF_STRUCT(s) \ - char (*__fail)[sizeof(struct s)] = 1 - -#ifdef __cplusplus -extern "C" { -#endif - - /** - * Container format for Xilinx bitstreams, metadata and other - * binary blobs. - * Every segment must be aligned at 8 byte boundary with null byte padding - * between adjacent segments if required. - * For segements which are not present both offset and length must be 0 in - * the header. - * Currently only xclbin0\0 is recognized as file magic. In future if/when file - * format is updated the magic string will be changed to xclbin1\0 and so on. - */ - enum XCLBIN_MODE { - XCLBIN_FLAT, - XCLBIN_PR, - XCLBIN_TANDEM_STAGE2, - XCLBIN_TANDEM_STAGE2_WITH_PR, - XCLBIN_HW_EMU, - XCLBIN_SW_EMU, - XCLBIN_HW_EMU_PR, - XCLBIN_MODE_MAX - }; - - /* - * AXLF LAYOUT - * ----------- - * - * ----------------------------------------- - * | Magic | - * ----------------------------------------- - * | Header | - * ----------------------------------------- - * | One or more section headers | - * ----------------------------------------- - * | Matching number of sections with data | - * ----------------------------------------- - * - */ - - enum axlf_section_kind { - BITSTREAM = 0, - CLEARING_BITSTREAM = 1, - EMBEDDED_METADATA = 2, - FIRMWARE = 3, - DEBUG_DATA = 4, - SCHED_FIRMWARE = 5, - MEM_TOPOLOGY = 6, - CONNECTIVITY = 7, - IP_LAYOUT = 8, - DEBUG_IP_LAYOUT = 9, - DESIGN_CHECK_POINT = 10, - CLOCK_FREQ_TOPOLOGY = 11, - MCS = 12, - BMC = 13, - BUILD_METADATA = 14, - KEYVALUE_METADATA = 15, - USER_METADATA = 16, - DNA_CERTIFICATE = 17, - PDI = 18, - BITSTREAM_PARTIAL_PDI = 19, - PARTITION_METADATA = 20, - EMULATION_DATA = 21, - SYSTEM_METADATA = 22, - SOFT_KERNEL = 23, - ASK_FLASH = 24, - AIE_METADATA = 25, - ASK_GROUP_TOPOLOGY = 26, - ASK_GROUP_CONNECTIVITY = 27, - SMARTNIC = 28, - AIE_RESOURCES = 29, - OVERLAY = 30, - VENDER_METADATA = 31, - AIE_PARTITION = 32, - IP_METADATA = 33, - AIE_RESOURCES_BIN = 34, - AIE_TRACE_METADATA = 35, - }; - - enum MEM_TYPE { - MEM_DDR3, - MEM_DDR4, - MEM_DRAM, - MEM_STREAMING, - MEM_PREALLOCATED_GLOB, - MEM_ARE, //Aurora - MEM_HBM, - MEM_BRAM, - MEM_URAM, - MEM_STREAMING_CONNECTION, - MEM_HOST, - MEM_PS_KERNEL, - }; - - enum IP_TYPE { - IP_MB = 0, - IP_KERNEL, //kernel instance - IP_DNASC, - IP_DDR4_CONTROLLER, - IP_MEM_DDR4, - IP_MEM_HBM, - IP_MEM_HBM_ECC, - IP_PS_KERNEL, - }; - - enum ACTION_MASK { - AM_LOAD_AIE = 0x1, /* Indicates to the driver to load the AIE PID section */ - AM_LOAD_PDI = 0x2, /* Indicates to the driver to program the PDI */ - }; - - struct axlf_section_header { - uint32_t m_sectionKind; /* Section type */ - char m_sectionName[16]; /* Examples: "stage2", "clear1", "clear2", "ocl1", "ocl2, "ublaze", "sched" */ - uint64_t m_sectionOffset; /* File offset of section data */ - uint64_t m_sectionSize; /* Size of section data */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct axlf_section_header) == 40, "axlf_section_header structure no longer is 40 bytes in size"); - - struct axlf_header { - uint64_t m_length; /* Total size of the xclbin file */ - uint64_t m_timeStamp; /* Number of seconds since epoch when xclbin was created */ - uint64_t m_featureRomTimeStamp; /* TimeSinceEpoch of the featureRom */ - uint16_t m_versionPatch; /* Patch Version */ - uint8_t m_versionMajor; /* Major Version - Version: 2.1.0*/ - uint8_t m_versionMinor; /* Minor Version */ - uint16_t m_mode; /* XCLBIN_MODE */ - uint16_t m_actionMask; /* Bit Mask */ - unsigned char m_interface_uuid[16]; /* Interface uuid of this xclbin */ - unsigned char m_platformVBNV[64]; /* e.g. xilinx:xil-accel-rd-ku115:4ddr-xpr:3.4: null terminated */ - union { - char m_next_axlf[16]; /* Name of next xclbin file in the daisy chain */ - xuid_t uuid; /* uuid of this xclbin*/ - }; - char m_debug_bin[16]; /* Name of binary with debug information */ - uint32_t m_numSections; /* Number of section headers */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct axlf_header) == 152, "axlf_header structure no longer is 152 bytes in size"); - #define XCLBIN_MAX_NUM_SECTION 0x10000 - - struct axlf { - char m_magic[8]; /* Should be "xclbin2\0" */ - int32_t m_signature_length; /* Length of the signature. -1 indicates no signature */ - unsigned char reserved[28]; /* Note: Initialized to 0xFFs */ - - unsigned char m_keyBlock[256]; /* Signature for validation of binary */ - uint64_t m_uniqueId; /* axlf's uniqueId, use it to skip redownload etc */ - struct axlf_header m_header; /* Inline header */ - struct axlf_section_header m_sections[1]; /* One or more section headers follow */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct axlf) == 496, "axlf structure no longer is 496 bytes in size"); - - typedef struct axlf xclBin; - - /**** BEGIN : Xilinx internal section *****/ - - /* bitstream information */ - struct xlnx_bitstream { - uint8_t m_freq[8]; - char bits[1]; - }; - XCLBIN_STATIC_ASSERT(sizeof(struct xlnx_bitstream) == 9, "xlnx_bitstream structure no longer is 9 bytes in size"); - - - /**** MEMORY TOPOLOGY SECTION ****/ - struct mem_data { - uint8_t m_type; // enum corresponding to mem_type. - uint8_t m_used; // if 0 this bank is not present - uint8_t padding[6]; // 8 Byte alignment padding (initialized to zeros) - union { - uint64_t m_size; // if mem_type DDR, then size in KB; - uint64_t route_id; // if streaming then "route_id" - }; - union { - uint64_t m_base_address; // if DDR then the base address; - uint64_t flow_id; // if streaming then "flow id" - }; - unsigned char m_tag[16]; // DDR: BANK0,1,2,3, has to be null terminated; if streaming then stream0, 1 etc - }; - XCLBIN_STATIC_ASSERT(sizeof(struct mem_data) == 40, "mem_data structure no longer is 40 bytes in size"); - - struct mem_topology { - int32_t m_count; //Number of mem_data - struct mem_data m_mem_data[1]; //Should be sorted on mem_type - }; - XCLBIN_STATIC_ASSERT(sizeof(struct mem_topology) == 48, "mem_topology structure no longer is 48 bytes in size"); - - - /**** CONNECTIVITY SECTION ****/ - /* Connectivity of each argument of Kernel. It will be in terms of argument - * index associated. For associating kernel instances with arguments and - * banks, start at the connectivity section. Using the m_ip_layout_index - * access the ip_data.m_name. Now we can associate this kernel instance - * with its original kernel name and get the connectivity as well. This - * enables us to form related groups of kernel instances. - */ - - struct connection { - int32_t arg_index; //From 0 to n, may not be contiguous as scalars skipped - int32_t m_ip_layout_index; //index into the ip_layout section. ip_layout.m_ip_data[index].m_type == IP_KERNEL - int32_t mem_data_index; //index of the m_mem_data . Flag error is m_used false. - }; - XCLBIN_STATIC_ASSERT(sizeof(struct connection) == 12, "connection structure no longer is 12 bytes in size"); - - struct connectivity { - int32_t m_count; - struct connection m_connection[1]; - }; - XCLBIN_STATIC_ASSERT(sizeof(struct connectivity) == 16, "connectivity structure no longer is 16 bytes in size"); - - /**** IP_LAYOUT SECTION ****/ - - // IP Kernel - #define IP_INT_ENABLE_MASK 0x0001 - #define IP_INTERRUPT_ID_MASK 0x00FE - #define IP_INTERRUPT_ID_SHIFT 0x1 - - enum IP_CONTROL { - AP_CTRL_HS = 0, - AP_CTRL_CHAIN = 1, - AP_CTRL_NONE = 2, - AP_CTRL_ME = 3, - ACCEL_ADAPTER = 4, - FAST_ADAPTER = 5 - }; - - // m_subtype - enum PS_SUBTYPE { - ST_PS = 0, - ST_DPU = 1, - }; - - // m_functional - enum PS_FUNCTIONAL { - FC_DPU = 0, - FC_PREPOST = 1, - }; - - #define IP_CONTROL_MASK 0xFF00 - #define IP_CONTROL_SHIFT 0x8 - - /* IPs on AXI lite - their types, names, and base addresses.*/ - struct ip_data { - uint32_t m_type; //map to IP_TYPE enum - union { - uint32_t properties; // Default: 32-bits to indicate ip specific property. - // m_type: IP_KERNEL - // m_int_enable : Bit - 0x0000_0001; - // m_interrupt_id : Bits - 0x0000_00FE; - // m_ip_control : Bits = 0x0000_FF00; - // properties is also used for ps kernel (i.e. -add-pskernel) - - // PS Kernels - // m_type: IP_PS_KERNEL - struct { - uint16_t m_subtype : 2; // Bits - 0x0003 - PS_SUBTYPE enum values - uint16_t : 2; // Bits - 0x000C - Future use - uint16_t m_functional : 2; // Bits - 0x0030 - PS_FUNCTIONAL enum values - uint16_t : 10; // Bits - 0xFFC0 - Future use - uint16_t m_kernel_id : 12; // Bits - 0x0FFF - uint16_t : 4; // Bits - 0xF000 - Future use - } ps_kernel; - - struct { // m_type: IP_MEM_* - uint16_t m_index; - uint8_t m_pc_index; - uint8_t unused; - } indices; - }; - uint64_t m_base_address; - uint8_t m_name[64]; //eg Kernel name corresponding to KERNEL instance, can embed CU name in future. - }; - XCLBIN_STATIC_ASSERT(sizeof(struct ip_data) == 80, "ip_data structure no longer is 80 bytes in size"); - - struct ip_layout { - int32_t m_count; - struct ip_data m_ip_data[1]; //All the ip_data needs to be sorted by m_base_address. - }; - XCLBIN_STATIC_ASSERT(sizeof(struct ip_layout) == 88, "ip_layout structure no longer is 88 bytes in size"); - - /*** Debug IP section layout ****/ - enum DEBUG_IP_TYPE { - UNDEFINED = 0, - LAPC, - ILA, - AXI_MM_MONITOR, - AXI_TRACE_FUNNEL, - AXI_MONITOR_FIFO_LITE, - AXI_MONITOR_FIFO_FULL, - ACCEL_MONITOR, - AXI_STREAM_MONITOR, - AXI_STREAM_PROTOCOL_CHECKER, - TRACE_S2MM, - AXI_DMA, - TRACE_S2MM_FULL, - AXI_NOC, - ACCEL_DEADLOCK_DETECTOR, - HSDP_TRACE, - DEBUG_IP_TYPE_MAX - }; - - struct debug_ip_data { - uint8_t m_type; // type of enum DEBUG_IP_TYPE - uint8_t m_index_lowbyte; - uint8_t m_properties; - uint8_t m_major; - uint8_t m_minor; - uint8_t m_index_highbyte; - uint8_t m_reserved[2]; - uint64_t m_base_address; - char m_name[128]; - }; - XCLBIN_STATIC_ASSERT(sizeof(struct debug_ip_data) == 144, "debug_ip_data structure no longer is 144 bytes in size"); - - struct debug_ip_layout { - uint16_t m_count; - struct debug_ip_data m_debug_ip_data[1]; - }; - XCLBIN_STATIC_ASSERT(sizeof(struct debug_ip_layout) == 152, "debug_ip_layout structure no longer is 152 bytes in size"); - - enum CLOCK_TYPE { /* Supported clock frequency types */ - CT_UNUSED = 0, /* Initialized value */ - CT_DATA = 1, /* Data clock */ - CT_KERNEL = 2, /* Kernel clock */ - CT_SYSTEM = 3 /* System Clock */ - }; - - struct clock_freq { /* Clock Frequency Entry */ - uint16_t m_freq_Mhz; /* Frequency in MHz */ - uint8_t m_type; /* Clock type (enum CLOCK_TYPE) */ - uint8_t m_unused[5]; /* Not used - padding */ - char m_name[128]; /* Clock Name */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct clock_freq) == 136, "clock_freq structure no longer is 136 bytes in size"); - - struct clock_freq_topology { /* Clock frequency section */ - int16_t m_count; /* Number of entries */ - struct clock_freq m_clock_freq[1]; /* Clock array */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct clock_freq_topology) == 138, "clock_freq_topology structure no longer is 138 bytes in size"); - - enum MCS_TYPE { /* Supported MCS file types */ - MCS_UNKNOWN = 0, /* Initialized value */ - MCS_PRIMARY = 1, /* The primary mcs file data */ - MCS_SECONDARY = 2, /* The secondary mcs file data */ - }; - - struct mcs_chunk { /* One chunk of MCS data */ - uint8_t m_type; /* MCS data type */ - uint8_t m_unused[7]; /* padding */ - uint64_t m_offset; /* data offset from the start of the section */ - uint64_t m_size; /* data size */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct mcs_chunk) == 24, "mcs_chunk structure no longer is 24 bytes in size"); - - struct mcs { /* MCS data section */ - int8_t m_count; /* Number of chunks */ - int8_t m_unused[7]; /* padding */ - struct mcs_chunk m_chunk[1]; /* MCS chunks followed by data */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct mcs) == 32, "mcs structure no longer is 32 bytes in size"); - - struct bmc { /* bmc data section */ - uint64_t m_offset; /* data offset from the start of the section */ - uint64_t m_size; /* data size (bytes)*/ - char m_image_name[64]; /* Name of the image (e.g., MSP432P401R) */ - char m_device_name[64]; /* Device ID (e.g., VCU1525) */ - char m_version[64]; - char m_md5value[33]; /* MD5 Expected Value(e.g., 56027182079c0bd621761b7dab5a27ca)*/ - char m_padding[7]; /* Padding */ - }; - XCLBIN_STATIC_ASSERT(sizeof(struct bmc) == 248, "bmc structure no longer is 248 bytes in size"); - - struct soft_kernel { /* soft kernel data section */ - // Prefix Syntax: - // mpo - member, pointer, offset - // This variable represents a zero terminated string - // that is offseted from the beginning of the section. - // - // The pointer to access the string is initialized as follows: - // char * pCharString = (address_of_section) + (mpo value) - uint32_t mpo_name; // Name of the soft kernel - uint32_t m_image_offset; // Image offset - uint32_t m_image_size; // Image size - uint32_t mpo_version; // Version - uint32_t mpo_md5_value; // MD5 checksum - uint32_t mpo_symbol_name; // Symbol name - uint32_t m_num_instances; // Number of instances - uint8_t padding[36]; // Reserved for future use - uint8_t reservedExt[16]; // Reserved for future extended data - }; - XCLBIN_STATIC_ASSERT(sizeof(struct soft_kernel) == 80, "soft_kernel structure no longer is 80 bytes in size"); - - struct aie_resources_bin { /* aie_resources_bin data section */ - // Prefix Syntax: - // mpo - member, pointer, offset - // This variable represents a zero terminated string - // that is offseted from the beginning of the section. - // - // The pointer to access the string is initialized as follows: - // char * pCharString = (address_of_section) + (mpo value) - uint32_t mpo_name; // Name of the aie_resources_bin section - uint32_t m_image_offset; // Image offset - uint32_t m_image_size; // Image size - uint32_t mpo_version; // Version - uint32_t m_start_column; // Start column - uint32_t m_num_columns; // Number of columns - uint8_t padding[36]; // Reserved for future use - uint8_t reservedExt[16]; // Reserved for future extended data - }; - XCLBIN_STATIC_ASSERT(sizeof(struct aie_resources_bin) == 76, "aie_resources_bin structure no longer is 76 bytes in size"); - - enum FLASH_TYPE - { - FLT_UNKNOWN = 0, - FLT_BIN_PRIMARY - }; - - struct flash { /* flash data section */ - // Prefix Syntax: - // mpo - member, pointer, offset - // This variable represents a zero terminated string - // that is offseted from the beginning of the section. - // - // The pointer to access the string is initialized as follows: - // char * pCharString = (address_of_section) + (mpo value) - uint16_t m_flash_type; // ENUM FLASH_TYPE - uint8_t padding[2]; // Alignment buffer - uint32_t m_image_offset; // Image offset - uint32_t m_image_size; // Image size - uint32_t mpo_name; // Name of the flash image - uint32_t mpo_version; // Version - uint32_t mpo_md5_value; // MD5 checksum - uint8_t reserved[32]; // Reserved for future use - uint8_t reservedExt[16]; // Reserved for future extended data - }; - XCLBIN_STATIC_ASSERT(sizeof(struct flash) == 72, "flash structure no longer is 72 bytes in size"); - - enum CHECKSUM_TYPE - { - CST_UNKNOWN = 0, - CST_SDBM = 1, - CST_LAST - }; - - struct vender_metadata { /* vender metadata section */ - // Prefix Syntax: - // mpo - member, pointer, offset - // This variable represents a zero terminated string - // that is offseted from the beginning of the section. - // - // The pointer to access the string is initialized as follows: - // char * pCharString = (address_of_section) + (mpo value) - uint32_t mpo_name; // Name of the the vender metadata section - uint32_t m_image_offset; // Image offset - uint32_t m_image_size; // Image size - uint8_t padding[36]; // Reserved for future use - }; - XCLBIN_STATIC_ASSERT(sizeof(struct vender_metadata) == 48, "vender metadata kernel structure no longer is 48 bytes in size"); - - - struct array_offset { - uint32_t size; // Number of elements in the array - uint32_t offset; // Array offset from the start of the section - }; - - XCLBIN_STATIC_ASSERT(sizeof(struct array_offset) == 8, "array_offset structure no longer is 8 bytes in size"); - - enum CDO_Type { - CT_UNKNOWN = 0, - CT_PRIMARY = 1, - CT_LITE = 2, - CT_PREPOST = 3 - }; - - struct cdo_group { - uint32_t mpo_name; // Name of the CDO group (Null terminated string) - uint8_t cdo_type; // CDO group type (CDO_Type) - uint8_t padding[3]; - uint64_t pdi_id; // PDI ID - struct array_offset dpu_kernel_ids; // Array of dpu_kernel_ids (uint64_t) - struct array_offset pre_cdo_groups; // Array of Pre CDO Group IDs (uint32_t) - uint8_t reserved[64]; // Reserved - }; - XCLBIN_STATIC_ASSERT(sizeof(struct cdo_group) == 96, "cdo_group structure no longer is 96 bytes in size"); - XCLBIN_STATIC_ASSERT(sizeof(struct cdo_group) % sizeof(uint64_t) == 0, "cdo_group structure needs to be 64-bit word aligned"); - - // 32KB per tile, 64 rows * 64 columns - #define PDI_IMAGE_MAX_SIZE 32*1024*64*64 - struct aie_pdi { - xuid_t uuid; // PDI container UUID (16 bytes) - struct array_offset pdi_image; // PDI Image (uint8_t) - struct array_offset cdo_groups; // Array of cdo_groups (cdo_group) - uint8_t reserved[64]; // Reserved - }; - - XCLBIN_STATIC_ASSERT(sizeof(struct aie_pdi) == 96, "aie_pdi structure no longer is 96 bytes in size"); - XCLBIN_STATIC_ASSERT(sizeof(struct aie_pdi) % sizeof(uint64_t) == 0, "aie_pdi structure needs to be 64-bit word aligned"); - - struct aie_partition_info { - uint16_t column_width; // Width of the partition - uint8_t padding[6]; // Byte alignment - struct array_offset start_columns; // Array of start column identifiers (uint16_t) - uint8_t reserved[72]; // Reserved - }; - XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition_info) == 88, "partition_info structure no longer is 88 bytes in size"); - - struct aie_partition { - uint8_t schema_version; // Group schema version (default 0) - uint8_t padding0[3]; // Byte alignment - uint32_t mpo_name; // Name of the aie_partition - uint32_t operations_per_cycle; // Operations per cycle. Used later to create TOPS (operations_per_cycle * ) - uint8_t padding[4]; - uint64_t inference_fingerprint; // The unique hash value of the inference function - uint64_t pre_post_fingerprint; // The unique hash value of pre post - struct aie_partition_info info; // Partition information - struct array_offset aie_pdi; // PDI Array (aie_partition_info) - // kernel_commit_id is modeled after mpo_name - // This variable represents a zero terminated string - // that is offseted from the beginning of the section. - // - // The pointer to access the string is initialized as follows: - // char * pCharString = (address_of_section) + (mpo value) - uint32_t kernel_commit_id; // The git repo commit id for DPU_PHX_KERNEL - uint8_t reserved[52]; // Reserved - }; - XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) == 184, "aie_partition structure no longer is 184 bytes in size"); - XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) % sizeof(uint64_t) == 0, "aie_partition structure needs to be 64-bit word aligned"); - - /**** END : Xilinx internal section *****/ - -# if defined(__cplusplus) && !defined(__KERNEL__) && !defined(_KERNEL_MODE) - namespace xclbin { - inline const axlf_section_header* - get_axlf_section(const axlf* top, axlf_section_kind kind) - { - auto begin = top->m_sections; - auto end = begin + top->m_header.m_numSections; - auto itr = std::find_if(begin,end,[kind](const axlf_section_header& sec) { return sec.m_sectionKind == static_cast(kind); }); - return (itr!=end) ? &(*itr) : nullptr; - } - - // Helper C++ section iteration - // To keep with with the current "coding" them, the function get_axlf_section_next() was - // introduced find 'next' common section names. - // - // Future TODO: Create a custom iterator and refactor the code base to use it. - // - // Example on how this function may be used: - // - // const axlf_section_header * pSection; - // const axlf* top = ; - // for (pSection = xclbin::get_axlf_section( top, SOFT_KERNEL); - // pSection != nullptr; - // pSection = xclbin::get_axlf_section_next( top, pSection, SOFT_KERNEL)) { - // - // } - inline const axlf_section_header* - get_axlf_section_next(const axlf* top, const axlf_section_header* current_section, axlf_section_kind kind) - { - if (top == nullptr) { return nullptr; } - if (current_section == nullptr) { return nullptr; } - - auto end = top->m_sections + top->m_header.m_numSections; - - auto begin = current_section + 1; // Point to the next section - if (begin == end) { return nullptr; } - - auto itr = std::find_if(begin, end, [kind](const axlf_section_header &sec) {return sec.m_sectionKind == static_cast(kind); }); - return (itr!=end) ? &(*itr) : nullptr; - } - } -# endif - -#ifdef __cplusplus -} -#endif - -#endif +// The content of this file has moved. This file is no longer +// exported but is used internally within XRT in files built by DKMS +#include "xrt/detail/xclbin.h" diff --git a/src/runtime_src/core/include/xclerr.h b/src/runtime_src/core/include/xclerr.h index 30c592e5c32..253def4a043 100644 --- a/src/runtime_src/core/include/xclerr.h +++ b/src/runtime_src/core/include/xclerr.h @@ -1,91 +1,3 @@ -/* - * Copyright (C) 2017 Xilinx, Inc - * Author: Umang Parekh - * - * This file is dual licensed. It may be redistributed and/or modified - * under the terms of the Apache 2.0 License OR version 2 of the GNU - * General Public License. - * - * Apache License Verbiage - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * GPL license Verbiage: - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the Free Software Foundation; - * either version 2 of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * DOC: Device error status related structs and defines - * This file is used by both userspace and xclmgmt kernel driver. - */ - -#ifndef XCLERR_H_ -#define XCLERR_H_ - -/** - * enum xclFirewallID - AXI Firewall IDs used to identify individual AXI Firewalls - * - * @XCL_FW_MGMT_CONTROL: MGMT BAR AXI-Lite BAR access protection - * @XCL_FW_USER_CONTROL: USER BAR AXI-Lite BAR access protection - * @XCL_FW_DATAPATH: DMA data path protection - */ -enum xclFirewallID { - XCL_FW_MGMT_CONTROL = 0, - XCL_FW_USER_CONTROL, - XCL_FW_DATAPATH, - XCL_FW_MAX_LEVEL // always the last one -}; - -/** - * struct xclAXIErrorStatus - Record used to capture specific error - * - * @mErrFirewallTime: Timestamp of when Firewall tripped - * @mErrFirewallStatus: Error code obtained from the Firewall - * @mErrFirewallID: Firewall ID - */ -struct xclAXIErrorStatus { - unsigned long mErrFirewallTime; - unsigned mErrFirewallStatus; - enum xclFirewallID mErrFirewallID; -}; - -struct xclPCIErrorStatus { - unsigned mDeviceStatus; - unsigned mUncorrErrStatus; - unsigned mCorrErrStatus; - unsigned rsvd1; - unsigned rsvd2; -}; - -/** - * struct xclErrorStatus - Container for all error records - * - * @mNumFirewalls: Count of Firewalls in the record (max is 8) - * @mAXIErrorStatus: Records holding Firewall information - * @mPCIErrorStatus: Unused - */ -struct xclErrorStatus { - unsigned mNumFirewalls; - struct xclAXIErrorStatus mAXIErrorStatus[8]; - struct xclPCIErrorStatus mPCIErrorStatus; - unsigned mFirewallLevel; -}; - -#endif /* XCLERR_H_ */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#include "xrt/deprecated/xclerr.h" diff --git a/src/runtime_src/core/include/xclhal2.h b/src/runtime_src/core/include/xclhal2.h index beac0ba5733..d03d305e464 100644 --- a/src/runtime_src/core/include/xclhal2.h +++ b/src/runtime_src/core/include/xclhal2.h @@ -24,6 +24,6 @@ */ #include "xrt.h" -#include "experimental/xrt-next.h" +#include "xrt/experimental/xrt-next.h" #endif diff --git a/src/runtime_src/core/include/xrt.h b/src/runtime_src/core/include/xrt.h index dabc3cd27dc..4d50d8c52aa 100644 --- a/src/runtime_src/core/include/xrt.h +++ b/src/runtime_src/core/include/xrt.h @@ -1,24 +1,4 @@ -/* - * Copyright (C) 2015-2022, Xilinx Inc - All rights reserved - * Copyright (C) 2022 Advanced Micro Devices, Inc. - All rights reserved - * Xilinx Runtime (XRT) APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#ifndef _XCL_XRT_CORE_H_ -#define _XCL_XRT_CORE_H_ - -#include "deprecated/xrt.h" - -#endif +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2015-2022, Xilinx Inc - All rights reserved +// Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved. +#include "xrt/deprecated/xrt.h" diff --git a/src/runtime_src/core/include/xrt/CMakeLists.txt b/src/runtime_src/core/include/xrt/CMakeLists.txt index e38606926ee..6fbc7416c3d 100644 --- a/src/runtime_src/core/include/xrt/CMakeLists.txt +++ b/src/runtime_src/core/include/xrt/CMakeLists.txt @@ -10,15 +10,16 @@ set(XRT_XRT_HEADER_SRC xrt_kernel.h xrt_uuid.h) +# xrt component install +install (FILES ${XRT_XRT_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt + COMPONENT ${XRT_DEV_COMPONENT}) -install (FILES ${XRT_XRT_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt COMPONENT ${XRT_DEV_COMPONENT}) +# base component install +install (FILES ${XRT_XRT_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt + COMPONENT ${XRT_BASE_DEV_COMPONENT}) -set(XRT_XRT_DETAIL_HEADER_SRC - detail/abi.h - detail/any.h - detail/bitmask.h - detail/config.h - detail/param_traits.h - detail/pimpl.h) - -install (FILES ${XRT_XRT_DETAIL_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail COMPONENT ${XRT_DEV_COMPONENT}) +add_subdirectory(detail) +add_subdirectory(experimental) +add_subdirectory(deprecated) diff --git a/src/runtime_src/core/include/xrt/deprecated/CMakeLists.txt b/src/runtime_src/core/include/xrt/deprecated/CMakeLists.txt new file mode 100644 index 00000000000..c4475e86f48 --- /dev/null +++ b/src/runtime_src/core/include/xrt/deprecated/CMakeLists.txt @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + +# These headers were moved from runtime_src/core/include/deprecated. +# Must be installed to legacy include dir for legacy xrt package as +# well as xrt/deprecated include dir for base package +set(XRT_DEPRECATED_HEADER_SRC + xrt.h + xclerr.h + ) + +# Legacy install +install (FILES ${XRT_DEPRECATED_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/deprecated + COMPONENT ${XRT_DEV_COMPONENT}) + +# Base component install +install (FILES ${XRT_DEPRECATED_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/deprecated + COMPONENT ${XRT_BASE_DEV_COMPONENT}) diff --git a/src/runtime_src/core/include/xrt/deprecated/xclerr.h b/src/runtime_src/core/include/xrt/deprecated/xclerr.h new file mode 100644 index 00000000000..f660a362481 --- /dev/null +++ b/src/runtime_src/core/include/xrt/deprecated/xclerr.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2017 Xilinx, Inc + * Author: Umang Parekh + * + * This file is dual licensed. It may be redistributed and/or modified + * under the terms of the Apache 2.0 License OR version 2 of the GNU + * General Public License. + * + * Apache License Verbiage + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * GPL license Verbiage: + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the Free Software Foundation; + * either version 2 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * DOC: Device error status related structs and defines + * This file is used by both userspace and xclmgmt kernel driver. + */ + +#ifndef INCLUDE_XRT_DEPRECATED_XCLERR_H_ +#define INCLUDE_XRT_DEPRECATED_XCLERR_H_ + +/** + * enum xclFirewallID - AXI Firewall IDs used to identify individual AXI Firewalls + * + * @XCL_FW_MGMT_CONTROL: MGMT BAR AXI-Lite BAR access protection + * @XCL_FW_USER_CONTROL: USER BAR AXI-Lite BAR access protection + * @XCL_FW_DATAPATH: DMA data path protection + */ +enum xclFirewallID { + XCL_FW_MGMT_CONTROL = 0, + XCL_FW_USER_CONTROL, + XCL_FW_DATAPATH, + XCL_FW_MAX_LEVEL // always the last one +}; + +/** + * struct xclAXIErrorStatus - Record used to capture specific error + * + * @mErrFirewallTime: Timestamp of when Firewall tripped + * @mErrFirewallStatus: Error code obtained from the Firewall + * @mErrFirewallID: Firewall ID + */ +struct xclAXIErrorStatus { + unsigned long mErrFirewallTime; + unsigned mErrFirewallStatus; + enum xclFirewallID mErrFirewallID; +}; + +struct xclPCIErrorStatus { + unsigned mDeviceStatus; + unsigned mUncorrErrStatus; + unsigned mCorrErrStatus; + unsigned rsvd1; + unsigned rsvd2; +}; + +/** + * struct xclErrorStatus - Container for all error records + * + * @mNumFirewalls: Count of Firewalls in the record (max is 8) + * @mAXIErrorStatus: Records holding Firewall information + * @mPCIErrorStatus: Unused + */ +struct xclErrorStatus { + unsigned mNumFirewalls; + struct xclAXIErrorStatus mAXIErrorStatus[8]; + struct xclPCIErrorStatus mPCIErrorStatus; + unsigned mFirewallLevel; +}; + +#endif /* XCLERR_H_ */ diff --git a/src/runtime_src/core/include/deprecated/xrt.h b/src/runtime_src/core/include/xrt/deprecated/xrt.h similarity index 99% rename from src/runtime_src/core/include/deprecated/xrt.h rename to src/runtime_src/core/include/xrt/deprecated/xrt.h index 4647a4d7a20..cd8ed534a9f 100644 --- a/src/runtime_src/core/include/deprecated/xrt.h +++ b/src/runtime_src/core/include/xrt/deprecated/xrt.h @@ -25,14 +25,14 @@ #if defined (_WIN32) #define NOMINMAX #include -#include "windows/types.h" +#include "xrt/detail/windows/types.h" #endif -#include "xclbin.h" -#include "xclerr.h" -#include "xclhal2_mem.h" +#include "xrt/detail/xclbin.h" +#include "xrt/deprecated/xclerr.h" +//#include "xclhal2_mem.h" -#include "deprecated/xcl_app_debug.h" +//#include "deprecated/xcl_app_debug.h" #ifdef __GNUC__ # define XRT_DEPRECATED __attribute__ ((deprecated)) @@ -869,12 +869,14 @@ int xclExecBufWithWaitList(xclDeviceHandle handle, xclBufferHandle cmdBO, size_t num_bo_in_wait_list, xclBufferHandle *bo_wait_list); +#if 0 /* Not supported */ XRT_DEPRECATED XCL_DRIVER_DLLESPEC size_t xclDebugReadIPStatus(xclDeviceHandle handle, enum xclDebugReadType type, void* debugResults); +#endif /* * This function is for internal use. We don't want outside user to use it. diff --git a/src/runtime_src/core/include/xrt/detail/CMakeLists.txt b/src/runtime_src/core/include/xrt/detail/CMakeLists.txt new file mode 100644 index 00000000000..b371779dbe4 --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/CMakeLists.txt @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +set(XRT_XRT_DETAIL_HEADER_SRC + abi.h + any.h + bitmask.h + config.h + param_traits.h + pimpl.h) + +# xrt component install +install (FILES ${XRT_XRT_DETAIL_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_DEV_COMPONENT}) + +# base component install +install (FILES ${XRT_XRT_DETAIL_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_BASE_DEV_COMPONENT}) + +set(XRT_XRT_DETAIL_LEGACY_SRC + ert.h + xclbin.h + xrt_error_code.h + xrt_mem.h) + +# xrt component install +install (FILES ${XRT_XRT_DETAIL_LEGACY_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_DEV_COMPONENT}) + +# base component install +install (FILES ${XRT_XRT_DETAIL_LEGACY_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail + COMPONENT ${XRT_BASE_DEV_COMPONENT}) + +if (WIN32) + add_subdirectory(windows) +endif() + diff --git a/src/runtime_src/core/include/xrt/detail/abi.h b/src/runtime_src/core/include/xrt/detail/abi.h index ca5bd691311..7324593b04f 100644 --- a/src/runtime_src/core/include/xrt/detail/abi.h +++ b/src/runtime_src/core/include/xrt/detail/abi.h @@ -1,11 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2021 Xilinx, Inc. All rights reserved. - +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. #ifndef XRT_DETAIL_ABI_H #define XRT_DETAIL_ABI_H -#ifndef DISABLE_ABI_CHECK +// Generated version.h file is installed into include/xrt/detail/version.h +// but at build time it is picked up from compile include search path +#if defined(XRT_BUILD) && !defined(DISABLE_ABI_CHECK) # include "version.h" +#elif !defined(XRT_BUILD) +# include "xrt/detail/version.h" #endif #ifdef __cplusplus diff --git a/src/runtime_src/core/include/xrt/detail/ert.h b/src/runtime_src/core/include/xrt/detail/ert.h new file mode 100644 index 00000000000..5532cfc53fe --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/ert.h @@ -0,0 +1,1176 @@ +/* + * Copyright (C) 2019-2022, Xilinx Inc + * + * This file is dual licensed. It may be redistributed and/or modified + * under the terms of the Apache 2.0 License OR version 2 of the GNU + * General Public License. + * + * Apache License Verbiage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * GPL license Verbiage: + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write + * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + */ + +/** + * DOC: XRT Embedded Runtime definition + * + * Header file *ert.h* defines data structures used by Emebdded Runtime (ERT) and + * XRT xclExecBuf() API. + */ + +#ifndef INCLUDE_XRT_DETAIL_ERT_H_ +#define INCLUDE_XRT_DETAIL_ERT_H_ + +#if defined(__linux__) && defined(__KERNEL__) +# include +#elif defined(__windows__) && defined(_KERNEL_MODE) +# include +#elif defined(__cplusplus) && !defined(_KERNEL_MODE) +# include +# include +#else +# include +# include +# include +#endif + +#ifdef _WIN32 +# pragma warning( push ) +# pragma warning( disable : 4200 4201 ) +#endif + +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +#endif + +#define to_cfg_pkg(pkg) \ + ((struct ert_configure_cmd *)(pkg)) +#define to_start_krnl_pkg(pkg) \ + ((struct ert_start_kernel_cmd *)(pkg)) +#define to_copybo_pkg(pkg) \ + ((struct ert_start_copybo_cmd *)(pkg)) +#define to_cfg_sk_pkg(pkg) \ + ((struct ert_configure_sk_cmd *)(pkg)) +#define to_init_krnl_pkg(pkg) \ + ((struct ert_init_kernel_cmd *)(pkg)) +#define to_validate_pkg(pkg) \ + ((struct ert_validate_cmd *)(pkg)) +#define to_abort_pkg(pkg) \ + ((struct ert_abort_cmd *)(pkg)) + + +#define HOST_RW_PATTERN 0xF0F0F0F0 +#define DEVICE_RW_PATTERN 0x0F0F0F0F + +/** + * struct ert_packet: ERT generic packet format + * + * @state: [3-0] current state of a command + * @custom: [11-4] custom per specific commands + * @count: [22-12] number of words in payload (data) + * @opcode: [27-23] opcode identifying specific command + * @type: [31-28] type of command (currently 0) + * @data: count number of words representing packet payload + */ +struct ert_packet { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t custom:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-28] */ + }; + uint32_t header; + }; + uint32_t data[1]; /* count number of words */ +}; + +/** + * struct ert_start_kernel_cmd: ERT start kernel command format + * + * @state: [3-0] current state of a command + * @stat_enabled: [4] enabled driver to record timestamp for various + * states cmd has gone through. The stat data + * is appended after cmd data. + * @extra_cu_masks: [11-10] extra CU masks in addition to mandatory mask + * @count: [22-12] number of words following header for cmd data. Not + * include stat data. + * @opcode: [27-23] 0, opcode for start_kernel + * @type: [31-27] 0, type of start_kernel + * + * @cu_mask: first mandatory CU mask + * @data: count-1 number of words representing interpreted payload + * + * The packet payload is comprised of reserved id field, a mandatory CU mask, + * and extra_cu_masks per header field, followed by a CU register map of size + * (count - (1 + extra_cu_masks)) uint32_t words. + */ +struct ert_start_kernel_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t stat_enabled:1; /* [4] */ + uint32_t unused:5; /* [9-5] */ + uint32_t extra_cu_masks:2; /* [11-10] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + /* payload */ + uint32_t cu_mask; /* mandatory cu mask */ + uint32_t data[1]; /* count-1 number of words */ +}; + +/** + * struct ert_dpu_data - interpretation of data payload for ERT_START_DPU + * + * @instruction_buffer: address of instruction buffer + * @instruction_buffer_size: size of instruction buffer in bytes + * @chained: number of following ert_dpu_data elements + * + * The ert_dpu_data is prepended to data payload of ert_start_kernel_cmd + * after any extra cu masks. The payload count of the ert packet is + * incremented with the size (words) of ert_dpu_data elements + * preprended to the data payload. + * + * The data payload for ERT_START_DPU is interpreted as fixed instruction + * buffer address along with instruction count, followed by regular kernel + * arguments. + */ +struct ert_dpu_data { + uint64_t instruction_buffer; /* buffer address 2 words */ + uint32_t instruction_buffer_size; /* size of buffer in bytes */ + uint32_t chained; /* number of following ert_dpu_data elements */ +}; + +/** + * struct ert_npu_data - interpretation of data payload for ERT_START_NPU + * + * @instruction_buffer: address of instruction buffer + * @instruction_buffer_size: size of instruction buffer in bytes + * @instruction_prop_count: WORD length of property name value pairs + * + * The ert_npu_data is prepended to data payload of ert_start_kernel_cmd + * after any extra cu masks. The payload count of the ert packet is + * incremented with the size (words) of ert_npu_data elements + * preprended to the data payload. + * + * The data payload for ERT_START_NPU is interpreted as instruction + * buffer address, instruction count along with instruction property, + * followed by regular kernel arguments. + * + * When instruction_prop_count is non-zero, it indicates the length + * (in 32 bits WORD) of the instruction buffer properties after this + * fields. This count is reserved for future extension. One example + * propertiy is the number of actual columns this instruction used. + */ +struct ert_npu_data { + uint64_t instruction_buffer; /* buffer address 2 words */ + uint32_t instruction_buffer_size; /* size of buffer in bytes */ + uint32_t instruction_prop_count; /* WORD length of following properties nv pairs */ +}; + +/** + * struct ert_npu_preempt_data - interpretation of data payload for ERT_START_NPU_PREEMPT + * + * @instruction_buffer: address of instruction buffer + * @save_buffer: address of save instruction buffer + * @restore_buffer: address of restrore instruction buffer + * @instruction_buffer_size: size of instruction buffer in bytes + * @save_buffer_size: size of save instruction buffer in bytes + * @restore_buffer_size: size of restore instruction buffer in bytes + * @instruction_prop_count: number of property name value pairs + * + * The ert_npu_preempt_data is prepended to data payload of ert_start_kernel_cmd + * after any extra cu masks. The payload count of the ert packet is + * incremented with the size (words) of ert_npu_preempt_data elements + * preprended to the data payload. + * + * The data payload for ERT_START_NPU_PREEMPT is interpreted as instruction + * buffer, save instruction buffer, restore instruction buffer and their + * size, along with instruction property, followed by regular kernel arguments. + * + * When instruction_prop_count is non-zero, it indicates the length + * (in 32 bits WORD) of the instruction buffer properties after this + * fields. This count is reserved for future extension. One example + * propertiy is the number of actual columns this instruction used. + */ +struct ert_npu_preempt_data { + uint64_t instruction_buffer; /* buffer address 2 words */ + uint64_t save_buffer; /* buffer address 2 words */ + uint64_t restore_buffer; /* buffer address 2 words */ + uint32_t instruction_buffer_size; /* size of buffer in bytes */ + uint32_t save_buffer_size; /* size of buffer in bytes */ + uint32_t restore_buffer_size; /* size of buffer in bytes */ + uint32_t instruction_prop_count; /* DWORD length of following properties nv pairs */ +}; + +/** + * struct ert_cmd_chain_data - interpretation of data payload for ERT_CMD_CHAIN + * + * @command_count: number of commands in chain + * @submit_index: index of last successfully submitted command in chain + * @error_index: index of failing command if cmd status is not completed + * @data[]: address of each command in chain + * + * This is the payload of an *ert_packet* when the opcode is ERT_CMD_CHAIN + */ +struct ert_cmd_chain_data { + uint32_t command_count; + uint32_t submit_index; + uint32_t error_index; + uint32_t reserved[3]; + uint64_t data[]; +}; + +#ifndef U30_DEBUG +#define ert_write_return_code(cmd, value) \ +do { \ + struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ + int end_idx = skcmd->count - 1 - skcmd->extra_cu_masks; \ + skcmd->data[end_idx] = value; \ +} while (0) + +#define ert_read_return_code(cmd, ret) \ +do { \ + struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ + int end_idx = skcmd->count - 1 - skcmd->extra_cu_masks; \ + ret = skcmd->data[end_idx]; \ +} while (0) +#else +/* These are for debug legacy U30 firmware */ +#define ert_write_return_code(cmd, value) \ +do { \ + struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ + skcmd->cu_mask = value; \ +} while (0) + +#define ert_read_return_code(cmd, ret) \ +do { \ + struct ert_start_kernel_cmd *skcmd = (struct ert_start_kernel_cmd *)cmd; \ + ret = skcmd->cu_mask; \ +} while (0) +#endif + +/** + * struct ert_init_kernel_cmd: ERT initialize kernel command format + * this command initializes CUs by writing CU registers. CUs are + * represented by cu_mask and extra_cu_masks. + * + * @state: [3-0] current state of a command + * @update_rtp: [4] command is for runtime update of cu argument + * @extra_cu_masks: [11-10] extra CU masks in addition to mandatory mask + * @count: [22-12] number of words following header + * @opcode: [27-23] 0, opcode for init_kernel + * @type: [31-27] 0, type of init_kernel + * + * @cu_run_timeout the configured CU timeout value in Microseconds + * setting to 0 means CU should not timeout + * @cu_reset_timeout the configured CU reset timeout value in Microseconds + * when CU timeout, CU will be reset. this indicates + * CU reset should be completed within the timeout value. + * if cu_run_timeout is set to 0, this field is undefined. + * + * @cu_mask: first mandatory CU mask + * @data: count-9 number of words representing interpreted payload + * + * The packet payload is comprised of reserved id field, 8 reserved fields, + * a mandatory CU mask, and extra_cu_masks per header field, followed by a + * CU register map of size (count - (9 + extra_cu_masks)) uint32_t words. + */ +struct ert_init_kernel_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t update_rtp:1; /* [4] */ + uint32_t unused:5; /* [9-5] */ + uint32_t extra_cu_masks:2; /* [11-10] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + uint32_t cu_run_timeout; /* CU timeout value in Microseconds */ + uint32_t cu_reset_timeout; /* CU reset timeout value in Microseconds */ + uint32_t reserved[6]; /* reserved for future use */ + + /* payload */ + uint32_t cu_mask; /* mandatory cu mask */ + uint32_t data[1]; /* count-9 number of words */ +}; + +#define KDMA_BLOCK_SIZE 64 /* Limited by KDMA CU */ +struct ert_start_copybo_cmd { + uint32_t state:4; /* [3-0], must be ERT_CMD_STATE_NEW */ + uint32_t unused:6; /* [9-4] */ + uint32_t extra_cu_masks:2; /* [11-10], = 3 */ + uint32_t count:11; /* [22-12], = 16, exclude 'arg' */ + uint32_t opcode:5; /* [27-23], = ERT_START_COPYBO */ + uint32_t type:4; /* [31-27], = ERT_DEFAULT */ + uint32_t cu_mask[4]; /* mandatory cu masks */ + uint32_t reserved[4]; /* for scheduler use */ + uint32_t src_addr_lo; /* low 32 bit of src addr */ + uint32_t src_addr_hi; /* high 32 bit of src addr */ + uint32_t src_bo_hdl; /* src bo handle, cleared by driver */ + uint32_t dst_addr_lo; /* low 32 bit of dst addr */ + uint32_t dst_addr_hi; /* high 32 bit of dst addr */ + uint32_t dst_bo_hdl; /* dst bo handle, cleared by driver */ + uint32_t size; /* size in bytes low 32 bit*/ + uint32_t size_hi; /* size in bytes high 32 bit*/ + void *arg; /* pointer to aux data for KDS */ +}; + +/** + * struct ert_configure_cmd: ERT configure command format + * + * @state: [3-0] current state of a command + * @count: [22-12] number of words in payload (5 + num_cus) + * @opcode: [27-23] 1, opcode for configure + * @type: [31-27] 0, type of configure + * + * @slot_size: command queue slot size + * @num_cus: number of compute units in program + * @cu_shift: shift value to convert CU idx to CU addr + * @cu_base_addr: base address to add to CU addr for actual physical address + * + * @ert:1 enable embedded HW scheduler + * @polling:1 poll for command completion + * @cu_dma:1 enable CUDMA custom module for HW scheduler + * @cu_isr:1 enable CUISR custom module for HW scheduler + * @cq_int:1 enable interrupt from host to HW scheduler + * @cdma:1 enable CDMA kernel + * @unused:25 + * @dsa52:1 reserved for internal use + * + * @data: addresses of @num_cus CUs + */ +struct ert_configure_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t unused:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + /* payload */ + uint32_t slot_size; + uint32_t num_cus; + uint32_t cu_shift; + uint32_t cu_base_addr; + + /* features */ + uint32_t ert:1; + uint32_t polling:1; + uint32_t cu_dma:1; + uint32_t cu_isr:1; + uint32_t cq_int:1; + uint32_t cdma:1; + uint32_t dataflow:1; + /* WORKAROUND: allow xclRegWrite/xclRegRead access shared CU */ + uint32_t rw_shared:1; + uint32_t kds_30:1; + uint32_t dmsg:1; + uint32_t echo:1; + uint32_t intr:1; + uint32_t unusedf:19; + uint32_t dsa52:1; + + /* cu address map size is num_cus */ + uint32_t data[1]; +}; + +/* + * Note: We need to put maximum 128 soft kernel image + * in one config command (1024 DWs including header). + * So each one needs to be smaller than 8 DWs. + * + * This data struct is obsoleted. Only used in legacy ERT firmware. + * Use 'struct config_sk_image_uuid' instead on XGQ based ERT. + * + * @start_cuidx: start index of compute units of each image + * @num_cus: number of compute units of each image + * @sk_name: symbol name of soft kernel of each image + */ +struct config_sk_image { + uint32_t start_cuidx; + uint32_t num_cus; + uint32_t sk_name[5]; +}; + +/* + * Note: We need to put maximum 128 soft kernel image + * in one config command (1024 DWs including header). + * So each one needs to be smaller than 8 DWs. + * + * @start_cuidx: start index of compute units of each image + * @num_cus: number of compute units of each image + * @sk_name: symbol name of soft kernel of each image + * @sk_uuid: xclbin uuid that this soft kernel image belones to + */ +struct config_sk_image_uuid { + uint32_t start_cuidx; + uint32_t num_cus; + uint32_t sk_name[5]; + unsigned char sk_uuid[16]; + uint32_t slot_id; +}; + +/** + * struct ert_configure_sk_cmd: ERT configure soft kernel command format + * + * @state: [3-0] current state of a command + * @count: [22-12] number of words in payload + * @opcode: [27-23] 1, opcode for configure + * @type: [31-27] 0, type of configure + * + * @num_image: number of images +*/ +struct ert_configure_sk_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t unused:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + /* payload */ + uint32_t num_image; + struct config_sk_image image[1]; +}; + +/** + * struct ert_unconfigure_sk_cmd: ERT unconfigure soft kernel command format + * + * @state: [3-0] current state of a command + * @count: [22-12] number of words in payload + * @opcode: [27-23] 1, opcode for configure + * @type: [31-27] 0, type of configure + * + * @start_cuidx: start index of compute units + * @num_cus: number of compute units in program + */ +struct ert_unconfigure_sk_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t unused:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + /* payload */ + uint32_t start_cuidx; + uint32_t num_cus; +}; + +/** + * struct ert_abort_cmd: ERT abort command format. + * + * @exec_bo_handle: The bo handle of execbuf command to abort + */ +struct ert_abort_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t custom:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + + /* payload */ + uint64_t exec_bo_handle; +}; + +/** + * struct ert_validate_cmd: ERT BIST command format. + * + */ +struct ert_validate_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t custom:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + uint32_t timestamp; + uint32_t cq_read_single; + uint32_t cq_write_single; + uint32_t cu_read_single; + uint32_t cu_write_single; +}; + +/** + * struct ert_validate_cmd: ERT BIST command format. + * + */ +struct ert_access_valid_cmd { + union { + struct { + uint32_t state:4; /* [3-0] */ + uint32_t custom:8; /* [11-4] */ + uint32_t count:11; /* [22-12] */ + uint32_t opcode:5; /* [27-23] */ + uint32_t type:4; /* [31-27] */ + }; + uint32_t header; + }; + uint32_t h2h_access; + uint32_t h2d_access; + uint32_t d2h_access; + uint32_t d2d_access; + uint32_t d2cu_access; + uint32_t wr_count; + uint32_t wr_test; +}; + +/** + * ERT command state + * + * @ERT_CMD_STATE_NEW: Set by host before submitting a command to + * scheduler + * @ERT_CMD_STATE_QUEUED: Internal scheduler state + * @ERT_CMD_STATE_SUBMITTED: Internal scheduler state + * @ERT_CMD_STATE_RUNNING: Internal scheduler state + * @ERT_CMD_STATE_COMPLETED: Set by scheduler when command completes + * @ERT_CMD_STATE_ERROR: Set by scheduler if command failed + * @ERT_CMD_STATE_ABORT: Set by scheduler if command abort + * @ERT_CMD_STATE_TIMEOUT: Set by scheduler if command timeout and reset + * @ERT_CMD_STATE_NORESPONSE: Set by scheduler if command timeout and fail to + * reset + */ +enum ert_cmd_state { + ERT_CMD_STATE_NEW = 1, + ERT_CMD_STATE_QUEUED = 2, + ERT_CMD_STATE_RUNNING = 3, + ERT_CMD_STATE_COMPLETED = 4, + ERT_CMD_STATE_ERROR = 5, + ERT_CMD_STATE_ABORT = 6, + ERT_CMD_STATE_SUBMITTED = 7, + ERT_CMD_STATE_TIMEOUT = 8, + ERT_CMD_STATE_NORESPONSE = 9, + ERT_CMD_STATE_SKERROR = 10, //Check for error return code from Soft Kernel + ERT_CMD_STATE_SKCRASHED = 11, //Soft kernel has crashed + ERT_CMD_STATE_MAX, // Always the last one +}; + +struct cu_cmd_state_timestamps { + uint64_t skc_timestamps[ERT_CMD_STATE_MAX]; // In nano-second +}; + +/** + * Opcode types for commands + * + * @ERT_START_CU: start a workgroup on a CU + * @ERT_START_KERNEL: currently aliased to ERT_START_CU + * @ERT_CONFIGURE: configure command scheduler + * @ERT_EXEC_WRITE: execute a specified CU after writing + * @ERT_CU_STAT: get stats about CU execution + * @ERT_START_COPYBO: start KDMA CU or P2P, may be converted to ERT_START_CU + * before cmd reach to scheduler, short-term hack + * @ERT_SK_CONFIG: configure soft kernel + * @ERT_SK_START: start a soft kernel + * @ERT_SK_UNCONFIG: unconfigure a soft kernel + * @ERT_START_KEY_VAL: same as ERT_START_CU but with key-value pair flavor + * @ERT_START_DPU: instruction buffer command format + * @ERT_CMD_CHAIN: command chain + * @ERT_START_NPU: instruction buffer command format on NPU format + * @ERT_START_NPU_PREEMPT: instruction buffer command with preemption format on NPU + */ +enum ert_cmd_opcode { + ERT_START_CU = 0, + ERT_START_KERNEL = 0, + ERT_CONFIGURE = 2, + ERT_EXIT = 3, + ERT_ABORT = 4, + ERT_EXEC_WRITE = 5, + ERT_CU_STAT = 6, + ERT_START_COPYBO = 7, + ERT_SK_CONFIG = 8, + ERT_SK_START = 9, + ERT_SK_UNCONFIG = 10, + ERT_INIT_CU = 11, + ERT_START_FA = 12, + ERT_CLK_CALIB = 13, + ERT_MB_VALIDATE = 14, + ERT_START_KEY_VAL = 15, + ERT_ACCESS_TEST_C = 16, + ERT_ACCESS_TEST = 17, + ERT_START_DPU = 18, + ERT_CMD_CHAIN = 19, + ERT_START_NPU = 20, + ERT_START_NPU_PREEMPT = 21, +}; + +/** + * Command types + * + * @ERT_DEFAULT: default command type + * @ERT_KDS_LOCAL: command processed by KDS locally + * @ERT_CTRL: control command uses reserved command queue slot + * @ERT_CU: compute unit command + */ +enum ert_cmd_type { + ERT_DEFAULT = 0, + ERT_KDS_LOCAL = 1, + ERT_CTRL = 2, + ERT_CU = 3, + ERT_SCU = 4, +}; + +/** + * Soft kernel types + * + * @SOFTKERNEL_TYPE_EXEC: executable + */ +enum softkernel_type { + SOFTKERNEL_TYPE_EXEC = 0, +}; + +/* + * Base address GPIO per spec + * | Offset | Description + * ----------------------- + * | 0x00 | ERT_MGMT_PF_base_addr (Not sure where this should be use) + * | 0x08 | ERT_USER_PF_base_addr. The base address of ERT peripherals + */ +#if defined(ERT_BUILD_V20) +uint32_t ert_base_addr = 0; +# define ERT_BASE_ADDR 0x01F30008 +#endif + +#if defined(ERT_BUILD_V30) +uint32_t ert_base_addr = 0; +# define ERT_BASE_ADDR 0x01F30008 +#endif + +/** + * Address constants per spec + */ +#define ERT_WORD_SIZE 4 /* 4 bytes */ +#define ERT_CQ_SIZE 0x10000 /* 64K */ +#if defined(ERT_BUILD_U50) +# define ERT_CQ_BASE_ADDR 0x340000 +# define ERT_CSR_ADDR 0x360000 +#elif defined(ERT_BUILD_V20) +# define ERT_CQ_BASE_ADDR (0x000000 + ert_base_addr) +# define ERT_CSR_ADDR (0x010000 + ert_base_addr) +#elif defined(ERT_BUILD_V30) +# define ERT_CQ_BASE_ADDR 0x1F60000 +# define ERT_CSR_ADDR (0x010000 + ert_base_addr) +#else +# define ERT_CQ_BASE_ADDR 0x190000 +# define ERT_CSR_ADDR 0x180000 +#endif + +/** + * The STATUS REGISTER is for communicating completed CQ slot indices + * MicroBlaze write, host reads. MB(W) / HOST(COR) + */ +#define ERT_STATUS_REGISTER_ADDR (ERT_CSR_ADDR) +#define ERT_STATUS_REGISTER_ADDR0 (ERT_CSR_ADDR) +#define ERT_STATUS_REGISTER_ADDR1 (ERT_CSR_ADDR + 0x4) +#define ERT_STATUS_REGISTER_ADDR2 (ERT_CSR_ADDR + 0x8) +#define ERT_STATUS_REGISTER_ADDR3 (ERT_CSR_ADDR + 0xC) + +/** + * The CU DMA REGISTER is for communicating which CQ slot is to be started + * on a specific CU. MB selects a free CU on which the command can + * run, then writes the 1<state = ERT_CMD_STATE_NEW; + pkt->extra_cu_masks = 3; + pkt->count = 16; + pkt->opcode = ERT_START_COPYBO; + pkt->type = ERT_DEFAULT; + pkt->cu_mask[0] = 0; + pkt->cu_mask[1] = 0; + pkt->cu_mask[2] = 0; + pkt->cu_mask[3] = 0; + pkt->src_addr_lo = (uint32_t)src_offset; + pkt->src_addr_hi = (src_offset >> 32) & 0xFFFFFFFF; + pkt->src_bo_hdl = src_bo; + pkt->dst_addr_lo = (uint32_t)dst_offset; + pkt->dst_addr_hi = (dst_offset >> 32) & 0xFFFFFFFF; + pkt->dst_bo_hdl = dst_bo; + pkt->size = size; + pkt->size_hi = 0; /* set to 0 explicitly */ + pkt->arg = 0; +} +static inline uint64_t +ert_copybo_src_offset(struct ert_start_copybo_cmd *pkt) +{ + return (uint64_t)pkt->src_addr_hi << 32 | pkt->src_addr_lo; +} +static inline uint64_t +ert_copybo_dst_offset(struct ert_start_copybo_cmd *pkt) +{ + return (uint64_t)pkt->dst_addr_hi << 32 | pkt->dst_addr_lo; +} +static inline uint64_t +ert_copybo_size(struct ert_start_copybo_cmd *pkt) +{ + return pkt->size; +} + +static inline bool +ert_valid_opcode(struct ert_packet *pkt) +{ + struct ert_start_kernel_cmd *skcmd; + struct ert_init_kernel_cmd *ikcmd; + struct ert_start_copybo_cmd *sccmd; + struct ert_configure_cmd *ccmd; + struct ert_configure_sk_cmd *cscmd; + struct ert_cmd_chain_data *ccdata; + bool valid; + + switch (pkt->opcode) { + case ERT_START_CU: + skcmd = to_start_krnl_pkg(pkt); + /* 1 cu mask + 4 registers */ + valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 4); + break; + case ERT_START_DPU: + skcmd = to_start_krnl_pkg(pkt); + /* 1 mandatory cumask + extra_cu_masks + size (in words) of ert_dpu_data */ + valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_dpu_data) / sizeof(uint32_t)); + break; + case ERT_CMD_CHAIN: + ccdata = (struct ert_cmd_chain_data*) pkt->data; + /* header count must match number of commands in payload */ + valid = (pkt->count == (ccdata->command_count * sizeof(uint64_t) + sizeof(struct ert_cmd_chain_data)) / sizeof(uint32_t)); + break; + case ERT_START_NPU: + skcmd = to_start_krnl_pkg(pkt); + /* 1 mandatory cumask + extra_cu_masks + ert_npu_data */ + valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_npu_data) / sizeof(uint32_t)); + break; + case ERT_START_NPU_PREEMPT: + skcmd = to_start_krnl_pkg(pkt); + /* 1 mandatory cumask + extra_cu_masks + ert_npu_preempt_data */ + valid = (skcmd->count >= 1+ skcmd->extra_cu_masks + sizeof(struct ert_npu_preempt_data) / sizeof(uint32_t)); + break; + case ERT_START_KEY_VAL: + skcmd = to_start_krnl_pkg(pkt); + /* 1 cu mask */ + valid = (skcmd->count >= skcmd->extra_cu_masks + 1); + break; + case ERT_EXEC_WRITE: + skcmd = to_start_krnl_pkg(pkt); + /* 1 cu mask + 6 registers */ + valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 6); + break; + case ERT_START_FA: + skcmd = to_start_krnl_pkg(pkt); + /* 1 cu mask */ + valid = (skcmd->count >= skcmd->extra_cu_masks + 1); + break; + case ERT_SK_START: + skcmd = to_start_krnl_pkg(pkt); + /* 1 cu mask + 1 control word */ + valid = (skcmd->count >= skcmd->extra_cu_masks + 1 + 1); + break; + case ERT_CONFIGURE: + ccmd = to_cfg_pkg(pkt); + /* 5 mandatory fields in struct */ + valid = (ccmd->count >= 5 + ccmd->num_cus); + break; + case ERT_START_COPYBO: + sccmd = to_copybo_pkg(pkt); + valid = (sccmd->count == 16); + break; + case ERT_INIT_CU: + ikcmd = to_init_krnl_pkg(pkt); + /* 9 mandatory words in struct + 4 control registers */ + valid = (ikcmd->count >= ikcmd->extra_cu_masks + 9 + 4); + break; + case ERT_SK_CONFIG: + cscmd = to_cfg_sk_pkg(pkt); + valid = (cscmd->count == sizeof(struct config_sk_image) * cscmd->num_image / 4 + 1); + break; + case ERT_CLK_CALIB: + case ERT_MB_VALIDATE: + case ERT_ACCESS_TEST_C: + case ERT_CU_STAT: /* TODO: Rules to validate? */ + case ERT_EXIT: + case ERT_ABORT: + valid = true; + break; + case ERT_SK_UNCONFIG: /* NOTE: obsolete */ + default: + valid = false; + } + + return valid; +} + +static inline uint64_t +get_ert_packet_size_bytes(struct ert_packet *pkt) +{ + // header plus payload + return sizeof(pkt->header) + pkt->count * sizeof(uint32_t); +} + +static inline struct ert_dpu_data* +get_ert_dpu_data(struct ert_start_kernel_cmd* pkt) +{ + if (pkt->opcode != ERT_START_DPU) + return NULL; + + // past extra cu_masks embedded in the packet data + return (struct ert_dpu_data*) (pkt->data + pkt->extra_cu_masks); +} + +static inline struct ert_dpu_data* +get_ert_dpu_data_next(struct ert_dpu_data* dpu_data) +{ + if (dpu_data->chained == 0) + return NULL; + + return dpu_data + 1; +} + +static inline struct ert_cmd_chain_data* +get_ert_cmd_chain_data(struct ert_packet* pkt) +{ + if (pkt->opcode != ERT_CMD_CHAIN) + return NULL; + + return (struct ert_cmd_chain_data*) pkt->data; +} + +static inline struct ert_npu_data* +get_ert_npu_data(struct ert_start_kernel_cmd* pkt) +{ + if (pkt->opcode != ERT_START_NPU) + return NULL; + + // past extra cu_masks embedded in the packet data + return (struct ert_npu_data*) (pkt->data + pkt->extra_cu_masks); +} + +static inline struct ert_npu_preempt_data* +get_ert_npu_preempt_data(struct ert_start_kernel_cmd* pkt) +{ + if (pkt->opcode != ERT_START_NPU_PREEMPT) + return NULL; + + // past extra cu_masks embedded in the packet data + return (struct ert_npu_preempt_data*) (pkt->data + pkt->extra_cu_masks); +} + +static inline uint32_t* +get_ert_regmap_begin(struct ert_start_kernel_cmd* pkt) +{ + switch (pkt->opcode) { + case ERT_START_DPU: + return pkt->data + pkt->extra_cu_masks + + (get_ert_dpu_data(pkt)->chained + 1) * sizeof(struct ert_dpu_data) / sizeof(uint32_t); + + case ERT_START_NPU: + return pkt->data + pkt->extra_cu_masks + + sizeof(struct ert_npu_data) / sizeof(uint32_t) + + get_ert_npu_data(pkt)->instruction_prop_count; + + case ERT_START_NPU_PREEMPT: + return pkt->data + pkt->extra_cu_masks + + sizeof(struct ert_npu_preempt_data) / sizeof(uint32_t) + + get_ert_npu_preempt_data(pkt)->instruction_prop_count; + + default: + // skip past embedded extra cu_masks + return pkt->data + pkt->extra_cu_masks; + } +} + +static inline uint32_t* +get_ert_regmap_end(struct ert_start_kernel_cmd* pkt) +{ + // pkt->count includes the mandatory cumask which precededs data array + return &pkt->cu_mask + pkt->count; +} + +static inline uint64_t +get_ert_regmap_size_bytes(struct ert_start_kernel_cmd* pkt) +{ + return (get_ert_regmap_end(pkt) - get_ert_regmap_begin(pkt)) * sizeof(uint32_t); +} + +#ifdef __linux__ +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) +static inline struct cu_cmd_state_timestamps * +ert_start_kernel_timestamps(struct ert_start_kernel_cmd *pkt) +{ + uint64_t offset = pkt->count * sizeof(uint32_t) + sizeof(pkt->header); + /* Make sure the offset of timestamps are properly aligned. */ + return (struct cu_cmd_state_timestamps *) + ((char *)pkt + P2ROUNDUP(offset, sizeof(uint64_t))); +} + +/* Return 0 if this pkt doesn't support timestamp or disabled */ +static inline int +get_size_with_timestamps_or_zero(struct ert_packet *pkt) +{ + struct ert_start_kernel_cmd *skcmd; + int size = 0; + + switch (pkt->opcode) { + case ERT_START_CU: + case ERT_EXEC_WRITE: + case ERT_START_FA: + case ERT_SK_START: + skcmd = to_start_krnl_pkg(pkt); + if (skcmd->stat_enabled) { + size = (char *)ert_start_kernel_timestamps(skcmd) - (char *)pkt; + size += sizeof(struct cu_cmd_state_timestamps); + } + } + + return size; +} +#endif + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + +#ifdef _WIN32 +# pragma warning( pop ) +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/detail/windows/CMakeLists.txt b/src/runtime_src/core/include/xrt/detail/windows/CMakeLists.txt new file mode 100644 index 00000000000..7f0fae1fab9 --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/windows/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + +# These headers were moved from runtime_src/core/include/windows. +# Must be installed to legacy include dir for legacy xrt package as +# well as xrt/detail include dir for base package +set(XRT_WINDOWS_HEADER_SRC + types.h + uuid.h) + +# xrt component deprecated install +install (FILES ${XRT_WINDOWS_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/windows + COMPONENT ${XRT_DEV_COMPONENT}) + +# xrt component install +install (FILES ${XRT_WINDOWS_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail/windows + COMPONENT ${XRT_DEV_COMPONENT}) + +# base component install +install (FILES ${XRT_WINDOWS_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail/windows + COMPONENT ${XRT_BASE_DEV_COMPONENT}) diff --git a/src/runtime_src/core/include/windows/types.h b/src/runtime_src/core/include/xrt/detail/windows/types.h similarity index 100% rename from src/runtime_src/core/include/windows/types.h rename to src/runtime_src/core/include/xrt/detail/windows/types.h diff --git a/src/runtime_src/core/include/windows/uuid.h b/src/runtime_src/core/include/xrt/detail/windows/uuid.h similarity index 100% rename from src/runtime_src/core/include/windows/uuid.h rename to src/runtime_src/core/include/xrt/detail/windows/uuid.h diff --git a/src/runtime_src/core/include/xrt/detail/xclbin.h b/src/runtime_src/core/include/xrt/detail/xclbin.h new file mode 100644 index 00000000000..531eb3e32d0 --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/xclbin.h @@ -0,0 +1,694 @@ +/** + * Copyright (C) 2015-2024, Advanced Micro Devices, Inc. All rights Reserved. + * + * This file is dual licensed. It may be redistributed and/or modified + * under the terms of the Apache 2.0 License OR version 2 of the GNU + * General Public License. + * + * Apache License Verbiage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * GPL license Verbiage: + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef INCLUDE_XRT_DETAIL_XCLBIN_H_ +#define INCLUDE_XRT_DETAIL_XCLBIN_H_ + +#if defined(__linux__) +# if defined(__KERNEL__) +# include +# include +# include +# elif defined(__cplusplus) +# include +# include +# include +# include +# else +# include +# include +# include +# endif +#elif defined(_WIN32) +# if defined(_KERNEL_MODE) +# include +# include +# elif defined(__cplusplus) +# include +# include +# include +# include +# else +# include +# include +# include +# endif +#endif + +#if defined(__linux__) && defined(__KERNEL__) +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) +typedef uuid_t xuid_t; +# elif defined(RHEL_RELEASE_CODE) +# if RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7,4) +typedef uuid_t xuid_t; +# else +typedef uuid_le xuid_t; +# endif +# else +typedef uuid_le xuid_t; +# endif +#elif defined(__linux__) && !defined(__KERNEL__) +typedef uuid_t xuid_t; +#elif defined(_WIN32) && defined(_KERNEL_MODE) +typedef GUID xuid_t; +#endif + +// ----------------- Custom Assert Macro ------------------------- +// The xclbin.h header file is used both by the driver and host +// applications/libraries. For C++ static_assert() would be used, but +// for the the drivers (e.g., linux) a more custom solution is needed +// e.g., BUILD_BUG_ON_ZERO()). Instead of creating a wrapper around the +// various OS builds, a custom assert (based on the linux assert) is used. + +#ifdef __cplusplus + // Used C++ static assert + #define XCLBIN_STATIC_ASSERT(e,m) \ + static_assert (e, m) +#else + // Use our "custom" kernel compilation assert + #define XLCBIN_ASSERT_CONCAT_(a, b) a##b + #define XLCBIN_ASSERT_CONCAT(a, b) XLCBIN_ASSERT_CONCAT_(a, b) + + // Create an artifitial assertion via a bad divide by zero assertion. + #define XCLBIN_STATIC_ASSERT(e,m) \ + enum { XLCBIN_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) } +#endif + +// *** Helper macro *** +// Reports a size of structure via an error +#define SIZE_OF_STRUCT(s) \ + char (*__fail)[sizeof(struct s)] = 1 + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * Container format for Xilinx bitstreams, metadata and other + * binary blobs. + * Every segment must be aligned at 8 byte boundary with null byte padding + * between adjacent segments if required. + * For segements which are not present both offset and length must be 0 in + * the header. + * Currently only xclbin0\0 is recognized as file magic. In future if/when file + * format is updated the magic string will be changed to xclbin1\0 and so on. + */ + enum XCLBIN_MODE { + XCLBIN_FLAT, + XCLBIN_PR, + XCLBIN_TANDEM_STAGE2, + XCLBIN_TANDEM_STAGE2_WITH_PR, + XCLBIN_HW_EMU, + XCLBIN_SW_EMU, + XCLBIN_HW_EMU_PR, + XCLBIN_MODE_MAX + }; + + /* + * AXLF LAYOUT + * ----------- + * + * ----------------------------------------- + * | Magic | + * ----------------------------------------- + * | Header | + * ----------------------------------------- + * | One or more section headers | + * ----------------------------------------- + * | Matching number of sections with data | + * ----------------------------------------- + * + */ + + enum axlf_section_kind { + BITSTREAM = 0, + CLEARING_BITSTREAM = 1, + EMBEDDED_METADATA = 2, + FIRMWARE = 3, + DEBUG_DATA = 4, + SCHED_FIRMWARE = 5, + MEM_TOPOLOGY = 6, + CONNECTIVITY = 7, + IP_LAYOUT = 8, + DEBUG_IP_LAYOUT = 9, + DESIGN_CHECK_POINT = 10, + CLOCK_FREQ_TOPOLOGY = 11, + MCS = 12, + BMC = 13, + BUILD_METADATA = 14, + KEYVALUE_METADATA = 15, + USER_METADATA = 16, + DNA_CERTIFICATE = 17, + PDI = 18, + BITSTREAM_PARTIAL_PDI = 19, + PARTITION_METADATA = 20, + EMULATION_DATA = 21, + SYSTEM_METADATA = 22, + SOFT_KERNEL = 23, + ASK_FLASH = 24, + AIE_METADATA = 25, + ASK_GROUP_TOPOLOGY = 26, + ASK_GROUP_CONNECTIVITY = 27, + SMARTNIC = 28, + AIE_RESOURCES = 29, + OVERLAY = 30, + VENDER_METADATA = 31, + AIE_PARTITION = 32, + IP_METADATA = 33, + AIE_RESOURCES_BIN = 34, + AIE_TRACE_METADATA = 35, + }; + + enum MEM_TYPE { + MEM_DDR3, + MEM_DDR4, + MEM_DRAM, + MEM_STREAMING, + MEM_PREALLOCATED_GLOB, + MEM_ARE, //Aurora + MEM_HBM, + MEM_BRAM, + MEM_URAM, + MEM_STREAMING_CONNECTION, + MEM_HOST, + MEM_PS_KERNEL, + }; + + enum IP_TYPE { + IP_MB = 0, + IP_KERNEL, //kernel instance + IP_DNASC, + IP_DDR4_CONTROLLER, + IP_MEM_DDR4, + IP_MEM_HBM, + IP_MEM_HBM_ECC, + IP_PS_KERNEL, + }; + + enum ACTION_MASK { + AM_LOAD_AIE = 0x1, /* Indicates to the driver to load the AIE PID section */ + AM_LOAD_PDI = 0x2, /* Indicates to the driver to program the PDI */ + }; + + struct axlf_section_header { + uint32_t m_sectionKind; /* Section type */ + char m_sectionName[16]; /* Examples: "stage2", "clear1", "clear2", "ocl1", "ocl2, "ublaze", "sched" */ + uint64_t m_sectionOffset; /* File offset of section data */ + uint64_t m_sectionSize; /* Size of section data */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct axlf_section_header) == 40, "axlf_section_header structure no longer is 40 bytes in size"); + + struct axlf_header { + uint64_t m_length; /* Total size of the xclbin file */ + uint64_t m_timeStamp; /* Number of seconds since epoch when xclbin was created */ + uint64_t m_featureRomTimeStamp; /* TimeSinceEpoch of the featureRom */ + uint16_t m_versionPatch; /* Patch Version */ + uint8_t m_versionMajor; /* Major Version - Version: 2.1.0*/ + uint8_t m_versionMinor; /* Minor Version */ + uint16_t m_mode; /* XCLBIN_MODE */ + uint16_t m_actionMask; /* Bit Mask */ + unsigned char m_interface_uuid[16]; /* Interface uuid of this xclbin */ + unsigned char m_platformVBNV[64]; /* e.g. xilinx:xil-accel-rd-ku115:4ddr-xpr:3.4: null terminated */ + union { + char m_next_axlf[16]; /* Name of next xclbin file in the daisy chain */ + xuid_t uuid; /* uuid of this xclbin*/ + }; + char m_debug_bin[16]; /* Name of binary with debug information */ + uint32_t m_numSections; /* Number of section headers */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct axlf_header) == 152, "axlf_header structure no longer is 152 bytes in size"); + #define XCLBIN_MAX_NUM_SECTION 0x10000 + + struct axlf { + char m_magic[8]; /* Should be "xclbin2\0" */ + int32_t m_signature_length; /* Length of the signature. -1 indicates no signature */ + unsigned char reserved[28]; /* Note: Initialized to 0xFFs */ + + unsigned char m_keyBlock[256]; /* Signature for validation of binary */ + uint64_t m_uniqueId; /* axlf's uniqueId, use it to skip redownload etc */ + struct axlf_header m_header; /* Inline header */ + struct axlf_section_header m_sections[1]; /* One or more section headers follow */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct axlf) == 496, "axlf structure no longer is 496 bytes in size"); + + typedef struct axlf xclBin; + + /**** BEGIN : Xilinx internal section *****/ + + /* bitstream information */ + struct xlnx_bitstream { + uint8_t m_freq[8]; + char bits[1]; + }; + XCLBIN_STATIC_ASSERT(sizeof(struct xlnx_bitstream) == 9, "xlnx_bitstream structure no longer is 9 bytes in size"); + + + /**** MEMORY TOPOLOGY SECTION ****/ + struct mem_data { + uint8_t m_type; // enum corresponding to mem_type. + uint8_t m_used; // if 0 this bank is not present + uint8_t padding[6]; // 8 Byte alignment padding (initialized to zeros) + union { + uint64_t m_size; // if mem_type DDR, then size in KB; + uint64_t route_id; // if streaming then "route_id" + }; + union { + uint64_t m_base_address; // if DDR then the base address; + uint64_t flow_id; // if streaming then "flow id" + }; + unsigned char m_tag[16]; // DDR: BANK0,1,2,3, has to be null terminated; if streaming then stream0, 1 etc + }; + XCLBIN_STATIC_ASSERT(sizeof(struct mem_data) == 40, "mem_data structure no longer is 40 bytes in size"); + + struct mem_topology { + int32_t m_count; //Number of mem_data + struct mem_data m_mem_data[1]; //Should be sorted on mem_type + }; + XCLBIN_STATIC_ASSERT(sizeof(struct mem_topology) == 48, "mem_topology structure no longer is 48 bytes in size"); + + + /**** CONNECTIVITY SECTION ****/ + /* Connectivity of each argument of Kernel. It will be in terms of argument + * index associated. For associating kernel instances with arguments and + * banks, start at the connectivity section. Using the m_ip_layout_index + * access the ip_data.m_name. Now we can associate this kernel instance + * with its original kernel name and get the connectivity as well. This + * enables us to form related groups of kernel instances. + */ + + struct connection { + int32_t arg_index; //From 0 to n, may not be contiguous as scalars skipped + int32_t m_ip_layout_index; //index into the ip_layout section. ip_layout.m_ip_data[index].m_type == IP_KERNEL + int32_t mem_data_index; //index of the m_mem_data . Flag error is m_used false. + }; + XCLBIN_STATIC_ASSERT(sizeof(struct connection) == 12, "connection structure no longer is 12 bytes in size"); + + struct connectivity { + int32_t m_count; + struct connection m_connection[1]; + }; + XCLBIN_STATIC_ASSERT(sizeof(struct connectivity) == 16, "connectivity structure no longer is 16 bytes in size"); + + /**** IP_LAYOUT SECTION ****/ + + // IP Kernel + #define IP_INT_ENABLE_MASK 0x0001 + #define IP_INTERRUPT_ID_MASK 0x00FE + #define IP_INTERRUPT_ID_SHIFT 0x1 + + enum IP_CONTROL { + AP_CTRL_HS = 0, + AP_CTRL_CHAIN = 1, + AP_CTRL_NONE = 2, + AP_CTRL_ME = 3, + ACCEL_ADAPTER = 4, + FAST_ADAPTER = 5 + }; + + // m_subtype + enum PS_SUBTYPE { + ST_PS = 0, + ST_DPU = 1, + }; + + // m_functional + enum PS_FUNCTIONAL { + FC_DPU = 0, + FC_PREPOST = 1, + }; + + #define IP_CONTROL_MASK 0xFF00 + #define IP_CONTROL_SHIFT 0x8 + + /* IPs on AXI lite - their types, names, and base addresses.*/ + struct ip_data { + uint32_t m_type; //map to IP_TYPE enum + union { + uint32_t properties; // Default: 32-bits to indicate ip specific property. + // m_type: IP_KERNEL + // m_int_enable : Bit - 0x0000_0001; + // m_interrupt_id : Bits - 0x0000_00FE; + // m_ip_control : Bits = 0x0000_FF00; + // properties is also used for ps kernel (i.e. -add-pskernel) + + // PS Kernels + // m_type: IP_PS_KERNEL + struct { + uint16_t m_subtype : 2; // Bits - 0x0003 - PS_SUBTYPE enum values + uint16_t : 2; // Bits - 0x000C - Future use + uint16_t m_functional : 2; // Bits - 0x0030 - PS_FUNCTIONAL enum values + uint16_t : 10; // Bits - 0xFFC0 - Future use + uint16_t m_kernel_id : 12; // Bits - 0x0FFF + uint16_t : 4; // Bits - 0xF000 - Future use + } ps_kernel; + + struct { // m_type: IP_MEM_* + uint16_t m_index; + uint8_t m_pc_index; + uint8_t unused; + } indices; + }; + uint64_t m_base_address; + uint8_t m_name[64]; //eg Kernel name corresponding to KERNEL instance, can embed CU name in future. + }; + XCLBIN_STATIC_ASSERT(sizeof(struct ip_data) == 80, "ip_data structure no longer is 80 bytes in size"); + + struct ip_layout { + int32_t m_count; + struct ip_data m_ip_data[1]; //All the ip_data needs to be sorted by m_base_address. + }; + XCLBIN_STATIC_ASSERT(sizeof(struct ip_layout) == 88, "ip_layout structure no longer is 88 bytes in size"); + + /*** Debug IP section layout ****/ + enum DEBUG_IP_TYPE { + UNDEFINED = 0, + LAPC, + ILA, + AXI_MM_MONITOR, + AXI_TRACE_FUNNEL, + AXI_MONITOR_FIFO_LITE, + AXI_MONITOR_FIFO_FULL, + ACCEL_MONITOR, + AXI_STREAM_MONITOR, + AXI_STREAM_PROTOCOL_CHECKER, + TRACE_S2MM, + AXI_DMA, + TRACE_S2MM_FULL, + AXI_NOC, + ACCEL_DEADLOCK_DETECTOR, + HSDP_TRACE, + DEBUG_IP_TYPE_MAX + }; + + struct debug_ip_data { + uint8_t m_type; // type of enum DEBUG_IP_TYPE + uint8_t m_index_lowbyte; + uint8_t m_properties; + uint8_t m_major; + uint8_t m_minor; + uint8_t m_index_highbyte; + uint8_t m_reserved[2]; + uint64_t m_base_address; + char m_name[128]; + }; + XCLBIN_STATIC_ASSERT(sizeof(struct debug_ip_data) == 144, "debug_ip_data structure no longer is 144 bytes in size"); + + struct debug_ip_layout { + uint16_t m_count; + struct debug_ip_data m_debug_ip_data[1]; + }; + XCLBIN_STATIC_ASSERT(sizeof(struct debug_ip_layout) == 152, "debug_ip_layout structure no longer is 152 bytes in size"); + + enum CLOCK_TYPE { /* Supported clock frequency types */ + CT_UNUSED = 0, /* Initialized value */ + CT_DATA = 1, /* Data clock */ + CT_KERNEL = 2, /* Kernel clock */ + CT_SYSTEM = 3 /* System Clock */ + }; + + struct clock_freq { /* Clock Frequency Entry */ + uint16_t m_freq_Mhz; /* Frequency in MHz */ + uint8_t m_type; /* Clock type (enum CLOCK_TYPE) */ + uint8_t m_unused[5]; /* Not used - padding */ + char m_name[128]; /* Clock Name */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct clock_freq) == 136, "clock_freq structure no longer is 136 bytes in size"); + + struct clock_freq_topology { /* Clock frequency section */ + int16_t m_count; /* Number of entries */ + struct clock_freq m_clock_freq[1]; /* Clock array */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct clock_freq_topology) == 138, "clock_freq_topology structure no longer is 138 bytes in size"); + + enum MCS_TYPE { /* Supported MCS file types */ + MCS_UNKNOWN = 0, /* Initialized value */ + MCS_PRIMARY = 1, /* The primary mcs file data */ + MCS_SECONDARY = 2, /* The secondary mcs file data */ + }; + + struct mcs_chunk { /* One chunk of MCS data */ + uint8_t m_type; /* MCS data type */ + uint8_t m_unused[7]; /* padding */ + uint64_t m_offset; /* data offset from the start of the section */ + uint64_t m_size; /* data size */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct mcs_chunk) == 24, "mcs_chunk structure no longer is 24 bytes in size"); + + struct mcs { /* MCS data section */ + int8_t m_count; /* Number of chunks */ + int8_t m_unused[7]; /* padding */ + struct mcs_chunk m_chunk[1]; /* MCS chunks followed by data */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct mcs) == 32, "mcs structure no longer is 32 bytes in size"); + + struct bmc { /* bmc data section */ + uint64_t m_offset; /* data offset from the start of the section */ + uint64_t m_size; /* data size (bytes)*/ + char m_image_name[64]; /* Name of the image (e.g., MSP432P401R) */ + char m_device_name[64]; /* Device ID (e.g., VCU1525) */ + char m_version[64]; + char m_md5value[33]; /* MD5 Expected Value(e.g., 56027182079c0bd621761b7dab5a27ca)*/ + char m_padding[7]; /* Padding */ + }; + XCLBIN_STATIC_ASSERT(sizeof(struct bmc) == 248, "bmc structure no longer is 248 bytes in size"); + + struct soft_kernel { /* soft kernel data section */ + // Prefix Syntax: + // mpo - member, pointer, offset + // This variable represents a zero terminated string + // that is offseted from the beginning of the section. + // + // The pointer to access the string is initialized as follows: + // char * pCharString = (address_of_section) + (mpo value) + uint32_t mpo_name; // Name of the soft kernel + uint32_t m_image_offset; // Image offset + uint32_t m_image_size; // Image size + uint32_t mpo_version; // Version + uint32_t mpo_md5_value; // MD5 checksum + uint32_t mpo_symbol_name; // Symbol name + uint32_t m_num_instances; // Number of instances + uint8_t padding[36]; // Reserved for future use + uint8_t reservedExt[16]; // Reserved for future extended data + }; + XCLBIN_STATIC_ASSERT(sizeof(struct soft_kernel) == 80, "soft_kernel structure no longer is 80 bytes in size"); + + struct aie_resources_bin { /* aie_resources_bin data section */ + // Prefix Syntax: + // mpo - member, pointer, offset + // This variable represents a zero terminated string + // that is offseted from the beginning of the section. + // + // The pointer to access the string is initialized as follows: + // char * pCharString = (address_of_section) + (mpo value) + uint32_t mpo_name; // Name of the aie_resources_bin section + uint32_t m_image_offset; // Image offset + uint32_t m_image_size; // Image size + uint32_t mpo_version; // Version + uint32_t m_start_column; // Start column + uint32_t m_num_columns; // Number of columns + uint8_t padding[36]; // Reserved for future use + uint8_t reservedExt[16]; // Reserved for future extended data + }; + XCLBIN_STATIC_ASSERT(sizeof(struct aie_resources_bin) == 76, "aie_resources_bin structure no longer is 76 bytes in size"); + + enum FLASH_TYPE + { + FLT_UNKNOWN = 0, + FLT_BIN_PRIMARY + }; + + struct flash { /* flash data section */ + // Prefix Syntax: + // mpo - member, pointer, offset + // This variable represents a zero terminated string + // that is offseted from the beginning of the section. + // + // The pointer to access the string is initialized as follows: + // char * pCharString = (address_of_section) + (mpo value) + uint16_t m_flash_type; // ENUM FLASH_TYPE + uint8_t padding[2]; // Alignment buffer + uint32_t m_image_offset; // Image offset + uint32_t m_image_size; // Image size + uint32_t mpo_name; // Name of the flash image + uint32_t mpo_version; // Version + uint32_t mpo_md5_value; // MD5 checksum + uint8_t reserved[32]; // Reserved for future use + uint8_t reservedExt[16]; // Reserved for future extended data + }; + XCLBIN_STATIC_ASSERT(sizeof(struct flash) == 72, "flash structure no longer is 72 bytes in size"); + + enum CHECKSUM_TYPE + { + CST_UNKNOWN = 0, + CST_SDBM = 1, + CST_LAST + }; + + struct vender_metadata { /* vender metadata section */ + // Prefix Syntax: + // mpo - member, pointer, offset + // This variable represents a zero terminated string + // that is offseted from the beginning of the section. + // + // The pointer to access the string is initialized as follows: + // char * pCharString = (address_of_section) + (mpo value) + uint32_t mpo_name; // Name of the the vender metadata section + uint32_t m_image_offset; // Image offset + uint32_t m_image_size; // Image size + uint8_t padding[36]; // Reserved for future use + }; + XCLBIN_STATIC_ASSERT(sizeof(struct vender_metadata) == 48, "vender metadata kernel structure no longer is 48 bytes in size"); + + + struct array_offset { + uint32_t size; // Number of elements in the array + uint32_t offset; // Array offset from the start of the section + }; + + XCLBIN_STATIC_ASSERT(sizeof(struct array_offset) == 8, "array_offset structure no longer is 8 bytes in size"); + + enum CDO_Type { + CT_UNKNOWN = 0, + CT_PRIMARY = 1, + CT_LITE = 2, + CT_PREPOST = 3 + }; + + struct cdo_group { + uint32_t mpo_name; // Name of the CDO group (Null terminated string) + uint8_t cdo_type; // CDO group type (CDO_Type) + uint8_t padding[3]; + uint64_t pdi_id; // PDI ID + struct array_offset dpu_kernel_ids; // Array of dpu_kernel_ids (uint64_t) + struct array_offset pre_cdo_groups; // Array of Pre CDO Group IDs (uint32_t) + uint8_t reserved[64]; // Reserved + }; + XCLBIN_STATIC_ASSERT(sizeof(struct cdo_group) == 96, "cdo_group structure no longer is 96 bytes in size"); + XCLBIN_STATIC_ASSERT(sizeof(struct cdo_group) % sizeof(uint64_t) == 0, "cdo_group structure needs to be 64-bit word aligned"); + + // 32KB per tile, 64 rows * 64 columns + #define PDI_IMAGE_MAX_SIZE 32*1024*64*64 + struct aie_pdi { + xuid_t uuid; // PDI container UUID (16 bytes) + struct array_offset pdi_image; // PDI Image (uint8_t) + struct array_offset cdo_groups; // Array of cdo_groups (cdo_group) + uint8_t reserved[64]; // Reserved + }; + + XCLBIN_STATIC_ASSERT(sizeof(struct aie_pdi) == 96, "aie_pdi structure no longer is 96 bytes in size"); + XCLBIN_STATIC_ASSERT(sizeof(struct aie_pdi) % sizeof(uint64_t) == 0, "aie_pdi structure needs to be 64-bit word aligned"); + + struct aie_partition_info { + uint16_t column_width; // Width of the partition + uint8_t padding[6]; // Byte alignment + struct array_offset start_columns; // Array of start column identifiers (uint16_t) + uint8_t reserved[72]; // Reserved + }; + XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition_info) == 88, "partition_info structure no longer is 88 bytes in size"); + + struct aie_partition { + uint8_t schema_version; // Group schema version (default 0) + uint8_t padding0[3]; // Byte alignment + uint32_t mpo_name; // Name of the aie_partition + uint32_t operations_per_cycle; // Operations per cycle. Used later to create TOPS (operations_per_cycle * ) + uint8_t padding[4]; + uint64_t inference_fingerprint; // The unique hash value of the inference function + uint64_t pre_post_fingerprint; // The unique hash value of pre post + struct aie_partition_info info; // Partition information + struct array_offset aie_pdi; // PDI Array (aie_partition_info) + // kernel_commit_id is modeled after mpo_name + // This variable represents a zero terminated string + // that is offseted from the beginning of the section. + // + // The pointer to access the string is initialized as follows: + // char * pCharString = (address_of_section) + (mpo value) + uint32_t kernel_commit_id; // The git repo commit id for DPU_PHX_KERNEL + uint8_t reserved[52]; // Reserved + }; + XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) == 184, "aie_partition structure no longer is 184 bytes in size"); + XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) % sizeof(uint64_t) == 0, "aie_partition structure needs to be 64-bit word aligned"); + + /**** END : Xilinx internal section *****/ + +# if defined(__cplusplus) && !defined(__KERNEL__) && !defined(_KERNEL_MODE) + namespace xclbin { + inline const axlf_section_header* + get_axlf_section(const axlf* top, axlf_section_kind kind) + { + auto begin = top->m_sections; + auto end = begin + top->m_header.m_numSections; + auto itr = std::find_if(begin,end,[kind](const axlf_section_header& sec) { return sec.m_sectionKind == static_cast(kind); }); + return (itr!=end) ? &(*itr) : nullptr; + } + + // Helper C++ section iteration + // To keep with with the current "coding" them, the function get_axlf_section_next() was + // introduced find 'next' common section names. + // + // Future TODO: Create a custom iterator and refactor the code base to use it. + // + // Example on how this function may be used: + // + // const axlf_section_header * pSection; + // const axlf* top = ; + // for (pSection = xclbin::get_axlf_section( top, SOFT_KERNEL); + // pSection != nullptr; + // pSection = xclbin::get_axlf_section_next( top, pSection, SOFT_KERNEL)) { + // + // } + inline const axlf_section_header* + get_axlf_section_next(const axlf* top, const axlf_section_header* current_section, axlf_section_kind kind) + { + if (top == nullptr) { return nullptr; } + if (current_section == nullptr) { return nullptr; } + + auto end = top->m_sections + top->m_header.m_numSections; + + auto begin = current_section + 1; // Point to the next section + if (begin == end) { return nullptr; } + + auto itr = std::find_if(begin, end, [kind](const axlf_section_header &sec) {return sec.m_sectionKind == static_cast(kind); }); + return (itr!=end) ? &(*itr) : nullptr; + } + } +# endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/detail/xrt_error_code.h b/src/runtime_src/core/include/xrt/detail/xrt_error_code.h new file mode 100644 index 00000000000..2b635a8d6f1 --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/xrt_error_code.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2020, Xilinx Inc + * + * This file is dual licensed. It may be redistributed and/or modified + * under the terms of the Apache 2.0 License OR version 2 of the GNU + * General Public License. + * + * Apache License Verbiage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * GPL license Verbiage: + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write + * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + */ +#ifndef INCLUDE_XRT_DETAIL_XRT_ERROR_CODE_H_ +#define INCLUDE_XRT_DETAIL_XRT_ERROR_CODE_H_ + +#if defined(__KERNEL__) +# include +#elif defined(__cplusplus) +# include +#else +# include +#endif + +/** + * xrtErrorCode layout + * + * This layout is internal to XRT (akin to a POSIX error code). + * + * The error code is populated by driver and consumed by XRT + * implementation where it is translated into an actual error / info / + * warning that is propagated to the end user. + * + * 63 - 48 47 - 40 39 - 32 31 - 24 23 - 16 15 - 0 + * -------------------------------------------------------- + * | | | | | | | | | | |----| xrtErrorNum + * | | | | | | | | |----|---------- xrtErrorDriver + * | | | | | | |----|-------------------- xrtErrorSeverity + * | | | | |----|------------------------------ xrtErrorModule + * | | |----|---------------------------------------- xrtErrorClass + * |----|-------------------------------------------------- reserved + * + */ +typedef uint64_t xrtErrorCode; +typedef uint64_t xrtErrorTime; + +#define XRT_ERROR_NUM_MASK 0xFFFFUL +#define XRT_ERROR_NUM_SHIFT 0 +#define XRT_ERROR_DRIVER_MASK 0xFUL +#define XRT_ERROR_DRIVER_SHIFT 16 +#define XRT_ERROR_SEVERITY_MASK 0xFUL +#define XRT_ERROR_SEVERITY_SHIFT 24 +#define XRT_ERROR_MODULE_MASK 0xFUL +#define XRT_ERROR_MODULE_SHIFT 32 +#define XRT_ERROR_CLASS_MASK 0xFUL +#define XRT_ERROR_CLASS_SHIFT 40 + +#define XRT_ERROR_CODE_BUILD(num, driver, severity, module, eclass) \ + ((((num) & XRT_ERROR_NUM_MASK) << XRT_ERROR_NUM_SHIFT) | \ + (((driver) & XRT_ERROR_DRIVER_MASK) << XRT_ERROR_DRIVER_SHIFT) | \ + (((severity) & XRT_ERROR_SEVERITY_MASK) << XRT_ERROR_SEVERITY_SHIFT) | \ + (((module) & XRT_ERROR_MODULE_MASK) << XRT_ERROR_MODULE_SHIFT) | \ + (((eclass) & XRT_ERROR_CLASS_MASK) << XRT_ERROR_CLASS_SHIFT)) + +#define XRT_ERROR_NUM(code) (((code) >> XRT_ERROR_NUM_SHIFT) & XRT_ERROR_NUM_MASK) +#define XRT_ERROR_DRIVER(code) (((code) >> XRT_ERROR_DRIVER_SHIFT) & XRT_ERROR_DRIVER_MASK) +#define XRT_ERROR_SEVERITY(code) (((code) >> XRT_ERROR_SEVERITY_SHIFT) & XRT_ERROR_SEVERITY_MASK) +#define XRT_ERROR_MODULE(code) (((code) >> XRT_ERROR_MODULE_SHIFT) & XRT_ERROR_MODULE_MASK) +#define XRT_ERROR_CLASS(code) (((code) >> XRT_ERROR_CLASS_SHIFT) & XRT_ERROR_CLASS_MASK) + +/** + * xrt_error_num - XRT specific error numbers + */ +enum xrtErrorNum { + XRT_ERROR_NUM_FIRWWALL_TRIP = 1, + XRT_ERROR_NUM_TEMP_HIGH, + XRT_ERROR_NUM_AIE_SATURATION, + XRT_ERROR_NUM_AIE_FP, + XRT_ERROR_NUM_AIE_STREAM, + XRT_ERROR_NUM_AIE_ACCESS, + XRT_ERROR_NUM_AIE_BUS, + XRT_ERROR_NUM_AIE_INSTRUCTION, + XRT_ERROR_NUM_AIE_ECC, + XRT_ERROR_NUM_AIE_LOCK, + XRT_ERROR_NUM_AIE_DMA, + XRT_ERROR_NUM_AIE_MEM_PARITY, + XRT_ERROR_NUM_KDS_CU, + XRT_ERROR_NUM_KDS_EXEC, + XRT_ERROR_NUM_UNKNOWN +}; + +enum xrtErrorDriver { + XRT_ERROR_DRIVER_XOCL = 1, + XRT_ERROR_DRIVER_XCLMGMT, + XRT_ERROR_DRIVER_ZOCL, + XRT_ERROR_DRIVER_AIE, + XRT_ERROR_DRIVER_UNKNOWN +}; + +enum xrtErrorSeverity { + XRT_ERROR_SEVERITY_EMERGENCY = 1, + XRT_ERROR_SEVERITY_ALERT, + XRT_ERROR_SEVERITY_CRITICAL, + XRT_ERROR_SEVERITY_ERROR, + XRT_ERROR_SEVERITY_WARNING, + XRT_ERROR_SEVERITY_NOTICE, + XRT_ERROR_SEVERITY_INFO, + XRT_ERROR_SEVERITY_DEBUG, + XRT_ERROR_SEVERITY_UNKNOWN +}; + +enum xrtErrorModule { + XRT_ERROR_MODULE_FIREWALL = 1, + XRT_ERROR_MODULE_CMC, + XRT_ERROR_MODULE_AIE_CORE, + XRT_ERROR_MODULE_AIE_MEMORY, + XRT_ERROR_MODULE_AIE_SHIM, + XRT_ERROR_MODULE_AIE_NOC, + XRT_ERROR_MODULE_AIE_PL, + XRT_ERROR_MODULE_UNKNOWN +}; + +enum xrtErrorClass { + XRT_ERROR_CLASS_FIRST_ENTRY = 1, + XRT_ERROR_CLASS_SYSTEM = XRT_ERROR_CLASS_FIRST_ENTRY, + XRT_ERROR_CLASS_AIE, + XRT_ERROR_CLASS_HARDWARE, + XRT_ERROR_CLASS_UNKNOWN, + XRT_ERROR_CLASS_LAST_ENTRY = XRT_ERROR_CLASS_UNKNOWN +}; + +#endif diff --git a/src/runtime_src/core/include/xrt/detail/xrt_mem.h b/src/runtime_src/core/include/xrt/detail/xrt_mem.h new file mode 100644 index 00000000000..00d8db31769 --- /dev/null +++ b/src/runtime_src/core/include/xrt/detail/xrt_mem.h @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2019-2022, Xilinx Inc - All rights reserved. + * Xilinx Runtime (XRT) APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * GPL license Verbiage: + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the Free Software Foundation; + * either version 2 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef INCLUDE_XRT_DETAIL_XRT_MEM_H_ +#define INCLUDE_XRT_DETAIL_XRT_MEM_H_ + +#ifdef _WIN32 +# pragma warning( push ) +# pragma warning( disable : 4201 ) +#endif + +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +#endif + +#ifdef __cplusplus +# include +extern "C" { +#else +# if defined(__KERNEL__) +# include +# else +# include +# endif +#endif + +/** + * Encoding of flags passed to xcl buffer allocation APIs + */ +struct xcl_bo_flags +{ + union { + uint64_t all; // [63-0] + + struct { + uint32_t flags; // [31-0] + uint32_t extension; // [63-32] + }; + + struct { + uint16_t bank; // [15-0] + uint8_t slot; // [23-16] + uint8_t boflags; // [31-24] + + // extension + uint32_t access : 2; // [33-32] + uint32_t dir : 2; // [35-34] + uint32_t use : 2; // [37-36] + uint32_t unused : 26; // [63-38] + }; + }; +}; + +/** + * XCL BO Flags bits layout + * + * bits 0 ~ 15: DDR BANK index + * bits 24 ~ 31: BO flags + */ +#define XRT_BO_FLAGS_MEMIDX_MASK (0xFFFFFFUL) +#define XCL_BO_FLAGS_NONE (0) +#define XCL_BO_FLAGS_CACHEABLE (1U << 24) +#define XCL_BO_FLAGS_KERNBUF (1U << 25) +#define XCL_BO_FLAGS_SGL (1U << 26) +#define XCL_BO_FLAGS_SVM (1U << 27) +#define XCL_BO_FLAGS_DEV_ONLY (1U << 28) +#define XCL_BO_FLAGS_HOST_ONLY (1U << 29) +#define XCL_BO_FLAGS_P2P (1U << 30) +#define XCL_BO_FLAGS_EXECBUF (1U << 31) + +/** + * Shim level BO Flags for extension + */ +#define XRT_BO_ACCESS_LOCAL 0 +#define XRT_BO_ACCESS_SHARED 1 +#define XRT_BO_ACCESS_PROCESS 2 +#define XRT_BO_ACCESS_HYBRID 3 + +/** + * Shim level BO Flags for direction of data transfer + * as seen from device. + */ +#define XRT_BO_ACCESS_READ (1U << 0) +#define XRT_BO_ACCESS_WRITE (1U << 1) +#define XRT_BO_ACCESS_READ_WRITE (XRT_BO_ACCESS_READ | XRT_BO_ACCESS_WRITE) + +/** + * Shim level BO Flags to distinguish use of BO + * + * The use flag is for internal use only. + * + * XRT_BO_USE_DEBUG indicates that the buffer will be used to + * communicate debug data from driver / firmware back to user + * space. This type of usage is supported on specific + * platforms only. + + * XRT_BO_USE_KMD indicates that the buffer content can be shared + * with the kernel mode driver. This type of usage is supported on + * specific platforms only. + */ +#define XRT_BO_USE_NORMAL 0 +#define XRT_BO_USE_DEBUG 1 +#define XRT_BO_USE_KMD 2 + +/** + * XRT Native BO flags + * + * These flags are simple aliases for use with XRT native BO APIs. + */ +#define XRT_BO_FLAGS_NONE XCL_BO_FLAGS_NONE +#define XRT_BO_FLAGS_CACHEABLE XCL_BO_FLAGS_CACHEABLE +#define XRT_BO_FLAGS_DEV_ONLY XCL_BO_FLAGS_DEV_ONLY +#define XRT_BO_FLAGS_HOST_ONLY XCL_BO_FLAGS_HOST_ONLY +#define XRT_BO_FLAGS_P2P XCL_BO_FLAGS_P2P +#define XRT_BO_FLAGS_SVM XCL_BO_FLAGS_SVM +#define XRT_BO_FLAGS_CARVEOUT XCL_BO_FLAGS_KERNBUF + +/** + * This is the legacy usage of XCL DDR Flags. + * + * byte-0 lower 4 bits for DDR Flags are one-hot encoded + */ +enum xclDDRFlags { + XCL_DEVICE_RAM_BANK0 = 0x00000000, + XCL_DEVICE_RAM_BANK1 = 0x00000002, + XCL_DEVICE_RAM_BANK2 = 0x00000004, + XCL_DEVICE_RAM_BANK3 = 0x00000008, +}; + +#ifdef __cplusplus +} +#endif + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + +#ifdef _WIN32 +# pragma warning( pop ) +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/CMakeLists.txt b/src/runtime_src/core/include/xrt/experimental/CMakeLists.txt new file mode 100644 index 00000000000..40ef4bbccf7 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/CMakeLists.txt @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + +# These headers were moved from runtime_src/core/include/experimental. +# Must be installed to legacy include dir for legacy xrt package as +# well as xrt/experimental include dir for base package +set(XRT_EXPERIMENTAL_HEADER_SRC + xrt-next.h + xrt_aie.h + xrt_graph.h + xrt_bo.h + xrt_device.h + xrt_elf.h + xrt_error.h + xrt_exception.h + xrt_ext.h + xrt_fence.h + xrt_hw_context.h + xrt_ini.h + xrt_ip.h + xrt_kernel.h + xrt_mailbox.h + xrt_message.h + xrt_module.h + xrt_profile.h + xrt_queue.h + xrt_system.h + xrt_uuid.h + xrt_version.h + xrt_xclbin.h + xclbin_util.h) + +# xrt component install +install (FILES ${XRT_EXPERIMENTAL_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/experimental + COMPONENT ${XRT_DEV_COMPONENT}) + +# base component install +install (FILES ${XRT_EXPERIMENTAL_HEADER_SRC} + DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/experimental + COMPONENT ${XRT_BASE_DEV_COMPONENT}) diff --git a/src/runtime_src/core/include/xrt/experimental/xclbin_util.h b/src/runtime_src/core/include/xrt/experimental/xclbin_util.h new file mode 100644 index 00000000000..8b18755f9c0 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xclbin_util.h @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2020 Xilinx, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** + * This file contains publically exported xclbin utilities. + */ + +#ifndef xclbin_util_h_ +#define xclbin_util_h_ + +#include "xrt/detail/xclbin.h" + +static inline const axlf* +xclbin_axlf_handle(const void *xclbin) +{ + const axlf* top = (const axlf*) xclbin; + return (strncmp(top->m_magic,"xclbin2",7)) ? NULL : top; +} + +/** + * xclbin_uuid() - Get the uuid of an xclbin + * + * @xclbin: Raw pointer the enture xclbin file content + * @out: A uuid to populate with the xclbin uuid + * Return: 0 on success, errcode otherwise + */ +static inline int +xclbin_uuid(const void *xclbin, xuid_t out) +{ + const axlf* top = xclbin_axlf_handle(xclbin); + return (top) ? uuid_copy(out, top->m_header.uuid) , 0 : -EINVAL; +} + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt-next.h b/src/runtime_src/core/include/xrt/experimental/xrt-next.h new file mode 100644 index 00000000000..5a83a2a3e0d --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt-next.h @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2019-2020, Xilinx Inc - All rights reserved + * Xilinx Runtime (XRT) Experimental APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +#ifndef _XRT_NEXT_APIS_H_ +#define _XRT_NEXT_APIS_H_ + +#include "xrt/deprecated/xrt.h" + +/* + * typedef xclInterruptNotifyHandle + * + * Implementation specific type representing an interrupt notify handle + * that is used by xclOpen/CloseIPInterruptNotify() + */ +#ifdef _WIN32 +typedef void* xclInterruptNotifyHandle; +# define XCL_NULL_INTC_HANDLE INVALID_HANDLE_VALUE +#else +typedef int xclInterruptNotifyHandle; +# define XCL_NULL_INTC_HANDLE -1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Place holder for experimental APIs + */ + +/** + * xclP2pEnable() - enable or disable p2p + * + * @handle: Device handle + * @enable: false-disable, true-enable + * @force: true-force to reassign bus IO memory + * Return: 0 on success or appropriate error number + * + * Enable or Disable P2P feature. Warm reboot might be required. + */ +XCL_DRIVER_DLLESPEC +int +xclP2pEnable(xclDeviceHandle handle, bool enable, bool force); + +/* + * API to get number of live processes on the given device. + * This uses kdsstat information in sysfs. + */ +XCL_DRIVER_DLLESPEC +uint32_t +xclGetNumLiveProcesses(xclDeviceHandle handle); + +/** + * xclGetSysfsPath() - Helper function to build a sysfs node full path + * + * @handle: Device handle + * @subdev: Sub-device name + * @entry: Name of sysfs node + * @sysfsPath: Return string with full path for sysfs node + * @size: Length of the return string + * Return: 0 or standard error number + * + * (For debug and profile usage only for now) The sysfs information is + * not accessible above XRT layer now. However, debug/profile needs + * information from sysfs (for example debug_ip_layout) to properly + * initialize xdp code, so this helper API can be used + */ +XCL_DRIVER_DLLESPEC +int +xclGetSysfsPath(xclDeviceHandle handle, const char* subdev, + const char* entry, char* sysfsPath, size_t size); + +struct KernelTransferData +{ + char* cuPortName; + char* argName; + char* memoryName; + + uint64_t totalReadBytes; + uint64_t totalReadTranx; + uint64_t totalReadLatency; + uint64_t totalReadBusyCycles; + uint64_t minReadLatency; + uint64_t maxReadLatency; + + uint64_t totalWriteBytes; + uint64_t totalWriteTranx; + uint64_t totalWriteLatency; + uint64_t totalWriteBusyCycles; + uint64_t minWriteLatency; + uint64_t maxWriteLatency; +}; + +struct CuExecData +{ + char* cuName; + char* kernelName; + + uint64_t cuExecCount; + uint64_t cuExecCycles; + uint64_t cuBusyCycles; + uint64_t cuMaxExecCycles; + uint64_t cuMinExecCycles; + uint64_t cuMaxParallelIter; + uint64_t cuStallExtCycles; + uint64_t cuStallIntCycles; + uint64_t cuStallStrCycles; + +}; + +struct StreamTransferData +{ + char* masterPortName; + char* slavePortName; + + uint64_t strmNumTranx; + uint64_t strmBusyCycles; + uint64_t strmDataBytes; + uint64_t strmStallCycles; + uint64_t strmStarveCycles; +}; + +struct ProfileResults +{ + char* deviceName; + + uint64_t numAIM; + struct KernelTransferData *kernelTransferData; + + uint64_t numAM; + struct CuExecData *cuExecData; + + uint64_t numASM; + struct StreamTransferData *streamData; +}; + +/** + * int xclCreateProfileResults(xclDeviceHandle, ProfileResults**) + * + * - Creates and initializes buffer for storing the ProfileResults from + * the device. + * - To use this API, "profile_api" configuration needs to be set to + * "true" in xrt.ini. "profile_api=true" enables profiling (for + * profile counters on device) using XRT APIs (no OpenCL API) + * + * @xclDeviceHandle : Device handle + * @ProfileResults : Double pointer to hold the pointer to buffer created + * to store profiling results (on success). This argument + * remains unchanged if xclCreateProfileResults fails. + */ +XCL_DRIVER_DLLESPEC +int +xclCreateProfileResults(xclDeviceHandle, struct ProfileResults**); + +/** + * int xclGetProfileResults(xclDeviceHandle, ProfileResults*) + * + * - Read the profiling counters from the hardware and populate + * profiling data in the “ProfileResults” structure (created using + * xclCreateProfileResults). + * - To use this API, "profile_api" configuration needs to be set to + * "true" in xrt.ini. "profile_api=true" enables profiling (for + * profile counters on device) using XRT APIs (no OpenCL API) + * + * @xclDeviceHandle : Device handle + * @ProfileResults* : Pointer to buffer to store profiling results. + * This buffer should be created using previous + * call to "xclCreateProfileResults" + */ +XCL_DRIVER_DLLESPEC +int +xclGetProfileResults(xclDeviceHandle, struct ProfileResults*); + +/** + * int xclDestroyProfileResults(xclDeviceHandle, ProfileResults*) + * + * - Traverse the given ProfileResults structure and delete the + * allocated memory + * - To use this API, "profile_api" configuration needs to be set to + * "true" in xrt.ini. "profile_api=true" enables profiling (for + * profile counters on device) using XRT APIs (no OpenCL API) + * + * @xclDeviceHandle : Device handle + * @ProfileResults : Pointer to buffer to be deleted + */ +XCL_DRIVER_DLLESPEC +int +xclDestroyProfileResults(xclDeviceHandle, struct ProfileResults*); + +/** + * xclRegRead() - Read register in register space of an IP + * + * @handle: Device handle + * @ipIndex: IP index + * @offset: Offset in the register space + * @datap: Pointer to where result will be saved + * Return: 0 or appropriate error number + * + * Caller should own an exclusive context on the IP obtained via + * xclOpenContext() This API may be used to read from device registers. + * Offset is relative to the the register map exposed by the IP. + * Please note that the intent of this API is to support legacy RTL IPs. + * If you are creating a new IP please use one of the well defined + * execution models which are natively supported by XRT. + * If you have a new execution model that you would like to be natively + * supported by XRT please look into ert.h to define new command objects. + */ +XCL_DRIVER_DLLESPEC +int +xclRegRead(xclDeviceHandle handle, uint32_t ipIndex, uint32_t offset, uint32_t *datap); + +/** + * xclRegWRite() - Write to register in register space of an IP + * + * @handle: Device handle + * @ipIndex: IP index + * @offset: Offset in the register space + * @data: Data to be written + * Return: 0 or appropriate error number + * + * Caller should own an exclusive context on the CU obtained via + * xclOpenContext() This API may be used to write to device registers. + * Offset is relative to the the register map exposed by the CU. + * Please note that the intent of this API is to support legacy RTL IPs. + * If you are creating a new IP please use one of the well defined + * execution models which are natively supported by XRT. + * If you have a new execution model that you would like to be natively + * supported by XRT please look into ert.h to define new command objects. + */ +XCL_DRIVER_DLLESPEC +int +xclRegWrite(xclDeviceHandle handle, uint32_t ipIndex, uint32_t offset, uint32_t data); + +/** + * xclOpenIPInterruptNotify() - Open a fd for IP interrupt notify + * + * @handle: Device handle + * @ipIndex: IP index + * @flags: flags for the fd + * Return: Interrupt notify handle + * + * Caller should own an exclusive context on the IP obtained via + * xclOpenContext() + * + * Support for non managed IP. This is the proper way to support + * custom IPs which doesn't compliant with supported control protocol. + * + * This API would open a handle used for CU interrupt + * notification. The usage is similar to open a UIO device. Caller + * could use standard read/poll/select system call to wait for IP + * interrupts. Once this API was called, xclExecBuf() could not be + * used to schedule this specific IP. The expectation is the caller + * performing any necessary actions to make it work. + * + * Note: the IP irq would be disable after this is called. Caller + * could manually enable the interrupt by write(). + */ +XCL_DRIVER_DLLESPEC +xclInterruptNotifyHandle +xclOpenIPInterruptNotify(xclDeviceHandle handle, uint32_t ipIndex, unsigned int flags); + +/** + * xclCloseIPInterruptNotify() - Clost the interrupt notify fd + * + * @handle: Device handle + * @fd: fd handle + * Return: 0 or appropriate error number + * + * Caller should own an exclusive context on the IP obtained via xclOpenContext() + * This API would close the file descriptor used for IP interrupt notification. + * Once this API was called, xclExecBuf() could schedule this specific IP. + */ +XCL_DRIVER_DLLESPEC +int +xclCloseIPInterruptNotify(xclDeviceHandle handle, int fd); + +/** + * xclErrorClear() - Clear all asynchronous error records in driver + * + * @handle: Device handle + * Return: 0 or appropriate error number + * + * Note: this API needs root privilege + */ +XCL_DRIVER_DLLESPEC +int +xclErrorClear(xclDeviceHandle handle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_aie.h b/src/runtime_src/core/include/xrt/experimental/xrt_aie.h new file mode 100644 index 00000000000..5199342ef8c --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_aie.h @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2021 Xilinx, Inc + * ZNYQ XRT Library layered on top of ZYNQ zocl kernel driver + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +#include "xrt/xrt_aie.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_bo.h b/src/runtime_src/core/include/xrt/experimental/xrt_bo.h new file mode 100644 index 00000000000..ba38e3802b3 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_bo.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021, Xilinx Inc - All rights reserved + * Xilinx Runtime (XRT) Experimental APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +#include "xrt/xrt_bo.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_device.h b/src/runtime_src/core/include/xrt/experimental/xrt_device.h new file mode 100644 index 00000000000..9049cd8ae90 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_device.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021, Xilinx Inc - All rights reserved + * Xilinx Runtime (XRT) Experimental APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +#include "xrt/xrt_device.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_elf.h b/src/runtime_src/core/include/xrt/experimental/xrt_elf.h new file mode 100644 index 00000000000..8cb2ad9ad78 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_elf.h @@ -0,0 +1,62 @@ +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +#ifndef XRT_ELF_H_ +#define XRT_ELF_H_ + +#include "xrt/detail/config.h" +#include "xrt/detail/pimpl.h" +#include "xrt/xrt_uuid.h" + +#ifdef __cplusplus +# include +# include +#endif + +#ifdef __cplusplus +namespace xrt { + +/*! + * @class elf + * + * @brief + * An elf contains instructions for functions to execute in some + * pre-configured hardware. The xrt::elf class provides APIs to mine + * the elf itself for relevant data. + * + * An xclbin is used to configure the hardware and an elf object is + * always associated with exactly one xclbin, meaning the instructions + * are for a specific hardware configuration. + */ +class elf_impl; +class elf : public detail::pimpl +{ +public: + elf() = default; + + XRT_API_EXPORT + explicit + elf(const std::string& fnm); + + /** + * elf() - Constructor from raw ELF data + * + * @param data + * Raw data of elf + * + */ + XRT_API_EXPORT + explicit + elf(std::istream& stream); + + XRT_API_EXPORT + xrt::uuid + get_cfg_uuid() const; +}; + +} // namespace xrt + +#else +# error xrt::elf is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_error.h b/src/runtime_src/core/include/xrt/experimental/xrt_error.h new file mode 100644 index 00000000000..d9c5936f8d6 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_error.h @@ -0,0 +1,126 @@ +/** + * Copyright (C) 2020 Xilinx, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +#ifndef xrt_error_h_ +#define xrt_error_h_ + +#include "xrt.h" +#include "xrt_device.h" +#include "xrt/detail/xrt_error_code.h" + +#ifdef __cplusplus +# include +# include +# include +#endif + +#ifdef __cplusplus +namespace xrt { + +class error_impl; +class error +{ +public: + /** + * error() - Constructor for last asynchronous error of a class + * + * @device: Device to get last errors from + * @ecl: Error class to retrieve error from + */ + XCL_DRIVER_DLLESPEC + error(const xrt::device& device, xrtErrorClass ecl); + + /** + * error() - Constructor from error code and time stamp + * + * @ecl: Error code + * @timestamp: Time stamp + * + * Allow construction of error object from manually retrieved + * error code and timestamp + */ + XCL_DRIVER_DLLESPEC + error(xrtErrorCode ecl, xrtErrorTime timestamp); + + /** + * get_timestamp() - Get the timestamp for this error + * + * Return: Error timestamp + */ + XCL_DRIVER_DLLESPEC + xrtErrorTime + get_timestamp() const; + + /** + * get_error_code() - Get the error code for this error + * + * Return: Underlying xrt error code + */ + XCL_DRIVER_DLLESPEC + xrtErrorCode + get_error_code() const; + + /** + * to_string() - Convert error object into a formatted string + * + * Return: Formatted string for error + */ + XCL_DRIVER_DLLESPEC + std::string + to_string() const; + +private: + std::shared_ptr handle; +}; + +} // xrt + +#endif + +/** + * xrtErrorGetLast - Get the last error code and its timestamp of a given error class. + * + * @handle: Device handle. + * @class: Error Class for the last error to get. + * @error: Returned XRT error code. + * @timestamp: The timestamp when the error generated + * + * Return: 0 on success or appropriate XRT error code. + */ +XCL_DRIVER_DLLESPEC +int +xrtErrorGetLast(xrtDeviceHandle handle, enum xrtErrorClass ecl, xrtErrorCode* error, uint64_t* timestamp); + +/** + * xrtErrorGetString - Get the description string of a given error code. + * + * @handle: Device handle. + * @error: XRT error code. + * @out: Preallocated output buffer for the error string. + * @len: Length of output buffer. + * @out_len: Output of length of message, ignored if null. + * + * Return: 0 on success or appropriate XRT error code. + * + * Specifying out_len while passing nullptr for output buffer will + * return the message length, which can then be used to allocate the + * output buffer itself. + */ +XCL_DRIVER_DLLESPEC +int +xrtErrorGetString(xrtDeviceHandle, xrtErrorCode error, char* out, size_t len, size_t* out_len); + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_exception.h b/src/runtime_src/core/include/xrt/experimental/xrt_exception.h new file mode 100644 index 00000000000..8f7c99ef19a --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_exception.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_EXCEPTION_H_ +#define XRT_EXCEPTION_H_ + +#ifdef __cplusplus +# include +# include +#endif + +#ifdef __cplusplus + +namespace xrt { + +/** + * class exception -- XRT specific exceptions + * + * In most APIs errors are propagated as std::exception or + * mostly as std::system_error with error codes corresponding to + * POSIX error codes. + * + * Specific non standard system errors are defined as a specific + * xrt::exception, which in turn is derived from a std::exception. + */ +class exception : public std::exception +{ +public: + exception() + {} +}; + +} // namespace xrt + +#else +# error xrt_exception is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_ext.h b/src/runtime_src/core/include/xrt/experimental/xrt_ext.h new file mode 100644 index 00000000000..dc1b79d6f7f --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_ext.h @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_EXT_H_ +#define XRT_EXT_H_ + +// XRT extensions to XRT coreutil +// These extensions are experimental + +#include "xrt/detail/config.h" +#include "xrt/detail/bitmask.h" +#include "xrt/xrt_bo.h" +#include "xrt/xrt_hw_context.h" +#include "xrt/xrt_kernel.h" +#include "xrt/experimental/xrt_module.h" + +#ifdef __cplusplus +# include +#endif + +#ifdef __cplusplus +namespace xrt::ext { + +/*! + * @class bo + * + * @brief Buffer object extension + * xrt::ext::bo is an extension of xrt::bo with additional functionality + * + * @details + * An extension buffer amends the contruction of an xrt::bo with + * additional simplified constructors for specifying access mode of + * host only buffers. + * + * Once constructed, the object must be assigned to an xrt::bo object + * before use. This is becayse XRT relies on templated kernel + * argument assignment and the templated assignment operator is not + * specialized for xrt::ext::bo. + * + * Ultimately the extension will be merged into class xrt::bo. + */ +class bo : public xrt::bo +{ +public: + + /** + * @enum access_mode - buffer object accessibility + * + * @var none + * No access is specified, same as read|write|local + * @var read + * The buffer is read by device, the cpu writes to the buffer + * @var write + * The buffer is written by device, the host reads from the buffer + * @var local + * Access is local to process and device on which it is allocated + * @var shared + * Access is shared between devices within process + * @var process + * Access is shared between processes and devices + * @var hybrid + * Access is shared between drivers (cross-adapter) + * + * The access mode is used to specify how the buffer is used by + * device and process. + * + * A buffer can be specified as local, meaning it is only used by + * the process and device on which it is allocated. A buffer can + * also be specified as shared, meaning it is shared between devices + * within the process. Finally a buffer can be specified as + * process, meaning it is shared between processes and devices. If + * neither local, shared, or process is specified, the default is + * local. Only one of local, shared, or process can be specified. + * + * A buffer can be opened for read, meaning the device will read the + * content written by host, or it can be opened for write, meaning + * the device will write to the buffer and the host will read. To + * specify that a buffer is used for both read and write, the access + * flags can be ORed. If neither read or write is specified, the + * default is read|write. + * + * The default access mode is read|write|local when no access mode + * is specified. + * + * Friend operators are provided for bitwise operations on access + * mode. It is invalid to combine local, shared, proces, and hybrid. + */ + enum class access_mode : uint64_t + { + none = 0, + + read = 1 << 0, + write = 1 << 1, + read_write = read | write, + + local = 0, + shared = 1 << 2, + process = 1 << 3, + hybrid = 1 << 4, + }; + + friend constexpr access_mode operator&(access_mode lhs, access_mode rhs) + { + return xrt::detail::operator&(lhs, rhs); + } + + friend constexpr access_mode operator|(access_mode lhs, access_mode rhs) + { + return xrt::detail::operator|(lhs, rhs); + } + + /** + * bo() - Constructor with user host buffer and access mode + * + * @param device + * The device on which to allocate this buffer + * @param userptr + * The host buffer which must be page aligned + * @param sz + * Size of buffer which must in multiple of page size + * @param access + * Specific access mode for the buffer (see `enum access_mode`) + * + * This constructor creates a host_only buffer object with + * specified access. + */ + XRT_API_EXPORT + bo(const xrt::device& device, void* userptr, size_t sz, access_mode access); + + /** + * bo() - Constructor with user host buffer and access mode + * + * @param device + * The device on which to allocate this buffer + * @param userptr + * The host buffer which must be page aligned + * @param sz + * Size of buffer which must in multiple of page size + * @param access + * Specific access mode for the buffer (see `enum access_mode`) + * + * This constructor creates a host_only buffer object with local + * access and read|write direction. + */ + XRT_API_EXPORT + bo(const xrt::device& device, void* userptr, size_t sz); + + /** + * bo() - Constructor for buffer object with specific access + * + * @param device + * The device on which to allocate this buffer + * @param sz + * Size of buffer + * @param access + * Specific access mode for the buffer (see `enum access_mode`) + * + * This constructor creates a host_only buffer object with + * specified access. + */ + XRT_API_EXPORT + bo(const xrt::device& device, size_t sz, access_mode access); + + /** + * bo() - Constructor for buffer object + * + * @param device + * The device on which to allocate this buffer + * @param sz + * Size of buffer + + * This constructor creates a host_only buffer object with local + * access and read|write direction. + */ + XRT_API_EXPORT + bo(const xrt::device& device, size_t sz); + + /** + * bo() - Constructor to import an exported buffer from another process + * + * @param device + * The device that imports this buffer + * @param pid + * Process id of exporting process + * @param ehdl + * Exported buffer handle, implementation specific type + * + * The exported buffer handle is obtained from exporting process by + * calling `export_buffer()` on the buffer to be exported. + */ + XRT_API_EXPORT + bo(const xrt::device& device, pid_type pid, xrt::bo::export_handle ehdl); + + /** + * bo() - Constructor for buffer object + * + * @param hwctx + * The hardware context that this buffer object uses for queue + * operations such as syncing and residency operations. + * @param sz + * Size of buffer + * @param access + * Specific access mode for the buffer (see `enum access_mode`) + * + * This constructor creates a host_only buffer object with specified + * access mode. The hardware context is used for syncing of data + * to from device and residency operations, which are all enqueued + * operations that are synchronized on fence objects. + */ + XRT_API_EXPORT + bo(const xrt::hw_context& hwctx, size_t sz, access_mode access); + + /** + * bo() - Constructor for buffer object + * + * @param hwctx + * The hardware context that this buffer object uses for queue + * operations such as syncing and residency operations. + * @param sz + * Size of buffer + * + * This constructor creates a host_only buffer object with local + * access and in|out direction. + */ + XRT_API_EXPORT + bo(const xrt::hw_context& hwctx, size_t sz); + + /// @cond + // Deprecated. Hardware context specific import is not supported + XRT_API_EXPORT + bo(const xrt::hw_context& hwctx, pid_type pid, xrt::bo::export_handle ehdl); + /// @endcond +}; + + +class kernel : public xrt::kernel +{ +public: + /** + * kernel() - Constructor from module + * + * @param hwctx + * The hardware context that this kernel is created in. + * @param module + * A module with elf binary instruction code which the + * kernel function will execute. + * @param name + * Name of kernel function to construct. + * + * The module contains an elf binary with instructions for maybe + * multiple functions. When the kernel is constructed, the + * corresponding function is located in the module. The + * instructions for the function are sent to the kernel mode driver + * in an ERT packet along with the kernel function arguments. + */ + XRT_API_EXPORT + kernel(const xrt::hw_context& ctx, const xrt::module& mod, const std::string& name); +}; + +} // xrt::ext + +#else +# error xrt::ext is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_fence.h b/src/runtime_src/core/include/xrt/experimental/xrt_fence.h new file mode 100644 index 00000000000..5ac082bba54 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_fence.h @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_FENCE_H_ +#define XRT_FENCE_H_ + +#include "xrt/detail/config.h" +#include "xrt/xrt_device.h" + +// Until better place for pid_type +#include "xrt/xrt_bo.h" + +#ifdef __cplusplus +# include +# include +# include +#endif + +#ifdef __cplusplus +// Opaque handle to internal use +namespace xrt_core { +class fence_handle; +} + +namespace xrt { + +/*! + * @class fence + * + * @brief + * Fence object for synchronization of operations + * + * @details + * A fence object is used to synchronize operations between + * run objects. + * + * A fence object should be signaled by one run object and waited on + * by other run objects. The fence represents the expected next state + * of a run object, it is enqueued as a wait for one or more run + * objects, and it is signaled upon completion of the run on which is + * was enqueued. + * + * The fence object has state that represents the next value (fence + * id) of an enqueued operation and is has state that represents the + * corresponding value to wait for. Both the next and the expected + * value is incremented when the fence is signaled or waited upon, and + * therefore a fence should be copied if more than one operation is + * dependent on it. A fence should never be signaled by more than one + * run object. + * + * A fence object can be exported for use by another process. This + * allows setting up a pipeline of operations between processes. + */ +class fence_impl; +class fence : public detail::pimpl +{ +public: +#ifdef _WIN32 + using export_handle = uint64_t; +#else + using export_handle = int; +#endif + +public: + /** + * @enum access_mode - buffer object accessibility + * + * @var local + * Access is local to process and device on which it is allocated + * @var shared + * Access is shared between devices within process + * @var process + * Access is shared between processes and devices + * @var hybrid + * Access is shared between drivers (cross-adapater) + */ + enum class access_mode : uint8_t { local, shared, process, hybrid }; + + /** + * fence() - Default constructor + * + * Constructs an empty fence object that converts to false in + * boolean comparisons. + */ + fence() = default; + + /** + * fence() - Constructor for fence object with specific access + * + * @param device + * The device on which to allocate this fence + * @param access + * Specific access mode for the buffer (see `enum access_mode`) + * + * The fence object should be signaled by one run object and waited + * on by other run objects. The fence represents the expected next + * state of a run object, it is enqueued as a wait for one or + * more run objects, and it is signaled upon completion of the run + * on which is was enqueued. + * + * The fence object has state that represents the next value (fence + * id) of an enqueued operation and is has state that represents the + * corresponding value to wait for. Both the next and the expected + * value is incremented when the fence is signaled or waited upon, + * and therefore a fence should be copied if more than one operation + * is dependent on it. A fence should never be signaled by more + * than one run object. + */ + XRT_API_EXPORT + fence(const xrt::device& device, access_mode access); + + /** + * fence() - Constructor to import an exported fence + * + * @param pid + * Process id of exporting process + * @param ehdl + * Exported fence handle, implementation specific type + * + * The exported fence handle is obtained from exporting process by + * calling `export_fence()` on the fence to be exported. + */ + XRT_API_EXPORT + fence(const xrt::device& device, pid_type pid, export_handle ehdl); + + /** + * fence() - Copy constructor + * + * Creates a new fence object that is a copy of the other fence. + * There is no shared state between the two fence objects. + * + * The copy constructor is used when a fence is to be waited on by + * more than one consumer. Since the fence has state that increments + * at each wait submission, the fence should be copied if more than + * one consumer is to wait on it. + */ + XRT_API_EXPORT + fence(const fence& other); + + /** + * fence() - Move constructor + * + * Move constructor. The other fence object is left in an + * unspecified state. + */ + XRT_API_EXPORT + fence(fence&& other) noexcept; + + /** + * Move assignment operator + * + * The other fence object is left in an unspecified state. + */ + XRT_API_EXPORT + fence& + operator=(fence&& other) noexcept = default; + + ///@cond + // Constructor from internal implementation + XRT_API_EXPORT + fence(std::unique_ptr handle); + ///@endcond + + /** + * export_fence() - Export fence object to another process + * + * @return + * Exported fence handle, implementation specific type. This + * exported handle can be imported by another process + */ + XRT_API_EXPORT + export_handle + export_fence(); + + /** + * wait() - Wait for fence to be signaled + * + * @paramm timeout Timeout for wait. A value of 0, implies block + * until completes. + * @return std::cv_status::no_timeout when wait + * completes succesfully. std::cv_status::timeout when wait times + * out. + * + * Throws on error (to-be-defined) + + * Wait for fence to be signaled at its current value. This is + * CPU blocking operation. + */ + XRT_API_EXPORT + std::cv_status + wait(const std::chrono::milliseconds& timeout); + + /** + * get_access_mode() - Return the mode of access for the fence + * + * See access mode. Only process level fence objects can be + * exported. + */ + XRT_API_EXPORT + access_mode + get_access_mode() const; + + /** + * get_next_state() - Return the next state of the fence + * + * The next state is the value that the fence will be set to when it + * is signaled and it is the value that will be waited on when the + * fence is submitted for wait. The next state is incremented each + * time the fence is signaled or waited on. + */ + XRT_API_EXPORT + uint64_t + get_next_state() const; +}; + +} // namespace xrt + +#else +# error xrt::fence is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_graph.h b/src/runtime_src/core/include/xrt/experimental/xrt_graph.h new file mode 100644 index 00000000000..a2de4fd79b2 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_graph.h @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2021 Xilinx, Inc + * ZNYQ XRT Library layered on top of ZYNQ zocl kernel driver + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +#include "xrt/xrt_graph.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_hw_context.h b/src/runtime_src/core/include/xrt/experimental/xrt_hw_context.h new file mode 100644 index 00000000000..dcd6ee243f8 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_hw_context.h @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. +#include "xrt/xrt_hw_context.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_ini.h b/src/runtime_src/core/include/xrt/experimental/xrt_ini.h new file mode 100644 index 00000000000..d128d25dc58 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_ini.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021-2022 Xilinx, Inc + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _XRT_INI_H_ +#define _XRT_INI_H_ + +#include "xrt.h" + +#ifdef __cplusplus +# include +#endif + +#ifdef __cplusplus + +/*! + * @namespace xrt::ini + * + * @brief + * APIs for XRT configuration control. + * + * @details + * XRT can be configured through a json xrt.ini file co-located with + * the host executable. If present, XRT uses configuration options + * from the ini file when a given option is first accessed. Without an + * ini file, the configuration options take on default values. + * + * The APIs in this file allow host application to specify + * configuration options for XRT programatically. It is only possible + * for the host application to change configuration options before a + * given option is used by XRT the very first time. + */ +namespace xrt { namespace ini { + +/*! + * set() - Change xrt.ini string value for specified key + * + * @param key + * Key to change value for + * @param value + * New value for key + * + * Throws if key value cannot be changed. + */ +XCL_DRIVER_DLLESPEC +void +set(const std::string& key, const std::string& value); + +/*! + * set() - Change xrt.ini string value for specified key + * + * @param key + * Key to change value for + * @param value + * New value for key + * + * Throws if key value cannot be changed. + */ +inline void +set(const std::string& key, unsigned int value) +{ + set(key, std::to_string(value)); +} + + +}} // ini, xrt + +/// @cond +extern "C" { +#endif + +/** + * xrtIniSet() - Change xrt.ini string value for specified key + * + * @key: Key to change value for + * @value: New value for key + * Return: 0 on success, error if key value cannot be changed + */ +XCL_DRIVER_DLLESPEC +int +xrtIniStringSet(const char* key, const char* value); + +/** + * xrtIniUintSet() - Change xrt.ini unsigned int value for specified key + * + * @key: Key to change value for + * @value: New value for key + * Return: 0 on success, error if key value cannot be changed + */ +XCL_DRIVER_DLLESPEC +int +xrtIniUintSet(const char* key, unsigned int value); + +/// @endcond +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_ip.h b/src/runtime_src/core/include/xrt/experimental/xrt_ip.h new file mode 100644 index 00000000000..1eff07f9f2c --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_ip.h @@ -0,0 +1,200 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved. +// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_IP_H_ +#define XRT_IP_H_ + +#include "xrt.h" +#include "xrt/xrt_uuid.h" +#include "xrt/xrt_device.h" +#include "xrt/xrt_hw_context.h" +#include "xrt/detail/pimpl.h" + +#ifdef __cplusplus +# include +# include +# include +#endif + +#ifdef __cplusplus + +namespace xrt { + +/*! + * @class ip + * + * @brief + * xrt::ip represent the custom IP + * + * @details The ip can be controlled through read- and write register + * only. If the IP supports interrupt notification, then xrt::ip + * objects supports enabling and control of underlying IP interrupt. + * + * In order to construct an ip object, the following requirements must be met: + * + * - The custom IP must appear in IP_LAYOUT section of xclbin. + * - The custom IP must have a base address such that it can be controlled + * through register access at offsets from base address. + * - The custom IP must have an address range so that write and read access + * to base address offset can be validated. + * - XRT supports exclusive access only for the custom IP, this is to other + * processes from accessing the same IP at the same time. + */ +class ip_impl; +class ip : public detail::pimpl +{ +public: + /*! + * @class interrupt + * + * @brief + * xrt::ip::interrupt represents an IP interrupt event. + * + * This class represents an IP interrupt event. The interrupt + * object is contructed via `xrt::ip::create_interrupt_notify()`. + * The object can be used to enable and disable IP interrupts + * and to wait for an interrupt to occur. + * + * Upon construction, the IP interrupt is automatically enabled. + */ + class interrupt_impl; + class interrupt : public detail::pimpl + { + public: + /// @cond + explicit + interrupt(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + /// @endcond + + /** + * enable() - Enable interrupt + * + * Enables the IP interrupt if not already enabled. The + * IP interrupt is automatically enabled when the interrupt + * object is created. + */ + XCL_DRIVER_DLLESPEC + void + enable(); + + /** + * disable() - Disable interrupt + * + * Disables the IP interrupt notification from IP. + */ + XCL_DRIVER_DLLESPEC + void + disable(); + + /** + * wait() - Wait for interrupt + * + * Wait for interrupt from IP. Upon return, interrupt is + * re-enabled. + */ + XCL_DRIVER_DLLESPEC + void + wait(); + + /** + * wait() - Wait for interrupt or timeout to occur + * + * @param timeout + * Timout in milliseconds. + * @return + * std::cv_status::timeout if the timeout specified expired, + * std::cv_status::no_timeout otherwise. + * + * Blocks the current thread until an interrupt is received from the IP, or + * until after the specified timeout duration + */ + XCL_DRIVER_DLLESPEC + std::cv_status + wait(const std::chrono::milliseconds& timeout) const; + }; + +public: + /** + * ip() - Construct empty ip object + */ + ip() + {} + + /** + * ip() - Constructor from a device and xclbin + * + * @param device + * Device programmed with the IP + * @param xclbin_id + * UUID of the xclbin with the IP + * @param name + * Name of IP to construct + * + * The IP is opened with exclusive access meaning that no other + * xrt::ip objects can use the same IP, nor will another process be + * able to use the IP while one process has been granted access. + * + * Constructor throws on error. + */ + XCL_DRIVER_DLLESPEC + ip(const xrt::device& device, const xrt::uuid& xclbin_id, const std::string& name); + + /// @cond + /// Experimental in 2022.2 + XCL_DRIVER_DLLESPEC + ip(const xrt::hw_context& ctx, const std::string& name); + /// @endcond + + /** + * write_register() - Write to the address range of an ip + * + * @param offset + * Offset in register space to write to + * @param data + * Data to write + * + * Throws std::out_or_range if offset is outside the + * ip address space + */ + XCL_DRIVER_DLLESPEC + void + write_register(uint32_t offset, uint32_t data); + + /** + * read_register() - Read data from ip address range + * + * @param offset + * Offset in register space to read from + * @return + * Value read from offset + * + * Throws std::out_or_range if offset is outside the + * ip address space + */ + XCL_DRIVER_DLLESPEC + uint32_t + read_register(uint32_t offset) const; + + /** + * create_interrupt_notify() - Create xrt::ip::interrupt object + * + * @return + * xrt::ip::interrupt object can be used to control IP interrupt. + * + * This function creates an xrt::ip::interrupt object that can be + * used to control and wait for IP interrupt. On successful + * return the IP has interrupt enabled. + * + * Throws if the custom IP doesn't support interrupts. + */ + XCL_DRIVER_DLLESPEC + interrupt + create_interrupt_notify(); +}; + +} // xrt +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_kernel.h b/src/runtime_src/core/include/xrt/experimental/xrt_kernel.h new file mode 100644 index 00000000000..54916a58d35 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_kernel.h @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2021 Xilinx, Inc. All rights reserved. +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_EXPERIMENTAL_KERNEL_H +#define XRT_EXPERIMENTAL_KERNEL_H +#include "xrt/xrt_kernel.h" +#include "xrt/xrt_hw_context.h" + +#include "xrt/detail/config.h" + +#ifdef __cplusplus +# include "xrt/detail/pimpl.h" +# include +# include +#endif + +#ifdef __cplusplus +namespace xrt { + +/** + * class runlist - A class to manage a list of xrt::run objects + * + * @brief + * This class is used to manage a list of xrt::run objects such + * that they can be executed atomically in the order they are added + * to the list. + * + * @details + * Run objects are added to the list using the add() method. A runlist + * is submitted for execution using the execute() method. Once the + * list is executing, no more run objects can be added until execution + * of the current last run object has completed. The list can be reset + * using the reset() method, which will clear all run objects, or the + * list can be reused by calling execute() again maybe with additional + * run objects. + * + * There is no support for removing individual run objects from the + * list. + */ +class runlist_impl; +class runlist : public detail::pimpl +{ +public: + /** + * class command_error - exception for abnormal runlist execution + * + * Captures the failing run object and the state at which it failed. + */ + class command_error_impl; + class command_error : public detail::pimpl, public std::exception + { + public: + XRT_API_EXPORT + command_error(const xrt::run& run, ert_cmd_state state, const std::string& what); + + /** + * get_run() - run object that failed + */ + XRT_API_EXPORT + xrt::run + get_run() const; + + /** + * get_command_state() - command state upon completion + */ + XRT_API_EXPORT + ert_cmd_state + get_command_state() const; + + XRT_API_EXPORT + const char* + what() const noexcept override; + }; + +public: + /** + * runlist() - Construct empty runlist object + * + * Can be used as lvalue in assignment. + * + * It is undefined behavior to use a default constructed runlist + * for anything but assignment. + */ + runlist() = default; + + /** + * runlist - Constructor + * + * A runlist is associated with a specific hwctx. All run objects + * added to the list must be associated with kernel objects that are + * created in specified hwctx. + * + * Throws is invariant per run object hwctx requirement is violated. + */ + XRT_API_EXPORT + explicit + runlist(const xrt::hw_context& hwctx); + + /** + * runlist - Destructor + * + * The destructor of the runlist clears the association with the run + * objects, but does not check for runlist state or wait for run + * object completion. It is the caller's responsibility to ensure + * that the runlist is not executing when the destructor is called + * or beware that there may be run objects still executing. + */ + XRT_API_EXPORT + ~runlist(); + + /** + * add() - Add a run object to the list + * + * The run object is added to the end of the list. A run object can + * only be added to a runlist once and only a runlist which must be + * associated with the same hwctx as the kernel from which the run + * object was created. + * + * It is undefined behavior to add a run object to a runlist which + * is currently executing or to explicitly start (xrt::run::start()) + * a run object that is part of a runlist. + * + * It is the caller's responsibility to ensure that the runlist is + * not executing when this method is called. This can be done by + * calling the wait() method on the runlist object. + * + * The state of run objects in a runlist should be ignored. The + * `xrt::run::state()` function is not guaranteed to reflect the + * actual run object state and cannot be called for run objects that + * are part of a runlist. If any run object fails to complete + * successfully, `xrt::runlist::wait()` will throw an exception with + * the failed run object and it's fail state. + * + * Throws if the kernel from which the run object was created does + * not match the hwctx from which the runlist was created. + * + * Throws if the run object is already part of a runlist. + * + * Throws if runlist is executing. + */ + XRT_API_EXPORT + void + add(const xrt::run& run); + + /** + * execute() - Execute the runlist + * + * The runlist is submitted for execution. The run objects in the + * list are executed atomically in the order they were added to the + * list. + * + * Executing an empty runlist is a no-op. + * + * Throws if runlist is already executing. + */ + XRT_API_EXPORT + void + execute(); + + /** + * wait() - Wait for the runlist to complete + * + * @param timeout + * Timeout for wait. A value of 0, implies block until all run + * objects have completed successfully. + * @return + * std::cv_status::no_timeout if list has completed execution of + * all run objects, std::cv_status::timeout if the timeout expired + * prior to all run objects completing. + * + * Completion of a runlist execution means that all run objects have + * completed succesfully. If any run object in the list fails to + * complete successfully, the function throws + * `xrt::runlist::command_error` with the failed run object and + * state. + */ + XRT_API_EXPORT + std::cv_status + wait(const std::chrono::milliseconds& timeout) const; + + /** + * wait() - Wait for the runlist to complete + * + * This is a convenience method that calls wait() with a timeout of 0. + * + * The function blocks until all run objects have completed or + * throws if any run object fails to complete successfully. + */ + void + wait() const + { + wait(std::chrono::milliseconds(0)); + } + + /** + * state() - Check the current state of a runlist object + * + * @return + * Current state of this run object. + * + * The state values are defined in ``include/ert.h`` + * The state of an empty runlist is ERT_CMD_STATE_COMPLETED. + * + * This function is the preferred way to poll a runlist for + * for completion. + */ + XRT_API_EXPORT + ert_cmd_state + state() const; + + /** + * DEPRECATED, prefer `state()`. + * + * Poll the runlist for completion. + * + * @return 0 if command list is still running, any other value + * indicates completion. + * + * Completion of a runlist execution means that all run objects have + * completed succesfully. If any run object in the list fails to + * complete successfully, the function throws + * `xrt::runlist::command_error` with the failed run object and + * state. + */ + XRT_API_EXPORT + int + poll() const; + + /** + * reset() - Reset the runlist + * + * The runlist is reset to its initial state. All run objects are + * removed from the list. + * + * It is the caller's responsibility to ensure that the runlist is + * not executing when this method is called. This can be done by + * calling the wait() method on the runlist object. + * + * Throws if runlist is executing. + */ + XRT_API_EXPORT + void + reset(); +}; + +} // namespace xrt + +#endif // __cplusplus +#endif // XRT_EXPERIMENTAL_KERNEL_H + + diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_mailbox.h b/src/runtime_src/core/include/xrt/experimental/xrt_mailbox.h new file mode 100644 index 00000000000..3a716b6545e --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_mailbox.h @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2021-2022 Xilinx, Inc + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _XRT_MAILBOX_H_ +#define _XRT_MAILBOX_H_ + +#include "xrt.h" +#include "xrt/xrt_kernel.h" +#include "xrt/xrt_bo.h" +#include "xrt/detail/pimpl.h" + +#ifdef __cplusplus +# include +#endif + +#ifdef __cplusplus + +namespace xrt { + +/*! + * @class mailbox + * + * @brief + * xrt::mailbox provides access to the kernel mailbox if any + * + * @details + * The mailbox extends the API of an xrt::run with mailbox specific + * APIs to explicitly control mailbox aspects of a kernel. It is an + * error to construct a mailbox from a run object or kernel that + * doesn't support mailbox. + */ +class mailbox_impl; +class mailbox : public detail::pimpl +{ +public: + /** + * mailbox() - Construct mailbox from a \ref xrt::run object. + * + * It is an error to construct a mailbox from a run object that is + * not associated with a kernel supporting mailbox, or from a run + * object associated with multiple compute units. In other words a + * mailbox is 1-1 with a compute unit that is managed by the + * argument run object. + */ + XCL_DRIVER_DLLESPEC + explicit + mailbox(const run& run); + + /** + * read() - Read kernel arguments into mailbox copy + * + * This function is asynchronous, it requests the kernel to update + * the content of the mailbox when it is safe to do so. If the + * kernel is in auto restart mode, then the update is delayed until + * beginning of next iteration. If the kernel is idle, then the + * update is immediate. + * + * The mailbox is busy until the kernel has updated the content. + * It is an error to call ``read()`` while the mailbox is busy, + * throws std::system_error with std::errc::device_or_resource_busy. + * + * This function invalidates any argument data returned through + * ``get_arg`` function. + */ + XCL_DRIVER_DLLESPEC + void + read(); + + /** + * write() - Write the mailbox copy of kernel arguments to kernel + * + * This function is asynchronous, it requests the kernel to copy + * the content of the mailbox when it is safe to do so. If the + * kernel is in auto restart mode, then the copying is delayed until + * beginning of next iteration. If the kernel is idle, then the + * copying is immediate. + * + * The mailbox is busy until the kernel has copied the content. + * It is an error to call ``write()`` while the mailbox is busy, + * throws std::system_error with std::errc::device_or_resource_busy. + */ + XCL_DRIVER_DLLESPEC + void + write(); + + /** + * get_arg() - Returns the mailbox copy of an argument + * + * @param index + * Index of kernel argument to read + * @return + * The raw data and size in bytes of data + * + * The argument data returned is a direct reference to the mailbox + * copy of the data. It is valid only until the mailbox is updated + * again. + * + * The function is synchronous and blocks if the mailbox is busy, + * per pending ``read()`` or ``write()``. + * + * Subject to deprecation in favor of type safe version. + */ + XCL_DRIVER_DLLESPEC + std::pair + get_arg(int index) const; + + /** + * set_arg() - Set a specific kernel global argument in the mailbox + * + * @param index + * Index of kernel argument to set + * @param boh + * The global buffer argument value to set (lvalue). + * + * Use this API to queue up a new kernel argument value that can + * be written to the kernel using ``write()``. + * + * The function is synchronous and blocks if the mailbox is busy, + * per pending ``read()`` or ``write()``. + */ + void + set_arg(int index, xrt::bo& boh) + { + set_arg_at_index(index, boh); + } + + /** + * set_arg() - xrt::bo variant for const lvalue + */ + void + set_arg(int index, const xrt::bo& boh) + { + set_arg_at_index(index, boh); + } + + /** + * set_arg() - xrt::bo variant for rvalue + */ + void + set_arg(int index, xrt::bo&& boh) + { + set_arg_at_index(index, boh); + } + + /** + * set_arg() - Set a specific kernel scalar argument in the mailbox + * + * @param index + * Index of kernel argument to set + * @param arg + * The scalar argument value to set. + * + * Use this API to queue up a new kernel scalar arguments value that + * can be written to the kernel using ``write()``. + * + * The function is synchronous and blocks if the mailbox is busy, + * per pending ``read()`` or ``write()``. + */ + template + void + set_arg(int index, ArgType&& arg) + { + set_arg_at_index(index, &arg, sizeof(arg)); + } + + /** + * set_arg - set named argument in the mailbox + * + * @param argnm + * Name of kernel argument + * @param argvalue + * Argument value + * + * Throws if specified argument name doesn't match kernel + * specification. Throws if argument value is incompatible with + * specified argument + */ + template + void + set_arg(const std::string& argnm, ArgType&& argvalue) + { + auto index = get_arg_index(argnm); + set_arg(index, std::forward(argvalue)); + } + + +private: + XCL_DRIVER_DLLESPEC + int + get_arg_index(const std::string& argnm) const; + + XCL_DRIVER_DLLESPEC + void + set_arg_at_index(int index, const void* value, size_t bytes); + + XCL_DRIVER_DLLESPEC + void + set_arg_at_index(int index, const xrt::bo&); +}; + +} // xrt +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_message.h b/src/runtime_src/core/include/xrt/experimental/xrt_message.h new file mode 100644 index 00000000000..b51ded4009e --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_message.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2021-2022 Xilinx, Inc + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef xrt_message_h_ +#define xrt_message_h_ + +#include "xrt.h" + +#ifdef __cplusplus +# include +# include +#endif + +#ifdef __cplusplus + +/*! + * @namespace xrt::message + * + * @brief + * APIs for XRT messaging. + * + * @details + * XRT internally uses a message system that supports dispatching of + * messages to null, console, file, or syslog under different verbosity + * levels. The sink and verbosity level is controlled statically + * through ``xrt.ini`` or at run-time using ``xrt::ini``. + * + * The APIs in this file allow host application to use the same + * message dispatch mechanism as XRT is configured to use. + */ +namespace xrt { namespace message { + +/*! + * @enum level + * + * @brief + * Verbosity level for messages + * + * @details + * Use logging APIs to control at what verbosity level the + * messages should be issued. The default verbosity can be changed in + * `xrt.ini` or programatically by using `xrt::ini::set`. + * + * @var emergency + * @var alert + * @var critical + * @var error + * @var warning + * @var notice + * @var info + * @var debug + */ +enum class level : unsigned short +{ + emergency = xrtLogMsgLevel::XRT_EMERGENCY, + alert = xrtLogMsgLevel::XRT_ALERT, + critical = xrtLogMsgLevel::XRT_CRITICAL, + error = xrtLogMsgLevel::XRT_ERROR, + warning = xrtLogMsgLevel::XRT_WARNING, + notice = xrtLogMsgLevel::XRT_NOTICE, + info = xrtLogMsgLevel::XRT_INFO, + debug = xrtLogMsgLevel::XRT_DEBUG +}; + +/// @cond +namespace detail { + +template +void +format(boost::format& fmt, ArgType&& arg) +{ + fmt % std::forward(arg); +} + +template +void +format(boost::format& fmt, ArgType&& arg, Args&&... args) +{ + fmt % std::forward(arg); + format(fmt, std::forward(args)...); +} + +// enabled() - check if specified level is enabled +XCL_DRIVER_DLLESPEC +bool +enabled(level lvl); + +} // detail +/// @endcond + +/** + * log() - Dispatch composed log message + * + * @param lvl + * Severity level, the message is ignored if configured level + * is less than specified level. + * @param tag + * The message tag to use. + * @param msg + * A formatted composed message + */ +XCL_DRIVER_DLLESPEC +void +log(level lvl, const std::string& tag, const std::string& msg); + +/** + * logf() - Compose and dispatch formatted log message + * + * @param lvl + * Severity level, the message is ignored if configured level + * is less than specified level. + * @param tag + * The message tag to use. + * @param format + * A format string similar to printf or boost::format + * @param args + * Message arguments for the placeholders used in the format string + * + * This log function uses boost::format to compose the message from + * specified format string and arguments. + */ +template +void +logf(level lvl, const std::string& tag, const char* format, Args&&... args) +{ + if (!detail::enabled(lvl)) + return; + + auto fmt = boost::format(format); + detail::format(fmt, std::forward(args)...); + log(lvl, tag, fmt.str()); +} + +}} + +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_module.h b/src/runtime_src/core/include/xrt/experimental/xrt_module.h new file mode 100644 index 00000000000..892db4b45df --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_module.h @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_MODULE_H_ +#define XRT_MODULE_H_ + +#include "xrt/detail/config.h" +#include "xrt/xrt_bo.h" +#include "xrt/xrt_hw_context.h" +#include "xrt/xrt_uuid.h" +#include "xrt/detail/pimpl.h" +#include "xrt/experimental/xrt_elf.h" + +#ifdef __cplusplus +# include +# include +#endif + +#ifdef __cplusplus +namespace xrt { + +/*! + * @class module + * + * @brief + * An xrt::module contains functions an application will execute in + * hardware. In Alveo the xclbin is the container that configures the + * hardware and provides the functions. In AIE the functions are a + * set of instructions that are run on configured hardware, the + * instructions are embedded in an elf file, which is parsed for meta + * data determining how the functions are invoked. + * + * An xrt::module is constructed from the object that contains the + * functions to execute. In the case of Alveo, the module is + * definitely constructed from an xrt::xclbin , in case of AIE the + * module is constructed from an xrt::elf or from a user pointer. + */ +class module_impl; +class module : public detail::pimpl +{ +public: + /** + */ + module() + {} + + /** + * module() - Constructor from elf + * + * @param elf + * An elf binary with functions to execute + * + * The elf binary contains instructions for functions to be executed + * in some hardware context. The elf binary has text segments with + * meta data to be mined for function arguments and type. + * + * The constructor retains ownership of the elf object. + */ + XRT_API_EXPORT + explicit + module(const xrt::elf& elf); + + /** + * module() - Constructor from user ptr + * + * @param userptr + * A pointer to an opaque representation of the instructions + * to execute on hardware configured by an xclbin with uuid + * @param sz + * Size in bytes of the userptr buffer + * @param uuid + * Unique id of the hardware configuration. Must match the + * xclbin uuid use to configure the hardware. + * + * The user pointer is an opaque representation of the instructions + * to execute on hardware configured by xclbin. + * + * The constructor copies the content of the userptr. + */ + XRT_API_EXPORT + module(void* userptr, size_t sz, const xrt::uuid& uuid); + + /** + * module() - Constructor associate module with hardware context + * + * @param parent + * Parent module with instruction buffer to move into hwctx + * @param hwctx + * Hardware context to associate with module + * + * Copy content of existing module into an allocation associated + * with the specified hardware context. + * + * Throws if module is not compatible with hardware context + */ + XRT_API_EXPORT + module(const xrt::module& parent, const xrt::hw_context& hwctx); + + /** + * get_cfg_uuid() - Get the uuid of the hardware configuration + * + * @return + * UUID of matching hardware configuration + * + * An module is associated with exactly one hardware configuration. + * This function returns the uuid that identifies the configuration. + */ + XRT_API_EXPORT + xrt::uuid + get_cfg_uuid() const; + + XRT_API_EXPORT + xrt::hw_context + get_hw_context() const; + +private: +}; + +} // namespace xrt + +#else +# error xrt::module is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_profile.h b/src/runtime_src/core/include/xrt/experimental/xrt_profile.h new file mode 100644 index 00000000000..2ee89a60a00 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_profile.h @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2020-2022, Xilinx Inc - All rights reserved + * Xilinx Runtime (XRT) Experimental APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +#ifndef _XRT_PROFILE_H_ +#define _XRT_PROFILE_H_ + +#include "xrt.h" + +#ifdef __cplusplus + +#include + +namespace xrt { namespace profile { + +/*! + * @class user_range + * + * @brief + * xrt::profile::user_range xrt::profile::user_range is used to track start and stop times + * between two user defined points in host program and add them to profiling output for + * visualization using post-processing tools. + * + * @details + * By turning on various trace options in the xrt.ini file, + * XRT applications will track events and generate files, which are turned into a + * timeline visualization and summary via post-processing tools. A user range is used + * to explicitly add events measured from start to stop from the host code to that + * timeline visualization and summary. + * Usage - + * 1. If a user_range is instantiated using the default constructor, no time is marked + * until the user calls start with two strings (label and tooltip) + * 2. The user must call start() and stop() to mark ranges of time they are interested in. + * If stop() is not called, then any range being tracked lasts until the user_range object is destructed + * 3. As a shortcut, the user can instantiate a user_range object passing two strings (label and tooltip). This starts monitoring the range immediately + * The user_range object can be reused any number of times, by calling start()/stop() pairs in the host code + * 4. Multiple sequential calls to start() ignore all but the first call + * 5. Multiple sequential calls to stop() ignore all but the first call + */ +class user_range +{ +private: + uint32_t id; + bool active; +public: + /** + * user_range() - Default Constructor for user range + * + * If this constructor is called, the object is created but the + * beginning of the range time is not marked. + */ + XCL_DRIVER_DLLESPEC + user_range(); + + /** + * user_range() - Constructor for user range with text + * + * @param label + * The string that appears embedded on the waveform for this range + * @param tooltip + * The string that appears on the waveform when hovering over the range + * + * Construct an object and start keeping track of time immediately + * upon construction. + */ + XCL_DRIVER_DLLESPEC + user_range(const char* label, const char* tooltip = nullptr); + + /** + * user_range() - Copy constructor + * + * Explicitly removed as ranges are actively keeping track of real time + * and cannot be copied. + */ + user_range(const user_range& rhs) = delete; + + /** + * user_range() - Move constructor + * + * Explicitly removed as ranges are actively keeping track of real time + * and cannot be moved. + */ + user_range(user_range&& rhs) = delete; + + /** + * operator=() + * + * Explicitly removed as ranges should not be assigned + */ + user_range& operator=(const user_range& rhs) = delete; + user_range& operator=(user_range&& rhs) = delete; + + /** + * ~user_range() - Destructor + * + * If the range is still active, mark this point as the end of the range + */ + XCL_DRIVER_DLLESPEC + ~user_range(); + + /** + * start() - Mark the start position of a user range + * + * @param label + * The string that appears embedded on the waveform for this range + * @param tooltip + * The string that appears on the waveform when hovering over the range + * + * If the range is still actively recording time, end the current + * range and start a new one. + */ + XCL_DRIVER_DLLESPEC + void + start(const char* label, const char* tooltip = nullptr); + + /** + * end() - Mark the end position of a user range + * + * If the range has already been ended, do nothing. Otherwise + * mark the end position of the range and stop tracking time. + */ + XCL_DRIVER_DLLESPEC + void + end(); +}; + +/*! + * @class user_event + * + * @brief + * xrt::profile::user_event mark a specific point in execution with a label for later visualization + * + * @details + * A user event can be generated from inside host code and optionally tagged with a label. + * These events are post-processed and represented on summary and trace waveforms as markers. + */ +class user_event +{ +public: + /** + * user_event() - Constructor + * + * Create an object, but do not mark any particular time + */ + XCL_DRIVER_DLLESPEC + user_event(); + + /** + * ~user_event() - Destructor + * + * Destroy the object, but do not mark any particular time + */ + XCL_DRIVER_DLLESPEC + ~user_event(); + + /** + * mark() - Mark the current moment in time with a marker on the waveform + * + * @param label + * An optional label that will be displayed on top of marker in waveform + * + */ + XCL_DRIVER_DLLESPEC + void + mark(const char* label = nullptr); + + /** + * mark_time_ns() - Mark a custom moment in time with a marker on the waveform + * + * @param time_ns + * Time duration in nanoseconds since appliction start. + * This must be compatible with xrt_core::time_ns() API. + * @param label + * An optional label that will be displayed on top of marker in waveform + * + */ + XCL_DRIVER_DLLESPEC + void + mark_time_ns(const std::chrono::nanoseconds& time_ns, const char* label = nullptr); +}; + +} // end namespace profile +} // end namespace xrt + +extern "C" { +#endif + +/** + * xrtURStart() - Mark the start time in the user code of a range + * + * @id: A user supplied id to match starts and ends of ranges + * @label: The text to display in the waveform for this particular range + * @tooltip: The text to display in the waveform when hovering over this range + * Return: none + * + */ +XCL_DRIVER_DLLESPEC +void +xrtURStart(unsigned int id, const char* label, const char* tooltip = nullptr); + +/** + * xrtUREnd() - Mark the end time in the user code of a range + * + * @id: A user supplied id to match starts and ends of ranges + * Return: none + * + */ +XCL_DRIVER_DLLESPEC +void +xrtUREnd(unsigned int id); + +/** + * xrtUEMark() - Mark the current time as when something happened + * + * @label: An optional label that is added to the marker in the waveform + * Return: none + * + */ +XCL_DRIVER_DLLESPEC +void +xrtUEMark(const char* label); + +/** + * xrtUEMarkTimeNs() - Mark a custom time as when something happened + * + * @time_ns: Time duration in nanoseconds since application start. + * This must be compatible with xrt_core::time_ns() API. + * @label: An optional label that is added to the marker in the waveform + * Return: none + * + */ +XCL_DRIVER_DLLESPEC +void +xrtUEMarkTimeNs(unsigned long long int time_ns, const char* label); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_queue.h b/src/runtime_src/core/include/xrt/experimental/xrt_queue.h new file mode 100644 index 00000000000..6dba9791797 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_queue.h @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2022 Xilinx, Inc. All rights reserved. +// Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. +#ifndef XRT_QUEUE_H_ +#define XRT_QUEUE_H_ + +#include "xrt/detail/config.h" + +#ifdef __cplusplus +# include +# include +# include +#endif + +#ifdef __cplusplus + +namespace xrt { + +/** + * class queue -- producer / consumer queue for tasks + * + * Used for sequencing operations in order of enqueuing. + * + * A queue has exactly one consumer which is a separate thread created + * when the queue is constructed. + * + * When an opeation is enqueued on the queue an event is returned to + * the caller. This event can be enqueued in a different queue, which + * will then wait for the former to complete the operaiton associated + * with the event. + */ +class queue_impl; +class queue +{ + friend class queue_impl; + + // class task - type-erased callable operation + // + // A task wraps a caller's typed operation such that it + // can be inserted into a queue. + // + // Tasks should be synchronous operations. + class task + { + struct task_iholder + { + virtual ~task_iholder() {}; + virtual void execute() = 0; + }; + + // Wrap typed operation + template + struct task_holder : public task_iholder + { + Callable m_held; + + explicit + task_holder(Callable&& t) + : m_held(std::move(t)) + {} + + void execute() override + { + m_held(); + } + }; + + std::unique_ptr m_content; + + public: + task() = default; + task(task&& rhs) = default; + + // task() - task constructor for synchronous operation + // + // @c : callable object, a std::packaged_task + template + task(Callable&& c) + : m_content(new task_holder(std::forward(c))) + {} + + task& + operator=(task&& rhs) = default; + + operator bool() const + { + return m_content != nullptr; + } + + void + execute() + { + m_content->execute(); + } + }; // class queue::task + +public: + + /** + * class event - type-erased std::shared_future + * + * Wraps typed future return value returned when + * enqueueing an operation. + * + * Returned futures implicitly convert to an event and as such + * enqueue return values can be stored in an event container if + * necessary. + * + * The event object is not needed where the typed future can be + * used. + */ + class event + { + struct event_iholder + { + virtual ~event_iholder() {}; + virtual void wait() const = 0; + }; + + // Wrap typed future + template + struct event_holder : public event_iholder + { + std::shared_future m_held; + + explicit + event_holder(std::shared_future&& e) + : m_held(std::move(e)) + {} + + void wait() const override + { + m_held.wait(); + } + }; + + std::shared_ptr m_content; + + public: + event() = default; + event(event&& rhs) = default; + event(const event& rhs) = default; + + // event() - event constructor for std::shared_future + // + // @e : shared_future to type erase + template + event(std::shared_future e) + : m_content(std::make_shared>(std::move(e))) + {} + + event& + operator=(event&& rhs) = default; + + operator bool() const + { + return m_content!=nullptr; + } + + void + wait() const + { + if (m_content) + m_content->wait(); + } + }; + +private: + // Add task to queue + XRT_API_EXPORT + void + add_task(task&& ev); + +public: + /** + * queue() - Constructor for queue object + * + * The queue is constructed with one consumer thread. + */ + XRT_API_EXPORT + queue(); + + /** + * enqueue() - Enqueue a callable + * + * @param c + * Callable function, typically a lambda + * @return + * Future result of the function (std::future) + * + * A callable is an argument-less lambda function. The function is + * executed asynchronously by the queue consumer (worker thread) + * once all previous enqueued operations have completed. + * + * Upon completion the returned future becomes valid and will + * contain the return value of executing the lambda. + */ + template + auto + enqueue(Callable&& c) + { + using return_type = decltype(c()); + std::packaged_task task{[cc = std::move(c)] { return cc(); }}; + std::shared_future f{task.get_future()}; + add_task(std::move(task)); + return f; + } + + /** + * enqueue() - Enqueue the future of an enqueued operation + * + * @param sf + * The future result to wait on (std::shared_future) + * @return + * Future of the future (std::shared_future) + * + * Subsequent enqueued task blocks until the enqueued future is + * valid. + * + * This type of enqueued future is used for synchronization between + * multiple queues. + */ + template + auto + enqueue(std::shared_future sf) + { + return enqueue([evc = xrt::queue::event{std::move(sf)}] { evc.wait(); }); + } + + /** + * enqueue() - Enqueue an event (type erased future) + * + * @oaram ev + * Event to enqueue + * @param + * Future of event (std::shared_future) + * + * Subsequent enqueued task blocks until the enqueued event is + * valid. + * + * This type of enqueued event is used for synchronization between + * multiple queues. + */ + auto + enqueue(xrt::queue::event ev) + { + return enqueue([evc = std::move(ev)] { evc.wait(); }); + } + +public: + queue_impl* + get_impl() const + { + return m_impl.get(); + } + +private: + std::shared_ptr m_impl; +}; + +} // namespace xrt + +#else +# error xrt_enqueue is only implemented for C++ +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_system.h b/src/runtime_src/core/include/xrt/experimental/xrt_system.h new file mode 100644 index 00000000000..d94892283b7 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_system.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021-2022 Xilinx, Inc + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef xrt_system_h_ +#define xrt_system_h_ + +#include "xrt.h" + +#ifdef __cplusplus + +/*! + * @namespace xrt::system + * + * @brief + * APIs for system level queries and control. + */ +namespace xrt { namespace system { + +/** + * enumerate_devices() - Enumerate devices found in the system + * + * @return + * Number of devices in the system recognized by XRT + */ +XCL_DRIVER_DLLESPEC +unsigned int +enumerate_devices(); + +}} + +#endif // __cplusplus + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_uuid.h b/src/runtime_src/core/include/xrt/experimental/xrt_uuid.h new file mode 100644 index 00000000000..268853b33ac --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_uuid.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021, Xilinx Inc - All rights reserved + * Xilinx Runtime (XRT) Experimental APIs + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may + * not use this file except in compliance with the License. A copy of the + * License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +#include "xrt/xrt_uuid.h" diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_version.h b/src/runtime_src/core/include/xrt/experimental/xrt_version.h new file mode 100644 index 00000000000..163febfd868 --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_version.h @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + +#ifndef xrt_version_h_ +#define xrt_version_h_ + +#include "xrt/detail/config.h" + +#ifdef __cplusplus + +/*! + * @namespace xrt::version + * + * @brief + * APIs for version queries + */ +namespace xrt::version { + +/** + * code() - Returns the version code for the library. + * + * The version code is a combination of major and minor version. + * The major version is shifted left by 16 bits and the minor version + * is added. + */ +XRT_API_EXPORT +unsigned int +code(); + +/** + * major() - Returns the major version for the library. + * + * The major version indicates ABI compatibility. The major version + * is incremented by 1 only if a release that breaks ABI compatibility. + */ +XRT_API_EXPORT +unsigned int +major(); + +/** + * minor() - Returns the minor version for the library. + * + * The minor version is incremented by 1 for each release within a + * major version. + */ +XRT_API_EXPORT +unsigned int +minor(); + +/** + * patch() - Returns the patch version for the library. + * + * The patch number defaults to 0 for local builds, but is otherwise + * controlled by CI and incremented by 1 for each build. + * + * The patch number is reset to 0 when the minor version is + * incremented. + */ +XRT_API_EXPORT +unsigned int +patch(); + +/** + * build() - Returns the build number for the library. + * + * The build number is the total number of commits to XRT + * on current branch. + */ +XRT_API_EXPORT +unsigned int +build(); + +/** + * feature() - Returns the feature number for the library. + * + * The feature number is the total number of commits to XRT + * main branch. For branches off of XRT's main branch, the + * feature number is the total number of commits at the time + * the branch diverged from XRT's main branch. + */ +XRT_API_EXPORT +unsigned int +feature(); + +} // namespace xrt::version + +/// @cond +extern "C" { +#endif + +/** + * See xrt::version::code() + */ +XRT_API_EXPORT +unsigned int +xrtVersionCode(); + +/** + * See xrt::version::major() + */ +XRT_API_EXPORT +unsigned int +xrtVersionMajor(); + +/** + * See xrt::version::minor() + */ +XRT_API_EXPORT +unsigned int +xrtVersionMinor(); + +/** + * See xrt::version::patch() + */ +XRT_API_EXPORT +unsigned int +xrtVersionPatch(); + +/** + * See xrt::version::build() + */ +XRT_API_EXPORT +unsigned int +xrtVersionBuild(); + +/** + * See xrt::version::feature() + */ +XRT_API_EXPORT +unsigned int +xrtVersionFeature(); + +/// @endcond +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/src/runtime_src/core/include/xrt/experimental/xrt_xclbin.h b/src/runtime_src/core/include/xrt/experimental/xrt_xclbin.h new file mode 100644 index 00000000000..dc3d40289ad --- /dev/null +++ b/src/runtime_src/core/include/xrt/experimental/xrt_xclbin.h @@ -0,0 +1,1117 @@ +/* + * Copyright (C) 2020-2022 Xilinx, Inc. All rights reserved. + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef XRT_XCLBIN_H_ +#define XRT_XCLBIN_H_ + +#include "xrt/xrt_uuid.h" + +#include "xrt/detail/config.h" +#include "xrt/detail/pimpl.h" +#include "xrt/detail/xclbin.h" +#include "xrt/deprecated/xrt.h" + +#ifdef __cplusplus +# include +# include +# include +# include +#endif + +/** + * typedef xrtXclbinHandle - opaque xclbin handle + */ +typedef void* xrtXclbinHandle; // NOLINT + +#ifdef __cplusplus +namespace xrt { + +/*! + * @class xclbin + * + * @brief + * xrt::xclbin represents an xclbin and provides APIs to access meta data. + * + * @details + * The xclbin object is constructed by the user from a file. + * + * When the xclbin object is constructed from a complete xclbin, then it + * can be used by xrt::device to program the xclbin onto the device. + * + * **First-class objects and class navigation** + * + * All meta data is rooted at xrt::xclbin. + * + * \image{inline} html xclbin_navigation.png "xclbin navigation" + * + * From the xclbin object + * xrt::xclbin::kernel or xrt::xclbin::ip objects can be constructed. + * + * The xrt:xclbin::kernel is a concept modelled only in the xclbin XML + * metadata, it corresponds to a function that can be executed by one + * or more compute units modelled by xrt::xclbin::ip objects. An + * xrt::xclbin::ip object corresponds to an entry in the xclbin + * IP_LAYOUT section, so the xrt::xclbin::kernel object is just a + * grouping of one or more of these. + * + * In some cases the kernel concept is not needed, thus + * xrt::xclbin::ip objects corresponding to entries in the xclbin + * IP_LAYOUT sections can be accessed directly. + * + * An xrt::xclbin::arg object corresponds to one or more entries in + * the xclbin CONNECTIVITY section decorated with additional meta data + * (offset, size, type, etc) from the XML section if available. An + * argument object represents a specific kernel or ip argument. If + * the argument is a global buffer, then it may connect to one or more + * memory objects. + * + * Finally the xrt::xclbin::mem object corresponds to an entry in the + * MEM_TOPOLOGY section of the xclbin. + */ +class xclbin_impl; +class xclbin : public detail::pimpl +{ +public: + /*! + * @enum target_type + * + * @brief + * Type of xclbin + * + * @details + * See `xclbin.h` + */ + enum class target_type { hw, sw_emu, hw_emu }; + +public: + /*! + * @class mem + * + * @brief + * xrt::xclbin::mem represents a physical device memory bank + * + * @details + * A memory object is constructed from an entry in the MEM_TOPOLOGY + * section of an xclbin. + */ + class mem_impl; + class mem : public detail::pimpl + { + public: + /** + * @enum memory_type - type of memory + * + * @details + * See `xclbin.h` + */ + enum class memory_type : uint8_t { + ddr3 = MEM_DDR3, + ddr4 = MEM_DDR4, + dram = MEM_DRAM, + streaming = MEM_STREAMING, + preallocated_global = MEM_PREALLOCATED_GLOB, + are = MEM_ARE, //Aurora + hbm = MEM_HBM, + bram = MEM_BRAM, + uram = MEM_URAM, + streaming_connection = MEM_STREAMING_CONNECTION, + host = MEM_HOST + }; + + public: + mem() = default; + + explicit + mem(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + /** + * get_tag() - Get tag name + * + * @return + * Memory tag name + */ + XRT_API_EXPORT + std::string + get_tag() const; + + /** + * get_base_address() - Get the base address of the memory bank + * + * @return + * Base address of the memory bank, or -1 for invalid base address + */ + XRT_API_EXPORT + uint64_t + get_base_address() const; + + /** + * get_size_kb() - Get the size of the memory in KB + * + * @return + * Size of memory in KB, or -1 for invalid size + */ + XRT_API_EXPORT + uint64_t + get_size_kb() const; + + /** + * get_used() - Get used status of the memory + * + * @return + * True of this memory bank is used by kernels in the xclbin + * or false otherwise. + * + * A value of false indicates that no buffer can be allocated + * in this memory bank. + */ + XRT_API_EXPORT + bool + get_used() const; + + /** + * get_type() - Get the type of the memory + * + * @return + * Memory type + * + */ + XRT_API_EXPORT + memory_type + get_type() const; + + /** + * get_index() - Get the index of the memory + * + * @return + * Index of the memory within the memory topology + * + * The returned index can be used when allocating buffers using + * \ref xrt::bo provided the memory bank is connected / used. + */ + XRT_API_EXPORT + int32_t + get_index() const; + }; + + /*! + * @class arg + * + * @brief + * class arg - xrt::xclbin::arg represents a compute unit argument + * + * @details + * The argument object constructed from the xclbin connectivity + * section. An argument is connected to a memory bank or a memory + * group, which dictates where in device memory a global buffer + * used with this kernel argument must be allocated. + */ + class arg_impl; + class arg : public detail::pimpl + { + public: + arg() = default; + + explicit + arg(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + /** + * get_name() - Get argument name + * + * @return + * Name of argument. + * + */ + XRT_API_EXPORT + std::string + get_name() const; + + /** + * get_mems() - Get list of device memories from xclbin. + * + * @return + * A list of xrt::xclbin::mem objects to which this argument + * is connected. + */ + XRT_API_EXPORT + std::vector + get_mems() const; + + /** + * get_port() - Get port name of this argument + * + * @return + * Port name + */ + XRT_API_EXPORT + std::string + get_port() const; + + /** + * get_size() - Argument size in bytes + * + * @return + * Argument size + */ + XRT_API_EXPORT + uint64_t + get_size() const; + + /** + * get_offset() - Argument offset + * + * @return + * Argument offset + */ + XRT_API_EXPORT + uint64_t + get_offset() const; + + /** + * get_host_type() - Get the argument host type + * + * @return + * Argument host type + */ + XRT_API_EXPORT + std::string + get_host_type() const; + + /** + * get_index() - Get the index of this argument + * + * @return + * Argument index + */ + XRT_API_EXPORT + size_t + get_index() const; + }; + + /*! + * @class ip + * + * @brief + * xrt::xclbin::ip represents a IP in an xclbin. + * + * @details + * The ip corresponds to an entry in the IP_LAYOUT section of the + * xclbin. + */ + class ip_impl; + class ip : public detail::pimpl + { + public: + /** + * @enum control_type - + * + * @details + * See `xclbin.h` + */ + enum class control_type : uint8_t { hs = 0, chain = 1, none = 2, fa = 5 }; + + /** + * @enum ip_type + * + * @details + * See `xclbin.h` + */ + enum class ip_type : uint8_t { pl = IP_KERNEL, ps = IP_PS_KERNEL }; + + public: + ip() = default; + + explicit + ip(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + /** + * get_name() - Get name of IP + * + * @return + * IP name. + */ + XRT_API_EXPORT + std::string + get_name() const; + + /** + * get_type() - Get the IP type + * + * @return + * IP type + */ + XRT_API_EXPORT + ip_type + get_type() const; + + /** + * get_control_type() - Get the IP control protocol + * + * @return + * Control type + */ + XRT_API_EXPORT + control_type + get_control_type() const; + + /** + * get_num_args() - Number of arguments + * + * @return + * Number of arguments for this IP per CONNECTIVITY section + */ + XRT_API_EXPORT + size_t + get_num_args() const; + + /** + * get_args() - Get list of IP arguments + * + * @return + * A list sorted of xclbin::arg sorted by argument indices + * + * An argument may have multiple memory connections + */ + XRT_API_EXPORT + std::vector + get_args() const; + + /** + * get_arg() - Get argument at index. + * + * @param index + * Index of argument + * @return + * The argument a specified index + * + * The argument may have multiple memory connections + */ + XRT_API_EXPORT + arg + get_arg(int32_t index) const; + + /** + * get_base_address() - Get the base address of the cu + * + * @return + * The base address of the IP + */ + XRT_API_EXPORT + uint64_t + get_base_address() const; + + /** + * get_size() - Get the address range size of this IP. + * + * @return + * The size of this IP + * + * The address range is a property of the kernel and + * as such only valid for for kernel compute units. + * + * For IPs that are not associated with a kernel, the + * size return is 0. + */ + XRT_API_EXPORT + size_t + get_size() const; + }; + + /*! + * class kernel + * + * @brief + * xrt::xclbin::kernel represents a kernel in an xclbin. + * + * @details + * The kernel corresponds to an entry in the XML meta data section + * of the xclbin combined with meta data from other xclbin sections. + * The kernel object is implicitly constructed from the xclbin + * object via APIs. + */ + class kernel_impl; + class kernel : public detail::pimpl + { + public: + /** + * @enum kernel_type + * + * The kernel type is extracted from the XML kernel meta data section + */ + enum class kernel_type : uint8_t { none = 0, pl = 1, ps = 2, dpu = 3}; + + public: + kernel() = default; + + explicit + kernel(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + /** + * get_name() - Get kernel name + * + * @return + * The name of the kernel + */ + XRT_API_EXPORT + std::string + get_name() const; + + /** + * get_type() - Get kernel type + * + * @return + * The type of the kernel + */ + XRT_API_EXPORT + kernel_type + get_type() const; + + /** + * get_cus() - Get list of cu from kernel. + * + * @return + * A list of xrt::xclbin::ip objects corresponding the compute units + * for this kernel object. + */ + XRT_API_EXPORT + std::vector + get_cus() const; + + /** + * get_cus() - Get list of compute units that matches name + * + * @param name + * Name to match against, prefixed with kernel name + * @return + * A list of xrt::xclbin::ip objects that are compute units + * of this kernel object and matches the specified name. + * + * The kernel name can optionally specify which kernel instance(s) to + * match "kernel:{cu1,cu2,...} syntax. + */ + XRT_API_EXPORT + std::vector + get_cus(const std::string& name) const; + + /** + * get_cu() - Get compute unit by name + * + * @return + * The xct::xclbin::ip object matching the specified name, or error if + * not present. + */ + XRT_API_EXPORT + ip + get_cu(const std::string& name) const; + + /** + * get_num_args() - Number of arguments + * + * @return + * Number of arguments for this kernel. + */ + XRT_API_EXPORT + size_t + get_num_args() const; + + /** + * get_args() - Get list of kernel arguments + * + * @return + * A list sorted of xclbin::arg sorted by argument indices + * + * An argument may have multiple memory connections + */ + XRT_API_EXPORT + std::vector + get_args() const; + + /** + * get_arg() - Get kernel argument at index. + * + * @return + * The xrt::xclbin::arg object at specified argument index. + * + * The memory connections of an argument is the union of the + * connections for each compute unit for that particular argument. + * In other words, for each connection of the argument returned + * by ``get_arg()`` there is at least one compute unit that has + * that connection. + */ + XRT_API_EXPORT + arg + get_arg(int32_t index) const; + }; + + /// @cond + /** undocumented access to aie metadata, subject to change **/ + class aie_partition_impl; + class aie_partition : detail::pimpl + { + public: + explicit + aie_partition(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + XRT_API_EXPORT + uint64_t + get_inference_fingerprint() const; + + XRT_API_EXPORT + uint64_t + get_pre_post_fingerprint() const; + + XRT_API_EXPORT + uint32_t + get_operations_per_cycle() const; + }; + /// @endcond + +public: + /** + * xclbin() - Construct empty xclbin object + */ + xclbin() = default; + + /// @cond + /** + * xclbin() - Construct from handle + */ + explicit + xclbin(std::shared_ptr handle) + : detail::pimpl(handle) + {} + /// @endcond + + /** + * xclbin() - Constructor from an xclbin filename + * + * + * @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. + */ + XRT_API_EXPORT + explicit + xclbin(const std::string& filename); + + /** + * xclbin() - Constructor from raw data + * + * @param data + * Raw data of xclbin + * + * The raw data of the xclbin can be deleted after calling the + * constructor. + */ + XRT_API_EXPORT + explicit + xclbin(const std::vector& data); + + /** + * xclbin() - Constructor from raw data + * + * @param top + * Raw data of xclbin file as axlf* + * + * The argument axlf is copied by the constructor. + */ + XRT_API_EXPORT + explicit + xclbin(const axlf* top); + + /** + * get_kernels() - Get list of kernels from xclbin. + * + * @return + * A list of xrt::xclbin::kernel from xclbin. + * + * Kernels are extracted from embedded XML metadata in the xclbin. + * A kernel groups one or more compute units. A kernel has arguments + * from which offset, type, etc can be retrived. + */ + XRT_API_EXPORT + std::vector + get_kernels() const; + + /** + * get_kernel() - Get a kernel by name from xclbin + * + * @param name + * Name of kernel to get. + * @return + * The matching kernel from the xclbin or error + * if no matching kernel is found. + * + * A matching kernel is extracted from embedded XML metadata in the + * xclbin. A kernel groups one or more compute units. A kernel has + * arguments from which offset, type, etc can be retrived. + */ + XRT_API_EXPORT + kernel + get_kernel(const std::string& name) const; + + /** + * get_ips() - Get a list of IPs from the xclbin + * + * @return + * A list of xrt::xclbin::ip objects from xclbin. + * + * The returned xrt::xclbin::ip objects are extracted from the + * IP_LAYOUT section of the xclbin. + */ + XRT_API_EXPORT + std::vector + get_ips() const; + + /** + * get_ips() - Get list of ips that matches name + * + * @param name + * Name to match against, prefixed with kernel name + * @return + * A list of xrt::xclbin::ip objects that are compute units + * of this kernel object and matches the specified name. + * + * The kernel name can optionally specify which kernel instance(s) to + * match "kernel:{ip1,ip2,...} syntax. + */ + XRT_API_EXPORT + std::vector + get_ips(const std::string& name) const; + + /** + * get_ip() - Get a specific IP from the xclbin + * + * @return + * A list of xrt::xclbin::ip objects from xclbin. + * + * The returned xrt::xclbin::ip object is extracted from the + * IP_LAYOUT section of the xclbin. + */ + XRT_API_EXPORT + ip + get_ip(const std::string& name) const; + + /** + * get_mems() - Get list of memory objects + * + * @return + * A list of xrt::xclbin::mem objects from xclbin + * + * The returned xrt::xclbin::mem objects are extracted from + * the xclbin. + */ + XRT_API_EXPORT + std::vector + get_mems() const; + + /// @cond + XRT_API_EXPORT + std::vector + get_aie_partitions() const; + /// @endcond + + /** + * get_xsa_name() - Get Xilinx Support Archive (XSA) name of xclbin + * + * @return + * Name of XSA (vbnv name). + * + * An exception is thrown if the data is missing. + */ + XRT_API_EXPORT + std::string + get_xsa_name() const; + + /** + * get_fpga_device_name() - Get FPGA device name + * + * @return + * Name of fpga device per XML metadata. + */ + XRT_API_EXPORT + std::string + get_fpga_device_name() const; + + /** + * get_uuid() - Get the uuid of the xclbin + * + * @return + * UUID of xclbin + * + * An exception is thrown if the data is missing. + */ + XRT_API_EXPORT + uuid + get_uuid() const; + + /** + * get_interface_uuid() - Get the interface uuid of the xclbin + * + * @return + * Interface uuid of the xclbin + * + * An exception is thrown if the data is missing. + */ + XRT_API_EXPORT + uuid + get_interface_uuid() const; + + /** + * get_target_type() - Get the type of this xclbin + * + * @return + * Target type, which can be hw, sw_emu, or hw_emu + */ + XRT_API_EXPORT + target_type + get_target_type() const; + + /// @cond + /** + * get_axlf() - Get the axlf data of the xclbin + * + * @return + * The axlf data of the xclbin object + * + * An exception is thrown if the data is missing. + */ + XRT_API_EXPORT + const axlf* + get_axlf() const; + + /** + * get_axlf_section() - Retrieve specified xclbin section + * + * @param section + * The section to retrieve + * @return + * The specified section if available cast to specified type. + * Note, that this is an unsafe cast, behavior is undefined if the + * specified SectionType is invalid. + * + * The SectionType template parameter is an axlf type from xclbin.h + * and it much match the type of the section data retrieved. + * + * Throws if requested section does not exist in the xclbin. + */ + template + SectionType + get_axlf_section(axlf_section_kind section) const + { + return reinterpret_cast(get_axlf_section(section).first); + } + /// @endcond + +private: + XRT_API_EXPORT + std::pair + get_axlf_section(axlf_section_kind section) const; +}; + +/** + * xclbin_repository - Repository of xclbins + * + * A repository of xclbins is a collection of xclbins that can be + * searched for a specific xclbin through iteration. + * + * The location of a repository is specified by a directory or it + * can be implementations and platform specific. + */ +class xclbin_repository_impl; +class xclbin_repository : public detail::pimpl +{ +public: + /** + * xclbin_repository - Default constructor + * + * Create repository from builtin platform specific repository + * path or paths. + */ + XRT_API_EXPORT + xclbin_repository(); + + /** + * xclbin_repository - + * + * Create repository from specified path. + * + * The specified directory can be an absolute path to a directory or + * it can be a relative path to a directory rooted at the current + * working directory. + */ + XRT_API_EXPORT + explicit + xclbin_repository(const std::string& dir); + + /** + * iterator - Iterator over xclbins in repository + * + * The iterator is a forward iterator that iterates over the + * xclbins in the repository. The iterator dereferences to an + * xrt::xclbin object by value. + */ + class iterator_impl; + class iterator : public detail::pimpl + { + public: + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = xclbin; + using pointer = value_type; + using reference = value_type; + + public: + /** + * iterator - Converting default constructor from implmentation + */ + iterator(std::shared_ptr handle) + : detail::pimpl(std::move(handle)) + {} + + /** + * iterator - Copy constructor + * + * Create a copy of an iterator + */ + XRT_API_EXPORT + iterator(const iterator&); + + /** + * Advance iterator to next xclbin + */ + XRT_API_EXPORT + iterator& + operator++(); + + /** + * Advance iterator to next xclbin return old iterator + * + * This is a relatively expensive operation that duplicates + * the internal representation of the original iterator. + */ + XRT_API_EXPORT + iterator + operator++(int); + + /** + * Compare iterators + */ + XRT_API_EXPORT + bool + operator==(const iterator& rhs) const; + + /** + * Compare iterators + */ + bool + operator!=(const iterator& rhs) const + { + return !(*this == rhs); + } + + /** + * Dereference iterator + * + * Returns xrt::xclbin object by value. The xclbin object + * is constructed on the fly. + */ + XRT_API_EXPORT + value_type + operator*() const; + + /** + * Dereference iterator + * + * Returns xrt::xclbin object by value. The xclbin object + * is constructed on the fly. + */ + XRT_API_EXPORT + value_type + operator->() const; + + /** + * Get path to xclbin file path in repository for this iterator + */ + XRT_API_EXPORT + std::string + path() const; + }; + + /** + * begin() - Get iterator to first xclbin in repository + */ + XRT_API_EXPORT + iterator + begin() const; + + /** + * end() - Get iterator to end of xclbin repository + */ + XRT_API_EXPORT + iterator + end() const; + + /** + * load() - Load xclbin from repository + */ + XRT_API_EXPORT + xclbin + load(const std::string& name) const; +}; + +} // namespace xrt + +/// @cond +extern "C" { +#endif + +/** + * xrtXclbinAllocFilename() - Allocate a xclbin using xclbin filename + * + * @filename: path to the xclbin file + * Return: xrtXclbinHandle on success or NULL with errno set + */ +XRT_API_EXPORT +xrtXclbinHandle +xrtXclbinAllocFilename(const char* filename); + + +/** + * xrtXclbinAllocAxlf() - Allocate a xclbin using an axlf + * + * @top_axlf: an axlf + * Return: xrtXclbinHandle on success or NULL with errno set + */ +XRT_API_EXPORT +xrtXclbinHandle +xrtXclbinAllocAxlf(const struct axlf* top_axlf); + +/** + * xrtXclbinAllocRawData() - Allocate a xclbin using raw data + * + * @data: raw data buffer of xclbin + * @size: size (in bytes) of raw data buffer of xclbin + * Return: xrtXclbinHandle on success or NULL with errno set + */ +XRT_API_EXPORT +xrtXclbinHandle +xrtXclbinAllocRawData(const char* data, int size); + +/** + * xrtXclbinFreeHandle() - Deallocate the xclbin handle + * + * @xhdl: xclbin handle + * Return: 0 on success, -1 on error + */ +XRT_API_EXPORT +int +xrtXclbinFreeHandle(xrtXclbinHandle xhdl); + +/** + * xrtXclbinGetXSAName() - Get Xilinx Support Archive (XSA) Name of xclbin handle + * + * @xhdl: Xclbin handle + * @name: Return name of XSA. + * If the value is nullptr, the content of this value will not be populated. + * Otherwise, the the content of this value will be populated. + * @size: size (in bytes) of @name. + * @ret_size: Return size (in bytes) of XSA name. + * If the value is nullptr, the content of this value will not be populated. + * Otherwise, the the content of this value will be populated. + * Return: 0 on success or appropriate error number + */ +XRT_API_EXPORT +int +xrtXclbinGetXSAName(xrtXclbinHandle xhdl, char* name, int size, int* ret_size); + +/** + * xrtXclbinGetUUID() - Get UUID of xclbin handle + * + * @xhdl: Xclbin handle + * @ret_uuid: Return xclbin id in this uuid_t struct + * Return: 0 on success or appropriate error number + */ +XRT_API_EXPORT +int +xrtXclbinGetUUID(xrtXclbinHandle xhdl, xuid_t ret_uuid); + +/** + * xrtXclbinGetNumKernels() - Get number of PL kernels in xclbin + * + * @xhdl: Xclbin handle obtained from an xrtXclbinAlloc function + * Return: The number of PL kernels in the xclbin + * + * Kernels are extracted from embedded XML metadata in the xclbin. + * A kernel groups one or more compute units. A kernel has arguments + * from which offset, type, etc can be retrived. + */ +XRT_API_EXPORT +size_t +xrtXclbinGetNumKernels(xrtXclbinHandle xhdl); + +/** + * xrtXclbinGetNumKernelComputeUnits() - Get number of CUs in xclbin + * + * @xhdl: Xclbin handle obtained from an xrtXclbinAlloc function + * Return: The number of compute units + * + * Compute units are associated with kernels. This function returns + * the total number of compute units as the sum of compute units over + * all kernels. + */ +XRT_API_EXPORT +size_t +xrtXclbinGetNumKernelComputeUnits(xrtXclbinHandle xhdl); + +/** + * xrtXclbinGetData() - Get the raw data of the xclbin handle + * + * @xhdl: Xclbin handle + * @data: Return raw data. + * If the value is nullptr, the content of this value will not be populated. + * Otherwise, the the content of this value will be populated. + * @size: Size (in bytes) of @data + * @ret_size: Return size (in bytes) of XSA name. + * If the value is nullptr, the content of this value will not be populated. + * Otherwise, the the content of this value will be populated. + * Return: 0 on success or appropriate error number + */ +XRT_API_EXPORT +int +xrtXclbinGetData(xrtXclbinHandle xhdl, char* data, int size, int* ret_size); + +/* + * xrtGetXclbinUUID() - Get UUID of xclbin image running on device + * + * @dhdl: Device handle + * @out: Return xclbin id in this uuid_t struct + * Return: 0 on success or appropriate error number + */ +XRT_API_EXPORT +int +xrtXclbinUUID(xclDeviceHandle dhdl, xuid_t out); + +/// @endcond +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/runtime_src/core/include/xrt/xrt_bo.h b/src/runtime_src/core/include/xrt/xrt_bo.h index d8ab3a0fc58..a6d257462c7 100644 --- a/src/runtime_src/core/include/xrt/xrt_bo.h +++ b/src/runtime_src/core/include/xrt/xrt_bo.h @@ -6,7 +6,7 @@ #define XRT_BO_H_ #include "xrt.h" -#include "xrt_mem.h" +#include "xrt/detail/xrt_mem.h" #include "xrt/detail/pimpl.h" #ifdef __cplusplus diff --git a/src/runtime_src/core/include/xrt/xrt_kernel.h b/src/runtime_src/core/include/xrt/xrt_kernel.h index 95116dcf268..dc1f905e89f 100644 --- a/src/runtime_src/core/include/xrt/xrt_kernel.h +++ b/src/runtime_src/core/include/xrt/xrt_kernel.h @@ -6,17 +6,17 @@ #ifndef XRT_KERNEL_H_ #define XRT_KERNEL_H_ -#include "ert.h" -#include "xrt.h" #include "xrt/xrt_bo.h" #include "xrt/xrt_device.h" #include "xrt/xrt_uuid.h" +#include "xrt/detail/ert.h" +#include "xrt/deprecated/xrt.h" #ifdef __cplusplus -# include "experimental/xrt_exception.h" -# include "experimental/xrt_fence.h" -# include "experimental/xrt_hw_context.h" +# include "xrt/experimental/xrt_exception.h" +# include "xrt/experimental/xrt_fence.h" +# include "xrt/experimental/xrt_hw_context.h" # include # include # include diff --git a/src/runtime_src/core/include/xrt/xrt_uuid.h b/src/runtime_src/core/include/xrt/xrt_uuid.h index 702c800f2b5..d9df9cdad9d 100644 --- a/src/runtime_src/core/include/xrt/xrt_uuid.h +++ b/src/runtime_src/core/include/xrt/xrt_uuid.h @@ -18,7 +18,7 @@ #define xrt_uuid_h_ #ifdef _WIN32 -# include "windows/uuid.h" +# include "xrt/detail/windows/uuid.h" #else # include typedef uuid_t xuid_t; diff --git a/src/runtime_src/core/include/xrt_error_code.h b/src/runtime_src/core/include/xrt_error_code.h index 4b3891fb8fe..38fd913a6f0 100644 --- a/src/runtime_src/core/include/xrt_error_code.h +++ b/src/runtime_src/core/include/xrt_error_code.h @@ -1,156 +1,10 @@ -/* - * Copyright (C) 2020, Xilinx Inc - * - * This file is dual licensed. It may be redistributed and/or modified - * under the terms of the Apache 2.0 License OR version 2 of the GNU - * General Public License. - * - * Apache License Verbiage - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * GPL license Verbiage: - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. You should have received a copy of the - * GNU General Public License along with this program; if not, write - * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - */ - +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. #ifndef XRT_ERROR_CODE_H_ #define XRT_ERROR_CODE_H_ -#if defined(__KERNEL__) -# include -#elif defined(__cplusplus) -# include -#else -# include -#endif - -/** - * xrtErrorCode layout - * - * This layout is internal to XRT (akin to a POSIX error code). - * - * The error code is populated by driver and consumed by XRT - * implementation where it is translated into an actual error / info / - * warning that is propagated to the end user. - * - * 63 - 48 47 - 40 39 - 32 31 - 24 23 - 16 15 - 0 - * -------------------------------------------------------- - * | | | | | | | | | | |----| xrtErrorNum - * | | | | | | | | |----|---------- xrtErrorDriver - * | | | | | | |----|-------------------- xrtErrorSeverity - * | | | | |----|------------------------------ xrtErrorModule - * | | |----|---------------------------------------- xrtErrorClass - * |----|-------------------------------------------------- reserved - * - */ -typedef uint64_t xrtErrorCode; -typedef uint64_t xrtErrorTime; - -#define XRT_ERROR_NUM_MASK 0xFFFFUL -#define XRT_ERROR_NUM_SHIFT 0 -#define XRT_ERROR_DRIVER_MASK 0xFUL -#define XRT_ERROR_DRIVER_SHIFT 16 -#define XRT_ERROR_SEVERITY_MASK 0xFUL -#define XRT_ERROR_SEVERITY_SHIFT 24 -#define XRT_ERROR_MODULE_MASK 0xFUL -#define XRT_ERROR_MODULE_SHIFT 32 -#define XRT_ERROR_CLASS_MASK 0xFUL -#define XRT_ERROR_CLASS_SHIFT 40 - -#define XRT_ERROR_CODE_BUILD(num, driver, severity, module, eclass) \ - ((((num) & XRT_ERROR_NUM_MASK) << XRT_ERROR_NUM_SHIFT) | \ - (((driver) & XRT_ERROR_DRIVER_MASK) << XRT_ERROR_DRIVER_SHIFT) | \ - (((severity) & XRT_ERROR_SEVERITY_MASK) << XRT_ERROR_SEVERITY_SHIFT) | \ - (((module) & XRT_ERROR_MODULE_MASK) << XRT_ERROR_MODULE_SHIFT) | \ - (((eclass) & XRT_ERROR_CLASS_MASK) << XRT_ERROR_CLASS_SHIFT)) - -#define XRT_ERROR_NUM(code) (((code) >> XRT_ERROR_NUM_SHIFT) & XRT_ERROR_NUM_MASK) -#define XRT_ERROR_DRIVER(code) (((code) >> XRT_ERROR_DRIVER_SHIFT) & XRT_ERROR_DRIVER_MASK) -#define XRT_ERROR_SEVERITY(code) (((code) >> XRT_ERROR_SEVERITY_SHIFT) & XRT_ERROR_SEVERITY_MASK) -#define XRT_ERROR_MODULE(code) (((code) >> XRT_ERROR_MODULE_SHIFT) & XRT_ERROR_MODULE_MASK) -#define XRT_ERROR_CLASS(code) (((code) >> XRT_ERROR_CLASS_SHIFT) & XRT_ERROR_CLASS_MASK) - -/** - * xrt_error_num - XRT specific error numbers - */ -enum xrtErrorNum { - XRT_ERROR_NUM_FIRWWALL_TRIP = 1, - XRT_ERROR_NUM_TEMP_HIGH, - XRT_ERROR_NUM_AIE_SATURATION, - XRT_ERROR_NUM_AIE_FP, - XRT_ERROR_NUM_AIE_STREAM, - XRT_ERROR_NUM_AIE_ACCESS, - XRT_ERROR_NUM_AIE_BUS, - XRT_ERROR_NUM_AIE_INSTRUCTION, - XRT_ERROR_NUM_AIE_ECC, - XRT_ERROR_NUM_AIE_LOCK, - XRT_ERROR_NUM_AIE_DMA, - XRT_ERROR_NUM_AIE_MEM_PARITY, - XRT_ERROR_NUM_KDS_CU, - XRT_ERROR_NUM_KDS_EXEC, - XRT_ERROR_NUM_UNKNOWN -}; - -enum xrtErrorDriver { - XRT_ERROR_DRIVER_XOCL = 1, - XRT_ERROR_DRIVER_XCLMGMT, - XRT_ERROR_DRIVER_ZOCL, - XRT_ERROR_DRIVER_AIE, - XRT_ERROR_DRIVER_UNKNOWN -}; - -enum xrtErrorSeverity { - XRT_ERROR_SEVERITY_EMERGENCY = 1, - XRT_ERROR_SEVERITY_ALERT, - XRT_ERROR_SEVERITY_CRITICAL, - XRT_ERROR_SEVERITY_ERROR, - XRT_ERROR_SEVERITY_WARNING, - XRT_ERROR_SEVERITY_NOTICE, - XRT_ERROR_SEVERITY_INFO, - XRT_ERROR_SEVERITY_DEBUG, - XRT_ERROR_SEVERITY_UNKNOWN -}; - -enum xrtErrorModule { - XRT_ERROR_MODULE_FIREWALL = 1, - XRT_ERROR_MODULE_CMC, - XRT_ERROR_MODULE_AIE_CORE, - XRT_ERROR_MODULE_AIE_MEMORY, - XRT_ERROR_MODULE_AIE_SHIM, - XRT_ERROR_MODULE_AIE_NOC, - XRT_ERROR_MODULE_AIE_PL, - XRT_ERROR_MODULE_UNKNOWN -}; - -enum xrtErrorClass { - XRT_ERROR_CLASS_FIRST_ENTRY = 1, - XRT_ERROR_CLASS_SYSTEM = XRT_ERROR_CLASS_FIRST_ENTRY, - XRT_ERROR_CLASS_AIE, - XRT_ERROR_CLASS_HARDWARE, - XRT_ERROR_CLASS_UNKNOWN, - XRT_ERROR_CLASS_LAST_ENTRY = XRT_ERROR_CLASS_UNKNOWN -}; +// The content of this file has moved. This file is no longer +// exported but is used internally within XRT in files built by DKMS +#include "xrt/detail/xrt_error_code.h" #endif diff --git a/src/runtime_src/core/include/xrt_mem.h b/src/runtime_src/core/include/xrt_mem.h old mode 100755 new mode 100644 index 8434cc42fee..a309bfdb9fe --- a/src/runtime_src/core/include/xrt_mem.h +++ b/src/runtime_src/core/include/xrt_mem.h @@ -1,167 +1,6 @@ -/* - * Copyright (C) 2019-2022, Xilinx Inc - All rights reserved. - * Xilinx Runtime (XRT) APIs - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may - * not use this file except in compliance with the License. A copy of the - * License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * GPL license Verbiage: - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the Free Software Foundation; - * either version 2 of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. -#ifndef _XRT_MEM_H_ -#define _XRT_MEM_H_ - -#ifdef _WIN32 -# pragma warning( push ) -# pragma warning( disable : 4201 ) -#endif - -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" -#endif - -#ifdef __cplusplus -# include -extern "C" { -#else -# if defined(__KERNEL__) -# include -# else -# include -# endif -#endif - -/** - * Encoding of flags passed to xcl buffer allocation APIs - */ -struct xcl_bo_flags -{ - union { - uint64_t all; // [63-0] - - struct { - uint32_t flags; // [31-0] - uint32_t extension; // [63-32] - }; - - struct { - uint16_t bank; // [15-0] - uint8_t slot; // [23-16] - uint8_t boflags; // [31-24] - - // extension - uint32_t access : 2; // [33-32] - uint32_t dir : 2; // [35-34] - uint32_t use : 2; // [37-36] - uint32_t unused : 26; // [63-38] - }; - }; -}; - -/** - * XCL BO Flags bits layout - * - * bits 0 ~ 15: DDR BANK index - * bits 24 ~ 31: BO flags - */ -#define XRT_BO_FLAGS_MEMIDX_MASK (0xFFFFFFUL) -#define XCL_BO_FLAGS_NONE (0) -#define XCL_BO_FLAGS_CACHEABLE (1U << 24) -#define XCL_BO_FLAGS_KERNBUF (1U << 25) -#define XCL_BO_FLAGS_SGL (1U << 26) -#define XCL_BO_FLAGS_SVM (1U << 27) -#define XCL_BO_FLAGS_DEV_ONLY (1U << 28) -#define XCL_BO_FLAGS_HOST_ONLY (1U << 29) -#define XCL_BO_FLAGS_P2P (1U << 30) -#define XCL_BO_FLAGS_EXECBUF (1U << 31) - -/** - * Shim level BO Flags for extension - */ -#define XRT_BO_ACCESS_LOCAL 0 -#define XRT_BO_ACCESS_SHARED 1 -#define XRT_BO_ACCESS_PROCESS 2 -#define XRT_BO_ACCESS_HYBRID 3 - -/** - * Shim level BO Flags for direction of data transfer - * as seen from device. - */ -#define XRT_BO_ACCESS_READ (1U << 0) -#define XRT_BO_ACCESS_WRITE (1U << 1) -#define XRT_BO_ACCESS_READ_WRITE (XRT_BO_ACCESS_READ | XRT_BO_ACCESS_WRITE) - -/** - * Shim level BO Flags to distinguish use of BO - * - * The use flag is for internal use only. - * - * XRT_BO_USE_DEBUG indicates that the buffer will be used to - * communicate debug data from driver / firmware back to user - * space. This type of usage is supported on specific - * platforms only. - - * XRT_BO_USE_KMD indicates that the buffer content can be shared - * with the kernel mode driver. This type of usage is supported on - * specific platforms only. - */ -#define XRT_BO_USE_NORMAL 0 -#define XRT_BO_USE_DEBUG 1 -#define XRT_BO_USE_KMD 2 - -/** - * XRT Native BO flags - * - * These flags are simple aliases for use with XRT native BO APIs. - */ -#define XRT_BO_FLAGS_NONE XCL_BO_FLAGS_NONE -#define XRT_BO_FLAGS_CACHEABLE XCL_BO_FLAGS_CACHEABLE -#define XRT_BO_FLAGS_DEV_ONLY XCL_BO_FLAGS_DEV_ONLY -#define XRT_BO_FLAGS_HOST_ONLY XCL_BO_FLAGS_HOST_ONLY -#define XRT_BO_FLAGS_P2P XCL_BO_FLAGS_P2P -#define XRT_BO_FLAGS_SVM XCL_BO_FLAGS_SVM -#define XRT_BO_FLAGS_CARVEOUT XCL_BO_FLAGS_KERNBUF - -/** - * This is the legacy usage of XCL DDR Flags. - * - * byte-0 lower 4 bits for DDR Flags are one-hot encoded - */ -enum xclDDRFlags { - XCL_DEVICE_RAM_BANK0 = 0x00000000, - XCL_DEVICE_RAM_BANK1 = 0x00000002, - XCL_DEVICE_RAM_BANK2 = 0x00000004, - XCL_DEVICE_RAM_BANK3 = 0x00000008, -}; - -#ifdef __cplusplus -} -#endif - -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - -#ifdef _WIN32 -# pragma warning( pop ) -#endif - -#endif +// The content of this file has moved. This file is no longer +// exported but is used internally within XRT in files built by DKMS +#include "xrt/detail/xrt_mem.h" diff --git a/src/runtime_src/core/pcie/CMakeLists.txt b/src/runtime_src/core/pcie/CMakeLists.txt index be8dcb13988..4fe931e3a62 100644 --- a/src/runtime_src/core/pcie/CMakeLists.txt +++ b/src/runtime_src/core/pcie/CMakeLists.txt @@ -10,7 +10,6 @@ xrt_add_subdirectory(tools) if(NOT WIN32) xrt_add_subdirectory(linux) - xrt_add_subdirectory(driver) if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") # Emulation flow only works on x86_64 xrt_add_subdirectory(emulation) diff --git a/src/runtime_src/core/pcie/driver/CMakeLists.txt b/src/runtime_src/core/pcie/driver/CMakeLists.txt deleted file mode 100644 index 8e512e7c051..00000000000 --- a/src/runtime_src/core/pcie/driver/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# -add_subdirectory(linux) diff --git a/src/runtime_src/core/pcie/driver/linux/CMakeLists.txt b/src/runtime_src/core/pcie/driver/linux/CMakeLists.txt deleted file mode 100644 index 19da9f293e4..00000000000 --- a/src/runtime_src/core/pcie/driver/linux/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# -add_subdirectory(include) - -set(XRT_KERNEL_HEADERS - include/xocl_ioctl.h -) - -install(FILES ${XRT_KERNEL_HEADERS} DESTINATION ${XRT_INSTALL_DIR}/include) - diff --git a/src/runtime_src/core/pcie/driver/linux/include/CMakeLists.txt b/src/runtime_src/core/pcie/driver/linux/include/CMakeLists.txt deleted file mode 100644 index 8be8bcec511..00000000000 --- a/src/runtime_src/core/pcie/driver/linux/include/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2019-2021 Xilinx, Inc. All rights reserved. -# -set(XRT_HEADER_SRC - mailbox_proto.h) - -install (FILES ${XRT_HEADER_SRC} DESTINATION ${XRT_INSTALL_INCLUDE_DIR} COMPONENT ${XRT_DEV_COMPONENT}) - -message("-- XRT header files") -foreach (header ${XRT_HEADER_SRC}) - message("-- ${header}") -endforeach() diff --git a/src/runtime_src/core/pcie/emulation/common_em/config.h b/src/runtime_src/core/pcie/emulation/common_em/config.h index 584601fe0fb..a39c70fc8f4 100644 --- a/src/runtime_src/core/pcie/emulation/common_em/config.h +++ b/src/runtime_src/core/pcie/emulation/common_em/config.h @@ -4,7 +4,7 @@ //XRT/Local includes #include "em_defines.h" #include "xbar_sys_parameters.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "xclfeatures.h" #include "xclhal2.h" //std includes diff --git a/src/runtime_src/core/pcie/emulation/common_em/em_defines.h b/src/runtime_src/core/pcie/emulation/common_em/em_defines.h index 5e9e9225cc8..4b91b00a555 100644 --- a/src/runtime_src/core/pcie/emulation/common_em/em_defines.h +++ b/src/runtime_src/core/pcie/emulation/common_em/em_defines.h @@ -34,7 +34,7 @@ #include #include #include -#include "xrt_mem.h" +#include "xrt/detail/xrt_mem.h" #define GCC_VERSION (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ + __GNUC_PATCHLEVEL__) diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/debug.cxx b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/debug.cxx index fa52e1bd71e..2e76a3f0061 100644 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/debug.cxx +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/debug.cxx @@ -38,7 +38,7 @@ // Local/XRT headers #include "config.h" #include "shim.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" // C++ headers #include #include diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/halapi.cxx b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/halapi.cxx index a019d6d74b8..4970c5ae6a4 100755 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/halapi.cxx +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/halapi.cxx @@ -4,6 +4,7 @@ #include "shim.h" #include "core/include/shim_int.h" #include "core/include/xdp/app_debug.h" +#include "core/include/deprecated/xcl_app_debug.h" #include "core/common/device.h" #include "core/common/system.h" diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler.h b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler.h index e95db9fbd44..b9148044002 100644 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler.h +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler.h @@ -11,7 +11,7 @@ #include #include #include -#include "ert.h" +#include "xrt/detail/ert.h" #define XOCL_U32_MASK 0xFFFFFFFF diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler_hwemu.h b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler_hwemu.h index 525e870cdbc..1156a596d0a 100644 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler_hwemu.h +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/mbscheduler_hwemu.h @@ -14,7 +14,7 @@ #include #include #include -#include "ert.h" +#include "xrt/detail/ert.h" #define MAX_CUS 128 #define MAX_SLOTS 128 diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.cxx b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.cxx index f601be78bca..a5146e73934 100644 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.cxx +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.cxx @@ -5,7 +5,7 @@ #include "system_hwemu.h" #include "plugin/xdp/device_offload.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/common/AlignedAllocator.h" #include "core/common/xclbin_parser.h" diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.h b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.h index 0cdcc4a6d76..e19cef21191 100755 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.h +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/shim.h @@ -16,7 +16,7 @@ #include "core/common/xrt_profiling.h" #include "core/common/shim/buffer_handle.h" #include "core/common/shim/hwctx_handle.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/include/xdp/common.h" #include "core/include/xdp/counters.h" @@ -26,7 +26,7 @@ #include "mem_model.h" #include "rpc_messages.pb.h" #include "xgq_hwemu.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "xcl_api_macros.h" #include "xcl_macros.h" #include "unix_socket.h" diff --git a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/xgq_hwemu.h b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/xgq_hwemu.h index 33596016aca..2d5641c7cf6 100644 --- a/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/xgq_hwemu.h +++ b/src/runtime_src/core/pcie/emulation/hw_emu/alveo_shim/xgq_hwemu.h @@ -47,8 +47,8 @@ #include #include "core/include/xrt/xrt_bo.h" +#include "core/include/xrt/detail/ert.h" #include "em_defines.h" -#include "ert.h" #include "xgq_cmd_common.h" #include "xgq_hwemu_plat.h" diff --git a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/halapi.cxx b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/halapi.cxx index a76125d7314..668532f3edc 100644 --- a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/halapi.cxx +++ b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/halapi.cxx @@ -7,7 +7,8 @@ #include "core/include/xdp/app_debug.h" #include "core/common/device.h" #include "core/common/system.h" -#include "core/include/experimental/xrt_hw_context.h" +#include "core/include/xrt/xrt_hw_context.h" +#include "core/include/deprecated/xcl_app_debug.h" namespace { diff --git a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.cxx b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.cxx index 9b62feaf020..5d43ffda87b 100644 --- a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.cxx +++ b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.cxx @@ -3,7 +3,7 @@ // Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. #include "shim.h" #include "system_swemu.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "core/common/xclbin_parser.h" diff --git a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.h b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.h index 99d3e3d6402..31d6a2afa20 100644 --- a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.h +++ b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/shim.h @@ -15,7 +15,7 @@ #include "swscheduler.h" #include "unix_socket.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "xcl_api_macros.h" #include "xcl_macros.h" @@ -28,7 +28,7 @@ #include "core/common/shim/buffer_handle.h" #include "core/common/shim/hwctx_handle.h" #include "core/common/shim/graph_handle.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/swscheduler.h b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/swscheduler.h index 3132bdc68c8..6c132383f74 100644 --- a/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/swscheduler.h +++ b/src/runtime_src/core/pcie/emulation/sw_emu/generic_pcie_hal2/swscheduler.h @@ -13,7 +13,7 @@ #include #include #include -#include "ert.h" +#include "xrt/detail/ert.h" #define XOCL_U32_MASK 0xFFFFFFFF diff --git a/src/runtime_src/core/pcie/linux/debug.cpp b/src/runtime_src/core/pcie/linux/debug.cpp index 65926b52c25..550b679c9d1 100644 --- a/src/runtime_src/core/pcie/linux/debug.cpp +++ b/src/runtime_src/core/pcie/linux/debug.cpp @@ -4,7 +4,7 @@ #include "pcidev.h" #include "shim.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "core/common/message.h" #include "core/include/xdp/aim.h" @@ -14,6 +14,7 @@ #include "core/include/xdp/counters.h" #include "core/include/xdp/lapc.h" #include "core/include/xdp/spc.h" +#include "core/include/deprecated/xcl_app_debug.h" #include #include diff --git a/src/runtime_src/core/pcie/linux/device_linux.cpp b/src/runtime_src/core/pcie/linux/device_linux.cpp index 00f2379750f..cf58c969fe8 100644 --- a/src/runtime_src/core/pcie/linux/device_linux.cpp +++ b/src/runtime_src/core/pcie/linux/device_linux.cpp @@ -9,7 +9,7 @@ #include "core/common/system.h" #include "core/common/utils.h" #include "core/common/xrt_profiling.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" #include "core/include/xdp/aim.h" #include "core/include/xdp/am.h" #include "core/include/xdp/asm.h" diff --git a/src/runtime_src/core/pcie/linux/pcidev.cpp b/src/runtime_src/core/pcie/linux/pcidev.cpp index 058408627bc..eda954720b5 100644 --- a/src/runtime_src/core/pcie/linux/pcidev.cpp +++ b/src/runtime_src/core/pcie/linux/pcidev.cpp @@ -3,7 +3,7 @@ // Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. #include "pcidev.h" #include "pcidrv.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "core/common/utils.h" diff --git a/src/runtime_src/core/pcie/linux/shim.cpp b/src/runtime_src/core/pcie/linux/shim.cpp index 872140c4713..756358bb9c3 100644 --- a/src/runtime_src/core/pcie/linux/shim.cpp +++ b/src/runtime_src/core/pcie/linux/shim.cpp @@ -5,10 +5,10 @@ #include "shim.h" // This file implements shim.h #include "xrt.h" // This file implements xrt.h -#include "ert.h" +#include "xrt/detail/ert.h" +#include "xrt/detail/xclbin.h" #include "pcidev.h" #include "system_linux.h" -#include "xclbin.h" #include "core/common/shim/buffer_handle.h" #include "core/common/shim/hwctx_handle.h" @@ -17,7 +17,7 @@ #include "core/include/shim_int.h" #include "core/include/xdp/fifo.h" #include "core/include/xdp/trace.h" -#include "core/include/experimental/xrt_hw_context.h" +#include "core/include/xrt/xrt_hw_context.h" #include "core/common/bo_cache.h" #include "core/common/config_reader.h" diff --git a/src/runtime_src/core/pcie/noop/shim.cpp b/src/runtime_src/core/pcie/noop/shim.cpp index 69a68eadd09..d6774d06e96 100644 --- a/src/runtime_src/core/pcie/noop/shim.cpp +++ b/src/runtime_src/core/pcie/noop/shim.cpp @@ -11,7 +11,7 @@ #define XRT_CORE_PCIE_NOOP_SOURCE #include "shim.h" // This file implements shim.h #include "core/include/shim_int.h" // This file implements shim_int.h -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" #include "core/common/config_reader.h" #include "core/common/device.h" diff --git a/src/runtime_src/core/pcie/tools/cloud-daemon/aws/aws_dev.cpp b/src/runtime_src/core/pcie/tools/cloud-daemon/aws/aws_dev.cpp index 6612d504a9b..2d70e7d6ca4 100644 --- a/src/runtime_src/core/pcie/tools/cloud-daemon/aws/aws_dev.cpp +++ b/src/runtime_src/core/pcie/tools/cloud-daemon/aws/aws_dev.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "aws_dev.h" static std::mapindex_map; diff --git a/src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp b/src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp index 73df8db77d8..05a3643374c 100644 --- a/src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp +++ b/src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "azure.h" /* diff --git a/src/runtime_src/core/pcie/tools/cloud-daemon/container/container.cpp b/src/runtime_src/core/pcie/tools/cloud-daemon/container/container.cpp index 32f43f9157e..6a5c6a1c605 100644 --- a/src/runtime_src/core/pcie/tools/cloud-daemon/container/container.cpp +++ b/src/runtime_src/core/pcie/tools/cloud-daemon/container/container.cpp @@ -26,7 +26,7 @@ #define OPENSSL_SUPPRESS_DEPRECATED #include #undef OPENSSL_SUPPRESS_DEPRECATED -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "container.h" /* diff --git a/src/runtime_src/core/pcie/tools/cloud-daemon/mpd_plugin.h b/src/runtime_src/core/pcie/tools/cloud-daemon/mpd_plugin.h index 36839044138..3251cfe1321 100644 --- a/src/runtime_src/core/pcie/tools/cloud-daemon/mpd_plugin.h +++ b/src/runtime_src/core/pcie/tools/cloud-daemon/mpd_plugin.h @@ -20,7 +20,7 @@ #ifndef MPD_PLUGIN_H #define MPD_PLUGIN_H -#include "xclbin.h" +#include "xrt/detail/xclbin.h" typedef int (*get_remote_msd_fd_fn)(size_t index, int *fd); typedef int (*mb_notify_fn)(size_t index, int fd, bool online); diff --git a/src/runtime_src/core/pcie/tools/cloud-daemon/msd.cpp b/src/runtime_src/core/pcie/tools/cloud-daemon/msd.cpp index 49e2d9fba77..f15a88e9e7c 100644 --- a/src/runtime_src/core/pcie/tools/cloud-daemon/msd.cpp +++ b/src/runtime_src/core/pcie/tools/cloud-daemon/msd.cpp @@ -37,7 +37,7 @@ #include "sw_msg.h" #include "common.h" #include "msd_plugin.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "core/pcie/driver/linux/include/mgmt-ioctl.h" static bool quit = false; diff --git a/src/runtime_src/core/tools/common/TestRunner.h b/src/runtime_src/core/tools/common/TestRunner.h index eae6fe5a9a1..fafe322b53d 100644 --- a/src/runtime_src/core/tools/common/TestRunner.h +++ b/src/runtime_src/core/tools/common/TestRunner.h @@ -9,9 +9,9 @@ #include "JSONConfigurable.h" #include "xrt/xrt_device.h" #include "xrt/xrt_bo.h" -#include "experimental/xrt_ext.h" -#include "experimental/xrt_module.h" -#include "experimental/xrt_elf.h" +#include "xrt/experimental/xrt_ext.h" +#include "xrt/experimental/xrt_module.h" +#include "xrt/experimental/xrt_elf.h" // 3rd Party Library - Include Files #include diff --git a/src/runtime_src/core/tools/common/reports/ReportAsyncError.cpp b/src/runtime_src/core/tools/common/reports/ReportAsyncError.cpp index 85bc578dea9..c247d1bd6a2 100644 --- a/src/runtime_src/core/tools/common/reports/ReportAsyncError.cpp +++ b/src/runtime_src/core/tools/common/reports/ReportAsyncError.cpp @@ -20,8 +20,8 @@ #include "core/common/device.h" #include "core/common/time.h" #include "core/common/api/error_int.h" -#include "core/include/experimental/xrt_error.h" -#include "core/include/xrt_error_code.h" +#include "core/include/xrt/experimental/xrt_error.h" +#include "core/include/xrt/detail/xrt_error_code.h" #include "core/common/query_requests.h" #include diff --git a/src/runtime_src/core/tools/common/reports/ReportDebugIpStatus.cpp b/src/runtime_src/core/tools/common/reports/ReportDebugIpStatus.cpp index 7ef82f62f57..f5967e9b5ff 100644 --- a/src/runtime_src/core/tools/common/reports/ReportDebugIpStatus.cpp +++ b/src/runtime_src/core/tools/common/reports/ReportDebugIpStatus.cpp @@ -30,7 +30,7 @@ namespace XBU = XBUtilities; #include "core/common/utils.h" #include "core/common/error.h" #include "core/common/xrt_profiling.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" #include "core/include/xdp/aim.h" #include "core/include/xdp/am.h" #include "core/include/xdp/asm.h" diff --git a/src/runtime_src/core/tools/common/tests/TestAiePl.cpp b/src/runtime_src/core/tools/common/tests/TestAiePl.cpp index 1f54b98bf97..25b2e08a578 100644 --- a/src/runtime_src/core/tools/common/tests/TestAiePl.cpp +++ b/src/runtime_src/core/tools/common/tests/TestAiePl.cpp @@ -13,7 +13,7 @@ namespace XBU = XBUtilities; #include "aie_pl_util/pl_controller_aie2.hpp" // XRT includes -#include "experimental/xrt_system.h" +#include "xrt/experimental/xrt_system.h" #include "xrt/xrt_bo.h" #include "xrt/xrt_device.h" #include "xrt/xrt_kernel.h" diff --git a/src/runtime_src/core/tools/common/tests/TestCmdChainLatency.cpp b/src/runtime_src/core/tools/common/tests/TestCmdChainLatency.cpp index a353ba52cd0..e3789ee4c21 100644 --- a/src/runtime_src/core/tools/common/tests/TestCmdChainLatency.cpp +++ b/src/runtime_src/core/tools/common/tests/TestCmdChainLatency.cpp @@ -10,7 +10,7 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" -#include +#include "xrt/experimental/xrt_kernel.h" namespace XBU = XBUtilities; #include diff --git a/src/runtime_src/core/tools/common/tests/TestCmdChainThroughput.cpp b/src/runtime_src/core/tools/common/tests/TestCmdChainThroughput.cpp index 471b62c40ad..8eaac29dcc7 100644 --- a/src/runtime_src/core/tools/common/tests/TestCmdChainThroughput.cpp +++ b/src/runtime_src/core/tools/common/tests/TestCmdChainThroughput.cpp @@ -10,7 +10,7 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" -#include +#include "xrt/experimental/xrt_kernel.h" namespace XBU = XBUtilities; #include diff --git a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp index fa21d57d1c1..4dfffa9d9d4 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp @@ -10,7 +10,7 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" -#include +#include "xrt/experimental/xrt_kernel.h" namespace XBU = XBUtilities; #include diff --git a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp index ae68666d6c5..c02fd6ec946 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp @@ -10,7 +10,7 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" -#include +#include "xrt/experimental/xrt_kernel.h" namespace XBU = XBUtilities; #include diff --git a/src/runtime_src/core/tools/xbmgmt2/flash/firmware_image.cpp b/src/runtime_src/core/tools/xbmgmt2/flash/firmware_image.cpp index 7fe5c758c43..bf71d1eecb6 100644 --- a/src/runtime_src/core/tools/xbmgmt2/flash/firmware_image.cpp +++ b/src/runtime_src/core/tools/xbmgmt2/flash/firmware_image.cpp @@ -17,7 +17,7 @@ #include "firmware_image.h" #include "core/common/utils.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" // 3rd Party Library - Include Files #include diff --git a/src/runtime_src/core/tools/xbreplay/src/replay_xrt/replay_xrt.hpp b/src/runtime_src/core/tools/xbreplay/src/replay_xrt/replay_xrt.hpp index d551a2244a4..54cb768abc2 100755 --- a/src/runtime_src/core/tools/xbreplay/src/replay_xrt/replay_xrt.hpp +++ b/src/runtime_src/core/tools/xbreplay/src/replay_xrt/replay_xrt.hpp @@ -3,13 +3,13 @@ #pragma once -#include "experimental/xrt_device.h" -#include "experimental/xrt_xclbin.h" -#include "experimental/xrt_ext.h" -#include "xrt/xrt_kernel.h" -#include "xrt.h" -#include "xclbin.h" #include "xrt/xrt_bo.h" +#include "xrt/xrt_device.h" +#include "xrt/xrt_kernel.h" +#include "xrt/experimental/xrt_xclbin.h" +#include "xrt/experimental/xrt_ext.h" +#include "xrt/deprecated/xrt.h" +#include "xrt/detail/xclbin.h" #include "utils/message.hpp" #include diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/logger.h b/src/runtime_src/core/tools/xbtracer/src/lib/logger.h index 94a3df07271..f21e00a8915 100644 --- a/src/runtime_src/core/tools/xbtracer/src/lib/logger.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/logger.h @@ -15,9 +15,9 @@ #include #include -#include "experimental/xrt_hw_context.h" -#include "experimental/xrt_xclbin.h" -#include "experimental/xrt_module.h" +#include "xrt/xrt_hw_context.h" +#include "xrt/experimental/xrt_xclbin.h" +#include "xrt/experimental/xrt_module.h" #include "xrt/xrt_bo.h" #include "xrt/xrt_device.h" #include "xrt/xrt_kernel.h" diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_bo_inst.h b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_bo_inst.h index b9ed896b0c8..2cb35bdc4d3 100755 --- a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_bo_inst.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_bo_inst.h @@ -3,8 +3,8 @@ #pragma once -#include "experimental/xrt_ext.h" #include "xrt/xrt_bo.h" +#include "xrt/experimental/xrt_ext.h" #ifdef _WIN32 using export_handle = uint64_t; diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_elf_inst.h b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_elf_inst.h index 531413e38a3..f4cb5867407 100644 --- a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_elf_inst.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_elf_inst.h @@ -3,7 +3,7 @@ #pragma once -#include "experimental/xrt_elf.h" +#include "xrt/experimental/xrt_elf.h" /* * elf class method aliases. diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_hw_context_inst.h b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_hw_context_inst.h index a1dd5cea217..6fb4cd4e4f6 100755 --- a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_hw_context_inst.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_hw_context_inst.h @@ -3,7 +3,7 @@ #pragma once -#include "experimental/xrt_hw_context.h" +#include "xrt/xrt_hw_context.h" /* * hw_context class method aliases. diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_module_inst.h b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_module_inst.h index 100c9934b74..d05357badcc 100644 --- a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_module_inst.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_module_inst.h @@ -3,7 +3,7 @@ #pragma once -#include "experimental/xrt_module.h" +#include "xrt/experimental/xrt_module.h" /* * module class method aliases. diff --git a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_xclbin_inst.h b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_xclbin_inst.h index ddf3ca8d33b..59463caf82a 100755 --- a/src/runtime_src/core/tools/xbtracer/src/lib/xrt_xclbin_inst.h +++ b/src/runtime_src/core/tools/xbtracer/src/lib/xrt_xclbin_inst.h @@ -3,7 +3,7 @@ #pragma once -#include "experimental/xrt_xclbin.h" +#include "xrt/experimental/xrt_xclbin.h" /* * xclbin class method aliases. diff --git a/src/runtime_src/core/tools/xbutil2/OO_P2P.cpp b/src/runtime_src/core/tools/xbutil2/OO_P2P.cpp index 47eb3de12f3..29c431f5a9c 100644 --- a/src/runtime_src/core/tools/xbutil2/OO_P2P.cpp +++ b/src/runtime_src/core/tools/xbutil2/OO_P2P.cpp @@ -12,10 +12,10 @@ #include "core/common/memalign.h" #include "core/common/device.h" #include "core/common/query_requests.h" -#include "experimental/xrt-next.h" -#include "experimental/xrt_bo.h" -#include "xrt.h" -#include "xclbin.h" +#include "xrt/experimental/xrt-next.h" +#include "xrt/xrt_bo.h" +#include "xrt/deprecated/xrt.h" +#include "xrt/detail/xclbin.h" namespace XBU = XBUtilities; // 3rd Party Library - Include Files diff --git a/src/runtime_src/doc/CMakeLists.txt b/src/runtime_src/doc/CMakeLists.txt index f84f761ba65..9c6550f65c3 100644 --- a/src/runtime_src/doc/CMakeLists.txt +++ b/src/runtime_src/doc/CMakeLists.txt @@ -11,16 +11,16 @@ file(GLOB XRT_XOCL_IOCTL_H ${XRT_RUNTIME_SRC_DIR}/core/pcie/driver/linux/include file(GLOB XRT_ZOCL_IOCTL_H ${XRT_RUNTIME_SRC_DIR}/core/edge/include/zynq_ioctl.h) file(GLOB XRT_BO_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/xrt_bo.h) file(GLOB XRT_DEVICE_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/xrt_device.h) -file(GLOB XRT_IP_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_ip.h) +file(GLOB XRT_IP_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_ip.h) file(GLOB XRT_KERNEL_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/xrt_kernel.h) -file(GLOB XRT_MAILBOX_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_mailbox.h) -file(GLOB XRT_MESSAGE_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_message.h) +file(GLOB XRT_MAILBOX_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_mailbox.h) +file(GLOB XRT_MESSAGE_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_message.h) #file(GLOB XRT_QUEUE_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_queue.h) -file(GLOB XRT_SYSTEM_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_system.h) +file(GLOB XRT_SYSTEM_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_system.h) file(GLOB XRT_UUID_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/xrt_uuid.h) -file(GLOB XRT_XCLBIN_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_xclbin.h) -file(GLOB XRT_INI_H ${XRT_RUNTIME_SRC_DIR}/core/include/experimental/xrt_ini.h) -file(GLOB XRT_ERT_H ${XRT_RUNTIME_SRC_DIR}/core/include/ert.h) +file(GLOB XRT_XCLBIN_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_xclbin.h) +file(GLOB XRT_INI_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/experimental/xrt_ini.h) +file(GLOB XRT_ERT_H ${XRT_RUNTIME_SRC_DIR}/core/include/xrt/detail/ert.h) file(GLOB XRT_MAILBOX_PROTO_H ${XRT_RUNTIME_SRC_DIR}/core/pcie/driver/linux/include/mailbox_proto.h) file(GLOB XRT_MAILBOX_C ${XRT_RUNTIME_SRC_DIR}/core/pcie/driver/linux/xocl/subdev/mailbox.c) diff --git a/src/runtime_src/ert/scheduler/sched.c b/src/runtime_src/ert/scheduler/sched.c index e3ab14b8f96..b348012bc20 100644 --- a/src/runtime_src/ert/scheduler/sched.c +++ b/src/runtime_src/ert/scheduler/sched.c @@ -18,7 +18,7 @@ /** * Embedded runtime scheduler */ -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" #include // includes from bsp diff --git a/src/runtime_src/ert/scheduler/sched.mk b/src/runtime_src/ert/scheduler/sched.mk index e6a0af4304b..58d22102754 100644 --- a/src/runtime_src/ert/scheduler/sched.mk +++ b/src/runtime_src/ert/scheduler/sched.mk @@ -7,7 +7,7 @@ include $(SRCDIR)/../ert.mk # Extract to build dir in includes target # Also update the MicroBlaze linker script when it changes RTS := $(SRCDIR)/../.. -HEADERS := $(SRCDIR)/*.h $(RTS)/core/include/xgq_impl.h $(RTS)/core/include/ert.h +HEADERS := $(SRCDIR)/*.h $(RTS)/core/include/xgq_impl.h $(RTS)/core/include/xrt/detail/ert.h SRC := $(SRCDIR)/sched.c $(HEADERS) XGQ_CTRL_SRC := $(SRCDIR)/xgq_ctrl.c $(HEADERS) XGQ_CU_SRC := $(SRCDIR)/xgq_cu.c $(HEADERS) diff --git a/src/runtime_src/ert/scheduler/scheduler.cpp b/src/runtime_src/ert/scheduler/scheduler.cpp index c8f1aa7eaa8..36f0e01be91 100644 --- a/src/runtime_src/ert/scheduler/scheduler.cpp +++ b/src/runtime_src/ert/scheduler/scheduler.cpp @@ -18,7 +18,7 @@ * Embedded runtime scheduler */ -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" // includes from bsp #ifndef ERT_HW_EMU #include diff --git a/src/runtime_src/ert/scheduler/scheduler_v30.cpp b/src/runtime_src/ert/scheduler/scheduler_v30.cpp index b93e4b4fa3b..f89642485e3 100644 --- a/src/runtime_src/ert/scheduler/scheduler_v30.cpp +++ b/src/runtime_src/ert/scheduler/scheduler_v30.cpp @@ -18,7 +18,7 @@ * Embedded runtime scheduler */ -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" // includes from bsp #ifndef ERT_HW_EMU #include diff --git a/src/runtime_src/tools/xclbinutil/FormattedOutput.h b/src/runtime_src/tools/xclbinutil/FormattedOutput.h index 32118380640..5a5bf72da05 100644 --- a/src/runtime_src/tools/xclbinutil/FormattedOutput.h +++ b/src/runtime_src/tools/xclbinutil/FormattedOutput.h @@ -22,7 +22,7 @@ #include #include #include -#include "xclbin.h" +#include "xrt/detail/xclbin.h" // #includes here - please keep these to a bare minimum! diff --git a/src/runtime_src/tools/xclbinutil/ParameterSectionData.h b/src/runtime_src/tools/xclbinutil/ParameterSectionData.h index fa622af6e2f..704d915eb0f 100644 --- a/src/runtime_src/tools/xclbinutil/ParameterSectionData.h +++ b/src/runtime_src/tools/xclbinutil/ParameterSectionData.h @@ -19,7 +19,7 @@ // ----------------------- I N C L U D E S ----------------------------------- #include "Section.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include // ---------- C L A S S : P a r a m e t e r S e c t i o n D a t a --------- diff --git a/src/runtime_src/tools/xclbinutil/Section.h b/src/runtime_src/tools/xclbinutil/Section.h index 31d37bed5d8..1b30b3eed69 100644 --- a/src/runtime_src/tools/xclbinutil/Section.h +++ b/src/runtime_src/tools/xclbinutil/Section.h @@ -20,7 +20,7 @@ // ----------------------- I N C L U D E S ----------------------------------- // #includes here - please keep these to a bare minimum! -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include #include diff --git a/src/runtime_src/tools/xclbinutil/SectionHeader.h b/src/runtime_src/tools/xclbinutil/SectionHeader.h index 36abad1880d..8d25e29db56 100644 --- a/src/runtime_src/tools/xclbinutil/SectionHeader.h +++ b/src/runtime_src/tools/xclbinutil/SectionHeader.h @@ -23,7 +23,7 @@ #include #include -#include "xclbin.h" +#include "xrt/detail/xclbin.h" // ------------ F O R W A R D - D E C L A R A T I O N S ---------------------- // Forward declarations - use these instead whenever possible... diff --git a/src/runtime_src/tools/xclbinutil/XclBinClass.h b/src/runtime_src/tools/xclbinutil/XclBinClass.h index 2e3323705eb..af87aa203fc 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinClass.h +++ b/src/runtime_src/tools/xclbinutil/XclBinClass.h @@ -23,7 +23,7 @@ #include #include -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "ParameterSectionData.h" class Section; diff --git a/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx b/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx index 2da10e3cb19..a728d396b93 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx +++ b/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx @@ -21,7 +21,7 @@ #include "FormattedOutput.h" #include "ParameterSectionData.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "XclBinClass.h" #include "XclBinSignature.h" #include "XclBinUtilities.h" diff --git a/src/runtime_src/tools/xclbinutil/XclBinUtilities.h b/src/runtime_src/tools/xclbinutil/XclBinUtilities.h index efe065e086b..87c1e01280f 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinUtilities.h +++ b/src/runtime_src/tools/xclbinutil/XclBinUtilities.h @@ -19,7 +19,7 @@ #define __XclBinUtilities_h_ // Include files -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include #include diff --git a/src/runtime_src/xdp/appdebug/appdebug.cpp b/src/runtime_src/xdp/appdebug/appdebug.cpp index fcdba6de8f8..6f322b7a84d 100644 --- a/src/runtime_src/xdp/appdebug/appdebug.cpp +++ b/src/runtime_src/xdp/appdebug/appdebug.cpp @@ -40,7 +40,7 @@ #include "core/include/xdp/axi_checker_codes.h" #include "core/include/xdp/common.h" #include "core/include/xdp/counters.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include #include diff --git a/src/runtime_src/xdp/appdebug/appdebug_track.h b/src/runtime_src/xdp/appdebug/appdebug_track.h index ce58b7ecfb3..e8b9598de35 100644 --- a/src/runtime_src/xdp/appdebug/appdebug_track.h +++ b/src/runtime_src/xdp/appdebug/appdebug_track.h @@ -24,7 +24,7 @@ #include "xocl/core/object.h" #include "xocl/core/command_queue.h" #include "xocl/core/execution_context.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/xrt_kernel.h" #include #include #include diff --git a/src/runtime_src/xdp/debug/debug_plugin.cpp b/src/runtime_src/xdp/debug/debug_plugin.cpp index c78da2d73fc..d81f64f9aea 100644 --- a/src/runtime_src/xdp/debug/debug_plugin.cpp +++ b/src/runtime_src/xdp/debug/debug_plugin.cpp @@ -17,7 +17,7 @@ #define XDP_PLUGIN_SOURCE -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "xdp/debug/debug_plugin.h" #include "xdp/debug/kernel_debug_manager.h" #include "xocl/api/plugin/xdp/debug.h" diff --git a/src/runtime_src/xdp/debug/debug_plugin.h b/src/runtime_src/xdp/debug/debug_plugin.h index 02b0e355787..44305e50bf9 100644 --- a/src/runtime_src/xdp/debug/debug_plugin.h +++ b/src/runtime_src/xdp/debug/debug_plugin.h @@ -18,7 +18,7 @@ #define DEBUG_PLUGIN_DOT_H #include "xdp/config.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" extern "C" { XDP_PLUGIN_EXPORT void cb_debug_reset(const axlf* xclbin) ; diff --git a/src/runtime_src/xdp/debug/kernel_debug_manager.cpp b/src/runtime_src/xdp/debug/kernel_debug_manager.cpp index 2410ac0870e..052db864312 100644 --- a/src/runtime_src/xdp/debug/kernel_debug_manager.cpp +++ b/src/runtime_src/xdp/debug/kernel_debug_manager.cpp @@ -25,7 +25,7 @@ #include "kernel_debug_manager.h" #include "xrt/util/message.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/common/xclbin_parser.h" // For PID and UID on different operating systems diff --git a/src/runtime_src/xdp/debug/kernel_debug_manager.h b/src/runtime_src/xdp/debug/kernel_debug_manager.h index b4bd0599e53..be659dcad84 100644 --- a/src/runtime_src/xdp/debug/kernel_debug_manager.h +++ b/src/runtime_src/xdp/debug/kernel_debug_manager.h @@ -18,7 +18,7 @@ #define KERNEL_DEBUG_MANAGER_DOT_H #include -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" namespace xdp { diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp index 33b7fa0367c..2cc0808b13a 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp @@ -27,7 +27,7 @@ #include "filetypes/aie_trace_config_filetype.h" #include "core/common/api/xclbin_int.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include #include diff --git a/src/runtime_src/xdp/profile/database/static_info/pl_constructs.h b/src/runtime_src/xdp/profile/database/static_info/pl_constructs.h index 1646ffde4fb..563eadf36f4 100644 --- a/src/runtime_src/xdp/profile/database/static_info/pl_constructs.h +++ b/src/runtime_src/xdp/profile/database/static_info/pl_constructs.h @@ -31,7 +31,7 @@ #include // For DEBUG_IP_TYPE -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "xdp/config.h" #include "xdp/profile/device/utility.h" diff --git a/src/runtime_src/xdp/profile/database/static_info_database.cpp b/src/runtime_src/xdp/profile/database/static_info_database.cpp index e35c2817f4a..f3e6f659e84 100644 --- a/src/runtime_src/xdp/profile/database/static_info_database.cpp +++ b/src/runtime_src/xdp/profile/database/static_info_database.cpp @@ -38,7 +38,7 @@ #include "core/common/config_reader.h" #include "core/common/message.h" #include "core/common/api/xclbin_int.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #define XDP_CORE_SOURCE diff --git a/src/runtime_src/xdp/profile/device/hal_device/xdp_hal_device.cpp b/src/runtime_src/xdp/profile/device/hal_device/xdp_hal_device.cpp index d70d9e2dbf6..4113002a3d6 100644 --- a/src/runtime_src/xdp/profile/device/hal_device/xdp_hal_device.cpp +++ b/src/runtime_src/xdp/profile/device/hal_device/xdp_hal_device.cpp @@ -23,8 +23,8 @@ #include "core/common/message.h" #include "core/common/query_requests.h" -#include "core/include/experimental/xrt-next.h" -#include "core/include/experimental/xrt_device.h" +#include "core/include/xrt/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt_device.h" #include "xdp/profile/device/utility.h" #include "xdp/profile/plugin/vp_base/utility.h" diff --git a/src/runtime_src/xdp/profile/device/pl_device_trace_logger.cpp b/src/runtime_src/xdp/profile/device/pl_device_trace_logger.cpp index 2a980ba3868..37d287ec9fe 100644 --- a/src/runtime_src/xdp/profile/device/pl_device_trace_logger.cpp +++ b/src/runtime_src/xdp/profile/device/pl_device_trace_logger.cpp @@ -23,7 +23,7 @@ #include "xdp/profile/database/static_info/xclbin_info.h" #include "core/common/message.h" -#include "experimental/xrt_profile.h" +#include "xrt/experimental/xrt_profile.h" #ifdef _WIN32 #pragma warning (disable : 4244) diff --git a/src/runtime_src/xdp/profile/device/pl_device_trace_offload.cpp b/src/runtime_src/xdp/profile/device/pl_device_trace_offload.cpp index 01539e6d402..721efb732e7 100644 --- a/src/runtime_src/xdp/profile/device/pl_device_trace_offload.cpp +++ b/src/runtime_src/xdp/profile/device/pl_device_trace_offload.cpp @@ -19,7 +19,7 @@ #include "xdp/profile/device/pl_device_trace_offload.h" #include "xdp/profile/device/pl_device_trace_logger.h" -#include "experimental/xrt_profile.h" +#include "xrt/experimental/xrt_profile.h" namespace xdp { diff --git a/src/runtime_src/xdp/profile/device/profile_ip_access.h b/src/runtime_src/xdp/profile/device/profile_ip_access.h index 4fecff9633d..8098ab4cd0f 100755 --- a/src/runtime_src/xdp/profile/device/profile_ip_access.h +++ b/src/runtime_src/xdp/profile/device/profile_ip_access.h @@ -23,7 +23,7 @@ #include #include #include "xclhal2.h" -#include "xclbin.h" +#include "xrt/detail/xclbin.h" #include "xdp_base_device.h" #define PROFILE_IP_SZ 0x1000 diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp index 27914efd66a..9966a43486a 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp @@ -27,7 +27,7 @@ #include "core/common/config_reader.h" #include "core/common/message.h" #include "core/common/system.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" #include "xdp/profile/database/database.h" #include "xdp/profile/database/static_info/aie_constructs.h" diff --git a/src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h b/src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h index 9e3d5a697b8..159c23a2e81 100644 --- a/src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h +++ b/src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h @@ -24,7 +24,7 @@ #include "xdp/profile/device/pl_device_intf.h" #include "xdp/profile/database/database.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" namespace xdp { diff --git a/src/runtime_src/xdp/profile/plugin/noc/noc_plugin.cpp b/src/runtime_src/xdp/profile/plugin/noc/noc_plugin.cpp index d7bd2a0cf6e..0c4cc806416 100755 --- a/src/runtime_src/xdp/profile/plugin/noc/noc_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/noc/noc_plugin.cpp @@ -20,7 +20,7 @@ #include "core/common/system.h" #include "core/common/time.h" #include "core/common/config_reader.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" #include "core/include/xrt/xrt_device.h" #include "xdp/profile/database/static_info/aie_constructs.h" diff --git a/src/runtime_src/xdp/profile/plugin/power/power_plugin.cpp b/src/runtime_src/xdp/profile/plugin/power/power_plugin.cpp index d537dffed12..c3d70ac4e1a 100644 --- a/src/runtime_src/xdp/profile/plugin/power/power_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/power/power_plugin.cpp @@ -24,7 +24,7 @@ #include "core/common/message.h" #include "core/common/system.h" #include "core/common/time.h" -#include "core/include/experimental/xrt-next.h" +#include "core/include/xrt/experimental/xrt-next.h" #include "core/common/query_requests.h" #include "core/include/xrt/xrt_device.h" diff --git a/src/runtime_src/xdp/profile/writer/vp_base/guidance_rules.cpp b/src/runtime_src/xdp/profile/writer/vp_base/guidance_rules.cpp index 783ecdb8ff1..c0e13a27199 100644 --- a/src/runtime_src/xdp/profile/writer/vp_base/guidance_rules.cpp +++ b/src/runtime_src/xdp/profile/writer/vp_base/guidance_rules.cpp @@ -27,7 +27,7 @@ #include "xdp/profile/plugin/vp_base/utility.h" #include "xdp/profile/plugin/vp_base/info.h" -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/common/time.h" // An anonymous namespace for all of the different guidance rules diff --git a/src/runtime_src/xocl/api/clCreateProgramWithBinary.cpp b/src/runtime_src/xocl/api/clCreateProgramWithBinary.cpp index 5f24e21bb1e..974b7fe3df3 100644 --- a/src/runtime_src/xocl/api/clCreateProgramWithBinary.cpp +++ b/src/runtime_src/xocl/api/clCreateProgramWithBinary.cpp @@ -26,8 +26,8 @@ #include "detail/context.h" #include "detail/device.h" -#include "core/include/xclbin.h" -#include "core/include/experimental/xclbin_util.h" +#include "core/include/xrt/detail/xclbin.h" +#include "core/include/xrt/experimental/xclbin_util.h" #include #include diff --git a/src/runtime_src/xocl/api/plugin/xdp/debug.cpp b/src/runtime_src/xocl/api/plugin/xdp/debug.cpp index 35e9744d7e6..118d8c92f1e 100644 --- a/src/runtime_src/xocl/api/plugin/xdp/debug.cpp +++ b/src/runtime_src/xocl/api/plugin/xdp/debug.cpp @@ -14,7 +14,7 @@ * under the License. */ -#include "core/include/xclbin.h" +#include "core/include/xrt/detail/xclbin.h" #include "core/common/dlfcn.h" #include "plugin/xdp/debug.h" #include "core/common/module_loader.h" diff --git a/src/runtime_src/xocl/api/plugin/xdp/profile_counters.cpp b/src/runtime_src/xocl/api/plugin/xdp/profile_counters.cpp index ce8fc5853e6..f3aff785e3a 100644 --- a/src/runtime_src/xocl/api/plugin/xdp/profile_counters.cpp +++ b/src/runtime_src/xocl/api/plugin/xdp/profile_counters.cpp @@ -21,7 +21,7 @@ #include "core/common/module_loader.h" #include "core/common/utils.h" #include "core/common/dlfcn.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/xrt_kernel.h" #include "xocl/core/command_queue.h" #include "xocl/core/program.h" diff --git a/src/runtime_src/xocl/api/plugin/xdp/profile_counters.h b/src/runtime_src/xocl/api/plugin/xdp/profile_counters.h index 5c68c83a4b7..c563e0db27d 100644 --- a/src/runtime_src/xocl/api/plugin/xdp/profile_counters.h +++ b/src/runtime_src/xocl/api/plugin/xdp/profile_counters.h @@ -19,7 +19,7 @@ #include "xocl/core/event.h" #include "xocl/core/execution_context.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/xrt_kernel.h" namespace xocl { diff --git a/src/runtime_src/xocl/api/xlnx/cl2xrt.cpp b/src/runtime_src/xocl/api/xlnx/cl2xrt.cpp index 664202eda53..4917c817541 100644 --- a/src/runtime_src/xocl/api/xlnx/cl2xrt.cpp +++ b/src/runtime_src/xocl/api/xlnx/cl2xrt.cpp @@ -19,9 +19,9 @@ #include "xocl/core/kernel.h" #include "xocl/core/memory.h" -#include "core/include/experimental/xrt_bo.h" -#include "core/include/experimental/xrt_device.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/xrt_bo.h" +#include "core/include/xrt/xrt_device.h" +#include "core/include/xrt/xrt_kernel.h" #include diff --git a/src/runtime_src/xocl/core/compute_unit.h b/src/runtime_src/xocl/core/compute_unit.h index 5f0db7700ab..cf5434b6294 100644 --- a/src/runtime_src/xocl/core/compute_unit.h +++ b/src/runtime_src/xocl/core/compute_unit.h @@ -18,7 +18,7 @@ #define xocl_core_compute_unit_h_ #include "xocl/xclbin/xclbin.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include "core/common/api/xclbin_int.h" #include diff --git a/src/runtime_src/xocl/core/execution_context.cpp b/src/runtime_src/xocl/core/execution_context.cpp index 25573c7eb70..1f0d737b54e 100644 --- a/src/runtime_src/xocl/core/execution_context.cpp +++ b/src/runtime_src/xocl/core/execution_context.cpp @@ -17,11 +17,11 @@ #include "execution_context.h" #include "device.h" #include "event.h" -#include "ert.h" +#include "xrt/detail/ert.h" #include "core/common/xclbin_parser.h" #include "core/common/api/kernel_int.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/xocl/core/execution_context.h b/src/runtime_src/xocl/core/execution_context.h index 3e7b23b8d0a..3f57e0e38ed 100644 --- a/src/runtime_src/xocl/core/execution_context.h +++ b/src/runtime_src/xocl/core/execution_context.h @@ -21,8 +21,8 @@ #include "xocl/core/kernel.h" #include "xocl/core/compute_unit.h" -#include "core/include/xclbin.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/detail/xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/xocl/core/kernel.h b/src/runtime_src/xocl/core/kernel.h index bcdf6f50c95..d060fa7e12f 100644 --- a/src/runtime_src/xocl/core/kernel.h +++ b/src/runtime_src/xocl/core/kernel.h @@ -22,7 +22,7 @@ #include "xocl/core/memory.h" #include "xocl/xclbin/xclbin.h" -#include "core/include/experimental/xrt_kernel.h" +#include "core/include/xrt/xrt_kernel.h" #include "core/common/api/kernel_int.h" #include "xrt/util/td.h" diff --git a/src/runtime_src/xocl/core/memory.h b/src/runtime_src/xocl/core/memory.h index 7266e01976b..aac0eab03bd 100644 --- a/src/runtime_src/xocl/core/memory.h +++ b/src/runtime_src/xocl/core/memory.h @@ -26,7 +26,7 @@ #include "core/common/memalign.h" #include "core/common/unistd.h" #include "core/common/api/bo.h" -#include "core/include/experimental/xrt_bo.h" +#include "core/include/xrt/xrt_bo.h" #include diff --git a/src/runtime_src/xocl/xclbin/xclbin.h b/src/runtime_src/xocl/xclbin/xclbin.h index a3762edbc64..549c63a6fe8 100644 --- a/src/runtime_src/xocl/xclbin/xclbin.h +++ b/src/runtime_src/xocl/xclbin/xclbin.h @@ -18,11 +18,11 @@ #define runtime_src_xocl_xclbin_h_ #include "xocl/config.h" -#include "core/include/xclbin.h" // definition of binary structs +#include "core/include/xrt/detail/xclbin.h" // definition of binary structs #include "core/common/device.h" #include "core/common/uuid.h" -#include "core/include/experimental/xrt_xclbin.h" +#include "core/include/xrt/experimental/xrt_xclbin.h" #include #include diff --git a/src/runtime_src/xrt/device/device.h b/src/runtime_src/xrt/device/device.h index dbfb0fa101b..35f1617c0b7 100644 --- a/src/runtime_src/xrt/device/device.h +++ b/src/runtime_src/xrt/device/device.h @@ -9,8 +9,8 @@ #include "xrt/util/range.h" #include "core/common/device.h" #include "core/include/xdp/common.h" -#include "xclbin.h" -#include "ert.h" +#include "core/include/xrt/detail/ert.h" +#include "core/include/xrt/detail/xclbin.h" #include #include diff --git a/src/runtime_src/xrt/device/hal.cpp b/src/runtime_src/xrt/device/hal.cpp index 1ea34a51faf..b31fbe3e358 100644 --- a/src/runtime_src/xrt/device/hal.cpp +++ b/src/runtime_src/xrt/device/hal.cpp @@ -18,7 +18,7 @@ #include "core/common/dlfcn.h" #include "core/common/device.h" -#include "core/include/experimental/xrt_system.h" +#include "core/include/xrt/experimental/xrt_system.h" #include diff --git a/src/runtime_src/xrt/device/hal.h b/src/runtime_src/xrt/device/hal.h index 4de399c29fc..f71d4530029 100644 --- a/src/runtime_src/xrt/device/hal.h +++ b/src/runtime_src/xrt/device/hal.h @@ -11,14 +11,15 @@ #include "xrt/util/uuid.h" #include "core/common/device.h" #include "core/include/xrt.h" -#include "core/include/experimental/xrt_device.h" +#include "core/include/xrt/xrt_device.h" +#include "core/include/deprecated/xcl_app_debug.h" #include "core/include/xdp/app_debug.h" #include "core/include/xdp/common.h" #include "core/include/xdp/counters.h" #include "core/include/xdp/trace.h" -#include "ert.h" +#include "xrt/detail/ert.h" #include #include @@ -27,7 +28,7 @@ #include #ifdef _WIN32 -# include "core/include/windows/types.h" +# include "core/include/xrt/detail/windows/types.h" # pragma warning( push ) # pragma warning ( disable : 4100 ) #endif diff --git a/src/runtime_src/xrt/device/hal2.cpp b/src/runtime_src/xrt/device/hal2.cpp index 0565b5cc3dd..9d3c4d1b32c 100644 --- a/src/runtime_src/xrt/device/hal2.cpp +++ b/src/runtime_src/xrt/device/hal2.cpp @@ -10,7 +10,7 @@ #include "core/common/scope_guard.h" #include "core/common/system.h" #include "core/common/thread.h" -#include "core/include/ert.h" +#include "core/include/xrt/detail/ert.h" #include diff --git a/src/runtime_src/xrt/device/hal2.h b/src/runtime_src/xrt/device/hal2.h index ea95d907cfc..14119a6e1bb 100644 --- a/src/runtime_src/xrt/device/hal2.h +++ b/src/runtime_src/xrt/device/hal2.h @@ -6,15 +6,14 @@ #include "xrt/device/hal.h" -#include "experimental/xrt_device.h" -#include "experimental/xrt_bo.h" +#include "xrt/xrt_device.h" +#include "xrt/xrt_bo.h" +#include "xrt/detail/ert.h" #include "core/common/device.h" #include "core/common/shim/buffer_handle.h" #include "core/common/query_requests.h" -#include "ert.h" - #include #include diff --git a/src/runtime_src/xrt/util/uuid.h b/src/runtime_src/xrt/util/uuid.h index ad7481138d5..b80d24053b0 100644 --- a/src/runtime_src/xrt/util/uuid.h +++ b/src/runtime_src/xrt/util/uuid.h @@ -17,7 +17,7 @@ #ifndef xrtx_uuid_h_ #define xrtx_uuid_h_ -#include "core/include/experimental/xrt_uuid.h" +#include "core/include/xrt/xrt_uuid.h" namespace xrt_xocl { diff --git a/src/runtime_src/xrt/xrt++/xrtexec.hpp b/src/runtime_src/xrt/xrt++/xrtexec.hpp index 259d10a261f..46ab36bdaec 100644 --- a/src/runtime_src/xrt/xrt++/xrtexec.hpp +++ b/src/runtime_src/xrt/xrt++/xrtexec.hpp @@ -21,8 +21,8 @@ #ifndef _XRT_XRTEXEC_H_ #define _XRT_XRTEXEC_H_ #include -#include "ert.h" -#include "xrt.h" +#include "xrt/detail/ert.h" +#include "xrt/deprecated/xrt.h" struct xrt_device;