aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Sujak <jakub.sujak@arm.com>2023-06-21 09:45:41 +0100
committerJakub Sujak <jakub.sujak@arm.com>2023-06-29 12:17:11 +0000
commit7a698a38c625047bd558027d4cbc493f063739f5 (patch)
tree1622318aee018d0b843c0378fb464723a513cada
parentcdb1ee068110111619b9e85b8477b6064c3797ac (diff)
downloadComputeLibrary-7a698a38c625047bd558027d4cbc493f063739f5.tar.gz
Improvements to building CKW
* Always link Compute Kernel Writer statically to Compute Library * Move CMake logic to be set on libckw target * Build CKW in parallel from SCons Resolves: COMPMID-6297 Change-Id: I247a1f6ddf84a58032358a196574866b857d9bdc Signed-off-by: Jakub Sujak <jakub.sujak@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9834 Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--SConscript11
-rw-r--r--SConstruct17
-rw-r--r--compute_kernel_writer/CMakeLists.txt94
3 files changed, 71 insertions, 51 deletions
diff --git a/SConscript b/SConscript
index c9a56ede76..c7139552e3 100644
--- a/SConscript
+++ b/SConscript
@@ -31,8 +31,12 @@ import zlib
import json
import codecs
-print("DEPRECATION NOTICE: Legacy libarm_compute_core has been deprecated. Link your application only to "
- "libarm_compute for core library functionality")
+from SCons.Warnings import warn, DeprecatedWarning
+
+warn(DeprecatedWarning,
+ "DEPRECATION NOTICE: Legacy libarm_compute_core has been deprecated and is scheduled for removal in 24.02 release."
+ " Link your application only to libarm_compute for core library functionality"
+ )
VERSION = "v0.0-unreleased"
LIBRARY_VERSION_MAJOR = 31
@@ -123,6 +127,9 @@ def build_library(name, build_env, sources, static=False, libs=[]):
cloned_build_env["LINKFLAGS"].remove('-pie')
cloned_build_env["LINKFLAGS"].remove('-static-libstdc++')
+ if env['ckw']:
+ libs.append('libckw.a')
+
if static:
obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
else:
diff --git a/SConstruct b/SConstruct
index 419fa33558..48f17472d3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -423,7 +423,7 @@ print("CXX", env['CXX'])
"""Build the Compute Kernel Writer subproject"""
if env['ckw']:
- # Strip ccache from CC and CXX
+ # Strip ccache prefix from CC and CXX to obtain only the target triple
CKW_CC = env['CC'].replace(env['compiler_cache'] + " ", "")
CKW_CXX = env['CXX'].replace(env['compiler_cache'] + " ", "")
CKW_CCACHE = 1 if env['compiler_cache'] else 0
@@ -452,20 +452,17 @@ if env['ckw']:
CKW_CCACHE=CKW_CCACHE
)
- CKW_CMAKE_CONFIGURE_STATIC = CKW_CMAKE_CMD + "-DBUILD_SHARED_LIBS=OFF"
- CKW_CMAKE_CONFIGURE_SHARED = CKW_CMAKE_CMD + "-DBUILD_SHARED_LIBS=ON"
- CKW_CMAKE_BUILD = "cmake --build {CKW_BUILD_DIR}".format(CKW_BUILD_DIR=CKW_BUILD_DIR)
+ # Configure CKW static objects with -fPIC (CMAKE_POSITION_INDEPENDENT_CODE) option to enable linking statically to ACL
+ CKW_CMAKE_CONFIGURE_STATIC = CKW_CMAKE_CMD + "-DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
+ CKW_CMAKE_BUILD = "cmake --build {CKW_BUILD_DIR} -j{NUM_JOBS}".format(CKW_BUILD_DIR=CKW_BUILD_DIR,
+ NUM_JOBS=GetOption('num_jobs')
+ )
# Build Compute Kernel Writer Static Library
subprocess.check_call(CKW_CMAKE_CONFIGURE_STATIC, stderr=subprocess.STDOUT, shell=True)
subprocess.check_call(CKW_CMAKE_BUILD, stderr=subprocess.STDOUT, shell=True)
- # Build Compute Kernel Writer Shared Library
- subprocess.check_call(CKW_CMAKE_CONFIGURE_SHARED, stderr=subprocess.STDOUT, shell=True)
- subprocess.check_call(CKW_CMAKE_BUILD, stderr=subprocess.STDOUT, shell=True)
-
- # Linking library
- env.Append(LIBS = ['ckw'])
+ # Let ACL know where to find CKW headers
env.Append(CPPPATH = CKW_INCLUDE_DIR)
if not GetOption("help"):
diff --git a/compute_kernel_writer/CMakeLists.txt b/compute_kernel_writer/CMakeLists.txt
index 4bf8494484..2c770e4efb 100644
--- a/compute_kernel_writer/CMakeLists.txt
+++ b/compute_kernel_writer/CMakeLists.txt
@@ -28,11 +28,10 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(ComputeKernelWriter
VERSION 1.0.0
LANGUAGES CXX
- )
+)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_EXTENSIONS OFF)
include(GNUInstallDirs)
@@ -41,17 +40,11 @@ message(STATUS "${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_VERSION}")
#---------------------------------------------------------------------
# Options
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wdisabled-optimization -Wformat=2 \
- -Winit-self -Wstrict-overflow=2 -Wswitch-default -Woverloaded-virtual \
- -Wformat-security -Wctor-dtor-privacy -Wsign-promo -Weffc++ \
- -Wlogical-op -Wstrict-null-sentinel")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
-
option(CKW_ENABLE_OPENCL "Enable OpenCL code generation" OFF)
option(CKW_ENABLE_ASSERTS "Enable assertions. Always enabled in Debug builds" OFF)
option(CKW_BUILD_TESTING "Build the Compute Kernel Writer validation test suite" OFF)
option(CKW_BUILD_EXAMPLES "Build the Compute Kernel Writer examples" OFF)
-option(CKW_CCACHE "Enable compiler cache builds" OFF)
+option(CKW_CCACHE "Use compiler cache for faster recompilation" OFF)
#---------------------------------------------------------------------
# Build configuration
@@ -79,25 +72,49 @@ endif()
#---------------------------------------------------------------------
# Library targets
-set(CKW_ASSERTS_OPTS "-fstack-protector-strong")
+set(CKW_CXX_FLAGS
+ -Wall
+ -Werror
+ -Wextra
+ -Wdisabled-optimization
+ -Wformat=2
+ -Winit-self
+ -Wstrict-overflow=2
+ -Wswitch-default
+ -Woverloaded-virtual
+ -Wformat-security
+ -Wctor-dtor-privacy
+ -Wsign-promo
+ -Weffc++
+ -pedantic
+)
+set(GNU_WARNINGS
+ -Wlogical-op
+ -Wstrict-null-sentinel
+)
+set(CKW_ASSERTS_OPTS
+ -fstack-protector-strong
+)
-# Define common properties across all targets
-add_library(ckw_common INTERFACE)
+add_library(ckw)
+target_compile_options(ckw
+ PUBLIC
+ ${CKW_CXX_FLAGS}
+ "$<$<CXX_COMPILER_ID:GNU>:${GNU_WARNINGS}>"
+ "$<$<CONFIG:Debug>:${CKW_ASSERTS_OPTS}>"
+ "$<$<BOOL:${CKW_ASSERTS}>:${CKW_ASSERTS_OPTS}>"
+ # Set CMAKE_CXX_FLAGS last so user can overwrite options
+ ${CMAKE_CXX_FLAGS}
+ PRIVATE
+ $<$<CONFIG:Release>:-Os>
+)
-target_compile_definitions(ckw_common INTERFACE
+target_compile_definitions(ckw PUBLIC
$<$<CONFIG:Debug>:COMPUTE_KERNEL_WRITER_DEBUG_ENABLED>
$<$<CONFIG:Debug>:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED>
$<$<BOOL:${CKW_ASSERTS}>:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED>
$<$<BOOL:${CKW_ENABLE_OPENCL}>:COMPUTE_KERNEL_WRITER_OPENCL_ENABLED>
- )
-
-target_compile_options(ckw_common INTERFACE
- -pedantic
- "$<$<BOOL:${CKW_ASSERTS}>:${CKW_ASSERTS_OPTS}>"
- )
-
-# Compute Kernel Writer library
-add_library(ckw)
+)
target_sources(ckw PRIVATE
src/Error.cpp
@@ -124,10 +141,9 @@ if(CKW_ENABLE_OPENCL)
src/cl/CLHelpers.cpp
src/cl/CLTile.cpp
src/cl/ICLTile.cpp
- )
+ )
endif()
-target_link_libraries(ckw PUBLIC ckw_common)
target_include_directories(ckw
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include
PRIVATE ${CMAKE_CURRENT_LIST_DIR}
@@ -142,30 +158,30 @@ if(CKW_BUILD_TESTING)
validation/tests/TensorBitMaskTest.hpp
validation/tests/UtilsTest.hpp
validation/Validation.cpp
- )
+ )
if(CKW_ENABLE_OPENCL)
- target_sources(ckw_validation PRIVATE
- validation/tests/CLConstantTileTest.hpp
- validation/tests/CLTileTest.hpp)
+ target_sources(ckw_validation PRIVATE
+ validation/tests/CLConstantTileTest.hpp
+ validation/tests/CLTileTest.hpp)
endif()
target_link_libraries(ckw_validation PRIVATE ckw)
target_include_directories(ckw_validation
PRIVATE ${CMAKE_CURRENT_LIST_DIR}
- )
+ )
endif()
#---------------------------------------------------------------------
-# Example
+# Examples
-if(CKW_BUILD_EXAMPLES)
- add_executable(ckw_example_add_exp_store
- examples/add_exp_store.cpp
- )
+function(add_ckw_example name)
+ add_executable(${name} ${ARGN})
+ target_link_libraries(${name} PUBLIC ckw)
+endfunction(add_ckw_example)
- target_link_libraries(ckw_example_add_exp_store
- PUBLIC ckw
- )
+if(CKW_BUILD_EXAMPLES)
+ add_ckw_example(ckw_example_add_exp_store
+ examples/add_exp_store.cpp)
endif()
#---------------------------------------------------------------------
@@ -176,8 +192,8 @@ install(TARGETS ckw
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- )
+)
install(DIRECTORY include/ckw
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- )
+)