aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Sujak <jakub.sujak@arm.com>2023-06-09 14:13:30 +0100
committerJakub Sujak <jakub.sujak@arm.com>2023-06-14 13:06:29 +0000
commitbec9b032ddcff449c7ad40febbcab24c23ee58a0 (patch)
tree4fbb8dc92d81c474a6ece4d2f5d596c1190ad725
parent3fcf3dcf7b6ffc613468ccaca580bde495677440 (diff)
downloadComputeLibrary-bec9b032ddcff449c7ad40febbcab24c23ee58a0.tar.gz
Add a Getting Started guide to CKW README
Resolves: COMPMID-6299 Change-Id: I3b9c464e8cdc6c081472ec0aa6b738c7ccb18b49 Signed-off-by: Jakub Sujak <jakub.sujak@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9759 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--SConstruct2
-rw-r--r--compute_kernel_writer/CMakeLists.txt8
-rw-r--r--compute_kernel_writer/README.md70
-rw-r--r--compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake27
4 files changed, 64 insertions, 43 deletions
diff --git a/SConstruct b/SConstruct
index e3bb68f857..03b0f918e2 100644
--- a/SConstruct
+++ b/SConstruct
@@ -432,7 +432,7 @@ if env['ckw']:
CKW_INCLUDE_DIR = CKW_PROJECT_DIR + "/include"
CKW_BUILD_DIR = build_path.replace("#", "")
- CKW_CMAKE_CMD = "CC={CKW_CC} CXX={CKW_CXX} cmake -G \"Unix Makefiles\" --clean-first " \
+ CKW_CMAKE_CMD = "CC={CKW_CC} CXX={CKW_CXX} cmake -G \"Unix Makefiles\" " \
"-S {CKW_PROJECT_DIR} -B {CKW_BUILD_DIR} " \
"-DCMAKE_BUILD_TYPE={CKW_BUILD_TYPE} " \
"-DCKW_ENABLE_OPENCL={CKW_ENABLE_OPENCL} " \
diff --git a/compute_kernel_writer/CMakeLists.txt b/compute_kernel_writer/CMakeLists.txt
index 705823f9f2..4338f7bbb4 100644
--- a/compute_kernel_writer/CMakeLists.txt
+++ b/compute_kernel_writer/CMakeLists.txt
@@ -45,6 +45,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wdisabled-optimization -W
-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)
@@ -56,10 +57,13 @@ option(CKW_CCACHE "Enable compiler cache builds" OFF)
get_property(CKW_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
-if(NOT CKW_IS_MULTI_CONFIG)
+# Allow only Release or Debug builds
+if(NOT CKW_IS_MULTI_CONFIG) # Single-config generators
if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE Debug CACHE STRING "Options: Release, Debug (default), RelWithDebInfo, MinSizeRel" FORCE)
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Options: Release (default) or Debug" FORCE)
endif()
+else() # Multi-config generators
+ list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES RelWithDebInfo MinSizeRel)
endif()
# Simplistic CCache setup
diff --git a/compute_kernel_writer/README.md b/compute_kernel_writer/README.md
index 951e6bea6b..8a24fe20ec 100644
--- a/compute_kernel_writer/README.md
+++ b/compute_kernel_writer/README.md
@@ -1,42 +1,86 @@
# Compute Kernel Writer
-Project description to follow.
+Compute Kernel Writer is a tile-based, just-in-time code writer for deep learning and computer vision applications.
+This tool offers a C++ interface to allow developers to write functions without a return type (called "kernels")
+using their preferred programming language (at the moment, only OpenCL is supported).
+The library is specifically designed to be lightweight and to offer an intuitive API for efficient code writing.
## Getting started
+The fastest way to get started with Compute Kernel Writer is to build and run the test suite.
+The following subsections show you how to do this.
+
+### Dependencies
+
+This project requires the following dependencies, obtainable via your preferred package manager, to be installed and available on your system.
+
+* `build-essential`
+* `cmake >= 3.14`
+* (Optional) `ninja-build`
+
+In addition, the guide makes use of the following toolchains:
+
+* (Optional) `Arm GNU toolchain` available to download from the [Arm Developer](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) website
+* (Optional) `Android NDK toolset` available to download from the [Android Developer](https://developer.android.com/ndk/downloads/index.html) website
### Building and running tests
-The fastest way to get started with Compute Kernel Writer is to build and run the test suite.
+#### Native compilation
-#### Compile natively on Linux x86_64
+You can quickly compile the library on your computer by using the following commands:
```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 ..
+mkdir -p build && cd build
+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 -S ..
cmake --build .
```
-#### Cross-compile to Linux aarch64
+The preceding commands build the library in release mode (`-DCMAKE_BUILD_TYPE=Release`) and targets OpenCL code generation (`-DCKW_ENABLE_OPENCL=ON`).
+In addition, code assertions are enabled (`-DCKW_ENABLE_ASSERTS=ON`) and the test suite is built (`-DCKW_BUILD_TESTING=ON`).
+Alternatively, choose to build a static instead of a shared library by setting `-DBUILD_SHARED_LIBS=OFF`.
+
+#### Cross-compile to Linux AArch64
+
+The Arm GNU toolchain can be used to cross-compile the project to a Linux system with an AArch64 processor, like a Raspberry Pi, using an x86_64 Linux host machine.
```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 ..
+mkdir -p build && cd build
+CXX=aarch64-none-linux-gnu-g++ cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCKW_ENABLE_OPENCL=ON -DCKW_ENABLE_ASSERTS=ON -DCKW_BUILD_TESTING=ON -S ..
cmake --build .
```
-#### Cross-compile to Android aarch64
+The build configuration is identical to the previous step but now requires specifying the target triple in the CXX compiler (`CXX=aarch64-none-linux-gnu-g++`) to generate binaries for the target platform.
+
+#### 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).
+Cross-compiling for Android systems requires the Android NDK toolset. The downloaded NDK contains the toolchain file necessary for cross-compiling the project.
```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=<NDK>/build/cmake/android.toolchain.cmake ..
+mkdir -p 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=<NDK>/build/cmake/android.toolchain.cmake -S ..
cmake --build .
```
-#### Run the validation suite
+This build re-uses the same build configuration as before, but this time does not require specifying the CXX compiler as this (and other target-specific information) is handled by the toolchain file (`-DCMAKE_TOOLCHAIN_FILE`).
+
+#### Run the validation test suite
+
+Confirm the project has been built successfully by running the validation test suite.
```shell
./ckw_validation
```
+
+### List of build options
+
+This project can be configured with the following build options. Enable options by passing them to the CMake command, preceded with `-D`.
+
+| Option | Description |
+|:---------------------|:------------------------------------------------------------------------------------------------------------------------------------------|
+| BUILD_SHARED_LIBS | Controls whether to build static or shared libraries. |
+| CMAKE_BUILD_TYPE | The project build type or configuration. Choose from Release or Debug. <br/>The release build will always build for smallest binary size. |
+| CKW_ENABLE_OPENCL | Enable OpenCL code generation. |
+| CKW_ENABLE_ASSERTS | Enable assertions. Always enabled for Debug builds. |
+| CKW_BUILD_TESTING | Build the validation test suite. |
+| CKW_CCACHE | Use compiler cache for faster recompilation. |
+| CMAKE_TOOLCHAIN_FILE | When cross-compiling, set this variable to the path of the CMake toolchain file. |
diff --git a/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake b/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake
deleted file mode 100644
index 78c33fc4d8..0000000000
--- a/compute_kernel_writer/cmake/toolchains/gcc_linux_aarch64.toolchain.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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++)