-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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] Do not auto-build apps when building TVM #9970
Merged
kparzysz-quic
merged 4 commits into
apache:main
from
kparzysz-quic:hexagon-cmake-no-apps
Jan 24, 2022
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,83 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
project(hexagon_api) | ||
|
||
include(ExternalProject) | ||
|
||
# Required variables: | ||
# ANDROID_ABI | ||
# ANDROID_PLATFORM | ||
# USE_ANDROID_TOOLCHAIN (Android toolchain .cmake file) | ||
# USE_HEXAGON_ARCH | ||
# USE_HEXAGON_SDK | ||
# USE_HEXAGON_TOOLCHAIN (Path to Hexagon toolchain ending with "Tools") | ||
|
||
set(TVM_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../..") | ||
set(HEXAGON_API_BINARY_DIR "${CMAKE_BINARY_DIR}/hexagon_rpc") | ||
|
||
kparzysz-quic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Build Android binaries: | ||
# - libtvm_runtime.so | ||
# - tvm_rpc_android | ||
|
||
ExternalProject_Add(android_tvm_runtime_rpc | ||
SOURCE_DIR "${TVM_SOURCE_DIR}" | ||
BUILD_COMMAND $(MAKE) runtime tvm_rpc | ||
CMAKE_ARGS | ||
"-DCMAKE_TOOLCHAIN_FILE=${USE_ANDROID_TOOLCHAIN}" | ||
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}" | ||
"-DANDROID_ABI=${ANDROID_ABI}" | ||
"-DUSE_HEXAGON_SDK=${USE_HEXAGON_SDK}" | ||
"-DUSE_HEXAGON_ARCH=${USE_HEXAGON_ARCH}" | ||
"-DCMAKE_CXX_STANDARD=14" | ||
"-DUSE_LIBBACKTRACE=OFF" | ||
"-DUSE_LLVM=OFF" | ||
"-DUSE_RPC=ON" | ||
"-DUSE_CPP_RPC=ON" | ||
"-DUSE_HEXAGON_RPC=ON" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
) | ||
ExternalProject_Get_Property(android_tvm_runtime_rpc BINARY_DIR) | ||
ExternalProject_Add_Step(android_tvm_runtime_rpc copy_runtime | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${BINARY_DIR}/libtvm_runtime.so | ||
${HEXAGON_API_BINARY_DIR} | ||
DEPENDEES install | ||
) | ||
ExternalProject_Add_Step(android_tvm_runtime_rpc copy_rpc_server | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${BINARY_DIR}/tvm_rpc | ||
${HEXAGON_API_BINARY_DIR}/tvm_rpc_android | ||
DEPENDEES install | ||
) | ||
|
||
|
||
# Build Hexagon binaries: | ||
# - libhexagon_rpc_skel.so | ||
# - libtvm_runtime.a | ||
|
||
ExternalProject_Add(hexagon_tvm_runtime_rpc | ||
SOURCE_DIR "${TVM_SOURCE_DIR}" | ||
BUILD_COMMAND $(MAKE) runtime | ||
CMAKE_ARGS | ||
"-DCMAKE_C_COMPILER=${USE_HEXAGON_TOOLCHAIN}/bin/hexagon-clang" | ||
"-DCMAKE_CXX_COMPILER=${USE_HEXAGON_TOOLCHAIN}/bin/hexagon-clang++" | ||
"-DUSE_HEXAGON_SDK=${USE_HEXAGON_SDK}" | ||
"-DUSE_HEXAGON_ARCH=${USE_HEXAGON_ARCH}" | ||
"-DUSE_LIBBACKTRACE=OFF" | ||
"-DUSE_RPC=OFF" | ||
"-DUSE_HEXAGON_RPC=ON" | ||
"-DBUILD_STATIC_RUNTIME=ON" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
) | ||
ExternalProject_Get_Property(hexagon_tvm_runtime_rpc BINARY_DIR) | ||
ExternalProject_Add_Step(hexagon_tvm_runtime_rpc copy_binaries | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
${BINARY_DIR}/libtvm_runtime.a | ||
${BINARY_DIR}/libhexagon_rpc_skel.so | ||
${HEXAGON_API_BINARY_DIR} | ||
DEPENDEES install | ||
) | ||
|
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,54 @@ | ||
<!--- 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. --> | ||
|
||
# Hexagon API app | ||
|
||
This is a meta-app that build the necessary binaries for use with | ||
the `HexagonLauncher` utility from `tvm.contrib.hexagon`. | ||
|
||
It will build the TVM runtime for Android, the RPC server application | ||
for Android, and the RPC library for Hexagon with the TVM runtime for | ||
Hexagon built into it. | ||
|
||
## Configuration | ||
|
||
There is a set of configuration variables that are required for cmake: | ||
- `ANDROID_ABI`: Set this to `arm64-v8a`. | ||
- `ANDROID_PLATFORM`: This can be `android-28`. | ||
- `USE_ANDROID_TOOLCHAIN`: The path to the Android toolchain file, i.e. | ||
`android.toolchain.cmake`. This file is a part of the Android NDK. | ||
- `USE_HEXAGON_ARCH`: The version string of the Hexagon architecture | ||
to use, i.e. vNN. The typical setting would be `v68` or later. | ||
- `USE_HEXAGON_SDK`: The path to the Hexagon SDK. Set this path in such | ||
a way that `${USE_HEXAGON_SDK}/setup_sdk_env.source` exists. | ||
- `USE_HEXAGON_TOOLCHAIN`: Path to Hexagon toolchain. It can be the | ||
Hexagon toolchain included in the SDK, for example | ||
`${USE_HEXAGON_TOOLCHAIN}/tools/HEXAGON_Tools/x.y.z/Tools`. The `x.y.z` | ||
in the path is the toolchain version number, which is specific to the | ||
version of the SDK. | ||
|
||
## Build | ||
|
||
The build will create a subdirectory `hexagon_rpc` with the following | ||
binaries | ||
- `tvm_runtime.so`: TVM runtime for Android (shared library). | ||
- `tvm_rpc_android`: RPC server for Android. | ||
- `libhexagon_rpc_skel.so`: RPC library for Hexagon. | ||
- `libtvm_runtime.a`: TVM runtime for Hexagon (static library). | ||
|
||
The RPC library for Hexagon contains the TVM runtime, so the static | ||
TVM runtime for Hexagon is not strictly necessary. | ||
kparzysz-quic marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change HEXAGON_API_BINARY_DIR to this to be compatible with current HexagonLauncher design:
set(HEXAGON_API_BINARY_DIR "${CMAKE_BINARY_DIR}/../../../build/hexagon_rpc")
This is with the assumption of building this CmakeLists.txt under
apps/hexagon_api/build
. Not the best solution, but we need to make sure everything is copied tobuild/hexagon_rpc
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be really fragile. Instead I propose a flag
USE_OUTPUT_BINARY_DIR
that could be set to any location, including.../build/hexagon_rpc
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kparzysz-quic makes sense. Thanks!