From 7151c2a79a4e714defa1c1654629fb4722562548 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 22 Mar 2018 10:56:09 +0900 Subject: [PATCH] Support ACL build without scon (#132) * Support ACL build without scon This commit updates CMakeLists.txt to support ACL build without scon. Signed-off-by: Jonghyun Park --- CMakeLists.txt | 5 +++ externals/CMakeLists.txt | 4 +++ externals/acl.cmake | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 externals/acl.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ef0293..ee701ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,11 @@ foreach(FLAG ${FLAGS_CXXONLY}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}") endforeach() +# +# Configuration flags +# +option(BUILD_ACL "Build ARM Compute Library" OFF) + add_subdirectory(externals) add_subdirectory(tools) add_subdirectory(src) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index a7ef719..02d21ff 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -91,3 +91,7 @@ target_compile_definitions(tensorflow_lite PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FA target_link_libraries(tensorflow_lite eigen3 pthread dl) install(TARGETS tensorflow_lite ARCHIVE DESTINATION lib) + +if(BUILD_ACL) + include(acl.cmake) +endif(BUILD_ACL) diff --git a/externals/acl.cmake b/externals/acl.cmake new file mode 100644 index 0000000..84e146b --- /dev/null +++ b/externals/acl.cmake @@ -0,0 +1,92 @@ +### +### ARM Compute Library +### +set(ACL_BASE ${CMAKE_CURRENT_SOURCE_DIR}/acl) +set(ACL_GENERATED ${CMAKE_CURRENT_BINARY_DIR}/acl_generated) + +# Create 'arm_compute_version.embed' +add_custom_command(OUTPUT "arm_compute_version.embed" + COMMAND mkdir -p "${ACL_GENERATED}" + COMMAND echo '"unknown"' > "${ACL_GENERATED}/arm_compute_version.embed") + +file(GLOB_RECURSE ACL_UTIL_SRCS "${ACL_BASE}/src/core/utils/*.cpp") + +### ARM Compute Library - Foundation library (such as I/O and logging) +add_library(acl_foundation ${ACL_UTIL_SRCS}) +target_include_directories(acl_foundation PUBLIC "${ACL_BASE}") +target_include_directories(acl_foundation PUBLIC "${ACL_BASE}/include") + +### +### ARM Compute Library Common (Core & Runtime) +### +file(GLOB ACL_CORE_COMMON_SRCS "${ACL_BASE}/src/core/*.cpp") +list(APPEND ACL_CORE_COMMON_SRCS "arm_compute_version.embed") + +add_library(acl_core_common ${ACL_CORE_COMMON_SRCS}) +target_include_directories(acl_core_common PUBLIC "${ACL_GENERATED}") +target_link_libraries(acl_core_common acl_foundation) + +file(GLOB ACL_RUNTIME_COMMON_SRCS "${ACL_BASE}/src/runtime/*.cpp") +# src/runtime/Scheduler.cpp depends on this scheduler +list(APPEND ACL_RUNTIME_COMMON_SRCS "${ACL_BASE}/src/runtime/CPP/SingleThreadScheduler.cpp") + +add_library(acl_runtime_common ${ACL_RUNTIME_COMMON_SRCS}) +target_link_libraries(acl_runtime_common acl_core_common) + +### +### ARM Compute Library Open CL (Core & Runtime & Example) +### +file(GLOB ACL_CORE_OPENCL_SRCS "${ACL_BASE}/src/core/CL/*.cpp") +file(GLOB ACL_CORE_OPENCL_KERNEL_SRCS "${ACL_BASE}/src/core/CL/kernels/*.cpp") +list(APPEND ACL_CORE_OPENCL_SRCS ${ACL_CORE_OPENCL_KERNEL_SRCS}) + +add_library(acl_core_opencl ${ACL_CORE_OPENCL_SRCS}) +target_link_libraries(acl_core_opencl acl_core_common OpenCL dl) + +file(GLOB_RECURSE ACL_RUNTIME_OPENCL_SRCS "${ACL_BASE}/src/runtime/CL/*.cpp") + +add_library(acl_runtime_opencl ${ACL_RUNTIME_OPENCL_SRCS}) +target_link_libraries(acl_runtime_opencl acl_runtime_common acl_core_opencl) + +add_executable(cl_convolution "${ACL_BASE}/examples/cl_convolution.cpp" "${ACL_BASE}/utils/Utils.cpp") +target_compile_definitions(cl_convolution PRIVATE ARM_COMPUTE_CL) +target_link_libraries(cl_convolution acl_runtime_opencl) + +### +### ARM Compute Library NEON (Core & Runtime & Example) +### +file(GLOB ACL_CORE_NEON_SRCS "${ACL_BASE}/src/core/NEON/kernels/*.cpp") +list(APPEND ACL_CORE_NEON_SRCS "${ACL_BASE}/src/core/CPP/ICPPSimpleKernel.cpp") + +add_library(acl_core_neon ${ACL_CORE_NEON_SRCS}) +target_link_libraries(acl_core_neon acl_core_common) + +file(GLOB_RECURSE ACL_RUNTIME_NEON_SRCS "${ACL_BASE}/src/runtime/NEON/*.cpp") +add_library(acl_runtime_neon ${ACL_RUNTIME_NEON_SRCS}) +target_link_libraries(acl_runtime_neon acl_runtime_common acl_core_neon) + +add_executable(neon_convolution "${ACL_BASE}/examples/neon_convolution.cpp" "${ACL_BASE}/utils/Utils.cpp") +target_link_libraries(neon_convolution acl_runtime_neon) + +# TODO Support Open MP core(?) +# TODO Support Open GLES core(?) + +### +### ARM Compute Shared Libraries +### +list(APPEND ACL_CORE_SRCS ${ACL_UTIL_SRCS}) +list(APPEND ACL_CORE_SRCS ${ACL_CORE_COMMON_SRCS}) +list(APPEND ACL_CORE_SRCS ${ACL_CORE_OPENCL_SRCS}) +list(APPEND ACL_CORE_SRCS ${ACL_CORE_NEON_SRCS}) + +add_library(arm_compute_core SHARED ${ACL_CORE_SRCS}) +target_include_directories(arm_compute_core PUBLIC "${ACL_GENERATED}") +target_include_directories(arm_compute_core PUBLIC "${ACL_BASE}") +target_include_directories(arm_compute_core PUBLIC "${ACL_BASE}/include") + +list(APPEND ACL_RUNTIME_SRCS ${ACL_RUNTIME_COMMON_SRCS}) +list(APPEND ACL_RUNTIME_SRCS ${ACL_RUNTIME_OPENCL_SRCS}) +list(APPEND ACL_RUNTIME_SRCS ${ACL_RUNTIME_NEON_SRCS}) + +add_library(arm_compute SHARED ${ACL_RUNTIME_SRCS}) +target_link_libraries(arm_compute arm_compute_core) -- 2.7.4