Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | #include "Utils.h" |
| 27 | #include "ValidationProgramOptions.h" |
| 28 | #include "ValidationUserConfiguration.h" |
Moritz Pflanzer | d0ae8b8 | 2017-06-29 14:51:57 +0100 | [diff] [blame] | 29 | #include "support/ToolchainSupport.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 30 | #include "tests/AssetsLibrary.h" |
| 31 | #include "tests/Globals.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 32 | |
| 33 | #include "arm_compute/runtime/Scheduler.h" |
| 34 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 35 | #include "tests/validation_old/boost_wrapper.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 36 | |
| 37 | #include <iostream> |
| 38 | #include <memory> |
| 39 | #include <random> |
| 40 | |
| 41 | using namespace arm_compute::test; |
| 42 | using namespace arm_compute::test::validation; |
| 43 | |
| 44 | namespace arm_compute |
| 45 | { |
| 46 | namespace test |
| 47 | { |
| 48 | ValidationUserConfiguration user_config; |
Moritz Pflanzer | fb5aabb | 2017-07-18 14:39:55 +0100 | [diff] [blame] | 49 | std::unique_ptr<AssetsLibrary> library; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | } // namespace test |
| 51 | } // namespace arm_compute |
| 52 | |
| 53 | struct GlobalFixture |
| 54 | { |
| 55 | GlobalFixture() |
| 56 | { |
Moritz Pflanzer | fb5aabb | 2017-07-18 14:39:55 +0100 | [diff] [blame] | 57 | library = arm_compute::support::cpp14::make_unique<AssetsLibrary>(user_config.path.get(), user_config.seed); |
Georgios Pinitas | e5f8fd6 | 2017-06-23 18:03:44 +0100 | [diff] [blame] | 58 | std::cout << "Seed: " << library->seed() << "\n"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 59 | } |
| 60 | }; |
| 61 | |
| 62 | BOOST_GLOBAL_FIXTURE(GlobalFixture); |
| 63 | |
| 64 | bool 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 | } |