From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 21 Feb 2019 02:21:14 +0000 (+0900) Subject: Revert "Revert acl cmake build" (#4447) X-Git-Tag: submit/tizen/20190325.013700~231 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f41034d5ec112e5af3ada656797ff54c981be42;p=platform%2Fcore%2Fml%2Fnnfw.git Revert "Revert acl cmake build" (#4447) This reverts commit eddc0157eeba4766ce3b121fe009a24788d262ce. Move acl build into cmake again Signed-off-by: Hyeongseok Oh --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c816098..f0b9d03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ option(DOWNLOAD_GEMMLOWP "Download GEMM low precesion library source" ON) option(DOWNLOAD_NEON2SSE "Download NEON2SSE library source" ON) option(DOWNLOAD_FLATBUFFERS "Download FlatBuffers source" ON) option(DOWNLOAD_ARMCOMPUTE "Download ARM Compute source" ON) +option(BUILD_ARMCOMPUTE "Build ARM Compute from the downloaded source" ON) option(DOWNLOAD_NONIUS "Download nonius source" ON) # GTest support diff --git a/Makefile b/Makefile index 92058f9..163a2e7 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,15 @@ ifeq ($(BENCHMARK_ACL_BUILD),1) OPTIONS+= -DBUILD_BENCHMARK_ACL=1 endif +ifneq ($(EXT_ACL_FOLDER),) + OPTIONS+= -DBUILD_ARMCOMPUTE=OFF + OPTIONS+= -DARMCompute_EXTDIR=$(EXT_ACL_FOLDER) +endif + +ifneq ($(OBS_BUILD),OFF) + OPTIONS+= -DBUILD_ARMCOMPUTE=FALSE +endif + ifeq ($(PARALLEL_BUILD),1) # Get number of processors (linux only for now) ifeq ($(HOST_OS),linux) @@ -132,7 +141,13 @@ clean: rm -rf $(WORKDIR) rm -rf externals/*.stamp -acl: internal_acl_build internal_acl_install +acl: +ifeq ($(EXT_ACL_FOLDER),) + # Skip internal_acl_build when EXT_ACL_FOLDER is set + # NOTE internal_acl_build depends on configure + make internal_acl_build +endif + make internal_acl_install check: check_internal @@ -176,13 +191,6 @@ install_internal: touch $(TIMESTAMP_INSTALL) internal_acl_build: configure_internal -ifeq ($(EXT_ACL_FOLDER),) -ifeq ($(TARGET_OS),android) - cd $(ACL_FOLDER) && CXX=clang++ CC=clang PATH=$(ANDROID_GNUSTL_PATH) $(ACL_COMMAND) -else - cd $(ACL_FOLDER) && $(ACL_COMMAND) -endif -endif internal_acl_install: @echo $(ACL_FOLDER_BUILD) diff --git a/cmake/packages/ARMComputeConfig.cmake b/cmake/packages/ARMComputeConfig.cmake index e979300..11c35ee 100644 --- a/cmake/packages/ARMComputeConfig.cmake +++ b/cmake/packages/ARMComputeConfig.cmake @@ -29,8 +29,8 @@ function(_ARMCompute_Import) endif() if(NOT CORE_LIBRARY) - return() set(ARMCompute_FOUND FALSE PARENT_SCOPE) + return() endif() if(NOT RUNTIME_LIBRARY AND EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libarm_compute.so) @@ -38,8 +38,8 @@ function(_ARMCompute_Import) endif() if(NOT RUNTIME_LIBRARY) - return() set(ARMCompute_FOUND FALSE PARENT_SCOPE) + return() endif() if(NOT GRAPH_LIBRARY AND EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libarm_compute_graph.so) @@ -47,8 +47,8 @@ function(_ARMCompute_Import) endif() if(NOT GRAPH_LIBRARY) - return() set(ARMCompute_FOUND FALSE PARENT_SCOPE) + return() endif() if(NOT TARGET arm_compute_core) @@ -78,4 +78,116 @@ function(_ARMCompute_Import) set(ARMCompute_FOUND TRUE PARENT_SCOPE) endfunction(_ARMCompute_Import) +### Check whether library exists +function(_ARMCompute_Check VAR LIBDIR) + set(FOUND TRUE) + + if(NOT EXISTS "${LIBDIR}/libarm_compute_core.so") + set(FOUND FALSE) + endif() + + if(NOT EXISTS "${LIBDIR}/libarm_compute.so") + set(FOUND FALSE) + endif() + + if(NOT EXISTS "${LIBDIR}/libarm_compute_graph.so") + set(FOUND FALSE) + endif() + + set(${VAR} ${FOUND} PARENT_SCOPE) +endfunction(_ARMCompute_Check) + +# Let's build and install ARMCompute libraries +# NOTE This function silently returns on error +function(_ARMCompute_Build ARMCompute_PREFIX) + ### Check whether library exists + _ARMCompute_Check(ARMCompute_FOUND ${ARMCompute_PREFIX}) + + if(ARMCompute_FOUND) + return() + endif(ARMCompute_FOUND) + + ### Let's build with SCONS + nnfw_find_package(ARMComputeSource QUIET) + + if(NOT ARMComputeSource_FOUND) + return() + endif(NOT ARMComputeSource_FOUND) + + find_program(SCONS_PATH scons) + + if(NOT SCONS_PATH) + return() + endif(NOT SCONS_PATH) + + #### Architecture-specific configurations + if(TARGET_ARCH STREQUAL "armv7l") + set(BUILD_ARCH "armv7a") + set(BUILD_DIR "${BUILD_ARCH}-${TARGET_OS}") + endif() + + if(TARGET_ARCH STREQUAL "aarch64") + set(BUILD_ARCH "arm64-v8a") + set(BUILD_DIR "${BUILD_ARCH}-${TARGET_OS}") + endif() + + if(TARGET_ARCH STREQUAL "arm64") + set(BUILD_ARCH "arm64-v8a") + set(BUILD_DIR "${BUILD_ARCH}-${TARGET_OS}") + endif() + + #### Platform-specific configurations + #### TODO Support android + + #### Mode-specific configurations + #### TODO Support debug and assert + + #### Generic configurations + #### TODO Support parallel build + list(APPEND SCONS_OPTIONS "neon=1") + list(APPEND SCONS_OPTIONS "opencl=1") + list(APPEND SCONS_OPTIONS "examples=0") + list(APPEND SCONS_OPTIONS "Werror=0") + list(APPEND SCONS_OPTIONS "os=${TARGET_OS}") + + if(DEFINED BUILD_ARCH) + list(APPEND SCONS_OPTIONS "arch=${BUILD_ARCH}") + endif(DEFINED BUILD_ARCH) + + if(DEFINED BUILD_DIR) + list(APPEND SCONS_OPTIONS "build_dir=${BUILD_DIR}") + endif(DEFINED BUILD_DIR) + + message(STATUS "Build ARMCompute with ${SCONS_PATH} ('${SCONS_OPTIONS}'") + + # Build ARMCompute libraries with SCONS + # NOTE ARMCompute SConstruct unconditioanlly appends "arm-linux-gnueabihf-" prefix for linux + execute_process(COMMAND /usr/bin/env CC=gcc CXX=g++ "${SCONS_PATH}" ${SCONS_OPTIONS} + WORKING_DIRECTORY ${ARMComputeSource_DIR} + RESULT_VARIABLE ARMCompute_BUILD) + + # Install ARMCompute libraries + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "build/${BUILD_DIR}/libarm_compute_core.so" "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "build/${BUILD_DIR}/libarm_compute.so" "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "build/${BUILD_DIR}/libarm_compute_graph.so" "${ARMCompute_PREFIX}" + WORKING_DIRECTORY ${ARMComputeSource_DIR} + RESULT_VARIABLE ARMCompute_BUILD) +endfunction(_ARMCompute_Build) + + +set(ARMCompute_PREFIX ${CMAKE_INSTALL_PREFIX}/lib) + +# This is a workaround for CI issues +# TODO Remove this workaround +if(DEFINED ARMCompute_EXTDIR) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "${ARMCompute_EXTDIR}/libarm_compute_core.so" "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "${ARMCompute_EXTDIR}/libarm_compute.so" "${ARMCompute_PREFIX}" + COMMAND ${CMAKE_COMMAND} -E copy "${ARMCompute_EXTDIR}/libarm_compute_graph.so" "${ARMCompute_PREFIX}") +endif(DEFINED ARMCompute_EXTDIR) + +if(BUILD_ARMCOMPUTE) + _ARMCompute_Build("${ARMCompute_PREFIX}") +endif(BUILD_ARMCOMPUTE) _ARMCompute_Import()