Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 4 | # Copyright (c) 2016-2021 Arm Limited. |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: MIT |
| 7 | # |
| 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | # of this software and associated documentation files (the "Software"), to |
| 10 | # deal in the Software without restriction, including without limitation the |
| 11 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 12 | # sell copies of the Software, and to permit persons to whom the Software is |
| 13 | # furnished to do so, subject to the following conditions: |
| 14 | # |
| 15 | # The above copyright notice and this permission notice shall be included in all |
| 16 | # copies or substantial portions of the Software. |
| 17 | # |
| 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | # SOFTWARE. |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 25 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 26 | import collections |
| 27 | import os.path |
| 28 | import re |
| 29 | import subprocess |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 30 | import zlib |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 31 | import json |
| 32 | import codecs |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 33 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 34 | VERSION = "v22.02" |
| 35 | LIBRARY_VERSION_MAJOR = 26 |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 36 | LIBRARY_VERSION_MINOR = 0 |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 37 | LIBRARY_VERSION_PATCH = 0 |
| 38 | SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 39 | |
| 40 | Import('env') |
| 41 | Import('vars') |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 42 | Import('install_lib') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 43 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 44 | def build_bootcode_objs(sources): |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 45 | arm_compute_env.Append(ASFLAGS = "-I bootcode/") |
| 46 | obj = arm_compute_env.Object(sources) |
| 47 | obj = install_lib(obj) |
| 48 | Default(obj) |
| 49 | return obj |
| 50 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 51 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 52 | |
| 53 | |
| 54 | # @brief Create a list of object from a given file list. |
| 55 | # |
| 56 | # @param arch_info A dictionary represents the architecture info such as the |
| 57 | # compiler flags and defines (filedefs.json). |
| 58 | # |
| 59 | # @param sources A list of files to build |
| 60 | # |
| 61 | # @return A list of objects for the corresponding architecture. |
| 62 | |
| 63 | def build_obj_list(arch_info, sources, static=False): |
| 64 | |
| 65 | # Clone environment |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 66 | tmp_env = arm_compute_env.Clone() |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 67 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 68 | # Append architecture spec |
| 69 | if 'cxxflags' in arch_info and len(arch_info['cxxflags']) > 0: |
| 70 | tmp_env.Append(CXXFLAGS = arch_info['cxxflags']) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 71 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 72 | # Build and return objects |
| 73 | if static: |
| 74 | objs = tmp_env.StaticObject(sources) |
| 75 | else: |
| 76 | objs = tmp_env.SharedObject(sources) |
| 77 | |
| 78 | tmp_env.Default(objs) |
| 79 | return objs |
| 80 | |
| 81 | # @brief Build multi-ISA files with the respective architecture. |
| 82 | # |
| 83 | # @return Two distinct lists: |
| 84 | # A list of static objects |
| 85 | # A list of shared objects |
| 86 | |
| 87 | def build_lib_objects(): |
| 88 | lib_static_objs = [] # static objects |
| 89 | lib_shared_objs = [] # shared objects |
| 90 | |
| 91 | arm_compute_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON', |
| 92 | 'ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE', |
| 93 | 'ARM_COMPUTE_ENABLE_FP16', 'ARM_COMPUTE_ENABLE_BF16', |
| 94 | 'ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_SVEF32MM']) |
| 95 | |
| 96 | # Build all the common files for the base architecture |
| 97 | lib_static_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=True) |
| 98 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=False) |
| 99 | |
| 100 | # Build the SVE specific files |
| 101 | lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=True) |
| 102 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=False) |
| 103 | |
| 104 | # Build the SVE2 specific files |
| 105 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2']) |
| 106 | lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=True) |
| 107 | lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=False) |
| 108 | |
| 109 | return lib_static_objs, lib_shared_objs |
| 110 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 111 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 112 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 113 | def build_library(name, build_env, sources, static=False, libs=[]): |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 114 | cloned_build_env = build_env.Clone() |
| 115 | if env['os'] == 'android' and static == False: |
| 116 | cloned_build_env["LINKFLAGS"].remove('-pie') |
| 117 | cloned_build_env["LINKFLAGS"].remove('-static-libstdc++') |
| 118 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 119 | if static: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 120 | obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 121 | else: |
| 122 | if env['set_soname']: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 123 | obj = cloned_build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 124 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 125 | obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 126 | |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 127 | obj = install_lib(obj) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 128 | build_env.Default(obj) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 129 | return obj |
| 130 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 131 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 132 | def remove_incode_comments(code): |
| 133 | def replace_with_empty(match): |
| 134 | s = match.group(0) |
| 135 | if s.startswith('/'): |
| 136 | return " " |
| 137 | else: |
| 138 | return s |
| 139 | |
| 140 | comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) |
| 141 | return re.sub(comment_regex, replace_with_empty, code) |
| 142 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 143 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 144 | def resolve_includes(target, source, env): |
| 145 | # File collection |
| 146 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
| 147 | |
| 148 | # Include pattern |
| 149 | pattern = re.compile("#include \"(.*)\"") |
| 150 | |
| 151 | # Get file contents |
| 152 | files = [] |
| 153 | for i in range(len(source)): |
| 154 | src = source[i] |
| 155 | dst = target[i] |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 156 | contents = src.get_contents().decode('utf-8') |
| 157 | contents = remove_incode_comments(contents).splitlines() |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 158 | entry = FileEntry(target_name=dst, file_contents=contents) |
| 159 | files.append((os.path.basename(src.get_path()),entry)) |
| 160 | |
| 161 | # Create dictionary of tupled list |
| 162 | files_dict = dict(files) |
| 163 | |
| 164 | # Check for includes (can only be files in the same folder) |
| 165 | final_files = [] |
| 166 | for file in files: |
| 167 | done = False |
| 168 | tmp_file = file[1].file_contents |
| 169 | while not done: |
| 170 | file_count = 0 |
| 171 | updated_file = [] |
| 172 | for line in tmp_file: |
| 173 | found = pattern.search(line) |
| 174 | if found: |
| 175 | include_file = found.group(1) |
| 176 | data = files_dict[include_file].file_contents |
| 177 | updated_file.extend(data) |
| 178 | else: |
| 179 | updated_file.append(line) |
| 180 | file_count += 1 |
| 181 | |
| 182 | # Check if all include are replaced. |
| 183 | if file_count == len(tmp_file): |
| 184 | done = True |
| 185 | |
| 186 | # Update temp file |
| 187 | tmp_file = updated_file |
| 188 | |
| 189 | # Append and prepend string literal identifiers and add expanded file to final list |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 190 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 191 | final_files.append((file[0], entry)) |
| 192 | |
| 193 | # Write output files |
| 194 | for file in final_files: |
| 195 | with open(file[1].target_name.get_path(), 'w+') as out_file: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 196 | file_to_write = "\n".join( file[1].file_contents ) |
| 197 | if env['compress_kernels']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 198 | file_to_write = zlib.compress(file_to_write.encode('utf-8'), 9) |
| 199 | file_to_write = codecs.encode(file_to_write, "base64").decode('utf-8').replace("\n", "") |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 200 | file_to_write = "R\"(" + file_to_write + ")\"" |
| 201 | out_file.write(file_to_write) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 202 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 203 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 204 | def create_version_file(target, source, env): |
| 205 | # Generate string with build options library version to embed in the library: |
| 206 | try: |
| 207 | git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) |
| 208 | except (OSError, subprocess.CalledProcessError): |
| 209 | git_hash="unknown" |
| 210 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 211 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip()) |
| 212 | with open(target[0].get_path(), "w") as fd: |
| 213 | fd.write(build_info) |
| 214 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 215 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 216 | def get_attrs_list(env, data_types, data_layouts): |
| 217 | attrs = [] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 218 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 219 | # Manage data-types |
| 220 | if 'all' in data_types: |
| 221 | attrs += ['fp16', 'fp32', 'integer', 'qasymm8', 'qasymm8_signed', 'qsymm16'] |
| 222 | else: |
| 223 | if 'fp16' in data_types: attrs += ['fp16'] |
| 224 | if 'fp32' in data_types: attrs += ['fp32'] |
| 225 | if 'integer' in data_types: attrs += ['integer'] |
| 226 | if 'qasymm8' in data_types: attrs += ['qasymm8'] |
| 227 | if 'qasymm8_signed' in data_types: attrs += ['qasymm8_signed'] |
| 228 | if 'qsymm16' in data_types: attrs += ['qsymm16'] |
| 229 | # Manage data-layouts |
| 230 | if 'all' in data_layouts: |
| 231 | attrs += ['nhwc', 'nchw'] |
| 232 | else: |
| 233 | if 'nhwc' in data_layouts: attrs += ['nhwc'] |
| 234 | if 'nchw' in data_layouts: attrs += ['nchw'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 235 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 236 | # Manage execution state |
| 237 | attrs += ['estate32' if (env['estate'] == 'auto' and 'v7a' in env['arch']) or '32' in env['estate'] else 'estate64'] |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 238 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 239 | return attrs |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 240 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 241 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 242 | def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[]): |
| 243 | files = { "common" : [] } |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 244 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 245 | # Early return if filelist is empty |
| 246 | if backend not in filelist: |
| 247 | return files |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 248 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 249 | # Iterate over operators and create the file lists to compiler |
| 250 | for operator in operators: |
| 251 | if operator in filelist[backend]['operators']: |
| 252 | files['common'] += filelist[backend]['operators'][operator]["files"]["common"] |
| 253 | for tech in techs: |
| 254 | if tech in filelist[backend]['operators'][operator]["files"]: |
| 255 | # Add tech as a key to dictionary if not there |
| 256 | if tech not in files: |
| 257 | files[tech] = [] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 258 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 259 | # Add tech files to the tech file list |
| 260 | tech_files = filelist[backend]['operators'][operator]["files"][tech] |
| 261 | files[tech] += tech_files.get('common', []) |
| 262 | for attr in attrs: |
| 263 | files[tech] += tech_files.get(attr, []) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 264 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 265 | # Remove duplicates if they exist |
| 266 | return {k: list(set(v)) for k,v in files.items()} |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 267 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 268 | def collect_operators(filelist, operators, backend=''): |
| 269 | ops = set() |
| 270 | for operator in operators: |
| 271 | if operator in filelist[backend]['operators']: |
| 272 | ops.add(operator) |
| 273 | if 'deps' in filelist[backend]['operators'][operator]: |
| 274 | ops.update(filelist[backend]['operators'][operator]['deps']) |
| 275 | else: |
| 276 | print("Operator {0} is unsupported on {1} backend!".format(operator, backend)) |
| 277 | |
| 278 | return ops |
| 279 | |
| 280 | |
| 281 | def resolve_operator_dependencies(filelist, operators, backend=''): |
| 282 | resolved_operators = collect_operators(filelist, operators, backend) |
| 283 | |
| 284 | are_ops_resolved = False |
| 285 | while not are_ops_resolved: |
| 286 | resolution_pass = collect_operators(filelist, resolved_operators, backend) |
| 287 | if len(resolution_pass) != len(resolved_operators): |
| 288 | resolved_operators.update(resolution_pass) |
| 289 | else: |
| 290 | are_ops_resolved = True |
| 291 | |
| 292 | return resolved_operators |
| 293 | |
| 294 | def read_build_config_json(build_config): |
| 295 | build_config_contents = {} |
| 296 | custom_operators = [] |
| 297 | custom_types = [] |
| 298 | custom_layouts = [] |
| 299 | if os.path.isfile(build_config): |
| 300 | with open(build_config) as f: |
| 301 | try: |
| 302 | build_config_contents = json.load(f) |
| 303 | except: |
| 304 | print("Warning: Build configuration file is of invalid JSON format!") |
| 305 | else: |
| 306 | try: |
| 307 | build_config_contents = json.loads(build_config) |
| 308 | except: |
| 309 | print("Warning: Build configuration string is of invalid JSON format!") |
| 310 | if build_config_contents: |
| 311 | custom_operators = build_config_contents.get("operators", []) |
| 312 | custom_types = build_config_contents.get("data_types", []) |
| 313 | custom_layouts = build_config_contents.get("data_layouts", []) |
| 314 | return custom_operators, custom_types, custom_layouts |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 315 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 316 | arm_compute_env = env.Clone() |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 317 | version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) |
| 318 | arm_compute_env.AlwaysBuild(version_file) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 319 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 320 | default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos', 'openbsd'] else 'clang++' |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 321 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 322 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 323 | # Generate embed files |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 324 | generate_embed = [ version_file ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 325 | if env['opencl'] and env['embed_kernels']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 326 | |
| 327 | # Header files |
| 328 | cl_helper_files = [ 'src/core/CL/cl_kernels/activation_float_helpers.h', |
| 329 | 'src/core/CL/cl_kernels/activation_quant_helpers.h', |
| 330 | 'src/core/CL/cl_kernels/gemm_helpers.h', |
| 331 | 'src/core/CL/cl_kernels/helpers_asymm.h', |
| 332 | 'src/core/CL/cl_kernels/helpers.h', |
| 333 | 'src/core/CL/cl_kernels/load_store_utility.h', |
| 334 | 'src/core/CL/cl_kernels/repeat.h', |
| 335 | 'src/core/CL/cl_kernels/tile_helpers.h', |
| 336 | 'src/core/CL/cl_kernels/types.h', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 337 | 'src/core/CL/cl_kernels/warp_helpers.h', |
| 338 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/fp_post_ops_act_eltwise_op_act.h', |
| 339 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h', |
| 340 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_elementwise_op_helpers.h', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 341 | ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 342 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 343 | # Common kernels |
| 344 | cl_files_common = ['src/core/CL/cl_kernels/common/activation_layer.cl', |
| 345 | 'src/core/CL/cl_kernels/common/activation_layer_quant.cl', |
| 346 | 'src/core/CL/cl_kernels/common/arg_min_max.cl', |
| 347 | 'src/core/CL/cl_kernels/common/batchnormalization_layer.cl', |
| 348 | 'src/core/CL/cl_kernels/common/bounding_box_transform.cl', |
| 349 | 'src/core/CL/cl_kernels/common/bounding_box_transform_quantized.cl', |
| 350 | 'src/core/CL/cl_kernels/common/bitwise_op.cl', |
| 351 | 'src/core/CL/cl_kernels/common/cast.cl', |
| 352 | 'src/core/CL/cl_kernels/common/comparisons.cl', |
| 353 | 'src/core/CL/cl_kernels/common/concatenate.cl', |
| 354 | 'src/core/CL/cl_kernels/common/col2im.cl', |
| 355 | 'src/core/CL/cl_kernels/common/convert_fc_weights.cl', |
| 356 | 'src/core/CL/cl_kernels/common/copy_tensor.cl', |
| 357 | 'src/core/CL/cl_kernels/common/crop_tensor.cl', |
| 358 | 'src/core/CL/cl_kernels/common/deconvolution_layer.cl', |
| 359 | 'src/core/CL/cl_kernels/common/dequantization_layer.cl', |
| 360 | 'src/core/CL/cl_kernels/common/elementwise_operation.cl', |
| 361 | 'src/core/CL/cl_kernels/common/elementwise_operation_quantized.cl', |
| 362 | 'src/core/CL/cl_kernels/common/elementwise_unary.cl', |
| 363 | 'src/core/CL/cl_kernels/common/fft_digit_reverse.cl', |
| 364 | 'src/core/CL/cl_kernels/common/fft.cl', |
| 365 | 'src/core/CL/cl_kernels/common/fft_scale.cl', |
| 366 | 'src/core/CL/cl_kernels/common/fill_border.cl', |
| 367 | 'src/core/CL/cl_kernels/common/floor.cl', |
| 368 | 'src/core/CL/cl_kernels/common/gather.cl', |
| 369 | 'src/core/CL/cl_kernels/common/gemm.cl', |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 370 | 'src/core/CL/cl_kernels/common/gemm_utils.cl', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 371 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_native.cl', |
| 372 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped.cl', |
| 373 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped_only_rhs.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 374 | 'src/core/CL/cl_kernels/common/gemv.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 375 | 'src/core/CL/cl_kernels/common/gemmlowp.cl', |
| 376 | 'src/core/CL/cl_kernels/common/generate_proposals.cl', |
| 377 | 'src/core/CL/cl_kernels/common/generate_proposals_quantized.cl', |
| 378 | 'src/core/CL/cl_kernels/common/instance_normalization.cl', |
| 379 | 'src/core/CL/cl_kernels/common/l2_normalize.cl', |
| 380 | 'src/core/CL/cl_kernels/common/mean_stddev_normalization.cl', |
| 381 | 'src/core/CL/cl_kernels/common/unpooling_layer.cl', |
| 382 | 'src/core/CL/cl_kernels/common/memset.cl', |
| 383 | 'src/core/CL/cl_kernels/common/nonmax.cl', |
| 384 | 'src/core/CL/cl_kernels/common/minmax_layer.cl', |
| 385 | 'src/core/CL/cl_kernels/common/pad_layer.cl', |
| 386 | 'src/core/CL/cl_kernels/common/permute.cl', |
| 387 | 'src/core/CL/cl_kernels/common/pixelwise_mul_float.cl', |
| 388 | 'src/core/CL/cl_kernels/common/pixelwise_mul_int.cl', |
| 389 | 'src/core/CL/cl_kernels/common/qlstm_layer_normalization.cl', |
| 390 | 'src/core/CL/cl_kernels/common/quantization_layer.cl', |
| 391 | 'src/core/CL/cl_kernels/common/range.cl', |
| 392 | 'src/core/CL/cl_kernels/common/reduction_operation.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 393 | 'src/core/CL/cl_kernels/common/reshape_layer.cl', |
| 394 | 'src/core/CL/cl_kernels/common/convolution_layer.cl', |
| 395 | 'src/core/CL/cl_kernels/common/reverse.cl', |
| 396 | 'src/core/CL/cl_kernels/common/roi_align_layer.cl', |
| 397 | 'src/core/CL/cl_kernels/common/roi_align_layer_quantized.cl', |
| 398 | 'src/core/CL/cl_kernels/common/roi_pooling_layer.cl', |
| 399 | 'src/core/CL/cl_kernels/common/select.cl', |
| 400 | 'src/core/CL/cl_kernels/common/softmax_layer.cl', |
| 401 | 'src/core/CL/cl_kernels/common/softmax_layer_quantized.cl', |
| 402 | 'src/core/CL/cl_kernels/common/stack_layer.cl', |
| 403 | 'src/core/CL/cl_kernels/common/slice_ops.cl', |
| 404 | 'src/core/CL/cl_kernels/common/tile.cl', |
| 405 | 'src/core/CL/cl_kernels/common/transpose.cl' |
| 406 | ] |
| 407 | |
| 408 | # NCHW kernels |
| 409 | cl_files_nchw = ['src/core/CL/cl_kernels/nchw/batch_to_space.cl', |
| 410 | 'src/core/CL/cl_kernels/nchw/batchnormalization_layer.cl', |
| 411 | 'src/core/CL/cl_kernels/nchw/channel_shuffle.cl', |
| 412 | 'src/core/CL/cl_kernels/nchw/depth_to_space.cl', |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 413 | 'src/core/CL/cl_kernels/nchw/direct_convolution.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 414 | 'src/core/CL/cl_kernels/nchw/dequantization_layer.cl', |
| 415 | 'src/core/CL/cl_kernels/nchw/im2col.cl', |
| 416 | 'src/core/CL/cl_kernels/nchw/normalization_layer.cl', |
| 417 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer.cl', |
| 418 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl', |
| 419 | 'src/core/CL/cl_kernels/nchw/pooling_layer.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 420 | 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 421 | 'src/core/CL/cl_kernels/nchw/reorg_layer.cl', |
| 422 | 'src/core/CL/cl_kernels/nchw/scale.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 423 | 'src/core/CL/cl_kernels/nchw/space_to_batch.cl', |
| 424 | 'src/core/CL/cl_kernels/nchw/space_to_depth.cl', |
| 425 | 'src/core/CL/cl_kernels/nchw/upsample_layer.cl', |
| 426 | 'src/core/CL/cl_kernels/nchw/winograd_filter_transform.cl', |
| 427 | 'src/core/CL/cl_kernels/nchw/winograd_input_transform.cl', |
| 428 | 'src/core/CL/cl_kernels/nchw/winograd_output_transform.cl' |
| 429 | ] |
| 430 | |
| 431 | # NHWC kernels |
| 432 | cl_files_nhwc = ['src/core/CL/cl_kernels/nhwc/batch_to_space.cl', |
| 433 | 'src/core/CL/cl_kernels/nhwc/batchnormalization_layer.cl', |
| 434 | 'src/core/CL/cl_kernels/nhwc/channel_shuffle.cl', |
| 435 | 'src/core/CL/cl_kernels/nhwc/direct_convolution.cl', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 436 | 'src/core/CL/cl_kernels/nhwc/direct_convolution3d.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 437 | 'src/core/CL/cl_kernels/nhwc/depth_to_space.cl', |
| 438 | 'src/core/CL/cl_kernels/nhwc/dequantization_layer.cl', |
| 439 | 'src/core/CL/cl_kernels/nhwc/dwc_native_fp_nhwc.cl', |
| 440 | 'src/core/CL/cl_kernels/nhwc/dwc_native_quantized_nhwc.cl', |
| 441 | 'src/core/CL/cl_kernels/nhwc/im2col.cl', |
| 442 | 'src/core/CL/cl_kernels/nhwc/normalization_layer.cl', |
| 443 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer.cl', |
| 444 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl', |
| 445 | 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl', |
| 446 | 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 447 | 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl', |
| 448 | 'src/core/CL/cl_kernels/nhwc/scale.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 449 | 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl', |
| 450 | 'src/core/CL/cl_kernels/nhwc/space_to_depth.cl', |
| 451 | 'src/core/CL/cl_kernels/nhwc/upsample_layer.cl', |
| 452 | 'src/core/CL/cl_kernels/nhwc/winograd_filter_transform.cl', |
| 453 | 'src/core/CL/cl_kernels/nhwc/winograd_input_transform.cl', |
| 454 | 'src/core/CL/cl_kernels/nhwc/winograd_output_transform.cl' |
| 455 | ] |
| 456 | |
| 457 | cl_files = cl_helper_files + cl_files_common + cl_files_nchw + cl_files_nhwc |
| 458 | |
| 459 | embed_files = [ f+"embed" for f in cl_files ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 460 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] ) |
| 461 | |
| 462 | generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes)) |
| 463 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 464 | Default(generate_embed) |
| 465 | if env["build"] == "embed_only": |
| 466 | Return() |
| 467 | |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 468 | # Append version defines for semantic versioning |
| 469 | arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), |
| 470 | ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR), |
| 471 | ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) |
| 472 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 473 | # Don't allow undefined references in the libraries: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 474 | undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined' |
| 475 | arm_compute_env.Append(LINKFLAGS=[undefined_flag]) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 476 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) |
| 477 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 478 | if env['os'] != 'openbsd': |
| 479 | arm_compute_env.Append(LIBS = ['dl']) |
| 480 | |
| 481 | # Load build definitions file |
| 482 | with (open(Dir('#').path + '/filedefs.json')) as fd: |
| 483 | filedefs = json.load(fd) |
| 484 | filedefs = filedefs['cpu']['arch'] |
| 485 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 486 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 487 | with (open(Dir('#').path + '/filelist.json')) as fp: |
| 488 | filelist = json.load(fp) |
| 489 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 490 | # Common backend files |
| 491 | lib_files = filelist['common'] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 492 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 493 | # Logging files |
| 494 | if env["logging"]: |
| 495 | lib_files += filelist['logging'] |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 496 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 497 | # C API files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 498 | lib_files += filelist['c_api']['common'] |
| 499 | lib_files += filelist['c_api']['operators'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 500 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 501 | # Scheduler infrastructure |
| 502 | lib_files += filelist['scheduler']['single'] |
| 503 | if env['cppthreads']: |
| 504 | lib_files += filelist['scheduler']['threads'] |
| 505 | if env['openmp']: |
| 506 | lib_files += filelist['scheduler']['omp'] |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 507 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 508 | # Graph files |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 509 | graph_files = Glob('src/graph/*.cpp') |
| 510 | graph_files += Glob('src/graph/*/*.cpp') |
| 511 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 512 | # Specify user-defined priority operators |
| 513 | custom_operators = [] |
| 514 | custom_types = [] |
| 515 | custom_layouts = [] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 516 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 517 | use_custom_ops = env['high_priority'] or env['build_config']; |
| 518 | |
| 519 | if env['high_priority']: |
| 520 | custom_operators = filelist['high_priority'] |
| 521 | custom_types = ['all'] |
| 522 | custom_layouts = ['all'] |
| 523 | |
| 524 | if env['build_config']: |
| 525 | custom_operators, custom_types, custom_layouts = read_build_config_json(env['build_config']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 526 | |
| 527 | if env['opencl']: |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 528 | lib_files += filelist['c_api']['gpu'] |
| 529 | lib_files += filelist['gpu']['common'] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 530 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 531 | cl_operators = custom_operators if use_custom_ops else filelist['gpu']['operators'].keys() |
| 532 | cl_ops_to_build = resolve_operator_dependencies(filelist, cl_operators, 'gpu') |
| 533 | lib_files += get_operator_backend_files(filelist, cl_ops_to_build, 'gpu')['common'] |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 534 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 535 | graph_files += Glob('src/graph/backends/CL/*.cpp') |
| 536 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 537 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 538 | lib_files_sve = [] |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 539 | lib_files_sve2 = [] |
| 540 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 541 | if env['neon']: |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 542 | # build winograd/depthwise sources for either v7a / v8a |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 543 | arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/", |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 544 | "src/core/NEON/kernels/convolution/winograd/", |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 545 | "src/core/NEON/kernels/convolution/depthwise/", |
| 546 | "src/core/NEON/kernels/assembly/", |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 547 | "arm_compute/core/NEON/kernels/assembly/", |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 548 | "src/cpu/kernels/assembly/"]) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 549 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 550 | lib_files += filelist['cpu']['common'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 551 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 552 | # Setup SIMD file list to include |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 553 | simd = ['neon'] |
| 554 | if env['multi_isa']: |
| 555 | simd += ['sve', 'sve2'] |
| 556 | else: |
| 557 | if 'sve' in env['arch']: simd += ['sve'] |
| 558 | if 'sve2' in env['arch']: simd += ['sve2'] |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 559 | |
| 560 | # Get attributes |
| 561 | if(use_custom_ops): |
| 562 | attrs = get_attrs_list(env, custom_types, custom_layouts) |
| 563 | else: |
| 564 | attrs = get_attrs_list(env, env['data_type_support'], env['data_layout_support']) |
| 565 | |
| 566 | # Setup data-type and data-layout files to include |
| 567 | cpu_operators = custom_operators if use_custom_ops else filelist['cpu']['operators'].keys() |
| 568 | cpu_ops_to_build = resolve_operator_dependencies(filelist, cpu_operators, 'cpu') |
| 569 | |
| 570 | cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 571 | |
| 572 | # Shared among ALL CPU files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 573 | lib_files += cpu_files.get('common', []) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 574 | |
| 575 | # Arm® Neon™ specific files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 576 | lib_files += cpu_files.get('neon', []) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 577 | |
| 578 | # SVE files only |
| 579 | lib_files_sve = cpu_files.get('sve', []) |
| 580 | |
| 581 | # SVE2 files only |
| 582 | lib_files_sve2 = cpu_files.get('sve2', []) |
Anthony Barbier | f45d5a9 | 2018-01-24 16:23:15 +0000 | [diff] [blame] | 583 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 584 | graph_files += Glob('src/graph/backends/NEON/*.cpp') |
| 585 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 586 | # Restrict from building graph API if a reduced operator list has been provided |
| 587 | if use_custom_ops: |
| 588 | print("WARNING: Graph library requires all operators to be built") |
| 589 | graph_files = [] |
| 590 | |
| 591 | # Build bootcode in case of bare-metal |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 592 | bootcode_o = [] |
| 593 | if env['os'] == 'bare_metal': |
| 594 | bootcode_files = Glob('bootcode/*.s') |
| 595 | bootcode_o = build_bootcode_objs(bootcode_files) |
| 596 | Export('bootcode_o') |
| 597 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 598 | |
| 599 | if (env['multi_isa']): |
| 600 | lib_static_objs, lib_shared_objs = build_lib_objects() |
| 601 | |
| 602 | |
| 603 | # STATIC library build. |
| 604 | if (env['multi_isa']): |
| 605 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_static_objs, static=True) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 606 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 607 | if 'sve2' in env['arch']: |
| 608 | lib_files += lib_files_sve |
| 609 | lib_files += lib_files_sve2 |
| 610 | elif 'sve' in env['arch']: |
| 611 | lib_files += lib_files_sve |
| 612 | |
| 613 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True) |
| 614 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 615 | Export('arm_compute_a') |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 616 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 617 | # SHARED library build. |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 618 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 619 | if (env['multi_isa']): |
| 620 | |
| 621 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_shared_objs, static=False) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 622 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 623 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 624 | |
| 625 | Export('arm_compute_so') |
| 626 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 627 | # Generate dummy core lib for backwards compatibility |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 628 | if env['os'] == 'macos': |
| 629 | # macos static library archiver fails if given an empty list of files |
| 630 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, lib_files, static=True) |
| 631 | else: |
| 632 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True) |
| 633 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 634 | Export('arm_compute_core_a') |
| 635 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 636 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 637 | arm_compute_core_a_so = build_library('arm_compute_core', arm_compute_env, [], static=False) |
| 638 | Export('arm_compute_core_a_so') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 639 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 640 | arm_compute_graph_env = arm_compute_env.Clone() |
| 641 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 642 | # Build graph libraries |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 643 | arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move']) |
| 644 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame^] | 645 | arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a ]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 646 | Export('arm_compute_graph_a') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 647 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 648 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 649 | arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" ]) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 650 | Depends(arm_compute_graph_so, arm_compute_so) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 651 | Export('arm_compute_graph_so') |
| 652 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 653 | if env['standalone']: |
| 654 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a]) |
| 655 | else: |
| 656 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so]) |
| 657 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 658 | Default(alias) |
| 659 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 660 | if env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 661 | Depends([alias], generate_embed) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 662 | else: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 663 | Depends([alias], generate_embed) |