Skip to content

Commit

Permalink
Reorganize XRT header files under core/include (#8648)
Browse files Browse the repository at this point in the history
* XRT Linux Packaging: Organize headers

Refactor header install per 4 buckets:

1. Internal to XRT, keep but stop exporting
2. Deprecated, delete from source tree
3. Indirectly included by xrt/xrt_<first class>.h, move to include/xrt/detail/
4. Included by application host code, move to include/xrt/legacy (and or other name(s))

Signed-off-by: Soren Soe <[email protected]>

* Move all exported headers under include/xrt

Signed-off-by: Soren Soe <[email protected]>

* cmake core infra changes to reflect file moves

Signed-off-by: Soren Soe <[email protected]>

* Fix include to pick up from new locations

Signed-off-by: Soren Soe <[email protected]>

* Fix windows includes

Signed-off-by: Soren Soe <[email protected]>

* Release core/include wrappers for legacy xrt

Signed-off-by: Soren Soe <[email protected]>

* Stop exporting internally used driver headers

Signed-off-by: Soren Soe <[email protected]>

* Fix typos

---------

Signed-off-by: Soren Soe <[email protected]>
  • Loading branch information
stsoe authored Dec 10, 2024
1 parent a81ded1 commit 07f11f2
Show file tree
Hide file tree
Showing 230 changed files with 6,902 additions and 6,664 deletions.
36 changes: 36 additions & 0 deletions src/CMake/components.cmake
Original file line number Diff line number Diff line change
@@ -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)
23 changes: 15 additions & 8 deletions src/CMake/dkms-aws.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 9 additions & 10 deletions src/CMake/dkms-edge.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
37 changes: 24 additions & 13 deletions src/CMake/dkms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
10 changes: 5 additions & 5 deletions src/CMake/nativeLnx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/CMake/nativeWin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
3 changes: 3 additions & 0 deletions src/CMake/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 15 additions & 3 deletions src/CMake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions src/include/1_2/CL/cl2xrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CL/cl.h>

Expand Down
6 changes: 3 additions & 3 deletions src/python/pybind11/src/pyxrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pybind11/pybind11.h>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/aie/xrt_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/bo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/common/api/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/runtime_src/core/common/api/context_mgr.h
Original file line number Diff line number Diff line change
@@ -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 <memory>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/elf_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdint>
#include <string>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/error_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/property_tree/ptree.hpp>

Expand Down
Loading

0 comments on commit 07f11f2

Please sign in to comment.