Michalis Spyrou | a8caa02 | 2022-05-18 17:43:39 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
Michele Di Giorgio | 33f41fa | 2021-03-09 14:09:08 +0000 | [diff] [blame] | 2 | # -*- coding: utf-8 -*- |
| 3 | |
Quoc Khanh Le | ea6c6d4 | 2024-05-17 14:39:49 +0100 | [diff] [blame] | 4 | # Copyright (c) 2017-2023, 2024 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +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. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 25 | import os.path |
Quoc Khanh Le | ea6c6d4 | 2024-05-17 14:39:49 +0100 | [diff] [blame] | 26 | import SCons |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | |
| 28 | Import('env') |
| 29 | Import('vars') |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 30 | Import('install_bin') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | |
| 32 | # vars is imported from arm_compute: |
| 33 | variables = [ |
Michele Di Giorgio | f9a611a | 2021-03-12 11:22:55 +0000 | [diff] [blame] | 34 | BoolVariable("benchmark_examples", "Build benchmark examples programs", False), |
| 35 | BoolVariable("validate_examples", "Build validate examples programs", False), |
Michalis Spyrou | d1d7722 | 2020-04-08 14:10:15 +0100 | [diff] [blame] | 36 | BoolVariable("reference_openmp", "Build reference validation with openmp", True), |
Michele Di Giorgio | f9a611a | 2021-03-12 11:22:55 +0000 | [diff] [blame] | 37 | BoolVariable("validation_tests", "Build validation test programs", False), |
| 38 | BoolVariable("benchmark_tests", "Build benchmark test programs", False), |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 39 | ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 40 | ] |
| 41 | |
| 42 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 43 | new_options = Variables('scons') |
| 44 | |
| 45 | for v in variables: |
| 46 | new_options.Add(v) |
| 47 | vars.Add(v) |
| 48 | |
| 49 | # 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] | 50 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 51 | vars.Update(test_env) |
| 52 | |
| 53 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 54 | |
Georgios Pinitas | 6a34264 | 2020-01-28 15:54:20 +0000 | [diff] [blame] | 55 | # Check if we need to build the test framework |
| 56 | build_test_framework = False |
| 57 | for opt in new_options.keys(): |
| 58 | option_value = test_env[opt] |
| 59 | if type(option_value) is bool and option_value: |
| 60 | build_test_framework = True |
| 61 | break |
| 62 | |
| 63 | if not build_test_framework: |
| 64 | Return() |
| 65 | else: |
| 66 | SConscript('./framework/SConscript', duplicate=0) |
| 67 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 68 | Import("arm_compute_test_framework") |
| 69 | test_env.Append(LIBS = arm_compute_test_framework) |
| 70 | |
Georgios Pinitas | 6a34264 | 2020-01-28 15:54:20 +0000 | [diff] [blame] | 71 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
Pablo Tello | 29cab36 | 2022-03-10 17:05:34 +0000 | [diff] [blame] | 72 | if not 'windows' in env['os']: |
| 73 | test_env.Append(CXXFLAGS = ['-ffp-contract=off']) |
Georgios Pinitas | 6a34264 | 2020-01-28 15:54:20 +0000 | [diff] [blame] | 74 | |
Georgios Pinitas | f8d8f3a | 2018-06-06 17:57:04 +0100 | [diff] [blame] | 75 | # Remove -Wnoexcept from tests |
| 76 | if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']: |
| 77 | test_env['CXXFLAGS'].remove("-Wnoexcept") |
| 78 | |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 79 | load_whole_archive = '-Wl,--whole-archive' |
| 80 | noload_whole_archive = '-Wl,--no-whole-archive' |
| 81 | if 'macos' in test_env['os']: |
| 82 | load_whole_archive = '-Wl,-force_load' |
Jakub Sujak | ebce280 | 2023-09-29 11:11:59 +0100 | [diff] [blame] | 83 | noload_whole_archive = '' |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 84 | |
Renato Arantes | 36a75da | 2024-01-26 17:31:18 +0000 | [diff] [blame] | 85 | if (env['multi_isa']): |
| 86 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_ENABLE_BF16']) |
| 87 | |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 88 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 89 | Import("arm_compute_a") |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 90 | Import("arm_compute_graph_a") |
Jakub Sujak | e30c874 | 2023-11-13 14:57:16 +0000 | [diff] [blame] | 91 | test_env.Append(LIBS = [arm_compute_graph_a, arm_compute_a]) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 92 | arm_compute_lib = arm_compute_graph_a |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 93 | else: |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 94 | Import("arm_compute_graph_so") |
Jakub Sujak | e30c874 | 2023-11-13 14:57:16 +0000 | [diff] [blame] | 95 | test_env.Append(LIBS = ["arm_compute_graph", "arm_compute"]) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 96 | arm_compute_lib = arm_compute_graph_so |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 97 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 98 | if env['os'] in ['bare_metal']: |
| 99 | Import("bootcode_o") |
| 100 | |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 101 | if env['external_tests_dir']: |
| 102 | test_env.Append(CPPPATH = [env['external_tests_dir'] + "/include"]) |
| 103 | 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] | 104 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 105 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 106 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 107 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 108 | files_benchmark = Glob('benchmark/*.cpp') |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 109 | if env['external_tests_dir']: |
| 110 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 111 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 112 | # Add unit tests |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 113 | files_validation = Glob('validation/UNIT/*/*.cpp') |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 114 | files_validation += Glob('validation/UNIT/*.cpp') |
| 115 | |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 116 | # Add CPP tests |
| 117 | filter_pattern = test_env['test_filter'] |
| 118 | files_validation += Glob('validation/CPP/' + filter_pattern) |
| 119 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 120 | if env['opencl']: |
Giorgio Arena | 892b70a | 2022-03-30 12:23:10 +0100 | [diff] [blame] | 121 | if env['experimental_dynamic_fusion']: |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 122 | files_validation += Glob('validation/dynamic_fusion/gpu/' + filter_pattern) |
Ramy Elgammal | 73f19af | 2022-10-23 11:44:49 +0100 | [diff] [blame] | 123 | files_validation += Glob('validation/dynamic_fusion/gpu/cl/' + filter_pattern) |
Giorgio Arena | 232c452 | 2022-03-03 10:09:01 +0000 | [diff] [blame] | 124 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 125 | filter_pattern = test_env['test_filter'] |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 126 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 127 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 128 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 129 | files_benchmark += Glob('benchmark/CL/*/' + filter_pattern) |
| 130 | files_benchmark += Glob('benchmark/CL/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 131 | if env['external_tests_dir']: |
| 132 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 133 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 134 | files_validation += Glob('validation/CL/*/' + filter_pattern) |
| 135 | files_validation += Glob('validation/CL/' + filter_pattern) |
Giorgio Arena | 892b70a | 2022-03-30 12:23:10 +0100 | [diff] [blame] | 136 | |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 137 | if env['external_tests_dir']: |
| 138 | files_validation += Glob(env['external_tests_dir'] + '/tests/validation/CL/' + filter_pattern) |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 139 | files_validation += Glob('validation/gpu/unit/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 140 | |
| 141 | if env['neon']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 142 | filter_pattern = test_env['test_filter'] |
| 143 | files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern) |
| 144 | files_benchmark += Glob('benchmark/NEON/' + filter_pattern) |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 145 | test_env.Append(CPPPATH = ["#/src/cpu/kernels/assembly/"]) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 146 | if env['external_tests_dir']: |
| 147 | files_benchmark += Glob(env['external_tests_dir'] + '/tests/benchmark/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 148 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 149 | files_validation += Glob('validation/NEON/' + filter_pattern) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 150 | if env['os'] == 'bare_metal': |
| 151 | files_validation += Glob('validation/NEON/UNIT/MemoryManager.cpp' + filter_pattern) |
| 152 | files_validation += Glob('validation/NEON/UNIT/DynamicTensor.cpp' + filter_pattern) |
| 153 | files_validation += Glob('validation/NEON/UNIT/TensorAllocator.cpp' + filter_pattern) |
| 154 | else: |
| 155 | files_validation += Glob('validation/NEON/*/' + filter_pattern) |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 156 | if env['external_tests_dir']: |
| 157 | files_validation += Glob(env['external_tests_dir'] + '/tests/validation/NEON/' + filter_pattern) |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 158 | files_validation += Glob('validation/cpu/unit/*.cpp') |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 159 | |
Ryo Suzuki | 232c9ad | 2024-06-19 09:37:24 +0000 | [diff] [blame] | 160 | # Add wrapper tests |
| 161 | files_validation += Glob('validation/runtime/experimental/*/' + filter_pattern) |
| 162 | |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 163 | extra_link_flags = [] |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 164 | if env['os'] == 'android': |
| 165 | test_env.Append(LIBS = ["log"]) |
Pablo Tello | 29cab36 | 2022-03-10 17:05:34 +0000 | [diff] [blame] | 166 | elif env['os'] not in ['windows','bare_metal', 'macos']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 167 | test_env.Append(LIBS = ["rt"]) |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 168 | extra_link_flags += ['-fstack-protector-strong'] |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 169 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 170 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 171 | 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] | 172 | arm_compute_benchmark = install_bin(arm_compute_benchmark) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 173 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 174 | Depends(arm_compute_benchmark, arm_compute_lib) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 175 | Default(arm_compute_benchmark) |
| 176 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 177 | |
Michalis Spyrou | 6a9e801 | 2020-02-07 09:45:55 +0000 | [diff] [blame] | 178 | bm_link_flags = [] |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 179 | if test_env['linker_script']: |
Michalis Spyrou | 7d30352 | 2020-01-07 12:56:01 +0000 | [diff] [blame] | 180 | bm_link_flags += ['-Wl,--build-id=none', '-T', env['linker_script']] |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 181 | |
Pablo Tello | 29cab36 | 2022-03-10 17:05:34 +0000 | [diff] [blame] | 182 | if test_env['reference_openmp'] and env['os'] not in ['bare_metal', 'macos','windows']: |
Giorgio Arena | b83e672 | 2022-03-24 14:23:07 +0000 | [diff] [blame] | 183 | test_env['CXXFLAGS'].append('-fopenmp') |
| 184 | test_env['LINKFLAGS'].append('-fopenmp') |
| 185 | |
| 186 | if 'ndk_above_r21' in env: |
| 187 | test_env['LINKFLAGS'].append('-static-openmp') |
Michalis Spyrou | d1d7722 | 2020-04-08 14:10:15 +0100 | [diff] [blame] | 188 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 189 | # Testing for fixed format GEMM kernels. |
Nathan John Sircombe | d7113e4 | 2023-04-26 15:02:43 +0100 | [diff] [blame] | 190 | if env['fixed_format_kernels'] and test_env['validation_tests']: |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 191 | test_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS']) |
| 192 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 193 | if test_env['validation_tests']: |
Quoc Khanh Le | c2237ec | 2024-06-21 11:07:38 +0100 | [diff] [blame] | 194 | #The following set up only works for posix system, RANLIBCOM env variable isn't available on win32 HOST_OS |
| 195 | if test_env['HOST_OS'] == 'posix': |
| 196 | #Set up to use temp file for long command when building and linking libraries |
| 197 | test_env['TEMPFILE'] = SCons.Platform.TempFileMunge |
Quoc Khanh Le | ea6c6d4 | 2024-05-17 14:39:49 +0100 | [diff] [blame] | 198 | |
Quoc Khanh Le | c2237ec | 2024-06-21 11:07:38 +0100 | [diff] [blame] | 199 | #To use temp file for any command, the following pattern should be used: |
| 200 | # env['COMMAND'] = "{$TEMPFILE('$COMMANDSTRING')}" |
| 201 | #See: https://github.com/SCons/scons/blob/05f2992377844bbfec9bcd4a9c7f5479c634b91b/SCons/Platform/__init__.py#L147 |
| 202 | #The commands' string are taken from https://github.com/SCons/scons |
| 203 | #The commands' explanations are taken from Scons userguide |
Quoc Khanh Le | ea6c6d4 | 2024-05-17 14:39:49 +0100 | [diff] [blame] | 204 | |
Quoc Khanh Le | c2237ec | 2024-06-21 11:07:38 +0100 | [diff] [blame] | 205 | #The command line used to compile C++ source file to an object files |
| 206 | test_env['CXXCOM'] = "${TEMPFILE('"+ test_env['CXXCOM'] + "')}" |
| 207 | #The command line used to generate a static library from object files |
| 208 | test_env['ARCOM'] = "${TEMPFILE('"+ test_env['ARCOM'] + "')}" |
| 209 | #The command line used to index a static library archive |
| 210 | test_env['RANLIBCOM'] = "${TEMPFILE('"+ test_env['RANLIBCOM'] + "')}" |
| 211 | #The command line used to link object files into an executable |
| 212 | test_env['LINKCOM'] = "${TEMPFILE('"+ test_env['LINKCOM'] + "')}" |
| 213 | #Set up directory for temp files. To prevent permission issue, the temp files are in the same directory with output files |
| 214 | test_env['TEMPFILEDIR'] = test_env['build_dir'] |
Quoc Khanh Le | ea6c6d4 | 2024-05-17 14:39:49 +0100 | [diff] [blame] | 215 | |
| 216 | arm_compute_validation_framework = test_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 ]) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 217 | Depends(arm_compute_validation_framework , arm_compute_test_framework) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 218 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 219 | program_objects = files_validation + common_objects |
| 220 | if test_env['os'] == 'bare_metal': |
| 221 | Depends(arm_compute_validation_framework , bootcode_o) |
| 222 | program_objects += bootcode_o |
| 223 | |
| 224 | |
| 225 | 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] | 226 | arm_compute_validation = install_bin(arm_compute_validation) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 227 | Depends(arm_compute_validation, arm_compute_validation_framework) |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 228 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 229 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 230 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 231 | Default(arm_compute_validation) |
| 232 | Export('arm_compute_validation') |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 233 | |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 234 | if test_env['validate_examples']: |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 235 | 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] | 236 | if test_env['os'] == 'bare_metal': |
| 237 | files_validate_examples += bootcode_o |
| 238 | |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 239 | arm_compute_validate_examples = [] |
| 240 | if test_env['neon']: |
| 241 | for file in Glob("validate_examples/neon_*.cpp"): |
| 242 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 243 | 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] | 244 | if test_env['opencl']: |
| 245 | cl_examples = [] |
| 246 | files = Glob("validate_examples/cl_*.cpp") |
| 247 | if test_env['neon']: |
| 248 | files += Glob("validate_examples/neoncl_*.cpp") |
| 249 | for file in files: |
| 250 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 251 | 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] | 252 | arm_compute_validate_examples += cl_examples |
| 253 | if test_env['opencl'] and test_env['neon']: |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 254 | graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils") |
| 255 | for file in Glob("validate_examples/graph_*.cpp"): |
| 256 | example = "validate_" + os.path.basename(os.path.splitext(str(file))[0]) |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 257 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
| 258 | 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] | 259 | arm_compute_validate_examples += [ prog ] |
| 260 | else: |
| 261 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 262 | 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] | 263 | arm_compute_validate_examples += [ prog ] |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 264 | arm_compute_validate_examples = install_bin(arm_compute_validate_examples) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 265 | Depends(arm_compute_validate_examples, arm_compute_validation_framework) |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 266 | Depends(arm_compute_validate_examples, arm_compute_test_framework) |
| 267 | Depends(arm_compute_validate_examples, arm_compute_lib) |
| 268 | Default(arm_compute_validate_examples) |
| 269 | Export('arm_compute_validate_examples') |
| 270 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 271 | if test_env['benchmark_examples']: |
| 272 | files_benchmark_examples = test_env.Object('benchmark_examples/RunExample.cpp') |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 273 | if test_env['os'] == 'bare_metal': |
| 274 | files_benchmark_examples += bootcode_o |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 275 | graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 276 | graph_params = test_env.Object(source="../utils/CommonGraphOptions.cpp", target="CommonGraphOptions") |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 277 | arm_compute_benchmark_examples = [] |
Michele Di Giorgio | 72610dc | 2020-11-18 15:29:08 +0000 | [diff] [blame] | 278 | all_examples_folders = ["../examples"] |
| 279 | if env['external_tests_dir']: |
| 280 | all_examples_folders.append(env['external_tests_dir'] + "/examples") |
| 281 | for examples_folder in all_examples_folders: |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 282 | if test_env['neon']: |
| 283 | for file in Glob("%s/neon_*.cpp" % examples_folder): |
| 284 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 285 | 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] | 286 | if test_env['opencl']: |
| 287 | cl_examples = [] |
| 288 | files = Glob("%s/cl_*.cpp" % examples_folder) |
| 289 | if test_env['neon']: |
| 290 | files += Glob("%s/neoncl_*.cpp" % examples_folder) |
| 291 | for file in files: |
| 292 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 293 | cl_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples, LIBS = test_env["LIBS"]) ] |
| 294 | arm_compute_benchmark_examples += cl_examples |
| 295 | |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 296 | if test_env['gemm_tuner'] and test_env['opencl']: |
| 297 | gemm_tuner_examples = [] |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 298 | 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] | 299 | files = Glob("%s/gemm_tuner/cl_*.cpp" % examples_folder) |
| 300 | for file in files: |
| 301 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 302 | example = os.path.join("gemm_tuner", example) |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 303 | 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] | 304 | arm_compute_benchmark_examples += gemm_tuner_examples |
| 305 | |
Anthony Barbier | 3b6cdbb | 2018-09-14 11:58:05 +0100 | [diff] [blame] | 306 | # Graph examples |
| 307 | for file in Glob("%s/graph_*.cpp" % examples_folder ): |
| 308 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 309 | if env['os'] in ['android', 'macos', 'bare_metal'] or env['standalone']: |
| 310 | 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] | 311 | arm_compute_benchmark_examples += [ prog ] |
| 312 | else: |
| 313 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 314 | 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] | 315 | arm_compute_benchmark_examples += [ prog ] |
SiCong Li | b63b119 | 2022-01-28 18:24:39 +0000 | [diff] [blame] | 316 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 317 | arm_compute_benchmark_examples = install_bin(arm_compute_benchmark_examples) |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 318 | Depends(arm_compute_benchmark_examples, arm_compute_test_framework) |
| 319 | Depends(arm_compute_benchmark_examples, arm_compute_lib) |
| 320 | Default(arm_compute_benchmark_examples) |
Pablo Tello | 29cab36 | 2022-03-10 17:05:34 +0000 | [diff] [blame] | 321 | Export('arm_compute_benchmark_examples') |