-
Notifications
You must be signed in to change notification settings - Fork 696
Initial framework of an ethos-u runtime backend #2 #595
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
Changes from 2 commits
521124b
2a6dce5
2083a71
f5cff0b
a1fbdb4
918c798
b2a395a
862e510
69c132d
e87db01
afd8080
a29523f
8efd2e3
52c1c09
8ae524c
a64e835
ec03f3c
1ba71d7
f29715e
3b35ff6
94c598e
683d428
3292199
e6ede01
76a393a
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,25 @@ | ||
| # Copyright 2023 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| cmake_minimum_required(VERSION 3.19) | ||
|
|
||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
|
||
| # Source root directory for executorch. | ||
| if(NOT EXECUTORCH_ROOT) | ||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
| endif() | ||
|
|
||
| include(${EXECUTORCH_ROOT}/build/Utils.cmake) | ||
|
|
||
| set(_common_include_directories ${EXECUTORCH_ROOT}/..) | ||
| set(_common_compile_options -Wno-deprecated-declarations) | ||
|
|
||
| include(cmake/Dependencies.cmake) | ||
|
|
||
| set(_arm_baremetal_sources backends/arm/runtime/ArmBackendEthosU.cpp) | ||
| list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/") | ||
| add_library(ethos_u STATIC ${_arm_baremetal_sources}) | ||
| target_include_directories(ethos_u PUBLIC ${_common_include_directories}) | ||
| target_include_directories(ethos_u PUBLIC ${DRIVER_ETHOSU_INCLUDE_DIR}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright 2023 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party") | ||
|
|
||
| # Ethos-U driver | ||
| set(DRIVER_ETHOSU_SOURCE_DIR "${THIRD_PARTY_ROOT}/ethos-u-core-driver") | ||
| set(DRIVER_ETHOSU_INCLUDE_DIR "${THIRD_PARTY_ROOT}/ethos-u-core-driver/include") | ||
| add_subdirectory( ${DRIVER_ETHOSU_SOURCE_DIR} ) | ||
| include_directories( ${DRIVER_ETHOSU_INCLUDE_DIR} ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Copyright 2023 Arm Limited and/or its affiliates. | ||
|
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. Is this same as - 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'd anticipate further changes and cleaning but it was derived from there, yes. It has a similar override but for m55 our only current supported target. The way the toolchain file is constructed, some of the general ./configure like step in cmake was invoking it without an appropriate value so the default prevents the -mfpu flag which was the default set on an m4 target messing things up. |
||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| set(TARGET_CPU "cortex-m4" CACHE STRING "Target CPU") | ||
| string(TOLOWER ${TARGET_CPU} CMAKE_SYSTEM_PROCESSOR) | ||
|
|
||
| set(CMAKE_SYSTEM_NAME Generic) | ||
| set(CMAKE_C_COMPILER "arm-none-eabi-gcc") | ||
| set(CMAKE_CXX_COMPILER "arm-none-eabi-g++") | ||
| set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc") | ||
| set(CMAKE_LINKER "arm-none-eabi-ld") | ||
|
|
||
| set(CMAKE_EXECUTABLE_SUFFIX ".elf") | ||
| set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
|
|
||
| # Select C/C++ version | ||
| set(CMAKE_C_STANDARD 11) | ||
| set(CMAKE_CXX_STANDARD 14) | ||
|
|
||
| set(GCC_CPU ${CMAKE_SYSTEM_PROCESSOR}) | ||
| string(REPLACE "cortex-m85" "cortex-m55" GCC_CPU ${GCC_CPU}) | ||
|
|
||
| # Compile options | ||
| add_compile_options( | ||
| -mcpu=${GCC_CPU} | ||
| -mthumb | ||
| "$<$<CONFIG:DEBUG>:-gdwarf-3>" | ||
| "$<$<COMPILE_LANGUAGE:CXX>:-fno-unwind-tables;-fno-rtti;-fno-exceptions>" | ||
| -fdata-sections | ||
| -ffunction-sections) | ||
|
|
||
| # Compile defines | ||
| add_compile_definitions( | ||
| "$<$<NOT:$<CONFIG:DEBUG>>:NDEBUG>") | ||
|
|
||
| # Link options | ||
| add_link_options( | ||
| -mcpu=${GCC_CPU} | ||
| -mthumb | ||
| --specs=nosys.specs) | ||
|
|
||
| # Set floating point unit | ||
| if(CMAKE_SYSTEM_PROCESSOR MATCHES "\\+fp") | ||
| set(FLOAT hard) | ||
| elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "\\+nofp") | ||
| set(FLOAT soft) | ||
| elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m33(\\+|$)" OR | ||
| CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m55(\\+|$)" OR | ||
| CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m85(\\+|$)") | ||
| set(FLOAT hard) | ||
| elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m4(\\+|$)" OR | ||
| CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m7(\\+|$)") | ||
| set(FLOAT hard) | ||
| set(FPU_CONFIG "fpv4-sp-d16") | ||
| add_compile_options(-mfpu=${FPU_CONFIG}) | ||
| add_link_options(-mfpu=${FPU_CONFIG}) | ||
| else() | ||
| set(FLOAT soft) | ||
| endif() | ||
|
|
||
| if (FLOAT) | ||
| add_compile_options(-mfloat-abi=${FLOAT}) | ||
| add_link_options(-mfloat-abi=${FLOAT}) | ||
| endif() | ||
|
|
||
| add_link_options(LINKER:--nmagic,--gc-sections) | ||
|
|
||
| # Compilation warnings | ||
| add_compile_options( | ||
| # -Wall | ||
| # -Wextra | ||
|
|
||
| # -Wcast-align | ||
| # -Wdouble-promotion | ||
| # -Wformat | ||
| # -Wmissing-field-initializers | ||
| # -Wnull-dereference | ||
| # -Wredundant-decls | ||
| # -Wshadow | ||
| # -Wswitch | ||
| # -Wswitch-default | ||
| # -Wunused | ||
| -Wno-redundant-decls | ||
| -Wno-psabi | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
| # Copyright 2023 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| set -e | ||
|
|
||
| # | ||
| # Setup toolchain | ||
| # | ||
| BASEDIR=`realpath $(dirname "$0")` | ||
| echo "building using build.sh in $BASEDIR" | ||
|
|
||
| ARCH=$(uname -i) | ||
| GCCPATH=${BASEDIR}/arm-gnu-toolchain-12.3.rel1-${ARCH}-arm-none-eabi/bin/ | ||
|
|
||
| echo $GCCPATH | ||
| if test -d "${GCCPATH}"; then | ||
| echo Using exising compiler ${GCCPATH} | ||
| else | ||
| pushd ${BASEDIR}/ | ||
| ./toolchain.sh | ||
| popd | ||
| fi | ||
| export PATH=${PATH}:${GCCPATH} | ||
|
|
||
| echo building with `arm-none-eabi-gcc -v 2>&1 | grep "^gcc"` | ||
|
|
||
|
|
||
| # | ||
| # Prepare and run clean build | ||
| # | ||
| rm -rf buck-out/ build/lib/ cmake-out/ | ||
| rm -rf cmake-corstone | ||
| mkdir cmake-corstone | ||
| cd cmake-corstone | ||
|
|
||
| #cmake -DBUCK2=buck2 .. | ||
|
|
||
| #cmake --toolchain backends/arm/cmake/arm-none-eabi-gcc.cmake .. | ||
| cmake -DFLATC_EXECUTABLE=flatc \ | ||
| -DEXECUTORCH_BUILD_XNNPACK=OFF \ | ||
| -DEXECUTORCH_BUILD_HOST_TARGETS=OFF \ | ||
| -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \ | ||
| -DCMAKE_SYSTEM_PROCESSOR=cortex-m55+nodsp+nofp \ | ||
| -DETHOSU_TARGET_NPU_CONFIG=ethos-u55-128 \ | ||
| --toolchain backends/arm/cmake/arm-none-eabi-gcc.cmake \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DEXECUTORCH_ENABLE_LOGGING_RELEASE_MODE=ON \ | ||
| .. | ||
|
|
||
| cd .. | ||
| cmake --build cmake-corstone -j9 --target ethos_u ethosu_core_driver executorch portable_ops_lib portable_kernels |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| # Copyright 2023 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| set -e | ||
|
|
||
| # Cross compiler for Arm baremetal (e.g. Corestone-300 FVP or silcon) | ||
| ARCH=$(uname -i) | ||
| curl -o gcc.tar.xz https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-${ARCH}-arm-none-eabi.tar.xz | ||
| tar xf gcc.tar.xz | ||
| export PATH=${PATH}:`(cd arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi/bin/; pwd)` |
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.
What is this used for?
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.
These are essentially the driver headers for ethos-u we need to link against.
I've also added a build of the ethos-u driver in executorch cmake (ethosu_core_driver target) but I moved to link against the demo app library build of it and can remove the target.
We still need this small submodule for the header/interface - it's fortunately small, but unfortunately it pulls in CMSIS for a few platform defines which is huge - this is really the area we discussed a build script pulling these in. Given ./run has a checkout of the core_platform and core_software, I'll look at moving to those and removing these submodules.
Uh oh!
There was an error while loading. Please reload this page.
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 removed most of this, we just have the small ethos-u-core-driver for headers now, and don't build it in tree and cmsis is removed. The driver builds in the driver/app repo and that app links the two together.
as it's only 25 files i suggest we keep the driver as a submodule to keep things simple until there's a more general "selective submodule" approach.