blob: a6c02ed4ddef43314dea0157ba8dfda0edcd8d25 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#define BOOST_TEST_ALTERNATIVE_INIT_API
25
Moritz Pflanzerfb5aabb2017-07-18 14:39:55 +010026#include "AssetsLibrary.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "Globals.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "Utils.h"
29#include "ValidationProgramOptions.h"
30#include "ValidationUserConfiguration.h"
Moritz Pflanzerd0ae8b82017-06-29 14:51:57 +010031#include "support/ToolchainSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032
33#include "arm_compute/runtime/Scheduler.h"
34
35#include "boost_wrapper.h"
36
37#include <iostream>
38#include <memory>
39#include <random>
40
41using namespace arm_compute::test;
42using namespace arm_compute::test::validation;
43
44namespace arm_compute
45{
46namespace test
47{
48ValidationUserConfiguration user_config;
Moritz Pflanzerfb5aabb2017-07-18 14:39:55 +010049std::unique_ptr<AssetsLibrary> library;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050} // namespace test
51} // namespace arm_compute
52
53struct GlobalFixture
54{
55 GlobalFixture()
56 {
Moritz Pflanzerfb5aabb2017-07-18 14:39:55 +010057 library = arm_compute::support::cpp14::make_unique<AssetsLibrary>(user_config.path.get(), user_config.seed);
Georgios Pinitase5f8fd62017-06-23 18:03:44 +010058 std::cout << "Seed: " << library->seed() << "\n";
Anthony Barbier6ff3b192017-09-04 18:44:23 +010059 }
60};
61
62BOOST_GLOBAL_FIXTURE(GlobalFixture);
63
64bool init_unit_test()
65{
66 boost::unit_test::framework::master_test_suite().p_name.value = "Compute Library Validation Tests";
67
68 ValidationProgramOptions options;
69
70 int &argc = boost::unit_test::framework::master_test_suite().argc;
71 char **argv = boost::unit_test::framework::master_test_suite().argv;
72
73 try
74 {
75 options.parse_commandline(argc, argv);
76
77 if(options.wants_help())
78 {
79 std::cout << "Usage: " << argv[0] << " [options] PATH\n";
80 std::cout << options.get_help() << "\n";
81 return false;
82 }
83
84 user_config = ValidationUserConfiguration(options);
85 }
86 catch(const boost::program_options::required_option &err)
87 {
88 std::cerr << "Error: " << err.what() << "\n";
89 std::cout << "\nUsage: " << argv[0] << " [options] PATH\n";
90 std::cout << options.get_help() << "\n";
91 return false;
92 }
93
94 std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n";
95 arm_compute::Scheduler::get().set_num_threads(user_config.threads);
96 return true;
97}