-
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
[RUNTIME] Hexagon driver for offloading kernels to simulator #5492
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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. | ||
|
||
project(SIM_DEV C CXX) | ||
cmake_minimum_required(VERSION 3.0.2) | ||
|
||
set(CMAKE_SYSTEM_NAME "Linux") | ||
|
||
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake) | ||
endif() | ||
|
||
set(EXTRA_CXX_FLAGS | ||
"-O2" | ||
"-Wno-format" | ||
"-mhvx -mhvx-length=128b" | ||
"-mv60" | ||
"-stdlib=libc++" | ||
) | ||
|
||
set(EXTRA_LINK_FLAGS | ||
"-stdlib=libc++" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I met the symbol (related with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We define our own pthread symbols now, so it works ok now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining, make sense to me now |
||
"-G0" | ||
"-Wl,--force-dynamic" | ||
"-Wl,--export-dynamic" | ||
"-Wl,--whole-archive" # This should link entire libc, libc++ and libc+abi. | ||
"-Wl,--defsym=HEAP_SIZE=0x40000000" | ||
) | ||
|
||
string(REGEX REPLACE ";" " " EXTRA_CXX_FLAGS_STR "${EXTRA_CXX_FLAGS}") | ||
string(REGEX REPLACE ";" " " EXTRA_LINK_FLAGS_STR "${EXTRA_LINK_FLAGS}") | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_FLAGS "${EXTRA_CXX_FLAGS_STR} ${CMAKE_CXX_FLAGS}") | ||
set(CMAKE_EXE_LINKER_FLAGS "${EXTRA_LINK_FLAGS_STR} ${CMAKE_EXE_LINKER_FLAGS}") | ||
|
||
# Set project properties. | ||
|
||
file(GLOB SOURCE_FILES "*.cc") | ||
add_executable(sim_dev ${SOURCE_FILES}) | ||
target_include_directories(sim_dev | ||
PUBLIC "." | ||
PUBLIC ".." | ||
PUBLIC "../../../../../include" | ||
PUBLIC "../../../../../3rdparty/dlpack/include" | ||
) | ||
|
||
target_link_libraries(sim_dev "-ldl") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!--- 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 simulator driver | ||
|
||
The driver (`sim_dev` executable) is the process running on the Hexagon simulator that handles the Hexagon-side communication with the TVM runtime running on x86. The location of `sim_dev` should be added to `PATH` before running any python code that uses Hexagon. The `sim_dev` executable is not intended to be run by users, it is automatically loaded by the simulator control code (in `hexagon_device_sim.cc`). | ||
|
||
### Prerequisites | ||
|
||
1. Hexagon C/C++ toolchain (such as the one in Hexagon SDK version 3.5.0 or later). | ||
|
||
Hexagon SDK is available at //developer.qualcomm.com/software/hexagon-dsp-sdk. | ||
|
||
### Configuring | ||
|
||
Set | ||
``` | ||
CMAKE_C_COMPILER=hexagon-clang | ||
CMAKE_CXX_COMPILER=hexagon-clang++ | ||
``` | ||
|
||
### Building | ||
|
||
There are no special options required for `make` (or the tool selected with `cmake`). The location of the resulting binary `sim_dev` should be added to `PATH`. |
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.
Better move this to cmake/modules/contrib dir?
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 a standalone
CMakeLists.txt
. The files in contrib seem to be some cmake "sub-files" for including in other cmake files. Could you elaborate on what you were suggesting?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.
VTA.cmake is an example of CMake config for building standalone lib. Also, given that it's unfriendly to require users to navigate to src/runtime/hexagon/sim/driver, and having CMakeLists.txt exist under src directory seems a bit odd to me, I think it's better to put this under
cmake
.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.
I was planning to add it as a dependency to the main CMakeLists.txt after it's checked in. This would remove the need for manual running.
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.
I don't have strong opinion on this, but suggest to improve the experience of potential users. They suppose to turn USE_HEXAGON_SIM_DRIVER flag ON in the config.cmake to have this driver build automatically, instead of navigating to src/runtime/hexagon/sim/driver and start another build configure again.
To achieve this goal,
https://github.com/apache/incubator-tvm/blob/19f322d70335c13c0d4f7af15c684bd414b90b40/cmake/modules/Hexagon.cmake#L22
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.
I've already added a commit that makes this a dependency and now it's compiled automatically. Does that address your concerns about user-friendliness?
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.
sure, thanks.