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 | |
| 28 | # vars is imported from arm_compute: |
| 29 | variables = [ |
| 30 | #FIXME Remove before release (And remove all references to INTERNAL_ONLY) |
| 31 | BoolVariable("internal_only", "Enable ARM internal only tests", True), |
| 32 | BoolVariable("pmu", "Enable PMU counters", False), |
| 33 | BoolVariable("validation_tests", "Build validation test programs", True), |
Anthony Barbier | 79c6178 | 2017-06-23 11:48:24 +0100 | [diff] [blame] | 34 | BoolVariable("benchmark_tests", "Build benchmark test programs", True) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | ] |
| 36 | |
| 37 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 38 | new_options = Variables('scons') |
| 39 | |
| 40 | for v in variables: |
| 41 | new_options.Add(v) |
| 42 | vars.Add(v) |
| 43 | |
| 44 | # Clone the environment to make sure we're not polluting the arm_compute one: |
| 45 | common_env = env.Clone() |
| 46 | vars.Update(common_env) |
| 47 | |
| 48 | Help(new_options.GenerateHelpText(common_env)) |
| 49 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 50 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 51 | Import('arm_compute_a') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 52 | common_env.Append(LIBS = [arm_compute_a]) |
| 53 | arm_compute_lib = arm_compute_a |
| 54 | else: |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 55 | Import('arm_compute_so') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 56 | common_env.Append(LIBS = ["arm_compute"]) |
| 57 | arm_compute_lib = arm_compute_so |
| 58 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 59 | #FIXME Delete before release |
| 60 | if common_env['internal_only']: |
| 61 | common_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
| 62 | |
| 63 | common_env.Append(CPPPATH = [".", "#3rdparty/include"]) |
| 64 | common_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 65 | common_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
| 66 | common_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
| 67 | common_env.Append(LIBS = ['boost_program_options']) |
| 68 | common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) |
| 69 | |
| 70 | validation_env = common_env.Clone() |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 71 | |
| 72 | validation_env.Append(CPPDEFINES=['BOOST']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 73 | |
| 74 | files = Glob('*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 75 | files = [f for f in files if "DatasetManager" not in os.path.basename(str(f))] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 76 | |
| 77 | common_objects = [ common_env.StaticObject( f ) for f in files ] |
| 78 | |
| 79 | validation_env.Append(LIBS = ['boost_unit_test_framework']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 80 | |
| 81 | files_validation = Glob('validation/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 82 | |
| 83 | # Add unit tests |
| 84 | files_validation += Glob('validation/UNIT/*.cpp') |
| 85 | files_validation += Glob('validation/UNIT/*/*.cpp') |
| 86 | |
| 87 | if env['opencl']: |
| 88 | Import('opencl') |
| 89 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 90 | files_validation += Glob('validation/CL/*.cpp') |
| 91 | files_validation += Glob('validation/CL/*/*.cpp') |
| 92 | files_validation += Glob('validation/system_tests/CL/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 93 | |
| 94 | validation_env.Append(LIBS = "OpenCL") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 95 | |
| 96 | if env['neon']: |
| 97 | files_validation += Glob('validation/NEON/*.cpp') |
| 98 | files_validation += Glob('validation/NEON/*/*.cpp') |
| 99 | files_validation += Glob('validation/system_tests/NEON/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 100 | |
| 101 | if env['os'] == 'android': |
| 102 | validation_env.Append(LIBS = ["log"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 103 | |
| 104 | if common_env['validation_tests']: |
| 105 | arm_compute_validation = validation_env.Program('arm_compute_validation', |
| 106 | files_validation + common_objects) |
| 107 | Depends(arm_compute_validation, arm_compute_lib) |
| 108 | if env['opencl']: |
| 109 | Depends(arm_compute_validation, opencl) |
| 110 | Default(arm_compute_validation) |
| 111 | Export('arm_compute_validation') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 112 | |
| 113 | ####################################################################### |
| 114 | # Using new framework |
| 115 | ####################################################################### |
| 116 | |
| 117 | # Clone the environment to make sure we're not polluting the arm_compute one: |
| 118 | benchmark_env = env.Clone() |
| 119 | # Workaround to build both test systems in parallel |
| 120 | benchmark_env.VariantDir("new", ".", duplicate=0) |
| 121 | |
| 122 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 123 | Import("arm_compute_a") |
| 124 | benchmark_env.Append(LIBS = [arm_compute_a]) |
| 125 | arm_compute_lib = arm_compute_a |
| 126 | else: |
| 127 | Import('arm_compute_so') |
| 128 | benchmark_env.Append(LIBS = ["arm_compute"]) |
| 129 | arm_compute_lib = arm_compute_so |
| 130 | |
| 131 | #FIXME Delete before release |
| 132 | if common_env['internal_only']: |
| 133 | benchmark_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
| 134 | |
| 135 | benchmark_env.Append(CPPPATH = [".", "#3rdparty/include"]) |
| 136 | benchmark_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 137 | benchmark_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
| 138 | benchmark_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']]) |
| 139 | benchmark_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
| 140 | |
| 141 | Import("arm_compute_test_framework") |
| 142 | benchmark_env.Append(LIBS = ['arm_compute_test_framework']) |
| 143 | |
| 144 | files_benchmark = Glob('new/DatasetManager.cpp') |
| 145 | files_benchmark += Glob('new/TensorLibrary.cpp') |
| 146 | files_benchmark += Glob('new/RawTensor.cpp') |
| 147 | files_benchmark += Glob('new/benchmark_new/*.cpp') |
| 148 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 149 | if env['opencl']: |
| 150 | Import('opencl') |
| 151 | |
Anthony Barbier | 15d5ac8 | 2017-07-17 15:22:17 +0100 | [diff] [blame] | 152 | benchmark_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 153 | |
| 154 | files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp') |
| 155 | files_benchmark += Glob('new/benchmark_new/CL/*.cpp') |
| 156 | |
| 157 | benchmark_env.Append(LIBS = "OpenCL") |
| 158 | |
| 159 | if env['neon']: |
| 160 | files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp') |
| 161 | files_benchmark += Glob('new/benchmark_new/NEON/*.cpp') |
| 162 | |
| 163 | if env['os'] == 'android': |
| 164 | benchmark_env.Append(LIBS = ["log"]) |
| 165 | else: |
| 166 | benchmark_env.Append(LIBS = ["rt"]) |
| 167 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 168 | if common_env['benchmark_tests']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 169 | arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark', files_benchmark) |
| 170 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 171 | Depends(arm_compute_benchmark, arm_compute_lib) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 172 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 173 | if env['opencl']: |
| 174 | Depends(arm_compute_benchmark, opencl) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 175 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 176 | Default(arm_compute_benchmark) |
| 177 | Export('arm_compute_benchmark') |