Support ACL build without scon (#132)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 22 Mar 2018 01:56:09 +0000 (10:56 +0900)
committer서상민/동작제어Lab(SR)/Senior Engineer/삼성전자 <sangmin7.seo@samsung.com>
Thu, 22 Mar 2018 01:56:09 +0000 (10:56 +0900)
* Support ACL build without scon

This commit updates CMakeLists.txt to support ACL build without scon.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
CMakeLists.txt
externals/CMakeLists.txt
externals/acl.cmake [new file with mode: 0644]

index 3ef0293..ee701ce 100644 (file)
@@ -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)
index a7ef719..02d21ff 100644 (file)
@@ -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 (file)
index 0000000..84e146b
--- /dev/null
@@ -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)