From ea857273d8b4a94fb7f1e63ce9068a60259fb9d3 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 22 Jan 2021 05:47:37 +0000 Subject: Compress OpenCL kernel files using zlib for Android Kernel files are embedded into the binary as the default option when building which leads to binary size bloating. Add `compress_kernels` option and utilize zlib for further compressing the text kernel files and reduce the overall binary size. We use a base64 encoding/decoding to ensure that the strings can be easily embedded. This adds to the binary size but still the overall reduction is significant. Maximum compression level 9 is used. Option is currently restricted to Android builds as android toolchain provides a zlib library. Initial experimentations indicate a binary size reduction of 50% Resolves: COMPMID-4017 Signed-off-by: Georgios Pinitas Change-Id: Iee81b8c00391b26a5f41642699692928a4d6bd6e Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4958 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice --- arm_compute/core/CL/CLKernelLibrary.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'arm_compute/core/CL') diff --git a/arm_compute/core/CL/CLKernelLibrary.h b/arm_compute/core/CL/CLKernelLibrary.h index caab78dc18..193389388e 100644 --- a/arm_compute/core/CL/CLKernelLibrary.h +++ b/arm_compute/core/CL/CLKernelLibrary.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -164,10 +164,11 @@ public: CLCompileContext &get_compile_context(); private: - CLCompileContext _compile_context; /**< Compile Context. */ - std::string _kernel_path; /**< Path to the kernels folder. */ - static const std::map _kernel_program_map; /**< Map that associates kernel names with programs. */ - static const std::map _program_source_map; /**< Contains sources for all programs. + CLCompileContext _compile_context; /**< Compile Context. */ + std::string _kernel_path; /**< Path to the kernels folder. */ + mutable std::map _decompressed_source_map; /**< Map holding the decompressed files when compression is used */ + static const std::map _kernel_program_map; /**< Map that associates kernel names with programs. */ + static const std::map _program_source_map; /**< Contains sources for all programs. Used for compile-time kernel inclusion. >*/ }; } // namespace arm_compute -- cgit v1.2.1