Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hexagon] Deprecate SDK 3.x, rewrite HexagonSDK.cmake #10612

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/cpp_rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ target_include_directories(
)

if (BUILD_FOR_ANDROID AND USE_HEXAGON_SDK)
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
link_directories(${HEXAGON_REMOTE_ROOT})
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
DSPRPC_LIB DSPRPC_LIB_DIRS
)
if(REMOTE_DIR)
link_directories(${DSPRPC_LIB_DIRS})
else()
message(WARNING "Could not locate some Hexagon SDK components")
endif()
list(APPEND TVM_RPC_LINKER_LIBS cdsprpc log)
endif()

Expand Down
24 changes: 20 additions & 4 deletions apps/hexagon_launcher/cmake/HexagonLauncher.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
# specific language governing permissions and limitations
# under the License.

# On successful execution, sets
# SDK_INCLUDE_DIRS
# QAIC_EXE_PATH
# and
# QAIC_FLAGS
# LAUNCHER_SRC
# LAUNCHER_RPC_IDL
# LAUNCHER_RPC_H
# LAUNCHER_RPC_SKEL_C
# LAUNCHER_RPC_STUB_C

if(NOT DEFINED USE_HEXAGON_SDK)
message(SEND_ERROR "Please set USE_HEXAGON_SDK to the location of Hexagon SDK")
endif()
Expand All @@ -28,12 +39,17 @@ include(ExternalProject)
include("${TVM_SOURCE_DIR}/cmake/utils/Utils.cmake")
include("${TVM_SOURCE_DIR}/cmake/modules/HexagonSDK.cmake")

find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
SDK_INCLUDE SDK_INCLUDE_DIRS
QAIC_EXE QAIC_EXE_PATH
)
if(NOT SDK_INCLUDE_DIRS OR NOT QAIC_EXE_PATH)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

include_directories(SYSTEM ${HEXAGON_SDK_INCLUDES} ${HEXAGON_REMOTE_ROOT})
include_directories(SYSTEM ${SDK_INCLUDE_DIRS})

set(QAIC_EXE "${HEXAGON_QAIC_EXE}")
foreach(INCDIR IN LISTS HEXAGON_SDK_INCLUDES HEXAGON_REMOTE_ROOT)
foreach(INCDIR IN LISTS SDK_INCLUDE_DIRS)
list(APPEND QAIC_FLAGS "-I${INCDIR}")
endforeach()

Expand Down
26 changes: 22 additions & 4 deletions apps/hexagon_launcher/cmake/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,38 @@ cmake_minimum_required(VERSION 3.2)
project(HexagonAndroidLauncher C CXX)

include("${CMAKE_CURRENT_SOURCE_DIR}/../HexagonLauncher.cmake")
# From the include above, get
# SDK_INCLUDE_DIRS
# QAIC_EXE_PATH
# and
# QAIC_FLAGS
# LAUNCHER_SRC
# LAUNCHER_RPC_IDL
# LAUNCHER_RPC_H
# LAUNCHER_RPC_SKEL_C
# LAUNCHER_RPC_STUB_C

add_custom_command(
OUTPUT ${LAUNCHER_RPC_STUB_C} ${LAUNCHER_RPC_H}
COMMAND ${QAIC_EXE} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
COMMAND ${QAIC_EXE_PATH} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
)

get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
RPCMEM_ROOT RPCMEM_ROOT_DIR
DSPRPC_LIB DSPRPC_LIB_DIRS
)
if(NOT RPCMEM_ROOT_DIR)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

include_directories(SYSTEM
"${HEXAGON_SDK_INCLUDES}"
"${HEXAGON_RPCMEM_ROOT}/inc"
"${SDK_INCLUDE_DIRS}"
"${RPCMEM_ROOT_DIR}/inc"
"${CMAKE_CURRENT_BINARY_DIR}" # Output of qaic will go here
)

link_directories(${HEXAGON_REMOTE_ROOT})
link_directories(${DSPRPC_LIB_DIRS})

add_definitions(-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)

Expand Down
24 changes: 21 additions & 3 deletions apps/hexagon_launcher/cmake/hexagon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,37 @@ cmake_minimum_required(VERSION 3.2)
project(HexagonLauncherRPCSkel C CXX)

include("${CMAKE_CURRENT_SOURCE_DIR}/../HexagonLauncher.cmake")
# From the include above get
# SDK_INCLUDE_DIRS
# QAIC_EXE_PATH
# and
# QAIC_FLAGS
# LAUNCHER_SRC
# LAUNCHER_RPC_IDL
# LAUNCHER_RPC_H
# LAUNCHER_RPC_SKEL_C
# LAUNCHER_RPC_STUB_C

add_custom_command(
OUTPUT ${LAUNCHER_RPC_SKEL_C} ${LAUNCHER_RPC_H}
COMMAND ${QAIC_EXE} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
COMMAND ${QAIC_EXE_PATH} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
)

