forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hexagon] Add hexagon launcher to apps and add to TVM's build system (a…
…pache#9220) * Add USE_HEXAGON_LAUNCHER cmake configuration to build the android hexagon launcher along with a standard TVM build. * Update hexagon launcher README.md to include instructions on how to build the launcher alongside TVM. * Move Hexagon launcher into top-level apps directory. * Refactor hexagon launcher cmake directory structure and group common code into cmake/HexagonLauncher.cmake. * Address CRs from @kparzysz-quic.
- Loading branch information
Showing
15 changed files
with
339 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
if(NOT "${FASTRPC_LIBS}" STREQUAL "SKEL" AND | ||
NOT "${FASTRPC_LIBS}" STREQUAL "STUB") | ||
message(SEND_ERROR "Please set FASTRPC_LIBS to either SKEL or STUB") | ||
endif() | ||
|
||
if(NOT DEFINED USE_HEXAGON_SDK) | ||
message(SEND_ERROR "Please set USE_HEXAGON_SDK to the location of Hexagon SDK") | ||
endif() | ||
if (NOT DEFINED USE_HEXAGON_ARCH) | ||
message(SEND_ERROR "Please set USE_HEXAGON_ARCH to the Hexagon architecture version") | ||
endif() | ||
|
||
set(TVM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../") | ||
|
||
include(ExternalProject) | ||
include("${TVM_SOURCE_DIR}/cmake/modules/HexagonSDK.cmake") | ||
|
||
find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}") | ||
|
||
include_directories(SYSTEM ${HEXAGON_SDK_INCLUDES} ${HEXAGON_REMOTE_ROOT}) | ||
|
||
set(QAIC_EXE "${HEXAGON_QAIC_EXE}") | ||
foreach(INCDIR IN LISTS HEXAGON_SDK_INCLUDES HEXAGON_REMOTE_ROOT) | ||
list(APPEND QAIC_FLAGS "-I${INCDIR}") | ||
endforeach() | ||
|
||
set(LAUNCHER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../") | ||
set(CMAKE_SKIP_RPATH TRUE) | ||
|
||
# Qaic for the domain header. | ||
# | ||
# Don't add paths to these filenames, or otherwise cmake may spontaneously | ||
# add -o option to the qaic invocation (with an undesirable path). | ||
set(LAUNCHER_RPC_IDL "launcher_rpc.idl") | ||
set(LAUNCHER_RPC_H "launcher_rpc.h") | ||
set(LAUNCHER_RPC_SKEL_C "launcher_rpc_skel.c") | ||
set(LAUNCHER_RPC_STUB_C "launcher_rpc_stub.c") | ||
|
||
include_directories( | ||
"${LAUNCHER_SRC}" | ||
"${TVM_SOURCE_DIR}/include" | ||
"${TVM_SOURCE_DIR}/3rdparty/dlpack/include" | ||
"${TVM_SOURCE_DIR}/3rdparty/dmlc-core/include" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
cmake_minimum_required(VERSION 3.2) | ||
project(HexagonAndroidLauncher C CXX) | ||
|
||
include("${CMAKE_CURRENT_SOURCE_DIR}/../HexagonLauncher.cmake") | ||
|
||
add_custom_command( | ||
OUTPUT ${LAUNCHER_RPC_STUB_C} | ||
COMMAND ${QAIC_EXE} ${QAIC_FLAGS} | ||
"${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}" | ||
COMMAND ${CMAKE_COMMAND} -E rename "${LAUNCHER_RPC_H}" | ||
"${LAUNCHER_SRC}/${LAUNCHER_RPC_H}" | ||
MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}" | ||
) | ||
|
||
include_directories(SYSTEM | ||
"${HEXAGON_SDK_INCLUDES}" | ||
"${HEXAGON_RPCMEM_ROOT}/inc" | ||
) | ||
|
||
link_directories(${HEXAGON_REMOTE_ROOT}) | ||
|
||
add_definitions(-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>) | ||
|
||
set(STUB_SRCS | ||
"${LAUNCHER_SRC}/launcher_android.cc" | ||
"${LAUNCHER_SRC}/launcher_core.cc" | ||
"${LAUNCHER_SRC}/launcher_main.cc" | ||
"${LAUNCHER_SRC}/launcher_util.cc" | ||
) | ||
|
||
add_executable(launcher_android | ||
"${STUB_SRCS}" | ||
"${LAUNCHER_RPC_STUB_C}" | ||
) | ||
|
||
ExternalProject_Add(android_tvm_runtime | ||
SOURCE_DIR "${TVM_SOURCE_DIR}" | ||
BUILD_COMMAND $(MAKE) runtime | ||
CMAKE_ARGS | ||
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" | ||
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}" | ||
"-DANDROID_ABI=${ANDROID_ABI}" | ||
"-DCMAKE_CXX_STANDARD=14" | ||
"-DUSE_LIBBACKTRACE=OFF" | ||
"-DUSE_LLVM=OFF" | ||
"-DUSE_RPC=OFF" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
) | ||
ExternalProject_Get_Property(android_tvm_runtime BINARY_DIR) | ||
ExternalProject_Add_Step(android_tvm_runtime copy_binaries | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BINARY_DIR} ${CMAKE_INSTALL_PREFIX} | ||
DEPENDEES install | ||
) | ||
|
||
add_dependencies(launcher_android android_tvm_runtime) | ||
add_library(tvm_runtime SHARED IMPORTED) | ||
set_target_properties(tvm_runtime PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/libtvm_runtime.so") | ||
|
||
target_link_libraries(launcher_android cdsprpc log tvm_runtime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
cmake_minimum_required(VERSION 3.2) | ||
project(HexagonLauncherRPCSkel C CXX) | ||
|
||
include("${CMAKE_CURRENT_SOURCE_DIR}/../HexagonLauncher.cmake") | ||
|
||
add_custom_command( | ||
OUTPUT ${LAUNCHER_RPC_SKEL_C} ${LAUNCHER_RPC_H} | ||
COMMAND ${QAIC_EXE} ${QAIC_FLAGS} | ||
"${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}" | ||
MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}" | ||
) | ||
|
||
include_directories(SYSTEM ${HEXAGON_QURT_INCLUDES}) | ||
|
||
link_directories(${HEXAGON_QURT_LIBS}) | ||
|
||
add_definitions(-D_MACH_I32=int) | ||
add_definitions(-DDMLC_CXX11_THREAD_LOCAL=0) | ||
add_definitions(-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>) | ||
|
||
# Extra compile flags (both C and C++). | ||
set(EXTRA_COMP_FLAGS | ||
"-O3" | ||
"-m${USE_HEXAGON_ARCH}" | ||
) | ||
string(REGEX REPLACE ";" " " EXTRA_COMP_FLAGS_STR "${EXTRA_COMP_FLAGS}") | ||
set(CMAKE_C_FLAGS "${EXTRA_COMP_FLAGS_STR} ${CMAKE_C_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${EXTRA_COMP_FLAGS_STR} ${CMAKE_CXX_FLAGS}") | ||
|
||
set(SKEL_SRCS | ||
"${LAUNCHER_SRC}/launcher_core.cc" | ||
"${LAUNCHER_SRC}/launcher_hexagon.cc" | ||
) | ||
add_library(launcher_rpc_skel SHARED | ||
"${LAUNCHER_SRC}/${LAUNCHER_RPC_H}" | ||
"${LAUNCHER_RPC_SKEL_C}" | ||
"${SKEL_SRCS}" | ||
) | ||
|
||
ExternalProject_Add(static_hexagon_tvm_runtime | ||
SOURCE_DIR "${TVM_SOURCE_DIR}" | ||
BUILD_COMMAND $(MAKE) runtime | ||
CMAKE_ARGS | ||
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" | ||
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" | ||
"-DUSE_HEXAGON_ARCH=${USE_HEXAGON_ARCH}" | ||
"-DCMAKE_CXX_STANDARD=14" | ||
"-DUSE_LIBBACKTRACE=OFF" | ||
"-DUSE_LLVM=OFF" | ||
"-DUSE_RPC=OFF" | ||
"-DBUILD_STATIC_RUNTIME=ON" | ||
"-DUSE_HEXAGON_SDK=${USE_HEXAGON_SDK}" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
) | ||
ExternalProject_Get_Property(static_hexagon_tvm_runtime BINARY_DIR) | ||
ExternalProject_Add_Step(static_hexagon_tvm_runtime copy_binaries | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BINARY_DIR} ${CMAKE_INSTALL_PREFIX} | ||
DEPENDEES install | ||
) | ||
|
||
add_dependencies(launcher_rpc_skel static_hexagon_tvm_runtime) | ||
add_library(static_tvm_runtime STATIC IMPORTED) | ||
set_target_properties(static_tvm_runtime PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/libtvm_runtime.a") | ||
|
||
target_link_libraries(launcher_rpc_skel -Wl,--whole-archive static_tvm_runtime -Wl,--no-whole-archive) | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.