aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2019-10-07 13:00:44 +0100
committerMichalis Spyrou <michalis.spyrou@arm.com>2019-12-20 14:04:51 +0000
commit748a7c81245ae81d04607b3a762cf65cd39026f2 (patch)
tree21ac8ad379989fde4aa73e6cf5814c6182f2c3d8
parent37cbc5781ac0aa5106941d0386070d6dc9958a2a (diff)
downloadComputeLibrary-748a7c81245ae81d04607b3a762cf65cd39026f2.tar.gz
COMPMID-2706: Add the ability to build bootcode for bare metal
Adds an option for providing a linker script and also adds the bootcode folder, it it exists, in the build path and links it with the executable binaries. Change-Id: I4119b21bdf1b4dd7fe38c4ee66741460666f53a1 Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/2051 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--SConscript14
-rw-r--r--SConstruct15
-rw-r--r--support/ToolchainSupport.h4
-rw-r--r--tests/SConscript38
-rw-r--r--tests/benchmark_examples/RunExample.cpp6
-rw-r--r--tests/validation/CPP/DetectionPostProcessLayer.cpp2
-rw-r--r--tests/validation/NEON/DetectionPostProcessLayer.cpp2
-rw-r--r--tests/validation/reference/ElementWiseUnary.cpp2
8 files changed, 68 insertions, 15 deletions
diff --git a/SConscript b/SConscript
index 0b7729cced..66dfff4511 100644
--- a/SConscript
+++ b/SConscript
@@ -31,6 +31,14 @@ Import('env')
Import('vars')
Import('install_lib')
+def build_bootcode_objs(sources):
+
+ arm_compute_env.Append(ASFLAGS = "-I bootcode/")
+ obj = arm_compute_env.Object(sources)
+ obj = install_lib(obj)
+ Default(obj)
+ return obj
+
def build_library(name, sources, static=False, libs=[]):
if static:
obj = arm_compute_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
@@ -240,6 +248,12 @@ if env['gles_compute']:
graph_files += Glob('src/graph/backends/GLES/*.cpp')
+bootcode_o = []
+if env['os'] == 'bare_metal':
+ bootcode_files = Glob('bootcode/*.s')
+ bootcode_o = build_bootcode_objs(bootcode_files)
+Export('bootcode_o')
+
arm_compute_core_a = build_library('arm_compute_core-static', core_files, static=True)
Export('arm_compute_core_a')
diff --git a/SConstruct b/SConstruct
index 216920f059..139c0e568a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -59,6 +59,7 @@ vars.AddVariables(
PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept),
PathVariable("install_dir", "Specify sub-folder for the install", "", PathVariable.PathAccept),
BoolVariable("exceptions", "Enable/disable C++ exception support", True),
+ PathVariable("linker_script", "Use an external linker script", "", PathVariable.PathAccept),
#FIXME Remove before release (And remove all references to INTERNAL_ONLY)
BoolVariable("internal_only", "Enable ARM internal only tests", False),
("toolchain_prefix", "Override the toolchain prefix", ""),
@@ -105,6 +106,10 @@ Export('install_bin')
Help(vars.GenerateHelpText(env))
+if env['linker_script'] and env['os'] != 'bare_metal':
+ print("Linker script is only supported for bare_metal builds")
+ Exit(1)
+
if env['build'] == "embed_only":
SConscript('./SConscript', variant_dir=build_path, duplicate=0)
Return()
@@ -330,8 +335,14 @@ if env['gles_compute'] and env['os'] != 'android':
SConscript('./SConscript', variant_dir=build_path, duplicate=0)
-if env['examples'] and env['os'] != 'bare_metal' and env['exceptions']:
+if env['examples'] and env['exceptions']:
+ if env['os'] == 'bare_metal' and env['arch'] == 'armv7a':
+ print("Building examples for bare metal and armv7a is not supported. Use examples=0.")
+ Exit(1)
SConscript('./examples/SConscript', variant_dir='%s/examples' % build_path, duplicate=0)
-if env['os'] != 'bare_metal' and env['exceptions']:
+if env['exceptions']:
+ if env['os'] == 'bare_metal' and env['arch'] == 'armv7a':
+ print("WARNING: Building tests for bare metal and armv7a is not supported")
+ Return()
SConscript('./tests/SConscript', variant_dir='%s/tests' % build_path, duplicate=0)
diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h
index deaded34f3..f90d65c9d9 100644
--- a/support/ToolchainSupport.h
+++ b/support/ToolchainSupport.h
@@ -155,7 +155,7 @@ inline std::string to_string(T && value)
template <typename T>
inline T nearbyint(T value)
{
- return ::nearbyint(value);
+ return static_cast<T>(::nearbyint(value));
}
/** Convert string values to float.
@@ -286,7 +286,7 @@ inline std::string to_string(T &&value)
template <typename T>
inline T nearbyint(T value)
{
- return std::nearbyint(value);
+ return static_cast<T>(std::nearbyint(value));
}
/** Convert string values to float.
diff --git a/tests/SConscript b/tests/SConscript
index 663216906f..0c56a7475c 100644
--- a/tests/SConscript
+++ b/tests/SConscript
@@ -73,6 +73,9 @@ else:
test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"])
arm_compute_lib = arm_compute_graph_so
+if env['os'] in ['bare_metal']:
+ Import("bootcode_o")
+
#FIXME Delete before release
if env['internal_only']:
test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
@@ -121,8 +124,14 @@ if env['neon']:
if env['internal_only']:
files_benchmark += Glob('../3rdparty/tests/benchmark/NEON/' + filter_pattern)
- files_validation += Glob('validation/NEON/*/' + filter_pattern)
files_validation += Glob('validation/NEON/' + filter_pattern)
+ if env['os'] == 'bare_metal':
+ files_validation += Glob('validation/NEON/UNIT/MemoryManager.cpp' + filter_pattern)
+ files_validation += Glob('validation/NEON/UNIT/DynamicTensor.cpp' + filter_pattern)
+ files_validation += Glob('validation/NEON/UNIT/TensorAllocator.cpp' + filter_pattern)
+ else:
+ files_validation += Glob('validation/NEON/*/' + filter_pattern)
+
if env['gles_compute']:
test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
@@ -146,12 +155,22 @@ if test_env['benchmark_tests']:
Default(arm_compute_benchmark)
Export('arm_compute_benchmark')
+bm_link_flags = []
+if test_env['linker_script']:
+ bm_link_flags = ['-Wl,--build-id=none', '-T', env['linker_script']]
+
if test_env['validation_tests']:
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])
Depends(arm_compute_validation_framework , arm_compute_test_framework)
Depends(arm_compute_validation_framework , arm_compute_core_a)
- arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects, LIBS=[arm_compute_validation_framework] + test_env['LIBS'])
+ program_objects = files_validation + common_objects
+ if test_env['os'] == 'bare_metal':
+ Depends(arm_compute_validation_framework , bootcode_o)
+ program_objects += bootcode_o
+
+
+ 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)
arm_compute_validation = install_bin(arm_compute_validation)
Depends(arm_compute_validation, arm_compute_validation_framework)
Depends(arm_compute_validation, arm_compute_test_framework)
@@ -162,11 +181,14 @@ if test_env['validation_tests']:
if test_env['validate_examples']:
files_validate_examples = [ test_env.Object('validate_examples/RunExample.cpp') ] + [ x for x in common_objects if not "main.o" in str(x)]
+ if test_env['os'] == 'bare_metal':
+ files_validate_examples += bootcode_o
+
arm_compute_validate_examples = []
if test_env['neon']:
for file in Glob("validate_examples/neon_*.cpp"):
example = "validate_" + os.path.basename(os.path.splitext(str(file))[0])
- arm_compute_validate_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_validate_examples, LIBS = [ arm_compute_validation_framework]) ]
+ 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) ]
if test_env['opencl']:
cl_examples = []
files = Glob("validate_examples/cl_*.cpp")
@@ -181,7 +203,7 @@ if test_env['validation_tests']:
for file in Glob("validate_examples/graph_*.cpp"):
example = "validate_" + os.path.basename(os.path.splitext(str(file))[0])
if env['os'] in ['android', 'bare_metal'] or env['standalone']:
- 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'])
+ 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)
arm_compute_validate_examples += [ prog ]
else:
#-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
@@ -196,6 +218,8 @@ if test_env['validation_tests']:
if test_env['benchmark_examples']:
files_benchmark_examples = test_env.Object('benchmark_examples/RunExample.cpp')
+ if test_env['os'] == 'bare_metal':
+ files_benchmark_examples += bootcode_o
graph_utils = test_env.Object(source="../utils/GraphUtils.cpp", target="GraphUtils")
graph_params = test_env.Object(source="../utils/CommonGraphOptions.cpp", target="CommonGraphOptions")
arm_compute_benchmark_examples = []
@@ -203,7 +227,7 @@ if test_env['benchmark_examples']:
if test_env['neon']:
for file in Glob("%s/neon_*.cpp" % examples_folder):
example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0])
- arm_compute_benchmark_examples += [ test_env.Program(example, [ test_env.Object(source=file, target=example) ] + files_benchmark_examples) ]
+ 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) ]
if test_env['opencl']:
cl_examples = []
files = Glob("%s/cl_*.cpp" % examples_folder)
@@ -228,11 +252,11 @@ if test_env['benchmark_examples']:
for file in Glob("%s/graph_*.cpp" % examples_folder ):
example = "benchmark_" + os.path.basename(os.path.splitext(str(file))[0])
if env['os'] in ['android', 'bare_metal'] or env['standalone']:
- 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'])
+ 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)
arm_compute_benchmark_examples += [ prog ]
else:
#-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
- 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'] )
+ 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'])
arm_compute_benchmark_examples += [ prog ]
arm_compute_benchmark_examples = install_bin(arm_compute_benchmark_examples)
Depends(arm_compute_benchmark_examples, arm_compute_test_framework)
diff --git a/tests/benchmark_examples/RunExample.cpp b/tests/benchmark_examples/RunExample.cpp
index 5c9dd7136e..f3de308bef 100644
--- a/tests/benchmark_examples/RunExample.cpp
+++ b/tests/benchmark_examples/RunExample.cpp
@@ -163,8 +163,12 @@ int run_example(int argc, char **argv, std::unique_ptr<Example> example)
}
framework.set_throw_errors(options.throw_errors->value());
arm_compute::test::framework::detail::TestSuiteRegistrar suite{ "Examples" };
- framework.add_test_case<ExampleTest>(basename(argv[0]), framework::DatasetMode::ALL, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE);
+#ifdef BARE_METAL
+ framework.add_test_case<ExampleTest>(argv[0], framework::DatasetMode::ALL, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE);
+#else /* BARE_METAL */
+ framework.add_test_case<ExampleTest>(basename(argv[0]), framework::DatasetMode::ALL, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE);
+#endif /* BARE_METAL */
//func(argc, argv);
bool success = framework.run();
if(options.log_level->value() > framework::LogLevel::NONE)
diff --git a/tests/validation/CPP/DetectionPostProcessLayer.cpp b/tests/validation/CPP/DetectionPostProcessLayer.cpp
index 51f3452b3d..f4528fb593 100644
--- a/tests/validation/CPP/DetectionPostProcessLayer.cpp
+++ b/tests/validation/CPP/DetectionPostProcessLayer.cpp
@@ -89,7 +89,7 @@ inline QuantizationInfo qinfo_scaleoffset_from_minmax(const float min, const flo
}
else
{
- uint8_offset = static_cast<uint8_t>(std::round(f_offset));
+ uint8_offset = static_cast<uint8_t>(arm_compute::support::cpp11::round(f_offset));
}
offset = uint8_offset;
}
diff --git a/tests/validation/NEON/DetectionPostProcessLayer.cpp b/tests/validation/NEON/DetectionPostProcessLayer.cpp
index f479a13b4b..4413ed470f 100644
--- a/tests/validation/NEON/DetectionPostProcessLayer.cpp
+++ b/tests/validation/NEON/DetectionPostProcessLayer.cpp
@@ -89,7 +89,7 @@ inline QuantizationInfo qinfo_scaleoffset_from_minmax(const float min, const flo
}
else
{
- uint8_offset = static_cast<uint8_t>(std::round(f_offset));
+ uint8_offset = static_cast<uint8_t>(support::cpp11::round(f_offset));
}
offset = uint8_offset;
}
diff --git a/tests/validation/reference/ElementWiseUnary.cpp b/tests/validation/reference/ElementWiseUnary.cpp
index 06beb2ac09..eaaaa4ec1e 100644
--- a/tests/validation/reference/ElementWiseUnary.cpp
+++ b/tests/validation/reference/ElementWiseUnary.cpp
@@ -59,7 +59,7 @@ SimpleTensor<T> elementwise_unary(const SimpleTensor<T> &src, ElementWiseUnary o
dst[i] = std::sin(src[i]);
break;
case ElementWiseUnary::ROUND:
- dst[i] = std::nearbyint(src[i]);
+ dst[i] = arm_compute::support::cpp11::nearbyint(src[i]);
break;
default:
ARM_COMPUTE_ERROR("Not implemented");