diff options
-rw-r--r-- | CMakeLists.txt | 19 | ||||
-rw-r--r-- | cmake/GlobalConfig.cmake | 1 | ||||
-rw-r--r-- | tests/profiling/CommandLineProcessor.cpp | 59 | ||||
-rw-r--r-- | tests/profiling/CommandLineProcessor.hpp | 25 | ||||
-rw-r--r-- | tests/profiling/GatordMockMain.cpp | 18 |
5 files changed, 122 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ef87c6d1fc..b29a709643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -818,3 +818,22 @@ if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD ${Boost_PROGRAM_OPTIONS_LIBRARY}) addDllCopyCommands(ArmnnConverter) endif() + +if(BUILD_GATORD_MOCK) + set(gatord_mock_sources) + list(APPEND gatord_mock_sources + tests/profiling/GatordMockMain.cpp + tests/profiling/CommandLineProcessor.hpp + tests/profiling/CommandLineProcessor.cpp + ) + + include_directories( ${Boost_INCLUDE_DIRS} ) + + add_executable_ex(GartordMock ${gatord_mock_sources}) + + target_link_libraries(GartordMock + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ) + +endif() + diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake index 9c59abfe8c..4880d591ab 100644 --- a/cmake/GlobalConfig.cmake +++ b/cmake/GlobalConfig.cmake @@ -21,6 +21,7 @@ option(FLATC_DIR "Path to Flatbuffers compiler" OFF) option(TF_LITE_GENERATED_PATH "Tensorflow lite generated C++ schema location" OFF) option(FLATBUFFERS_ROOT "Location where the flatbuffers 'include' and 'lib' folders to be found" Off) option(DYNAMIC_BACKEND_PATHS "Colon seperated list of paths where to load the dynamic backends from" "") +option(BUILD_GATORD_MOCK "Build the Gatord simulator for external profiling testing." OFF) include(SelectLibraryConfigurations) diff --git a/tests/profiling/CommandLineProcessor.cpp b/tests/profiling/CommandLineProcessor.cpp new file mode 100644 index 0000000000..6affbbe2b8 --- /dev/null +++ b/tests/profiling/CommandLineProcessor.cpp @@ -0,0 +1,59 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommandLineProcessor.hpp" + +#include <boost/program_options.hpp> + +#include <iostream> + +namespace armnn +{ +namespace gatordmock +{ + +bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[]) +{ + namespace po = boost::program_options; + + po::options_description desc("Options"); + try + { + desc.add_options()("help,h", "Display help messages"); + } + catch (const std::exception& e) + { + std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl; + return false; + } + + po::variables_map vm; + try + { + po::store(po::parse_command_line(argc, argv, desc), vm); + + if (vm.count("help") || argc <= 1) + { + std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl; + std::cout << std::endl; + std::cout << desc << std::endl; + return false; + } + + po::notify(vm); + } + catch (const po::error& e) + { + std::cerr << e.what() << std::endl << std::endl; + std::cerr << desc << std::endl; + return false; + } + + return true; +} + +} // namespace gatordmock + +} // namespace armnn
\ No newline at end of file diff --git a/tests/profiling/CommandLineProcessor.hpp b/tests/profiling/CommandLineProcessor.hpp new file mode 100644 index 0000000000..441d7cddd9 --- /dev/null +++ b/tests/profiling/CommandLineProcessor.hpp @@ -0,0 +1,25 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// +#pragma once + +namespace armnn +{ + +namespace gatordmock +{ + +// Parses the command line to extract: +// + +class CommandLineProcessor +{ +public: + bool ProcessCommandLine(int argc, char *argv[]); + +}; + +} // namespace gatordmock + +} // namespace armnn diff --git a/tests/profiling/GatordMockMain.cpp b/tests/profiling/GatordMockMain.cpp new file mode 100644 index 0000000000..91fa907795 --- /dev/null +++ b/tests/profiling/GatordMockMain.cpp @@ -0,0 +1,18 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommandLineProcessor.hpp" + +#include <cstdlib> + +int main(int argc, char *argv[]) +{ + armnn::gatordmock::CommandLineProcessor cmdline; + if (!cmdline.ProcessCommandLine(argc, argv)) + { + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} |