Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | 6da6a45 | 2020-07-14 14:26:27 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "IProfilingConnection.hpp" |
| 7 | |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 8 | #include <Runtime.hpp> |
Finn Williams | 9937f93 | 2020-04-29 12:00:24 +0100 | [diff] [blame] | 9 | #include <common/include/NetworkSockets.hpp> |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | namespace profiling |
| 16 | { |
| 17 | |
| 18 | class SocketProfilingConnection : public IProfilingConnection |
| 19 | { |
| 20 | public: |
| 21 | SocketProfilingConnection(); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 22 | bool IsOpen() const final; |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 23 | void Close() final; |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 24 | bool WritePacket(const unsigned char* buffer, uint32_t length) final; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 25 | arm::pipe::Packet ReadPacket(uint32_t timeout) final; |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 26 | |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 27 | private: |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 28 | |
| 29 | // Read a full packet from the socket. |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 30 | arm::pipe::Packet ReceivePacket(); |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 31 | |
Jim Flynn | 6da6a45 | 2020-07-14 14:26:27 +0100 | [diff] [blame] | 32 | #ifndef __APPLE__ |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 33 | // To indicate we want to use an abstract UDS ensure the first character of the address is 0. |
| 34 | const char* m_GatorNamespace = "\0gatord_namespace"; |
Jim Flynn | 6da6a45 | 2020-07-14 14:26:27 +0100 | [diff] [blame] | 35 | #else |
| 36 | // MACOSX does not support abstract UDS |
| 37 | const char* m_GatorNamespace = "/tmp/gatord_namespace"; |
| 38 | #endif |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 39 | arm::pipe::PollFd m_Socket[1]{}; |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | } // namespace profiling |
| 43 | } // namespace armnn |