From 6e2705e55bfe96c1f23946f2a074d4cbfb6efb68 Mon Sep 17 00:00:00 2001 From: Digant Desai Date: Mon, 1 Apr 2024 10:29:37 -0700 Subject: [PATCH] Arm CI fix (#2771) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/2771 - buck issue with inotify limit. Default is 8K. 24K seems to work. Setting it to 1M. Didn't investigate further. - top CMake always building cpuinfo and threadpool. Added an option to turn it off with ARM_BAREMETAL - arm example building w/o ARM_BAREMETAL. Added that. Reviewed By: shoumikhin, Gasoonjia, mikekgfb Differential Revision: D55538019 fbshipit-source-id: 1a22504d157e47a1052e9b49ca28d56eb5eb22c5 --- .github/workflows/trunk.yml | 4 ++ CMakeLists.txt | 94 ++++++++++++++++++++++--------------- build/Utils.cmake | 7 +++ examples/arm/run.sh | 1 + 4 files changed, 67 insertions(+), 39 deletions(-) diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 2558333554..16ed6a2757 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -159,6 +159,10 @@ jobs: git config --global user.name "Github Executorch" bash examples/arm/setup.sh --i-agree-to-the-contained-eula + # Increase number of files user can monitor to bypass buck failures. + # Hopefully this is high enough for this setup. + sudo sysctl fs.inotify.max_user_watches=1048576 # 1024 * 1024 + # Test ethos-u delegate examples with run.sh source examples/arm/ethos-u-scratch/setup_path.sh PYTHON_EXECUTABLE=python bash examples/arm/run.sh examples/arm/ethos-u-scratch/ buck2 diff --git a/CMakeLists.txt b/CMakeLists.txt index a5c0200865..25ab253c04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,45 +56,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -# --- cpuinfo -set(CPUINFO_SOURCE_DIR "backends/xnnpack/third-party/cpuinfo") -set(CPUINFO_BUILD_TOOLS - OFF - CACHE BOOL "") -set(CPUINFO_BUILD_UNIT_TESTS - OFF - CACHE BOOL "") -set(CPUINFO_BUILD_MOCK_TESTS - OFF - CACHE BOOL "") -set(CPUINFO_BUILD_BENCHMARKS - OFF - CACHE BOOL "") -set(CPUINFO_LIBRARY_TYPE - "static" - CACHE STRING "") -set(CPUINFO_LOG_LEVEL - "error" - CACHE STRING "") -set(CLOG_SOURCE_DIR "${CPUINFO_SOURCE_DIR}/deps/clog") -add_subdirectory("${CPUINFO_SOURCE_DIR}") - -# --- pthreadpool -set(PTHREADPOOL_SOURCE_DIR "backends/xnnpack/third-party/pthreadpool") -set(PTHREADPOOL_BUILD_TESTS - OFF - CACHE BOOL "") -set(PTHREADPOOL_BUILD_BENCHMARKS - OFF - CACHE BOOL "") -set(PTHREADPOOL_LIBRARY_TYPE - "static" - CACHE STRING "") -set(PTHREADPOOL_ALLOW_DEPRECATED_API - ON - CACHE BOOL "") -add_subdirectory("${PTHREADPOOL_SOURCE_DIR}") - # ------------------------------ OPTIONS ------------------------------------- # WARNING: Please don't add example specific options in this CMakeLists.txt. # Instead please use `find_package(executorch REQUIRED)` in the example @@ -211,6 +172,61 @@ option(EXECUTORCH_BUILD_XNNPACK "Build the XNNPACK backend" OFF) option(EXECUTORCH_BUILD_VULKAN "Build the Vulkan backend" OFF) +# +# pthreadpool: build pthreadpool library. Disable on unsupported platforms +# +cmake_dependent_option(EXECUTORCH_BUILD_PTHREADPOOL "Build pthreadpool library." + ON "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF) + +# +# cpuinfo: build cpuinfo library. Disable on unsupported platforms +# +cmake_dependent_option(EXECUTORCH_BUILD_CPUINFO "Build cpuinfo library." ON + "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF) + +if(EXECUTORCH_BUILD_CPUINFO) + # --- cpuinfo + set(CPUINFO_SOURCE_DIR "backends/xnnpack/third-party/cpuinfo") + set(CPUINFO_BUILD_TOOLS + OFF + CACHE BOOL "") + set(CPUINFO_BUILD_UNIT_TESTS + OFF + CACHE BOOL "") + set(CPUINFO_BUILD_MOCK_TESTS + OFF + CACHE BOOL "") + set(CPUINFO_BUILD_BENCHMARKS + OFF + CACHE BOOL "") + set(CPUINFO_LIBRARY_TYPE + "static" + CACHE STRING "") + set(CPUINFO_LOG_LEVEL + "error" + CACHE STRING "") + set(CLOG_SOURCE_DIR "${CPUINFO_SOURCE_DIR}/deps/clog") + add_subdirectory("${CPUINFO_SOURCE_DIR}") +endif() + +if(EXECUTORCH_BUILD_PTHREADPOOL) + # --- pthreadpool + set(PTHREADPOOL_SOURCE_DIR "backends/xnnpack/third-party/pthreadpool") + set(PTHREADPOOL_BUILD_TESTS + OFF + CACHE BOOL "") + set(PTHREADPOOL_BUILD_BENCHMARKS + OFF + CACHE BOOL "") + set(PTHREADPOOL_LIBRARY_TYPE + "static" + CACHE STRING "") + set(PTHREADPOOL_ALLOW_DEPRECATED_API + ON + CACHE BOOL "") + add_subdirectory("${PTHREADPOOL_SOURCE_DIR}") +endif() + if(NOT PYTHON_EXECUTABLE) resolve_python_executable() endif() diff --git a/build/Utils.cmake b/build/Utils.cmake index 862cc8d636..39fa7317da 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -88,6 +88,13 @@ function(executorch_print_configuration_summary) message( STATUS " EXECUTORCH_BUILD_VULKAN : ${EXECUTORCH_BUILD_VULKAN}") + message( + STATUS + " EXECUTORCH_BUILD_PTHREADPOOL : ${EXECUTORCH_BUILD_PTHREADPOOL}") + message( + STATUS + " EXECUTORCH_BUILD_CPUINFO : ${EXECUTORCH_BUILD_CPUINFO}") + endfunction() # This is the funtion to use -Wl, --whole-archive to link static library NB: diff --git a/examples/arm/run.sh b/examples/arm/run.sh index 7d53df5454..9441b80b53 100755 --- a/examples/arm/run.sh +++ b/examples/arm/run.sh @@ -85,6 +85,7 @@ function build_executorch() { -DCMAKE_INSTALL_PREFIX=${et_build_dir} \ -DCMAKE_BUILD_TYPE=Release \ -DEXECUTORCH_SELECT_OPS_LIST="aten::_softmax.out" \ + -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \ -DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \ -B"${et_build_dir}"/examples/arm \ "${et_root_dir}"/examples/arm