ArmNN
NotReleased
GatordMockMain.cpp
Go to the documentation of this file.
1
//
2
// Copyright © 2019 Arm Ltd. All rights reserved.
3
// SPDX-License-Identifier: MIT
4
//
5
6
#include "../../../src/profiling/PacketVersionResolver.hpp"
7
#include "../../../src/profiling/PeriodicCounterSelectionCommandHandler.hpp"
8
#include "
CommandFileParser.hpp
"
9
#include "
CommandLineProcessor.hpp
"
10
#include "
DirectoryCaptureCommandHandler.hpp
"
11
#include "
GatordMockService.hpp
"
12
#include "
PeriodicCounterCaptureCommandHandler.hpp
"
13
#include "
PeriodicCounterSelectionResponseHandler.hpp
"
14
15
#include <iostream>
16
#include <string>
17
18
int
main
(
int
argc,
char
* argv[])
19
{
20
// Process command line arguments
21
armnn::gatordmock::CommandLineProcessor
cmdLine;
22
if
(!cmdLine.
ProcessCommandLine
(argc, argv))
23
{
24
return
EXIT_FAILURE;
25
}
26
27
armnn::profiling::PacketVersionResolver
packetVersionResolver;
28
// Create the Command Handler Registry
29
armnn::profiling::CommandHandlerRegistry
registry;
30
31
// This functor will receive back the selection response packet.
32
armnn::gatordmock::PeriodicCounterSelectionResponseHandler
periodicCounterSelectionResponseHandler(
33
0, 4, packetVersionResolver.
ResolvePacketVersion
(0, 4).
GetEncodedValue
());
34
// This functor will receive the counter data.
35
armnn::gatordmock::PeriodicCounterCaptureCommandHandler
counterCaptureCommandHandler(
36
3, 0, packetVersionResolver.
ResolvePacketVersion
(3, 0).
GetEncodedValue
());
37
38
armnn::profiling::DirectoryCaptureCommandHandler
directoryCaptureCommandHandler(
39
0, 2, packetVersionResolver.
ResolvePacketVersion
(0, 2).
GetEncodedValue
(),
false
);
40
41
// Register different derived functors
42
registry.
RegisterFunctor
(&periodicCounterSelectionResponseHandler);
43
registry.
RegisterFunctor
(&counterCaptureCommandHandler);
44
registry.
RegisterFunctor
(&directoryCaptureCommandHandler);
45
46
armnn::gatordmock::GatordMockService
mockService(registry, cmdLine.
IsEchoEnabled
());
47
48
if
(!mockService.OpenListeningSocket(cmdLine.
GetUdsNamespace
()))
49
{
50
return
EXIT_FAILURE;
51
}
52
std::cout <<
"Bound to UDS namespace: \\0"
<< cmdLine.
GetUdsNamespace
() << std::endl;
53
54
// Wait for a single connection.
55
if
(-1 == mockService.BlockForOneClient())
56
{
57
return
EXIT_FAILURE;
58
}
59
std::cout <<
"Client connection established."
<< std::endl;
60
61
// Send receive the strweam metadata and send connection ack.
62
if
(!mockService.WaitForStreamMetaData())
63
{
64
return
EXIT_FAILURE;
65
}
66
mockService.SendConnectionAck();
67
68
// Prepare to receive data.
69
mockService.LaunchReceivingThread();
70
71
// Process the SET and WAIT command from the file.
72
armnn::gatordmock::CommandFileParser
commandLineParser;
73
commandLineParser.
ParseFile
(cmdLine.
GetCommandFile
(), mockService);
74
75
// Once we've finished processing the file wait for the receiving thread to close.
76
mockService.WaitForReceivingThread();
77
78
return
EXIT_SUCCESS;
79
}
PeriodicCounterSelectionResponseHandler.hpp
main
int main(int argc, char *argv[])
Definition:
GatordMockMain.cpp:18
armnn::profiling::PacketVersionResolver::ResolvePacketVersion
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
Definition:
PacketVersionResolver.cpp:55
armnn::profiling::Version::GetEncodedValue
uint32_t GetEncodedValue()
Definition:
EncodeVersion.hpp:45
armnn::gatordmock::CommandFileParser
Definition:
CommandFileParser.hpp:22
DirectoryCaptureCommandHandler.hpp
GatordMockService.hpp
armnn::profiling::DirectoryCaptureCommandHandler
Definition:
DirectoryCaptureCommandHandler.hpp:33
armnn::gatordmock::PeriodicCounterSelectionResponseHandler
Definition:
PeriodicCounterSelectionResponseHandler.hpp:19
PeriodicCounterCaptureCommandHandler.hpp
CommandFileParser.hpp
armnn::gatordmock::CommandLineProcessor::ProcessCommandLine
bool ProcessCommandLine(int argc, char *argv[])
Definition:
CommandLineProcessor.cpp:16
armnn::gatordmock::CommandLineProcessor
Definition:
CommandLineProcessor.hpp:20
armnn::gatordmock::GatordMockService
Definition:
GatordMockService.hpp:37
armnn::profiling::CommandHandlerRegistry::RegisterFunctor
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)
Definition:
CommandHandlerRegistry.cpp:17
armnn::gatordmock::CommandLineProcessor::IsEchoEnabled
bool IsEchoEnabled()
Definition:
CommandLineProcessor.hpp:24
armnn::profiling::CommandHandlerRegistry
Definition:
CommandHandlerRegistry.hpp:32
CommandLineProcessor.hpp
armnn::gatordmock::CommandFileParser::ParseFile
void ParseFile(std::string CommandFile, GatordMockService &mockService)
Definition:
CommandFileParser.cpp:19
armnn::gatordmock::PeriodicCounterCaptureCommandHandler
Definition:
PeriodicCounterCaptureCommandHandler.hpp:26
armnn::gatordmock::CommandLineProcessor::GetCommandFile
std::string GetCommandFile()
Definition:
CommandLineProcessor.hpp:33
armnn::gatordmock::CommandLineProcessor::GetUdsNamespace
std::string GetUdsNamespace()
Definition:
CommandLineProcessor.hpp:29
armnn::profiling::PacketVersionResolver
Definition:
PacketVersionResolver.hpp:36
tests
profiling
gatordmock
GatordMockMain.cpp
Generated on Fri Mar 13 2020 16:06:59 for ArmNN by
1.8.13