Michele Di Giorgio | f9a611a | 2021-03-12 11:22:55 +0000 | [diff] [blame^] | 1 | # Copyright (c) 2017-2021 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 SCons |
| 23 | import os.path |
| 24 | |
| 25 | Import('env') |
| 26 | Import('vars') |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 27 | Import('install_bin') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | |
| 29 | # vars is imported from arm_compute: |
| 30 | variables = [ |
Michele Di Giorgio | f9a611a | 2021-03-12 11:22:55 +0000 | [diff] [blame^] | 31 | BoolVariable("benchmark_examples", "Build benchmark examples programs", False), |
| 32 | BoolVariable("validate_examples", "Build validate examples programs", False), |
Michalis Spyrou | d1d7722 | 2020-04-08 14:10:15 +0100 | [diff] [blame] | 33 | BoolVariable("reference_openmp", "Build reference validation with openmp", True), |
Michele Di Giorgio | f9a611a | 2021-03-12 11:22:55 +0000 | [diff] [blame^] | 34 | BoolVariable("validation_tests", "Build validation test programs", False), |
| 35 | BoolVariable("benchmark_tests", "Build benchmark test programs", False), |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 36 | ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | ] |
| 38 | |
| 39 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 40 | new_options = Variables('scons') |
| 41 | |
| 42 | for v in variables: |
| 43 | new_options.Add(v) |
| 44 | vars.Add(v) |
| 45 | |
| 46 | # Clone the environment to make sure we're not polluting the arm_compute one: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 47 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 48 | vars.Update(test_env) |
| 49 | |
| 50 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 51 | |
Georgios Pinitas | 6a34264 | 2020-01-28 15:54:20 +0000 | [diff] [blame] | 52 | # Check if we need to build the test framework |
| 53 | build_test_framework = False |
| 54 | for opt in new_options.keys(): |
| 55 | option_value = test_env[opt] |
| 56 | if type(option_value) is bool and option_value: |
| 57 | build_test_framework = True |
| 58 | break |
| 59 | |
| 60 | if not build_test_framework: |
| 61 | Return() |
| 62 | else: |
| 63 | SConscript('./framework/SConscript', duplicate=0) |
| 64 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 65 | Import("arm_compute_test_framework") |
| 66 | test_env.Append(LIBS = arm_compute_test_framework) |
| 67 | |
Georgios Pinitas | 6a34264 | 2020-01-28 15:54:20 +0000 | [diff] [blame] | 68 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
| 69 | test_env.Append(CXXFLAGS = ['-ffp-contract=off']) |
| 70 | |
Georgios Pinitas | f8d8f3a | 2018-06-06 17:57:04 +0100 | [diff] [blame] | 71 | # Remove -Wnoexcept from tests |
| 72 | if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']: |
| 73 | test_env['CXXFLAGS'].remove("-Wnoexcept") |
| 74 | |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 75 | load_whole_archive = '-Wl,--whole-archive' |
| 76 | noload_whole_archive = '-Wl,--no-whole-archive' |
| 77 | if 'macos' in test_env['os']: |
| 78 | load_whole_archive = '-Wl,-force_load' |
| 79 | noload_whole_archive = '-Wl,-noall_load' |
| 80 | |
| 81 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 82 | Import("arm_compute_a") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 83 | Import("arm_compute_core_a") |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 84 | Import("arm_compute_graph_a") |
| 85 | test_env.Append(LIBS = [arm_compute_graph_a, arm_compute_a, arm_compute_core_a]) |
| 86 | arm_compute_lib = arm_compute_graph_a |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 87 | else: |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 88 | Import("arm_compute_graph_so") |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 89 | Import("arm_compute_core_a") |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 90 | test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"]) |
| 91 | arm_compute_lib = arm_compute_graph_so |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 92 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 93 | if env['os'] in ['bare_metal']: |
| 94 | Import("bootcode_o") |
| 95 | |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 96 | if env['external_tests_dir']: |
| 97 | test_env.Append(CPPPATH = [env['external_tests_dir'] + "/include"]) |
| 98 | test_env.Append(LIBPATH = [env['external_tests_dir'] + "/%s/%s" % (env['os'], env['arch'])]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 99 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 100 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 101 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 102 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 103 | files_benchmark = Glob('benchmark/*.cpp') |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 104 | if env['external_tests_dir']: |
| 105 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 106 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 107 | # Add unit tests |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 108 | files_validation = Glob('validation/UNIT/*/*.cpp') |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 109 | files_validation += Glob('validation/UNIT/*.cpp') |
| 110 | |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 111 | # Add CPP tests |
| 112 | filter_pattern = test_env['test_filter'] |
| 113 | files_validation += Glob('validation/CPP/' + filter_pattern) |
| 114 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 115 | if env['opencl']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 116 | filter_pattern = test_env['test_filter'] |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 117 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 118 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 119 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 120 | files_benchmark += Glob('benchmark/CL/*/' + filter_pattern) |
| 121 | files_benchmark += Glob('benchmark/CL/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 122 | if env['external_tests_dir']: |
| 123 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 124 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 125 | files_validation += Glob('validation/CL/*/' + filter_pattern) |
| 126 | files_validation += Glob('validation/CL/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 127 | if env['external_tests_dir']: |
| 128 | files_validation += Glob(env['external_tests_dir'] + '/tests/validation/CL/' + filter_pattern) |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 129 | files_validation += Glob('validation/gpu/unit/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 130 | |
| 131 | if env['neon']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 132 | filter_pattern = test_env['test_filter'] |
| 133 | files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern) |
| 134 | files_benchmark += Glob('benchmark/NEON/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 135 | if env['external_tests_dir']: |
| 136 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 137 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 138 | files_validation += Glob('validation/NEON/' + filter_pattern) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 139 | if env['os'] == 'bare_metal': |
| 140 | files_validation += Glob('validation/NEON/UNIT/MemoryManager.cpp' + filter_pattern) |
| 141 | files_validation += Glob('validation/NEON/UNIT/DynamicTensor.cpp' + filter_pattern) |
| 142 | files_validation += Glob('validation/NEON/UNIT/TensorAllocator.cpp' + filter_pattern) |
| 143 | else: |
| 144 | files_validation += Glob('validation/NEON/*/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 145 | if env['external_tests_dir']: |
| 146 | files_validation += Glob(env['external_tests_dir'] + '/tests/validation/NEON/' + filter_pattern) |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 147 | files_validation += Glob('validation/cpu/unit/*.cpp') |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 148 | |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 149 | extra_link_flags = [] |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 150 | if env['os'] == 'android': |
| 151 | test_env.Append(LIBS = ["log"]) |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 152 | elif env['os'] not in ['bare_metal', 'macos']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 153 | test_env.Append(LIBS = ["rt"]) |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 154 | extra_link_flags += ['-fstack-protector-strong'] |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 155 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 156 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 157 | arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 158 | arm_compute_benchmark = install_bin(arm_compute_benchmark) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 159 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 160 | Depends(arm_compute_benchmark, arm_compute_lib) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 161 | Default(arm_compute_benchmark) |
| 162 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 163 | |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 164 | bm_link_flags = [] |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 165 | if test_env['linker_script']: |
Michalis Spyrou | 7d30352 | 2020-01-07 12:56:01 +0000 | [diff] [blame] | 166 | bm_link_flags += ['-Wl,--build-id=none', '-T', env['linker_script']] |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 167 | |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 168 | if test_env['reference_openmp'] and env['os'] not in ['bare_metal', 'macos']: |
Michalis Spyrou | d1d7722 | 2020-04-08 14:10:15 +0100 | [diff] [blame] | 169 | test_env['CXXFLAGS'].append('-fopenmp') |
| 170 | test_env['LINKFLAGS'].append('-fopenmp') |
| 171 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 172 | if test_env['validation_tests']: |
Michalis Spyrou | d1d7722 | 2020-04-08 14:10:15 +0100 | [diff] [blame] | 173 | arm_compute_validation_framework = env.StaticLibrary('arm_compute_validation_framework', Glob('validation/reference/*.cpp') + Glob('validation/*.cpp'), LINKFLAGS=test_env['LINKFLAGS'], CXXFLAGS=test_env['CXXFLAGS'], LIBS= [ arm_compute_test_framework, arm_compute_core_a]) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 174 | Depends(arm_compute_validation_framework , arm_compute_test_framework) |
| 175 | Depends(arm_compute_validation_framework , arm_compute_core_a) |
| 176 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 177 | program_objects = files_validation + common_objects |
| 178 | if test_env['os'] == 'bare_metal': |
| 179 | Depends(arm_compute_validation_framework , bootcode_o) |
| 180 | program_objects += bootcode_o |
| 181 | |
| 182 | |
| 183 | arm_compute_validation = test_env.Program('arm_compute_validation', program_objects, LIBS=[arm_compute_validation_framework] + test_env['LIBS'], LINKFLAGS=test_env['LINKFLAGS'] + bm_link_flags) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 184 | arm_compute_validation = install_bin(arm_compute_validation) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 185 | Depends(arm_compute_validation, arm_compute_validation_framework) |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 186 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 187 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 188 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 189 | Default(arm_compute_validation) |
| 190 | Export('arm_compute_validation') |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 191 | |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 192 | if test_env['validate_examples']: |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 193 | files_validate_examples = [ test_env.Object('validate_examples/RunExample.cpp') ] + [ x for x in common_objects if not "main.o" in str(x)] |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 194 | if test_env['os'] == 'bare_metal': |
| 195 | files_validate_examples += bootcode_o |
| 196 | |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 197 | arm_compute_validate_examples = [] |
| 198 | if test_env['neon']: |
| 199 | for file in Glob("validate_examples/neon_*.cpp"): |
| 200 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 201 | arm_compute_validate_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_validate_examples, LIBS = [ arm_compute_validation_framework], LINKFLAGS=test_env['LINKFLAGS'] + bm_link_flags) ] |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 202 | if test_env['opencl']: |
| 203 | cl_examples = [] |
| 204 | files = Glob("validate_examples/cl_*.cpp") |
| 205 | if test_env['neon']: |
| 206 | files += Glob("validate_examples/neoncl_*.cpp") |
| 207 | for file in files: |
| 208 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 209 | cl_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_validate_examples, LIBS = test_env["LIBS"] + [ arm_compute_validation_framework ]) ] |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 210 | arm_compute_validate_examples += cl_examples |
| 211 | if test_env['opencl'] and test_env['neon']: |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 212 | graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils") |
| 213 | for file in Glob("validate_examples/graph_*.cpp"): |
| 214 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 215 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
| 216 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils]+ files_validate_examples, LIBS = test_env["LIBS"] + [ arm_compute_validation_framework ], LINKFLAGS=test_env["LINKFLAGS"]+[load_whole_archive, arm_compute_lib, noload_whole_archive] + bm_link_flags + extra_link_flags) |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 217 | arm_compute_validate_examples += [ prog ] |
| 218 | else: |
| 219 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 220 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils]+ files_validate_examples, LIBS = test_env["LIBS"] + ["arm_compute_graph", arm_compute_validation_framework], LINKFLAGS=test_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 221 | arm_compute_validate_examples += [ prog ] |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 222 | arm_compute_validate_examples = install_bin(arm_compute_validate_examples) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 223 | Depends(arm_compute_validate_examples, arm_compute_validation_framework) |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 224 | Depends(arm_compute_validate_examples, arm_compute_test_framework) |
| 225 | Depends(arm_compute_validate_examples, arm_compute_lib) |
| 226 | Default(arm_compute_validate_examples) |
| 227 | Export('arm_compute_validate_examples') |
| 228 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 229 | if test_env['benchmark_examples']: |
| 230 | files_benchmark_examples = test_env.Object('benchmark_examples/RunExample.cpp') |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 231 | if test_env['os'] == 'bare_metal': |
| 232 | files_benchmark_examples += bootcode_o |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 233 | graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 234 | graph_params = test_env.Object(source="../utils/CommonGraphOptions.cpp", target="CommonGraphOptions") |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 235 | arm_compute_benchmark_examples = [] |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 236 | all_examples_folders = ["../examples"] |
| 237 | if env['external_tests_dir']: |
| 238 | all_examples_folders.append(env['external_tests_dir'] + "/examples") |
| 239 | for examples_folder in all_examples_folders: |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 240 | if test_env['neon']: |
| 241 | for file in Glob("%s/neon_*.cpp" % examples_folder): |
| 242 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 243 | arm_compute_benchmark_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples, LINKFLAGS=test_env["LINKFLAGS"]+ bm_link_flags) ] |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 244 | if test_env['opencl']: |
| 245 | cl_examples = [] |
| 246 | files = Glob("%s/cl_*.cpp" % examples_folder) |
| 247 | if test_env['neon']: |
| 248 | files += Glob("%s/neoncl_*.cpp" % examples_folder) |
| 249 | for file in files: |
| 250 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 251 | cl_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples, LIBS = test_env["LIBS"]) ] |
| 252 | arm_compute_benchmark_examples += cl_examples |
| 253 | |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 254 | if test_env['gemm_tuner'] and test_env['opencl']: |
| 255 | gemm_tuner_examples = [] |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 256 | gemm_tuner_common_options = test_env.Object(source="../examples/gemm_tuner/CommonGemmExampleOptions.cpp", target="CommonGemmExampleOptions") |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 257 | files = Glob("%s/gemm_tuner/cl_*.cpp" % examples_folder) |
| 258 | for file in files: |
| 259 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 260 | example = os.path.join("gemm_tuner", example) |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 261 | gemm_tuner_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example), gemm_tuner_common_options ] + files_benchmark_examples, LIBS = test_env["LIBS"]) ] |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 262 | arm_compute_benchmark_examples += gemm_tuner_examples |
| 263 | |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 264 | # Graph examples |
| 265 | for file in Glob("%s/graph_*.cpp" % examples_folder ): |
| 266 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 267 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
| 268 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils, graph_params]+ files_benchmark_examples, LIBS = test_env["LIBS"], LINKFLAGS=test_env["LINKFLAGS"]+[load_whole_archive, arm_compute_lib, noload_whole_archive] + bm_link_flags + extra_link_flags) |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 269 | arm_compute_benchmark_examples += [ prog ] |
| 270 | else: |
| 271 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 272 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils, graph_params]+ files_benchmark_examples, LIBS = test_env["LIBS"] + ["arm_compute_graph"], LINKFLAGS=test_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined']) |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 273 | arm_compute_benchmark_examples += [ prog ] |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 274 | arm_compute_benchmark_examples = install_bin(arm_compute_benchmark_examples) |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 275 | Depends(arm_compute_benchmark_examples, arm_compute_test_framework) |
| 276 | Depends(arm_compute_benchmark_examples, arm_compute_lib) |
| 277 | Default(arm_compute_benchmark_examples) |
SiCong Li | 7061eb2 | 2021-01-08 15:16:02 +0000 | [diff] [blame] | 278 | Export('arm_compute_benchmark_examples') |