From df5d9878008be9b60586df97ebfff197abb5195e Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Mon, 22 May 2023 17:38:56 +0100 Subject: Add CMakeLists to Compute Kernel Writer Resolves: COMPMID-6276 Change-Id: Id6d6d8c1a92cf2b11c1240e044d31f386fbda61e Signed-off-by: Jakub Sujak Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9700 Tested-by: Arm Jenkins Reviewed-by: Viet-Hoa Do Benchmark: Arm Jenkins --- .gitignore | 2 + compute_kernel_writer/CMakeLists.txt | 160 +++++++++++++ compute_kernel_writer/README.md | 42 ++++ compute_kernel_writer/SConscript | 81 ------- compute_kernel_writer/SConstruct | 254 --------------------- .../toolchains/gcc_linux_aarch64.toolchain.cmake | 27 +++ compute_kernel_writer/validation/SConscript | 100 -------- compute_kernel_writer/validation/Validation.cpp | 9 +- 8 files changed, 237 insertions(+), 438 deletions(-) create mode 100644 compute_kernel_writer/CMakeLists.txt create mode 100644 compute_kernel_writer/README.md delete mode 100644 compute_kernel_writer/SConscript delete mode 100644 compute_kernel_writer/SConstruct create mode 100644 compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake delete mode 100644 compute_kernel_writer/validation/SConscript diff --git a/.gitignore b/.gitignore index ac38812141..bea1f8e11b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Library builds build/ bazel-* +compute_kernel_writer/build/ +compute_kernel_writer/cmake-build* # Cscope/Ctags files *cscope* diff --git a/compute_kernel_writer/CMakeLists.txt b/compute_kernel_writer/CMakeLists.txt new file mode 100644 index 0000000000..e76daf4885 --- /dev/null +++ b/compute_kernel_writer/CMakeLists.txt @@ -0,0 +1,160 @@ +# Copyright (c) 2023 Arm Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) + +#--------------------------------------------------------------------- +# Compute Kernel Writer Project + +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) + +message(STATUS "${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_VERSION}") +message(STATUS "Options:") +message(STATUS " CKW_ENABLE_OPENCL: ${CKW_ENABLE_OPENCL}") +message(STATUS " CKW_ENABLE_ASSERTS: ${CKW_ASSERTS}") +message(STATUS " CKW_BUILD_TESTING: ${CKW_BUILD_TESTING}") +message(STATUS " CKW_CCACHE: ${CKW_CCACHE}") + +#--------------------------------------------------------------------- +# 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") + +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_CCACHE "Enable compiler cache builds" OFF) + +#--------------------------------------------------------------------- +# Build configuration + +get_property(CKW_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + +if(NOT CKW_IS_MULTI_CONFIG) + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Options: Release, Debug (default), RelWithDebInfo, MinSizeRel" FORCE) + endif() +endif() + +# Simplistic CCache setup +if(CKW_CCACHE) + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + set(CMAKE_C_COMPILER_LAUNCHER ${CACHE_FOUND}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_FOUND}) + endif() +endif() + +#--------------------------------------------------------------------- +# Library targets + +set(CKW_ASSERTS_OPTS "-fstack-protector-strong") + +# Define common properties across all targets +add_library(ckw_common INTERFACE) + +target_compile_definitions(ckw_common INTERFACE + $<$:COMPUTE_KERNEL_WRITER_DEBUG_ENABLED> + $<$:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED> + $<$:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED> + $<$:COMPUTE_KERNEL_WRITER_OPENCL_ENABLED> + ) + +target_compile_options(ckw_common INTERFACE + -pedantic + "$<$:${CKW_ASSERTS_OPTS}>" + ) + +# Compute Kernel Writer library +add_library(ckw) + +target_sources(ckw PRIVATE + src/Error.cpp + src/Helpers.cpp + src/TensorInfo.cpp + src/TensorUtils.cpp + src/TileInfo.cpp + ) +if(CKW_ENABLE_OPENCL) + target_sources(ckw PRIVATE + src/cl/CLHelpers.cpp + src/cl/CLTile.cpp + ) +endif() + +target_link_libraries(ckw PUBLIC ckw_common) +target_include_directories(ckw + PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include + PRIVATE ${CMAKE_CURRENT_LIST_DIR} + ) + +set_target_properties(ckw + PROPERTIES + SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR} + VERSION ${CMAKE_PROJECT_VERSION} + ) + +#--------------------------------------------------------------------- +# Validation tests + +if(CKW_BUILD_TESTING) + add_executable(ckw_validation + validation/tests/common/Common.h + validation/tests/TensorBitMaskTest.hpp + validation/tests/UtilsTest.hpp + validation/Validation.cpp + ) + if(CKW_ENABLE_OPENCL) + target_sources(ckw_validation PRIVATE validation/tests/CLTileTest.hpp) + endif() + + target_link_libraries(ckw_validation PRIVATE ckw) + target_include_directories(ckw_validation + PRIVATE ${CMAKE_CURRENT_LIST_DIR} + ) +endif() + +#--------------------------------------------------------------------- +# Installing + +install(TARGETS ckw + CONFIGURATIONS Release + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + +install(DIRECTORY include/ckw + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) diff --git a/compute_kernel_writer/README.md b/compute_kernel_writer/README.md new file mode 100644 index 0000000000..951e6bea6b --- /dev/null +++ b/compute_kernel_writer/README.md @@ -0,0 +1,42 @@ +# Compute Kernel Writer + +Project description to follow. + +## Getting started + + +### Building and running tests + +The fastest way to get started with Compute Kernel Writer is to build and run the test suite. + +#### Compile natively on Linux x86_64 + +```shell +mkdir build && cd build +CC=gcc CXX=g++ cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCKW_ENABLE_OPENCL=ON -DCKW_ENABLE_ASSERTS=ON -DCKW_BUILD_TESTING=ON .. +cmake --build . +``` + +#### Cross-compile to Linux aarch64 + +```shell +mkdir build && cd build +cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCKW_ENABLE_OPENCL=ON -DCKW_ENABLE_ASSERTS=ON -DCKW_BUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc_linux_aarch64.toolchain.cmake .. +cmake --build . +``` + +#### Cross-compile to Android aarch64 + +Cross-compiling to the Android platform requires the toolchain CMake file downloaded in the [Android NDK](https://developer.android.com/ndk). + +```shell +mkdir build && cd build +cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCKW_ENABLE_OPENCL=ON -DCKW_ENABLE_ASSERTS=ON -DCKW_BUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=/build/cmake/android.toolchain.cmake .. +cmake --build . +``` + +#### Run the validation suite + +```shell +./ckw_validation +``` diff --git a/compute_kernel_writer/SConscript b/compute_kernel_writer/SConscript deleted file mode 100644 index 8fc2b11dec..0000000000 --- a/compute_kernel_writer/SConscript +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2023 Arm Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -import os.path - -LIB_PREFIX = "ckw" # Compute Kernel Writer (CKW) -VERSION = "v0.0-unreleased" -LIBRARY_VERSION_MAJOR = 1 -LIBRARY_VERSION_MINOR = 0 -LIBRARY_VERSION_PATCH = 0 -SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH) - -Import('env') -Import('vars') -Import('install_lib') - -def build_library(name, build_env, sources, static=False, libs=[]): - cloned_build_env = build_env.Clone() - if env['os'] == 'android' and static == False: - cloned_build_env["LINKFLAGS"].remove('-pie') - cloned_build_env["LINKFLAGS"].remove('-static-libstdc++') - - if static: - obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = ckw_env["LIBS"] + libs) - else: - obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = ckw_env["LIBS"] + libs) - - obj = install_lib(obj) - build_env.Default(obj) - return obj - -ckw_env = env.Clone() - -default_cpp_compiler = 'g++' if env['os'] not in ['android'] else 'clang++' -cpp_compiler = os.environ.get('CXX', default_cpp_compiler) - -ckw_env.Append(CPPPATH =[Dir("./src/").path] ) - -# Append version defines for semantic versioning -ckw_env.Append(CPPDEFINES = [('COMPUTE_KERNEL_WRITER_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), - ('COMPUTE_KERNEL_WRITER_VERSION_MINOR', LIBRARY_VERSION_MINOR), - ('COMPUTE_KERNEL_WRITER_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) - -# Don't allow undefined references in the libraries: -undefined_flag = '-Wl,--no-undefined' -ckw_env.Append(LINKFLAGS=[undefined_flag]) - -# Kernel writer files -kernel_writer_files = Glob('./src/*.cpp') - -# OpenCL specific files -kernel_writer_files += Glob('./src/cl/*.cpp') - -ckw_a = build_library(LIB_PREFIX + '-static', ckw_env, kernel_writer_files, static=True) -Export('ckw_a') - -# SHARED library build. -ckw_so = build_library(LIB_PREFIX, ckw_env, kernel_writer_files, static=False) -Export('ckw_so') \ No newline at end of file diff --git a/compute_kernel_writer/SConstruct b/compute_kernel_writer/SConstruct deleted file mode 100644 index a67522fedd..0000000000 --- a/compute_kernel_writer/SConstruct +++ /dev/null @@ -1,254 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2023 Arm Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -import SCons -import os -from subprocess import check_output - -def version_at_least(version, required): - - version_list = version.split('.') - required_list = required.split('.') - end = min(len(version_list), len(required_list)) - for i in range(0, end): - if int(version_list[i]) < int(required_list[i]): - return False - elif int(version_list[i]) > int(required_list[i]): - return True - - return True - -vars = Variables("scons") -vars.AddVariables( - BoolVariable("debug", "Debug", False), - BoolVariable("asserts", "Enable asserts (this flag is forced to 1 for debug=1)", False), - EnumVariable("arch", "Target Architecture.", "armv8.2-a", - allowed_values=("x86_64", "armv8.2-a")), - EnumVariable("os", "Target OS.", "linux", allowed_values=("linux", "android")), - EnumVariable("build", "Either build directly on your device (native) or cross compile from your desktop machine (cross-compile). In both cases make sure the compiler is available in your path.", "cross_compile", allowed_values=("native", "cross_compile", "embed_only")), - BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True), - PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept), - PathVariable("install_dir", "Specify sub-folder for the install", "", PathVariable.PathAccept), - BoolVariable("exceptions", "Enable/disable C++ exception support", True), - PathVariable("linker_script", "Use an external linker script", "", PathVariable.PathAccept), - ("toolchain_prefix", "Override the toolchain prefix; used by all toolchain components: compilers, linker, assembler etc. If unspecified, use default(auto) prefixes; if passed an empty string '' prefixes would be disabled", "auto"), - ("compiler_prefix", "Override the compiler prefix; used by just compilers (CC,CXX); further overrides toolchain_prefix for compilers; this is for when the compiler prefixes are different from that of the linkers, archivers etc. If unspecified, this is the same as toolchain_prefix; if passed an empty string '' prefixes would be disabled", "auto"), - ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""), - ("extra_link_flags", "Extra LD flags to be appended to the build command", ""), - ("compiler_cache", "Command to prefix to the C and C++ compiler (e.g ccache)", ""), - ("specs_file", "Specs file to use (e.g. rdimon.specs)", "") -) - -if version_at_least(SCons.__version__, "4.0"): - vars.Add(BoolVariable("export_compile_commands", "Export compile_commands.json file.", False)) - -env = Environment(variables=vars, ENV = os.environ) - -build_path = env['build_dir'] -# If build_dir is a relative path then add a #build/ prefix: -if not env['build_dir'].startswith('/'): - SConsignFile('build/%s/.scons' % build_path) - build_path = "#build/%s" % build_path -else: - SConsignFile('%s/.scons' % build_path) - -install_path = env['install_dir'] -#If the install_dir is a relative path then assume it's from inside build_dir -if not env['install_dir'].startswith('/') and install_path != "": - install_path = "%s/%s" % (build_path, install_path) - -env.Append(LIBPATH = [build_path]) -Export('env') -Export('vars') - -def install_lib( lib ): - # If there is no install folder, then there is nothing to do: - if install_path == "": - return lib - return env.Install( "%s/lib/" % install_path, lib) -def install_bin( bin ): - # If there is no install folder, then there is nothing to do: - if install_path == "": - return bin - return env.Install( "%s/bin/" % install_path, bin) -def install_include( inc ): - if install_path == "": - return inc - return env.Install( "%s/include/" % install_path, inc) - -Export('install_lib') -Export('install_bin') - -Help(vars.GenerateHelpText(env)) - -env.Append(CXXFLAGS = [ - '-Wextra','-Wdisabled-optimization','-Wformat=2', - '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', - '-Woverloaded-virtual', '-Wformat-security', - '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-overlength-strings']) - -env.Append(CXXFLAGS = ['-Wall','-std=c++14', '-pedantic' ]) - -env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP']) - -cpp_tool = {'linux': 'g++', 'android' : 'clang++'} - -c_tool = {'linux':'gcc', 'android': 'clang'} - -default_cpp_compiler = cpp_tool[env['os']] -default_c_compiler = c_tool[env['os']] -cpp_compiler = os.environ.get('CXX', default_cpp_compiler) -c_compiler = os.environ.get('CC', default_c_compiler) - -if env['os'] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ): - print( "WARNING: Only clang is officially supported to build the Compute Kernel Writer (CKW) for Android") - -if 'clang++' in cpp_compiler: - env.Append(CXXFLAGS = ['-Wno-vla-extension']) -elif 'armclang' in cpp_compiler: - pass -else: - env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel','-Wno-misleading-indentation']) - -if cpp_compiler == 'g++': - # Don't strip comments that could include markers - env.Append(CXXFLAGS = ['-C']) - -if 'armv8-a' in env['arch']: - env.Append(CXXFLAGS = ['-march=armv8-a']) - -if 'x86_64' in env['arch']: - env.Append(CXXFLAGS = ['-fPIC']) - env.Append(CCFLAGS = ['-m64']) - env.Append(LINKFLAGS = ['-m64']) - -# Define toolchain -# The reason why we distinguish toolchain_prefix from compiler_prefix is for cases where the linkers/archivers use a -# different prefix than the compilers. An example is the NDK r20 toolchain -auto_toolchain_prefix = "" -if 'x86' not in env['arch']: - if env['os'] == 'linux': - auto_toolchain_prefix = "aarch64-linux-gnu-" - elif env['os'] == 'android': - auto_toolchain_prefix = "aarch64-tizen-linux-gnu-" - -if env['build'] == 'native' or env["toolchain_prefix"] == "": - toolchain_prefix = "" -elif env["toolchain_prefix"] == "auto": - toolchain_prefix = auto_toolchain_prefix -else: - toolchain_prefix = env["toolchain_prefix"] - -if env['build'] == 'native' or env["compiler_prefix"] == "": - compiler_prefix = "" -elif env["compiler_prefix"] == "auto": - compiler_prefix = toolchain_prefix -else: - compiler_prefix = env["compiler_prefix"] - -env['CC'] = env['compiler_cache']+ " " + compiler_prefix + c_compiler -env['CXX'] = env['compiler_cache']+ " " + compiler_prefix + cpp_compiler -env['LD'] = toolchain_prefix + "ld" -env['AS'] = toolchain_prefix + "as" -env['AR'] = toolchain_prefix + "ar" -env['RANLIB'] = toolchain_prefix + "ranlib" - -print("Using compilers:") -print("CC", env['CC']) -print("CXX", env['CXX']) - -if not GetOption("help"): - try: - compiler_ver = check_output(env['CXX'].split() + ["-dumpversion"]).decode().strip() - except OSError: - print("ERROR: Compiler '%s' not found" % env['CXX']) - Exit(1) - - if 'armclang' in cpp_compiler: - pass - elif 'clang++' not in cpp_compiler: - if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'): - print("GCC 6.2.1 or newer is required to compile armv8.2-a code") - Exit(1) - - if version_at_least(compiler_ver, '6.1'): - env.Append(CXXFLAGS = ['-Wno-ignored-attributes']) - - if compiler_ver == '4.8.3': - env.Append(CXXFLAGS = ['-Wno-array-bounds']) - - # Add Android NDK toolchain specific flags - if 'clang++' in cpp_compiler and env['os'] == 'android': - # For NDK >= r21, clang 9 or above is used - if version_at_least(compiler_ver, '9.0.0'): - env['ndk_above_r21'] = True - - # For NDK >= r23, clang 12 or above is used. This condition detects NDK < r23 - if not version_at_least(compiler_ver, '12.0.0'): - # System assembler is deprecated and integrated assembler is preferred since r23. - # However integrated assembler has always been suppressed for NDK < r23. - # Thus for backward compatibility, we include this flag only for NDK < r23 - env.Append(CXXFLAGS = ['-no-integrated-as']) - -if env['Werror']: - env.Append(CXXFLAGS = ['-Werror']) - -if env['os'] == 'android': - env.Append(CPPDEFINES = ['ANDROID']) - env.Append(LINKFLAGS = ['-pie', '-static-libstdc++', '-ldl']) - -if env['specs_file'] != "": - env.Append(LINKFLAGS = ['-specs='+env['specs_file']]) - -if env['debug']: - env['asserts'] = True - env.Append(CXXFLAGS = ['-O0','-g','-gdwarf-2']) - env.Append(CPPDEFINES = ['COMPUTE_KERNEL_WRITER_DEBUG_ENABLED']) -else: - # Optimize for size - env.Append(CXXFLAGS = ['-Os']) - -if env['asserts']: - env.Append(CPPDEFINES = ['COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED']) - env.Append(CXXFLAGS = ['-fstack-protector-strong']) - -env.Append(CPPPATH = ['#/include', "#"]) -env.Append(CXXFLAGS = env['extra_cxx_flags']) -env.Append(LINKFLAGS = env['extra_link_flags']) -env.Append(LIBS = []) - -Export('version_at_least') - -SConscript('./SConscript', variant_dir=build_path, duplicate=0) - -# Tests -SConscript('./validation/SConscript', variant_dir='%s/validation' % build_path, duplicate=0) - -# Unknown variables are not allowed -# Note: we must delay the call of UnknownVariables until after -# we have applied the Variables object to the construction environment -unknown = vars.UnknownVariables() -if unknown: - print("Unknown variables: %s" % " ".join(unknown.keys())) - Exit(1) diff --git a/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake b/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake new file mode 100644 index 0000000000..78c33fc4d8 --- /dev/null +++ b/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake @@ -0,0 +1,27 @@ +# Copyright (c) 2023 Arm Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) diff --git a/compute_kernel_writer/validation/SConscript b/compute_kernel_writer/validation/SConscript deleted file mode 100644 index 452cc0a9ea..0000000000 --- a/compute_kernel_writer/validation/SConscript +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2023 Arm Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -import os.path - -Import('env') -Import('vars') -Import('install_bin') - -# vars is imported from compute_kernel_writer: -variables = [ - BoolVariable("validation_tests", "Build validation test programs", False) -] - -# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) -new_options = Variables('scons') - -for v in variables: - new_options.Add(v) - vars.Add(v) - -# Clone the environment to make sure we're not polluting the compute_kernel_writer one: -test_env = env.Clone() -vars.Update(test_env) - -Help(new_options.GenerateHelpText(test_env)) - -# Check if we need to build the test framework -build_test_framework = False -for opt in new_options.keys(): - option_value = test_env[opt] - if type(option_value) is bool and option_value: - build_test_framework = True - break - -if not build_test_framework: - Return() - -# Remove -Wnoexcept from tests -if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']: - test_env['CXXFLAGS'].remove("-Wnoexcept") - -load_whole_archive = '-Wl,--whole-archive' -noload_whole_archive = '-Wl,--no-whole-archive' - -if env['os'] in ['android']: - Import("ckw_a") - - test_env.Append(LIBS = [ckw_a]) - ckw_lib = ckw_a -else: - Import("ckw_so") - test_env.Append(LIBS = ["ckw"]) - ckw_lib = ckw_so - -# Add main file -files_validation = Glob('Validation.cpp') - -# Add unit tests -files_validation += Glob('tests/*.cpp') - -extra_link_flags = [] - -test_env.Append(LIBS = ["rt"]) -extra_link_flags += ['-fstack-protector-strong'] - -bm_link_flags = [] -if test_env['linker_script']: - bm_link_flags += ['-Wl,--build-id=none', '-T', env['linker_script']] - -if test_env['validation_tests']: - program_objects = files_validation - - ckw_validation = test_env.Program('ckw_validation', program_objects, LIBS=test_env['LIBS'], LINKFLAGS=test_env['LINKFLAGS'] + bm_link_flags) - ckw_validation = install_bin(ckw_validation) - Depends(ckw_validation, ckw_lib) - - Default(ckw_validation) - Export('ckw_validation') diff --git a/compute_kernel_writer/validation/Validation.cpp b/compute_kernel_writer/validation/Validation.cpp index cc9dbfa7d0..9bdf0dfdd2 100644 --- a/compute_kernel_writer/validation/Validation.cpp +++ b/compute_kernel_writer/validation/Validation.cpp @@ -41,19 +41,22 @@ int32_t main() const auto test0 = std::make_unique(); const auto test1 = std::make_unique(); const auto test2 = std::make_unique(); + tests.push_back(test0.get()); + tests.push_back(test1.get()); + tests.push_back(test2.get()); + +#ifdef COMPUTE_KERNEL_WRITER_OPENCL_ENABLED const auto test3 = std::make_unique(); const auto test4 = std::make_unique(); const auto test5 = std::make_unique(); const auto test6 = std::make_unique(); const auto test7 = std::make_unique(); - tests.push_back(test0.get()); - tests.push_back(test1.get()); - tests.push_back(test2.get()); tests.push_back(test3.get()); tests.push_back(test4.get()); tests.push_back(test5.get()); tests.push_back(test6.get()); tests.push_back(test7.get()); +#endif /* COMPUTE_KERNEL_WRITER_OPENCL_ENABLED */ bool all_test_passed = true; -- cgit v1.2.1