Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | # Copyright (c) 2017 ARM Limited. |
| 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 | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 28 | SConscript('./framework/SConscript', duplicate=0) |
| 29 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | # vars is imported from arm_compute: |
| 31 | variables = [ |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 32 | #FIXME: Remove before release! |
| 33 | BoolVariable("benchmark_examples", "Build benchmark examples programs", True), |
Anthony Barbier | e4904c7 | 2018-02-21 15:57:15 +0000 | [diff] [blame] | 34 | #FIXME Switch the following two options to False before releasing |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | BoolVariable("validation_tests", "Build validation test programs", True), |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 36 | BoolVariable("benchmark_tests", "Build benchmark test programs", True), |
| 37 | ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 38 | ] |
| 39 | |
| 40 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 41 | new_options = Variables('scons') |
| 42 | |
| 43 | for v in variables: |
| 44 | new_options.Add(v) |
| 45 | vars.Add(v) |
| 46 | |
Gian Marco Iodice | f239953 | 2017-09-13 14:16:41 +0100 | [diff] [blame] | 47 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
| 48 | env.Append(CXXFLAGS = ['-ffp-contract=off']) |
| 49 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | # 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] | 51 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 52 | vars.Update(test_env) |
| 53 | |
| 54 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 55 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 56 | Import("arm_compute_test_framework") |
| 57 | test_env.Append(LIBS = arm_compute_test_framework) |
| 58 | |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 59 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 60 | Import("arm_compute_a") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 61 | Import("arm_compute_core_a") |
| 62 | test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 63 | arm_compute_lib = arm_compute_a |
| 64 | else: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 65 | Import("arm_compute_so") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 66 | test_env.Append(LIBS = ["arm_compute", "arm_compute_core"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 67 | arm_compute_lib = arm_compute_so |
| 68 | |
| 69 | #FIXME Delete before release |
Anthony Barbier | a4e5e1e | 2017-10-05 14:55:34 +0100 | [diff] [blame] | 70 | if env['internal_only']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 71 | test_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 72 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 73 | test_env.Append(CPPPATH = ["#3rdparty/include"]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 74 | test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 75 | test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 76 | test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 77 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 78 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 79 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 80 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 81 | files_benchmark = Glob('benchmark/*.cpp') |
| 82 | files_validation = Glob('validation/*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 83 | |
| 84 | # Always compile reference for validation |
Georgios Pinitas | 5a7e776 | 2017-12-01 16:27:29 +0000 | [diff] [blame] | 85 | files_validation += Glob('validation/reference/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 86 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 87 | # Add unit tests |
| 88 | files_validation += Glob('validation/UNIT/*/*.cpp') |
| 89 | files_validation += Glob('validation/UNIT/*.cpp') |
| 90 | |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 91 | # Add CPP tests |
| 92 | filter_pattern = test_env['test_filter'] |
| 93 | files_validation += Glob('validation/CPP/' + filter_pattern) |
| 94 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 95 | if env['opencl']: |
| 96 | Import('opencl') |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 97 | filter_pattern = test_env['test_filter'] |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 98 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 99 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
| 100 | test_env.Append(LIBS = ["OpenCL"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 101 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 102 | files_benchmark += Glob('benchmark/CL/*/' + filter_pattern) |
| 103 | files_benchmark += Glob('benchmark/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 104 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 105 | files_validation += Glob('validation/CL/*/' + filter_pattern) |
| 106 | files_validation += Glob('validation/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 107 | |
| 108 | if env['neon']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 109 | filter_pattern = test_env['test_filter'] |
| 110 | files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern) |
| 111 | files_benchmark += Glob('benchmark/NEON/' + 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/NEON/*/' + filter_pattern) |
| 114 | files_validation += Glob('validation/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 115 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 116 | if env['gles_compute']: |
| 117 | if env['os'] != 'android': |
| 118 | Import('egl') |
| 119 | Import('glesv2') |
| 120 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 121 | test_env.Append(LIBS = ["EGL", "GLESv2"]) |
| 122 | else: |
| 123 | if env['arch'] != 'armv7a': |
| 124 | test_env.Append(LIBS = ["EGL", "GLESv3"]) |
| 125 | else: |
| 126 | test_env.Append(LIBS = ["EGL", "GLESv2"]) |
| 127 | |
| 128 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC']) |
| 129 | |
| 130 | files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp') |
| 131 | files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp') |
| 132 | |
| 133 | files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp') |
| 134 | files_validation += Glob('validation/GLES_COMPUTE/*.cpp') |
| 135 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 136 | if env['os'] == 'android': |
| 137 | test_env.Append(LIBS = ["log"]) |
| 138 | else: |
| 139 | test_env.Append(LIBS = ["rt"]) |
| 140 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 141 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 142 | arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 143 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 144 | Depends(arm_compute_benchmark, arm_compute_lib) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 145 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 146 | if env['opencl']: |
| 147 | Depends(arm_compute_benchmark, opencl) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 148 | if env['gles_compute'] and env['os'] != 'android': |
| 149 | Depends(arm_compute_benchmark, egl) |
| 150 | Depends(arm_compute_benchmark, glesv2) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 151 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 152 | Default(arm_compute_benchmark) |
| 153 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 154 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 155 | if test_env['validation_tests']: |
| 156 | arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects) |
| 157 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 158 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 159 | |
| 160 | if env['opencl']: |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 161 | Depends(arm_compute_validation, opencl) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 162 | if env['gles_compute'] and env['os'] != 'android': |
| 163 | Depends(arm_compute_validation, egl) |
| 164 | Depends(arm_compute_validation, glesv2) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 165 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 166 | Default(arm_compute_validation) |
| 167 | Export('arm_compute_validation') |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 168 | |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 169 | #FIXME: Remove before release! |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 170 | if test_env['benchmark_examples']: |
| 171 | files_benchmark_examples = test_env.Object('benchmark_examples/RunExample.cpp') |
| 172 | arm_compute_benchmark_examples = [] |
| 173 | if test_env['neon']: |
| 174 | for file in Glob("../examples/neon_*.cpp"): |
| 175 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 176 | arm_compute_benchmark_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples) ] |
| 177 | if test_env['opencl']: |
| 178 | cl_examples = [] |
| 179 | files = Glob("../examples/cl_*.cpp") |
| 180 | if test_env['neon']: |
| 181 | files += Glob("../examples/neoncl_*.cpp") |
| 182 | for file in files: |
| 183 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 184 | cl_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples, CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = test_env["LIBS"] + ["OpenCL"]) ] |
| 185 | Depends(cl_examples, opencl) |
| 186 | arm_compute_benchmark_examples += cl_examples |
| 187 | if test_env['opencl'] and test_env['neon']: |
| 188 | if env['os'] == 'android': |
| 189 | Import('arm_compute_graph_a') |
| 190 | graph_dependency = arm_compute_graph_a |
| 191 | else: |
| 192 | Import('arm_compute_graph_so') |
| 193 | graph_dependency = arm_compute_graph_so |
| 194 | |
| 195 | graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils") |
| 196 | for file in Glob("../examples/graph_*.cpp"): |
| 197 | example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0]) |
| 198 | if env['os'] == 'android': |
| 199 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils]+ files_benchmark_examples, LIBS = test_env["LIBS"] + ["OpenCL"], LINKFLAGS=test_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive']) |
| 200 | Depends(prog, [graph_dependency, opencl]) |
| 201 | arm_compute_benchmark_examples += [ prog ] |
| 202 | else: |
| 203 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
| 204 | prog = test_env.Program(example, [ test_env.Object(source=file, target=example), graph_utils]+ files_benchmark_examples, LIBS = test_env["LIBS"] + ["arm_compute_graph"], LINKFLAGS=test_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) |
| 205 | Depends(prog, graph_dependency) |
| 206 | arm_compute_benchmark_examples += [ prog ] |
| 207 | Depends(arm_compute_benchmark_examples, arm_compute_test_framework) |
| 208 | Depends(arm_compute_benchmark_examples, arm_compute_lib) |
| 209 | Default(arm_compute_benchmark_examples) |
| 210 | Export('arm_compute_benchmark_examples') |
| 211 | |