get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
QURT_INCLUDE QURT_INCLUDE_DIRS
QURT_LIB QURT_LIB_DIRS
)
if(NOT QURT_INCLUDE_DIRS OR NOT QURT_LIB_DIRS)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

include_directories(SYSTEM
${HEXAGON_QURT_INCLUDES}
${QURT_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} # Output of qaic will go here
)

link_directories(${HEXAGON_QURT_LIBS})
link_directories(${QURT_LIB_DIRS})

add_definitions(-D_MACH_I32=int)
add_definitions(-DDMLC_CXX11_THREAD_LOCAL=0)
Expand Down
120 changes: 0 additions & 120 deletions cmake/libs/hexagon_rpc_skel/CMakeLists.txt

This file was deleted.

43 changes: 27 additions & 16 deletions cmake/modules/Hexagon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,20 @@ endif()


function(add_android_paths)
if(NOT DEFINED HEXAGON_SDK_INCLUDES OR
NOT DEFINED HEXAGON_RPCMEM_ROOT OR
NOT DEFINED HEXAGON_REMOTE_ROOT)
message(FATAL_ERROR "This function must be called after find_hexagon_sdk_root")
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
SDK_INCLUDE SDK_INCLUDE_DIRS
DSPRPC_LIB DSPRPC_LIB_DIRS
RPCMEM_ROOT RPCMEM_ROOT_DIR
)
if(NOT SDK_INCLUDE_DIRS OR NOT DSPRPC_LIB_DIRS OR NOT RPCMEM_ROOT_DIR)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

include_directories(SYSTEM
${HEXAGON_SDK_INCLUDES}
${HEXAGON_RPCMEM_ROOT}/inc
${HEXAGON_REMOTE_ROOT}
${SDK_INCLUDE_DIRS}
"${RPCMEM_ROOT_DIR}/inc"
)
link_directories(${HEXAGON_REMOTE_ROOT})
link_directories(${DSPRPC_LIB_DIRS})
endfunction()

function(add_hexagon_wrapper_paths)
Expand All @@ -137,9 +140,16 @@ file_glob_append(RUNTIME_HEXAGON_COMMON_SRCS


if(BUILD_FOR_HEXAGON)
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
SDK_INCLUDE SDK_INCLUDE_DIRS
QURT_INCLUDE QURT_INCLUDE_DIRS
)
if(NOT SDK_INCLUDE_DIRS OR NOT QURT_INCLUDE_DIRS)
message(WARNING "Could not locate some Hexagon SDK components")
endif()

# Add SDK and QuRT includes when building for Hexagon.
include_directories(SYSTEM ${HEXAGON_SDK_INCLUDES} ${HEXAGON_QURT_INCLUDES})
include_directories(SYSTEM ${SDK_INCLUDE_DIRS} ${QURT_INCLUDE_DIRS})

list(APPEND RUNTIME_HEXAGON_SRCS ${RUNTIME_HEXAGON_COMMON_SRCS})
set(USE_CUSTOM_LOGGING ON) # To use a custom logger
Expand Down Expand Up @@ -181,7 +191,6 @@ if(USE_HEXAGON_DEVICE)
if(NOT USE_HEXAGON_DEVICE STREQUAL "${PICK_HW}")
invalid_device_value_for("Android")
endif()
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
find_hexagon_toolchain()
add_android_paths()
file_glob_append(RUNTIME_HEXAGON_SRCS
Expand All @@ -199,8 +208,11 @@ endif() # USE_HEXAGON_DEVICE

if(USE_HEXAGON_RPC)
function(build_rpc_idl)
set(QAIC_EXE "${HEXAGON_QAIC_EXE}")
foreach(INCDIR IN LISTS HEXAGON_SDK_INCLUDES HEXAGON_REMOTE_ROOT)
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
SDK_INCLUDE SDK_INCLUDE_DIRS
QAIC_EXE QAIC_EXE_PATH
)
foreach(INCDIR IN LISTS SDK_INCLUDE_DIRS)
list(APPEND QAIC_FLAGS "-I${INCDIR}")
endforeach()

Expand All @@ -210,7 +222,8 @@ if(USE_HEXAGON_RPC)
"${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc_skel.c"
"${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc_stub.c"
COMMAND
${QAIC_EXE} ${QAIC_FLAGS} "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc.idl"
${QAIC_EXE_PATH} ${QAIC_FLAGS}
"${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc.idl"
-o "${TVMRT_SOURCE_DIR}/hexagon/rpc"
MAIN_DEPENDENCY "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc.idl"
)
Expand All @@ -220,7 +233,6 @@ if(USE_HEXAGON_RPC)

if(BUILD_FOR_ANDROID)
# Android part
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
add_android_paths()
build_rpc_idl()
file_glob_append(RUNTIME_HEXAGON_SRCS
Expand All @@ -236,7 +248,6 @@ if(USE_HEXAGON_RPC)

elseif(BUILD_FOR_HEXAGON)
# Hexagon part
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")
find_hexagon_toolchain()
build_rpc_idl()

Expand Down
Loading