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