Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 1 | # Copyright (c) 2016, 2017 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 2 | # |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | # of this software and associated documentation files (the "Software"), to |
| 7 | # deal in the Software without restriction, including without limitation the |
| 8 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 9 | # sell copies of the Software, and to permit persons to whom the Software is |
| 10 | # furnished to do so, subject to the following conditions: |
| 11 | # |
| 12 | # The above copyright notice and this permission notice shall be included in all |
| 13 | # copies or substantial portions of the Software. |
| 14 | # |
| 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | # SOFTWARE. |
| 22 | import collections |
| 23 | import os.path |
| 24 | import re |
| 25 | import subprocess |
Georgios Pinitas | ea85727 | 2021-01-22 05:47:37 +0000 | [diff] [blame] | 26 | import zlib |
| 27 | import base64 |
| 28 | import string |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | |
| 30 | VERSION = "v0.0-unreleased" |
Giorgio Arena | 328b511 | 2021-02-17 15:13:10 +0000 | [diff] [blame] | 31 | LIBRARY_VERSION_MAJOR = 22 |
Sang-Hoon Park | 6d0b384 | 2020-08-14 14:48:08 +0100 | [diff] [blame] | 32 | LIBRARY_VERSION_MINOR = 0 |
Georgios Pinitas | 35fcc43 | 2020-03-26 18:47:46 +0000 | [diff] [blame] | 33 | LIBRARY_VERSION_PATCH = 0 |
| 34 | SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | |
| 36 | Import('env') |
| 37 | Import('vars') |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 38 | Import('install_lib') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 40 | def build_bootcode_objs(sources): |
| 41 | |
| 42 | arm_compute_env.Append(ASFLAGS = "-I bootcode/") |
| 43 | obj = arm_compute_env.Object(sources) |
| 44 | obj = install_lib(obj) |
| 45 | Default(obj) |
| 46 | return obj |
| 47 | |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 48 | def build_library(name, build_env, sources, static=False, libs=[]): |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | if static: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 50 | obj = build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 51 | else: |
| 52 | if env['set_soname']: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 53 | obj = build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 54 | else: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 55 | obj = build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 56 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 57 | obj = install_lib(obj) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 58 | Default(obj) |
| 59 | return obj |
| 60 | |
Georgios Pinitas | f605bd2 | 2020-11-26 11:55:09 +0000 | [diff] [blame] | 61 | def remove_incode_comments(code): |
| 62 | def replace_with_empty(match): |
| 63 | s = match.group(0) |
| 64 | if s.startswith('/'): |
| 65 | return " " |
| 66 | else: |
| 67 | return s |
| 68 | |
| 69 | comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) |
| 70 | return re.sub(comment_regex, replace_with_empty, code) |
| 71 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 72 | def resolve_includes(target, source, env): |
| 73 | # File collection |
| 74 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
| 75 | |
| 76 | # Include pattern |
| 77 | pattern = re.compile("#include \"(.*)\"") |
| 78 | |
| 79 | # Get file contents |
| 80 | files = [] |
| 81 | for i in range(len(source)): |
| 82 | src = source[i] |
| 83 | dst = target[i] |
Georgios Pinitas | f605bd2 | 2020-11-26 11:55:09 +0000 | [diff] [blame] | 84 | contents = src.get_contents().decode('utf-8') |
| 85 | contents = remove_incode_comments(contents).splitlines() |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 86 | entry = FileEntry(target_name=dst, file_contents=contents) |
| 87 | files.append((os.path.basename(src.get_path()),entry)) |
| 88 | |
| 89 | # Create dictionary of tupled list |
| 90 | files_dict = dict(files) |
| 91 | |
| 92 | # Check for includes (can only be files in the same folder) |
| 93 | final_files = [] |
| 94 | for file in files: |
| 95 | done = False |
| 96 | tmp_file = file[1].file_contents |
| 97 | while not done: |
| 98 | file_count = 0 |
| 99 | updated_file = [] |
| 100 | for line in tmp_file: |
| 101 | found = pattern.search(line) |
| 102 | if found: |
| 103 | include_file = found.group(1) |
| 104 | data = files_dict[include_file].file_contents |
| 105 | updated_file.extend(data) |
| 106 | else: |
| 107 | updated_file.append(line) |
| 108 | file_count += 1 |
| 109 | |
| 110 | # Check if all include are replaced. |
| 111 | if file_count == len(tmp_file): |
| 112 | done = True |
| 113 | |
| 114 | # Update temp file |
| 115 | tmp_file = updated_file |
| 116 | |
| 117 | # Append and prepend string literal identifiers and add expanded file to final list |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 118 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 119 | final_files.append((file[0], entry)) |
| 120 | |
| 121 | # Write output files |
| 122 | for file in final_files: |
| 123 | with open(file[1].target_name.get_path(), 'w+') as out_file: |
Georgios Pinitas | ea85727 | 2021-01-22 05:47:37 +0000 | [diff] [blame] | 124 | file_to_write = "\n".join( file[1].file_contents ) |
| 125 | if env['compress_kernels']: |
| 126 | file_to_write = zlib.compress(file_to_write, 9).encode("base64").replace("\n", "") |
| 127 | file_to_write = "R\"(" + file_to_write + ")\"" |
| 128 | out_file.write(file_to_write) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 129 | |
| 130 | def create_version_file(target, source, env): |
| 131 | # Generate string with build options library version to embed in the library: |
| 132 | try: |
| 133 | git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) |
| 134 | except (OSError, subprocess.CalledProcessError): |
| 135 | git_hash="unknown" |
| 136 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 137 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip()) |
| 138 | with open(target[0].get_path(), "w") as fd: |
| 139 | fd.write(build_info) |
| 140 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 141 | arm_compute_env = env.Clone() |
Anthony Barbier | 0e72c69 | 2018-08-24 11:22:08 +0100 | [diff] [blame] | 142 | version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) |
| 143 | arm_compute_env.AlwaysBuild(version_file) |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 144 | |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 145 | default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos'] else 'clang++' |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 146 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 147 | |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 148 | # Generate embed files |
Anthony Barbier | 0e72c69 | 2018-08-24 11:22:08 +0100 | [diff] [blame] | 149 | generate_embed = [ version_file ] |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 150 | if env['opencl'] and env['embed_kernels']: |
| 151 | cl_files = Glob('src/core/CL/cl_kernels/*.cl') |
| 152 | cl_files += Glob('src/core/CL/cl_kernels/*.h') |
| 153 | |
| 154 | embed_files = [ f.get_path()+"embed" for f in cl_files ] |
| 155 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] ) |
| 156 | |
| 157 | generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes)) |
| 158 | |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 159 | Default(generate_embed) |
| 160 | if env["build"] == "embed_only": |
| 161 | Return() |
| 162 | |
Georgios Pinitas | 35fcc43 | 2020-03-26 18:47:46 +0000 | [diff] [blame] | 163 | # Append version defines for semantic versioning |
| 164 | arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), |
| 165 | ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR), |
| 166 | ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) |
| 167 | |
Isabella Gottardi | b28f29d | 2017-11-09 17:05:07 +0000 | [diff] [blame] | 168 | # Don't allow undefined references in the libraries: |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 169 | undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined' |
| 170 | arm_compute_env.Append(LINKFLAGS=[undefined_flag]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 171 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) |
| 172 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 173 | arm_compute_env.Append(LIBS = ['dl']) |
| 174 | |
| 175 | core_files = Glob('src/core/*.cpp') |
| 176 | core_files += Glob('src/core/CPP/*.cpp') |
| 177 | core_files += Glob('src/core/CPP/kernels/*.cpp') |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 178 | core_files += Glob('src/core/helpers/*.cpp') |
Sang-Hoon Park | 3687ee1 | 2020-06-24 13:34:04 +0100 | [diff] [blame] | 179 | core_files += Glob('src/core/utils/*.cpp') |
Michalis Spyrou | 7043d36 | 2018-12-03 13:58:32 +0000 | [diff] [blame] | 180 | core_files += Glob('src/core/utils/helpers/*.cpp') |
| 181 | core_files += Glob('src/core/utils/io/*.cpp') |
| 182 | core_files += Glob('src/core/utils/quantization/*.cpp') |
Georgios Pinitas | b8d5b95 | 2019-05-16 14:13:03 +0100 | [diff] [blame] | 183 | core_files += Glob('src/core/utils/misc/*.cpp') |
Michalis Spyrou | 7043d36 | 2018-12-03 13:58:32 +0000 | [diff] [blame] | 184 | if env["logging"]: |
| 185 | core_files += Glob('src/core/utils/logging/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 186 | |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 187 | runtime_files = Glob('src/runtime/*.cpp') |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 188 | runtime_files += Glob('src/runtime/CPP/ICPPSimpleFunction.cpp') |
| 189 | runtime_files += Glob('src/runtime/CPP/functions/*.cpp') |
| 190 | |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 191 | runtime_files += Glob('src/c/*.cpp') |
| 192 | runtime_files += Glob('src/common/*.cpp') |
| 193 | runtime_files += Glob('src/cpu/*.cpp') |
| 194 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 195 | # CLHarrisCorners uses the Scheduler to run CPP kernels |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 196 | runtime_files += Glob('src/runtime/CPP/SingleThreadScheduler.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 197 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 198 | graph_files = Glob('src/graph/*.cpp') |
| 199 | graph_files += Glob('src/graph/*/*.cpp') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 200 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 201 | if env['cppthreads']: |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 202 | runtime_files += Glob('src/runtime/CPP/CPPScheduler.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 203 | |
| 204 | if env['openmp']: |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 205 | runtime_files += Glob('src/runtime/OMP/OMPScheduler.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 206 | |
| 207 | if env['opencl']: |
| 208 | core_files += Glob('src/core/CL/*.cpp') |
| 209 | core_files += Glob('src/core/CL/kernels/*.cpp') |
Gian Marco Iodice | 926afe1 | 2019-03-19 11:44:13 +0000 | [diff] [blame] | 210 | core_files += Glob('src/core/CL/gemm/*.cpp') |
Gian Marco Iodice | 06be6f8 | 2019-06-24 17:47:51 +0100 | [diff] [blame] | 211 | core_files += Glob('src/core/CL/gemm/native/*.cpp') |
Gian Marco Iodice | 926afe1 | 2019-03-19 11:44:13 +0000 | [diff] [blame] | 212 | core_files += Glob('src/core/CL/gemm/reshaped/*.cpp') |
| 213 | core_files += Glob('src/core/CL/gemm/reshaped_only_rhs/*.cpp') |
Michele Di Giorgio | 7d61ff0 | 2021-01-18 21:15:59 +0000 | [diff] [blame] | 214 | core_files += Glob('src/core/gpu/cl/*.cpp') |
| 215 | core_files += Glob('src/core/gpu/cl/kernels/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 216 | |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 217 | runtime_files += Glob('src/runtime/CL/*.cpp') |
| 218 | runtime_files += Glob('src/runtime/CL/functions/*.cpp') |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 219 | runtime_files += Glob('src/runtime/CL/gemm/*.cpp') |
Georgios Pinitas | c0d1c86 | 2018-03-23 15:13:15 +0000 | [diff] [blame] | 220 | runtime_files += Glob('src/runtime/CL/tuners/*.cpp') |
Michele Di Giorgio | 7d61ff0 | 2021-01-18 21:15:59 +0000 | [diff] [blame] | 221 | runtime_files += Glob('src/runtime/gpu/cl/*.cpp') |
| 222 | runtime_files += Glob('src/runtime/gpu/cl/operators/*.cpp') |
SiCong Li | 7061eb2 | 2021-01-08 15:16:02 +0000 | [diff] [blame] | 223 | runtime_files += Glob('src/runtime/CL/mlgo/*.cpp') |
SiCong Li | bd8b1e2 | 2021-02-04 13:07:09 +0000 | [diff] [blame] | 224 | runtime_files += Glob('src/runtime/CL/gemm_auto_heuristics/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 225 | |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 226 | runtime_files += Glob('src/gpu/cl/*.cpp') |
| 227 | runtime_files += Glob('src/c/cl/*.cpp') |
| 228 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 229 | graph_files += Glob('src/graph/backends/CL/*.cpp') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 230 | |
| 231 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 232 | if env['neon']: |
| 233 | core_files += Glob('src/core/NEON/*.cpp') |
| 234 | core_files += Glob('src/core/NEON/kernels/*.cpp') |
Anthony Barbier | c8e84b5 | 2018-07-17 16:48:42 +0100 | [diff] [blame] | 235 | core_files += Glob('src/core/NEON/kernels/assembly/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 236 | |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 237 | core_files += Glob('src/core/NEON/kernels/arm_gemm/*.cpp') |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 238 | core_files += Glob('src/core/NEON/kernels/arm_conv/*.cpp') |
| 239 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/*.cpp') |
| 240 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/cpp_*/*.cpp') |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 241 | |
Georgios Pinitas | 30271c7 | 2019-06-24 14:56:34 +0100 | [diff] [blame] | 242 | # build winograd/depthwise sources for either v7a / v8a |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 243 | core_files += Glob('src/core/NEON/kernels/convolution/*/*.cpp') |
| 244 | core_files += Glob('src/core/NEON/kernels/convolution/winograd/*/*.cpp') |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 245 | arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/", |
Michele Di Giorgio | 6ad60af | 2020-06-09 14:52:15 +0100 | [diff] [blame] | 246 | "src/core/NEON/kernels/convolution/winograd/", |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 247 | "src/core/NEON/kernels/convolution/depthwise/", |
| 248 | "src/core/NEON/kernels/assembly/", |
Georgios Pinitas | 30271c7 | 2019-06-24 14:56:34 +0100 | [diff] [blame] | 249 | "arm_compute/core/NEON/kernels/assembly/"]) |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 250 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 251 | graph_files += Glob('src/graph/backends/NEON/*.cpp') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 252 | |
Georgios Pinitas | f2cdce3 | 2019-12-09 18:35:57 +0000 | [diff] [blame] | 253 | if env['estate'] == '32': |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 254 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a32_*/*.cpp') |
| 255 | |
Georgios Pinitas | f2cdce3 | 2019-12-09 18:35:57 +0000 | [diff] [blame] | 256 | if env['estate'] == '64': |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 257 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a64_*/*.cpp') |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 258 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/a64_*/*.cpp') |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 259 | if "sve" in env['arch']: |
| 260 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/sve_*/*.cpp') |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 261 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/sve_*/*.cpp') |
Moritz Pflanzer | beabe3b | 2017-08-31 14:56:32 +0100 | [diff] [blame] | 262 | |
Georgios Pinitas | ff4fca0 | 2020-10-02 21:00:00 +0100 | [diff] [blame] | 263 | if any(i in env['data_type_support'] for i in ['all', 'fp16']): |
Michalis Spyrou | aa51a5b | 2020-11-22 00:49:42 +0000 | [diff] [blame] | 264 | core_files += Glob('src/core/NEON/kernels/*/impl/*/fp16.cpp') |
Georgios Pinitas | ff4fca0 | 2020-10-02 21:00:00 +0100 | [diff] [blame] | 265 | if any(i in env['data_type_support'] for i in ['all', 'fp32']): |
Michalis Spyrou | aa51a5b | 2020-11-22 00:49:42 +0000 | [diff] [blame] | 266 | core_files += Glob('src/core/NEON/kernels/*/impl/*/fp32.cpp') |
Michalis Spyrou | c4d4555 | 2020-10-19 12:41:30 +0100 | [diff] [blame] | 267 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8']): |
Michalis Spyrou | aa51a5b | 2020-11-22 00:49:42 +0000 | [diff] [blame] | 268 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8.cpp') |
Michalis Spyrou | c4d4555 | 2020-10-19 12:41:30 +0100 | [diff] [blame] | 269 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']): |
Michalis Spyrou | aa51a5b | 2020-11-22 00:49:42 +0000 | [diff] [blame] | 270 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8_signed.cpp') |
Michalis Spyrou | c4d4555 | 2020-10-19 12:41:30 +0100 | [diff] [blame] | 271 | if any(i in env['data_type_support'] for i in ['all', 'qsymm16']): |
Michalis Spyrou | aa51a5b | 2020-11-22 00:49:42 +0000 | [diff] [blame] | 272 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qsymm16.cpp') |
Michalis Spyrou | a3c9a3b | 2020-12-08 21:02:16 +0000 | [diff] [blame] | 273 | if any(i in env['data_type_support'] for i in ['all', 'integer']): |
| 274 | core_files += Glob('src/core/NEON/kernels/*/impl/*/integer.cpp') |
Georgios Pinitas | ff4fca0 | 2020-10-02 21:00:00 +0100 | [diff] [blame] | 275 | |
Anthony Barbier | 8e6faf1 | 2017-08-01 17:03:19 +0100 | [diff] [blame] | 276 | runtime_files += Glob('src/runtime/NEON/*.cpp') |
| 277 | runtime_files += Glob('src/runtime/NEON/functions/*.cpp') |
Anthony Barbier | c8e84b5 | 2018-07-17 16:48:42 +0100 | [diff] [blame] | 278 | runtime_files += Glob('src/runtime/NEON/functions/assembly/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 279 | |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 280 | core_files += Glob('src/core/cpu/*.cpp') |
| 281 | core_files += Glob('src/core/cpu/kernels/*.cpp') |
| 282 | core_files += Glob('src/core/cpu/kernels/*/*.cpp') |
| 283 | if any(i in env['data_type_support'] for i in ['all', 'fp16']): |
Georgios Pinitas | f8f0442 | 2021-01-08 17:25:55 +0000 | [diff] [blame] | 284 | core_files += Glob('src/core/cpu/kernels/*/*/fp16.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 285 | if any(i in env['data_type_support'] for i in ['all', 'fp32']): |
Georgios Pinitas | f8f0442 | 2021-01-08 17:25:55 +0000 | [diff] [blame] | 286 | core_files += Glob('src/core/cpu/kernels/*/*/fp32.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 287 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8']): |
Georgios Pinitas | f8f0442 | 2021-01-08 17:25:55 +0000 | [diff] [blame] | 288 | core_files += Glob('src/core/cpu/kernels/*/*/qasymm8.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 289 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']): |
Georgios Pinitas | f8f0442 | 2021-01-08 17:25:55 +0000 | [diff] [blame] | 290 | core_files += Glob('src/core/cpu/kernels/*/*/qasymm8_signed.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 291 | if any(i in env['data_type_support'] for i in ['all', 'qsymm16']): |
Georgios Pinitas | f8f0442 | 2021-01-08 17:25:55 +0000 | [diff] [blame] | 292 | core_files += Glob('src/core/cpu/kernels/*/*/qsymm16.cpp') |
Sheri Zhang | 6124390 | 2021-01-12 18:25:16 +0000 | [diff] [blame] | 293 | if any(i in env['data_type_support'] for i in ['all', 'integer']): |
| 294 | core_files += Glob('src/core/cpu/kernels/*/*/integer.cpp') |
Sheri Zhang | 79144a6 | 2021-02-08 17:43:04 +0000 | [diff] [blame] | 295 | |
| 296 | if any(i in env['data_layout_support'] for i in ['all', 'nchw']): |
| 297 | core_files += Glob('src/core/cpu/kernels/*/*/nchw/all.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 298 | |
| 299 | runtime_files += Glob('src/runtime/cpu/*.cpp') |
| 300 | runtime_files += Glob('src/runtime/cpu/operators/*.cpp') |
| 301 | |
Anthony Barbier | b467021 | 2018-05-18 16:55:39 +0100 | [diff] [blame] | 302 | if env['tracing']: |
| 303 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_TRACING_ENABLED']) |
| 304 | else: |
| 305 | # Remove TracePoint files if tracing is disabled: |
| 306 | core_files = [ f for f in core_files if not "TracePoint" in str(f)] |
| 307 | runtime_files = [ f for f in runtime_files if not "TracePoint" in str(f)] |
Georgios Pinitas | fbb8054 | 2018-03-27 17:15:49 +0100 | [diff] [blame] | 308 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 309 | bootcode_o = [] |
| 310 | if env['os'] == 'bare_metal': |
| 311 | bootcode_files = Glob('bootcode/*.s') |
| 312 | bootcode_o = build_bootcode_objs(bootcode_files) |
| 313 | Export('bootcode_o') |
| 314 | |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 315 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, core_files, static=True) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 316 | Export('arm_compute_core_a') |
| 317 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 318 | if env['os'] != 'bare_metal' and not env['standalone']: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 319 | arm_compute_core_so = build_library('arm_compute_core', arm_compute_env, core_files, static=False) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 320 | Export('arm_compute_core_so') |
| 321 | |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 322 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, runtime_files, static=True, libs = [ arm_compute_core_a ]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 323 | Export('arm_compute_a') |
| 324 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 325 | if env['os'] != 'bare_metal' and not env['standalone']: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 326 | arm_compute_so = build_library('arm_compute', arm_compute_env, runtime_files, static=False, libs = [ "arm_compute_core" ]) |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 327 | Depends(arm_compute_so, arm_compute_core_so) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 328 | Export('arm_compute_so') |
| 329 | |
Sang-Hoon Park | 18fbb92 | 2021-01-14 14:50:25 +0000 | [diff] [blame] | 330 | arm_compute_graph_env = arm_compute_env.Clone() |
| 331 | |
| 332 | arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move']) |
| 333 | |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 334 | arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a]) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 335 | Export('arm_compute_graph_a') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 336 | |
| 337 | if env['os'] != 'bare_metal' and not env['standalone']: |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 338 | arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" , "arm_compute_core"]) |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 339 | Depends(arm_compute_graph_so, arm_compute_so) |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 340 | Export('arm_compute_graph_so') |
| 341 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 342 | if env['standalone']: |
| 343 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a]) |
| 344 | else: |
| 345 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so]) |
| 346 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 347 | Default(alias) |
| 348 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 349 | if env['standalone']: |
| 350 | Depends([alias,arm_compute_core_a], generate_embed) |
| 351 | else: |
| 352 | Depends([alias,arm_compute_core_so, arm_compute_core_a], generate_embed) |