blob: 41731c2343d9ea290aa079f19633ab22f8601b42 [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001# Copyright (c) 2017, 2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002#
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.
22import SCons
23import os.path
24
25Import('env')
26Import('vars')
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000027Import('install_bin')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010029SConscript('./framework/SConscript', duplicate=0)
30
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031# vars is imported from arm_compute:
32variables = [
Anthony Barbiere8a49832018-01-18 10:04:05 +000033 #FIXME: Remove before release!
34 BoolVariable("benchmark_examples", "Build benchmark examples programs", True),
Anthony Barbier979dc4f2018-03-07 09:27:48 +000035 BoolVariable("validate_examples", "Build benchmark examples programs", True),
Anthony Barbiere4904c72018-02-21 15:57:15 +000036 #FIXME Switch the following two options to False before releasing
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037 BoolVariable("validation_tests", "Build validation test programs", True),
Pablo Telloea1c9502017-11-09 11:49:18 +000038 BoolVariable("benchmark_tests", "Build benchmark test programs", True),
39 ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp")
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040]
41
42# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
43new_options = Variables('scons')
44
45for v in variables:
46 new_options.Add(v)
47 vars.Add(v)
48
Gian Marco Iodicef2399532017-09-13 14:16:41 +010049# Disable floating-point expression contraction (e.g. fused multiply-add operations)
50env.Append(CXXFLAGS = ['-ffp-contract=off'])
51
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010053test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010054vars.Update(test_env)
55
56Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010057
Anthony Barbier6db0ff52018-01-05 10:59:12 +000058Import("arm_compute_test_framework")
59test_env.Append(LIBS = arm_compute_test_framework)
60
Georgios Pinitasf8d8f3a2018-06-06 17:57:04 +010061# Remove -Wnoexcept from tests
62if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']:
63 test_env['CXXFLAGS'].remove("-Wnoexcept")
64
Georgios Pinitas9873ea32017-12-05 15:28:55 +000065if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010066 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010067 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010068 Import("arm_compute_graph_a")
69 test_env.Append(LIBS = [arm_compute_graph_a, arm_compute_a, arm_compute_core_a])
70 arm_compute_lib = arm_compute_graph_a
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010071else:
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010072 Import("arm_compute_graph_so")
Anthony Barbier2df1f992018-07-11 13:37:23 +010073 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010074 test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"])
75 arm_compute_lib = arm_compute_graph_so
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010076
77#FIXME Delete before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010078if env['internal_only']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010079 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010080
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010081test_env.Append(CPPPATH = ["#3rdparty/include"])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010082test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010083
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010084common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010085common_objects = [test_env.StaticObject(f) for f in common_files]
86
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010087files_benchmark = Glob('benchmark/*.cpp')
Georgios Pinitaseb6aad72018-11-28 15:07:29 +000088#FIXME Delete before release
89if env['internal_only']:
90 files_benchmark += Glob('../3rdparty/tests/benchmark/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010091
Abe Mbise925ca0f2017-10-02 19:16:33 +010092# Add unit tests
Anthony Barbier979dc4f2018-03-07 09:27:48 +000093files_validation = Glob('validation/UNIT/*/*.cpp')
Abe Mbise925ca0f2017-10-02 19:16:33 +010094files_validation += Glob('validation/UNIT/*.cpp')
95
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000096# Add CPP tests
97filter_pattern = test_env['test_filter']
98files_validation += Glob('validation/CPP/' + filter_pattern)
99
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100100if env['opencl']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000101 filter_pattern = test_env['test_filter']
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100102
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100103 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100104
Pablo Telloea1c9502017-11-09 11:49:18 +0000105 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
106 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Georgios Pinitaseb6aad72018-11-28 15:07:29 +0000107 #FIXME Delete before release
108 if env['internal_only']:
109 files_benchmark += Glob('../3rdparty/tests/benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100110
Pablo Telloea1c9502017-11-09 11:49:18 +0000111 files_validation += Glob('validation/CL/*/' + filter_pattern)
112 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100113
114if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000115 filter_pattern = test_env['test_filter']
116 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
117 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Georgios Pinitaseb6aad72018-11-28 15:07:29 +0000118 #FIXME Delete before release
119 if env['internal_only']:
120 files_benchmark += Glob('../3rdparty/tests/benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100121
Pablo Telloea1c9502017-11-09 11:49:18 +0000122 files_validation += Glob('validation/NEON/*/' + filter_pattern)
123 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100124
Anthony Barbier7068f992017-10-26 15:23:08 +0100125if env['gles_compute']:
Anthony Barbier7068f992017-10-26 15:23:08 +0100126 test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
127
128 files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp')
129 files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp')
130
131 files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp')
132 files_validation += Glob('validation/GLES_COMPUTE/*.cpp')
133
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100134if env['os'] == 'android':
135 test_env.Append(LIBS = ["log"])
Georgios Pinitas421405b2018-10-26 19:05:32 +0100136elif env['os'] != 'bare_metal':
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100137 test_env.Append(LIBS = ["rt"])
138
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100139if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100140 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000141 arm_compute_benchmark = install_bin(arm_compute_benchmark)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100142 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100143 Depends(arm_compute_benchmark, arm_compute_lib)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144 Default(arm_compute_benchmark)
145 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100146
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100147if test_env['validation_tests']:
Anthony Barbier069818d2018-07-13 14:45:37 +0100148 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 Barbier2df1f992018-07-11 13:37:23 +0100149 Depends(arm_compute_validation_framework , arm_compute_test_framework)
150 Depends(arm_compute_validation_framework , arm_compute_core_a)
151
Anthony Barbier069818d2018-07-13 14:45:37 +0100152 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects, LIBS=[arm_compute_validation_framework] + test_env['LIBS'])
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000153 arm_compute_validation = install_bin(arm_compute_validation)
Anthony Barbier2df1f992018-07-11 13:37:23 +0100154 Depends(arm_compute_validation, arm_compute_validation_framework)
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100155 Depends(arm_compute_validation, arm_compute_test_framework)
156 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100157
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100158 Default(arm_compute_validation)
159 Export('arm_compute_validation')
Anthony Barbier6db0ff52018-01-05 10:59:12 +0000160
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000161 #FIXME: Remove before release!
162 if test_env['validate_examples']:
Anthony Barbier2df1f992018-07-11 13:37:23 +0100163 files_validate_examples = [ test_env.Object('validate_examples/RunExample.cpp') ] + [ x for x in common_objects if not "main.o" in str(x)]
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000164 arm_compute_validate_examples = []
165 if test_env['neon']:
166 for file in Glob("validate_examples/neon_*.cpp"):
167 example = "validate_" + os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier2df1f992018-07-11 13:37:23 +0100168 arm_compute_validate_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_validate_examples, LIBS = [ arm_compute_validation_framework]) ]
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000169 if test_env['opencl']:
170 cl_examples = []
171 files = Glob("validate_examples/cl_*.cpp")
172 if test_env['neon']:
173 files += Glob("validate_examples/neoncl_*.cpp")
174 for file in files:
175 example = "validate_" + os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier2df1f992018-07-11 13:37:23 +0100176 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 Barbier979dc4f2018-03-07 09:27:48 +0000177 arm_compute_validate_examples += cl_examples
178 if test_env['opencl'] and test_env['neon']:
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000179 graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils")
180 for file in Glob("validate_examples/graph_*.cpp"):
181 example = "validate_" + os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier9fb0cac2018-04-20 15:46:21 +0100182 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Anthony Barbier2df1f992018-07-11 13:37:23 +0100183 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'])
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000184 arm_compute_validate_examples += [ prog ]
185 else:
186 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
Anthony Barbier2df1f992018-07-11 13:37:23 +0100187 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 Barbier979dc4f2018-03-07 09:27:48 +0000188 arm_compute_validate_examples += [ prog ]
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000189 arm_compute_validate_examples = install_bin(arm_compute_validate_examples)
Anthony Barbier2df1f992018-07-11 13:37:23 +0100190 Depends(arm_compute_validate_examples, arm_compute_validation_framework)
Anthony Barbier979dc4f2018-03-07 09:27:48 +0000191 Depends(arm_compute_validate_examples, arm_compute_test_framework)
192 Depends(arm_compute_validate_examples, arm_compute_lib)
193 Default(arm_compute_validate_examples)
194 Export('arm_compute_validate_examples')
195
Anthony Barbiere8a49832018-01-18 10:04:05 +0000196#FIXME: Remove before release!
Anthony Barbier6db0ff52018-01-05 10:59:12 +0000197if test_env['benchmark_examples']:
198 files_benchmark_examples = test_env.Object('benchmark_examples/RunExample.cpp')
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100199 graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100200 graph_params = test_env.Object(source="../utils/CommonGraphOptions.cpp", target="CommonGraphOptions")
Anthony Barbier3b6cdbb2018-09-14 11:58:05 +0100201 arm_compute_benchmark_examples = []
202 for examples_folder in [ "../examples", "../3rdparty/examples"]:
203 if test_env['neon']:
204 for file in Glob("%s/neon_*.cpp" % examples_folder):
205 example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0])
206 arm_compute_benchmark_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples) ]
207 if test_env['opencl']:
208 cl_examples = []
209 files = Glob("%s/cl_*.cpp" % examples_folder)
210 if test_env['neon']:
211 files += Glob("%s/neoncl_*.cpp" % examples_folder)
212 for file in files:
213 example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0])
214 cl_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples, LIBS = test_env["LIBS"]) ]
215 arm_compute_benchmark_examples += cl_examples
216
217 # Graph examples
218 for file in Glob("%s/graph_*.cpp" % examples_folder ):
219 example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0])
220 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
221 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'])
222 arm_compute_benchmark_examples += [ prog ]
223 else:
224 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
225 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'] )
226 arm_compute_benchmark_examples += [ prog ]
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000227 arm_compute_benchmark_examples = install_bin(arm_compute_benchmark_examples)
Anthony Barbier6db0ff52018-01-05 10:59:12 +0000228 Depends(arm_compute_benchmark_examples, arm_compute_test_framework)
229 Depends(arm_compute_benchmark_examples, arm_compute_lib)
230 Default(arm_compute_benchmark_examples)
231 Export('arm_compute_benchmark_examples')