IVGCVSW-6710 Add compile of BareMetalDeserializedGraph sample

Change-Id: Ice69c2a22f589f68d302f80500dfe4e514a796d2
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/profiling/client/src/BufferManager.cpp b/profiling/client/src/BufferManager.cpp
index 42e3200..592d374 100644
--- a/profiling/client/src/BufferManager.cpp
+++ b/profiling/client/src/BufferManager.cpp
@@ -24,19 +24,25 @@
 IPacketBufferPtr BufferManager::Reserve(unsigned int requestedSize, unsigned int& reservedSize)
 {
     reservedSize = 0;
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> availableListLock(m_AvailableMutex, std::defer_lock);
+#endif
     if (requestedSize > m_MaxBufferSize)
     {
         return nullptr;
     }
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.lock();
+#endif
     if (m_AvailableList.empty())
     {
         if (m_CurrentNumberOfBuffers < m_MaxNumberOfBuffers)
         {
             // create a temporary overflow/surge buffer and hand it back
             m_CurrentNumberOfBuffers++;
+#if !defined(ARMNN_DISABLE_THREADS)
             availableListLock.unlock();
+#endif
             IPacketBufferPtr buffer = std::make_unique<PacketBuffer>(m_MaxBufferSize);
             reservedSize = requestedSize;
             return buffer;
@@ -44,25 +50,34 @@
         else
         {
             // we have totally busted the limit. call a halt to new memory allocations.
+#if !defined(ARMNN_DISABLE_THREADS)
             availableListLock.unlock();
+#endif
             return nullptr;
         }
     }
     IPacketBufferPtr buffer = std::move(m_AvailableList.back());
     m_AvailableList.pop_back();
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.unlock();
+#endif
     reservedSize = requestedSize;
     return buffer;
 }
 
 void BufferManager::Commit(IPacketBufferPtr& packetBuffer, unsigned int size, bool notifyConsumer)
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> readableListLock(m_ReadableMutex, std::defer_lock);
+#endif
     packetBuffer->Commit(size);
+#if !defined(ARMNN_DISABLE_THREADS)
     readableListLock.lock();
+#endif
     m_ReadableList.push(std::move(packetBuffer));
+#if !defined(ARMNN_DISABLE_THREADS)
     readableListLock.unlock();
-
+#endif
     if (notifyConsumer)
     {
         FlushReadList();
@@ -82,9 +97,13 @@
 
 void BufferManager::Release(IPacketBufferPtr& packetBuffer)
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> availableListLock(m_AvailableMutex, std::defer_lock);
+#endif
     packetBuffer->Release();
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.lock();
+#endif
     if (m_AvailableList.size() <= m_NumberOfBuffers)
     {
         m_AvailableList.push_back(std::move(packetBuffer));
@@ -98,14 +117,18 @@
             --m_CurrentNumberOfBuffers;
         }
     }
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.unlock();
+#endif
 }
 
 void BufferManager::Reset()
 {
     //This method should only be called once all threads have been joined
+#if !defined(ARMNN_DISABLE_THREADS)
     std::lock_guard<std::mutex> readableListLock(m_ReadableMutex);
     std::lock_guard<std::mutex> availableListLock(m_AvailableMutex);
+#endif
 
     m_AvailableList.clear();
     std::queue<IPacketBufferPtr>().swap(m_ReadableList);
@@ -115,12 +138,16 @@
 
 IPacketBufferPtr BufferManager::GetReadableBuffer()
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> readableListLock(m_ReadableMutex);
+#endif
     if (!m_ReadableList.empty())
     {
         IPacketBufferPtr buffer = std::move(m_ReadableList.front());
         m_ReadableList.pop();
+#if !defined(ARMNN_DISABLE_THREADS)
         readableListLock.unlock();
+#endif
         return buffer;
     }
     return nullptr;
@@ -128,9 +155,13 @@
 
 void BufferManager::MarkRead(IPacketBufferPtr& packetBuffer)
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> availableListLock(m_AvailableMutex, std::defer_lock);
+#endif
     packetBuffer->MarkRead();
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.lock();
+#endif
     if (m_AvailableList.size() <= m_NumberOfBuffers)
     {
         m_AvailableList.push_back(std::move(packetBuffer));
@@ -144,7 +175,9 @@
             --m_CurrentNumberOfBuffers;
         }
     }
+#if !defined(ARMNN_DISABLE_THREADS)
     availableListLock.unlock();
+#endif
 }
 
 void BufferManager::SetConsumer(IConsumer* consumer)
diff --git a/profiling/client/src/BufferManager.hpp b/profiling/client/src/BufferManager.hpp
index 0ab3e0e..548edec 100644
--- a/profiling/client/src/BufferManager.hpp
+++ b/profiling/client/src/BufferManager.hpp
@@ -8,8 +8,10 @@
 #include "IBufferManager.hpp"
 #include "IConsumer.hpp"
 
-#include <condition_variable>
+#if !defined(ARMNN_DISABLE_THREADS)
 #include <mutex>
+#endif
+
 #include <vector>
 #include <queue>
 
@@ -61,11 +63,13 @@
     // List of readable packet buffers
     std::queue<IPacketBufferPtr> m_ReadableList;
 
+#if !defined(ARMNN_DISABLE_THREADS)
     // Mutex for available packet buffer list
     std::mutex m_AvailableMutex;
 
     // Mutex for readable packet buffer list
     std::mutex m_ReadableMutex;
+#endif
 
     // Consumer thread to notify packet is ready to read
     IConsumer* m_Consumer = nullptr;
diff --git a/profiling/client/src/CommandHandler.cpp b/profiling/client/src/CommandHandler.cpp
index 6ba49c2..b5a7551 100644
--- a/profiling/client/src/CommandHandler.cpp
+++ b/profiling/client/src/CommandHandler.cpp
@@ -8,6 +8,10 @@
 
 #include <common/include/Logging.hpp>
 
+#if defined(ARMNN_DISABLE_THREADS)
+#include <common/include/IgnoreUnused.hpp>
+#endif
+
 namespace arm
 {
 
@@ -21,24 +25,32 @@
         return;
     }
 
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_CommandThread.joinable())
     {
         m_CommandThread.join();
     }
+#endif
 
     m_IsRunning.store(true);
     m_KeepRunning.store(true);
+#if !defined(ARMNN_DISABLE_THREADS)
     m_CommandThread = std::thread(&CommandHandler::HandleCommands, this, std::ref(profilingConnection));
+#else
+    IgnoreUnused(profilingConnection);
+#endif
 }
 
 void CommandHandler::Stop()
 {
     m_KeepRunning.store(false);
 
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_CommandThread.joinable())
     {
         m_CommandThread.join();
     }
+#endif
 }
 
 void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
diff --git a/profiling/client/src/CommandHandler.hpp b/profiling/client/src/CommandHandler.hpp
index b097f9e..bc0461f 100644
--- a/profiling/client/src/CommandHandler.hpp
+++ b/profiling/client/src/CommandHandler.hpp
@@ -11,7 +11,9 @@
 #include <common/include/CommandHandlerRegistry.hpp>
 
 #include <atomic>
+#if !defined(ARMNN_DISABLE_THREADS)
 #include <thread>
+#endif
 
 namespace arm
 {
@@ -30,7 +32,9 @@
           m_StopAfterTimeout(stopAfterTimeout),
           m_IsRunning(false),
           m_KeepRunning(false),
+#if !defined(ARMNN_DISABLE_THREADS)
           m_CommandThread(),
+#endif
           m_CommandHandlerRegistry(commandHandlerRegistry),
           m_PacketVersionResolver(packetVersionResolver)
     {}
@@ -38,7 +42,6 @@
 
     void SetTimeout(uint32_t timeout) { m_Timeout.store(timeout); }
     void SetStopAfterTimeout(bool stopAfterTimeout) { m_StopAfterTimeout.store(stopAfterTimeout); }
-
     void Start(IProfilingConnection& profilingConnection);
     void Stop();
     bool IsRunning() const { return m_IsRunning.load(); }
@@ -50,7 +53,9 @@
     std::atomic<bool>     m_StopAfterTimeout;
     std::atomic<bool>     m_IsRunning;
     std::atomic<bool>     m_KeepRunning;
+#if !defined(ARMNN_DISABLE_THREADS)
     std::thread           m_CommandThread;
+#endif
 
     arm::pipe::CommandHandlerRegistry& m_CommandHandlerRegistry;
     arm::pipe::PacketVersionResolver&  m_PacketVersionResolver;
diff --git a/profiling/client/src/FileOnlyProfilingConnection.cpp b/profiling/client/src/FileOnlyProfilingConnection.cpp
index bee2c62..01ea3a2 100644
--- a/profiling/client/src/FileOnlyProfilingConnection.cpp
+++ b/profiling/client/src/FileOnlyProfilingConnection.cpp
@@ -11,7 +11,10 @@
 
 #include <algorithm>
 #include <iostream>
-#include <thread>
+
+#if defined(ARMNN_DISABLE_THREADS)
+#include <common/include/IgnoreUnused.hpp>
+#endif
 
 namespace arm
 {
@@ -97,12 +100,14 @@
     }
     // dispose of the processing thread
     m_KeepRunning.store(false);
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_LocalHandlersThread.joinable())
     {
         // make sure the thread wakes up and sees it has to stop
         m_ConditionPacketReadable.notify_one();
         m_LocalHandlersThread.join();
     }
+#endif
 }
 
 bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length)
@@ -116,14 +121,19 @@
 void FileOnlyProfilingConnection::ReturnPacket(arm::pipe::Packet& packet)
 {
     {
+#if !defined(ARMNN_DISABLE_THREADS)
         std::lock_guard<std::mutex> lck(m_PacketAvailableMutex);
+#endif
         m_PacketQueue.push(std::move(packet));
     }
+#if !defined(ARMNN_DISABLE_THREADS)
     m_ConditionPacketAvailable.notify_one();
+#endif
 }
 
 arm::pipe::Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout)
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> lck(m_PacketAvailableMutex);
 
     // Here we are using m_PacketQueue.empty() as a predicate variable
@@ -135,6 +145,9 @@
         arm::pipe::Packet empty;
         return empty;
     }
+#else
+    IgnoreUnused(timeout);
+#endif
 
     arm::pipe::Packet returnedPacket = std::move(m_PacketQueue.front());
     m_PacketQueue.pop();
@@ -188,13 +201,17 @@
         return;
     }
     // make sure if there was one running before it is joined
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_LocalHandlersThread.joinable())
     {
         m_LocalHandlersThread.join();
     }
+#endif
     m_IsRunning.store(true);
     m_KeepRunning.store(true);
+#if !defined(ARMNN_DISABLE_THREADS)
     m_LocalHandlersThread = std::thread(&FileOnlyProfilingConnection::ServiceLocalHandlers, this);
+#endif
 }
 
 void FileOnlyProfilingConnection::ForwardPacketToHandlers(arm::pipe::Packet& packet)
@@ -208,14 +225,18 @@
         return;
     }
     {
+#if !defined(ARMNN_DISABLE_THREADS)
         std::unique_lock<std::mutex> readableListLock(m_ReadableMutex);
+#endif
         if (!m_KeepRunning.load())
         {
             return;
         }
         m_ReadableList.push(std::move(packet));
     }
+#if !defined(ARMNN_DISABLE_THREADS)
     m_ConditionPacketReadable.notify_one();
+#endif
 }
 
 void FileOnlyProfilingConnection::ServiceLocalHandlers()
@@ -225,17 +246,23 @@
         arm::pipe::Packet returnedPacket;
         bool readPacket = false;
         {   // only lock while we are taking the packet off the incoming list
+#if !defined(ARMNN_DISABLE_THREADS)
             std::unique_lock<std::mutex> lck(m_ReadableMutex);
+#endif
             if (m_Timeout < 0)
             {
+#if !defined(ARMNN_DISABLE_THREADS)
                 m_ConditionPacketReadable.wait(lck,
                                                [&] { return !m_ReadableList.empty(); });
+#endif
             }
             else
             {
+#if !defined(ARMNN_DISABLE_THREADS)
                 m_ConditionPacketReadable.wait_for(lck,
                                                    std::chrono::milliseconds(std::max(m_Timeout, 1000)),
                                                    [&] { return !m_ReadableList.empty(); });
+#endif
             }
             if (m_KeepRunning.load())
             {
diff --git a/profiling/client/src/FileOnlyProfilingConnection.hpp b/profiling/client/src/FileOnlyProfilingConnection.hpp
index c7e60f5..9ecbd6c 100644
--- a/profiling/client/src/FileOnlyProfilingConnection.hpp
+++ b/profiling/client/src/FileOnlyProfilingConnection.hpp
@@ -17,12 +17,15 @@
 #include <server/include/timelineDecoder/DirectoryCaptureCommandHandler.hpp>
 
 #include <atomic>
-#include <condition_variable>
 #include <fstream>
 #include <map>
-#include <mutex>
 #include <queue>
+
+#if !defined(ARMNN_DISABLE_THREADS)
+#include <condition_variable>
+#include <mutex>
 #include <thread>
+#endif
 
 namespace arm
 {
@@ -111,8 +114,10 @@
     std::queue<arm::pipe::Packet> m_PacketQueue;
     TargetEndianness m_Endianness;
 
+#if !defined(ARMNN_DISABLE_THREADS)
     std::mutex m_PacketAvailableMutex;
     std::condition_variable m_ConditionPacketAvailable;
+#endif
 
     std::vector<ILocalPacketHandlerSharedPtr> m_PacketHandlers;
     std::map<uint32_t, std::vector<ILocalPacketHandlerSharedPtr>> m_IndexedHandlers;
@@ -121,11 +126,13 @@
     // List of readable packets for the local packet handlers
     std::queue<arm::pipe::Packet> m_ReadableList;
     // Mutex and condition variable for the readable packet list
+#if !defined(ARMNN_DISABLE_THREADS)
     std::mutex m_ReadableMutex;
     std::condition_variable m_ConditionPacketReadable;
     // thread that takes items from the readable list and dispatches them
     // to the handlers.
     std::thread m_LocalHandlersThread;
+#endif
     // atomic booleans that control the operation of the local handlers thread
     std::atomic<bool> m_IsRunning;
     std::atomic<bool> m_KeepRunning;
diff --git a/profiling/client/src/PeriodicCounterCapture.cpp b/profiling/client/src/PeriodicCounterCapture.cpp
index 490173c..25d1a17 100644
--- a/profiling/client/src/PeriodicCounterCapture.cpp
+++ b/profiling/client/src/PeriodicCounterCapture.cpp
@@ -31,7 +31,9 @@
     m_KeepRunning.store(true);
 
     // Start the new capture thread.
+#if !defined(ARMNN_DISABLE_THREADS)
     m_PeriodCaptureThread = std::thread(&PeriodicCounterCapture::Capture, this, std::ref(m_ReadCounterValues));
+#endif
 }
 
 void PeriodicCounterCapture::Stop()
@@ -39,12 +41,14 @@
     // Signal the capture thread to stop
     m_KeepRunning.store(false);
 
+#if !defined(ARMNN_DISABLE_THREADS)
     // Check that the capture thread is running
     if (m_PeriodCaptureThread.joinable())
     {
         // Wait for the capture thread to complete operations
         m_PeriodCaptureThread.join();
     }
+#endif
 
     // Mark the capture thread as not running
     m_IsRunning = false;
@@ -85,7 +89,9 @@
         if (capturePeriod == 0)
         {
             // No data capture, wait the indicated capture period (milliseconds), if it is not zero
+#if !defined(ARMNN_DISABLE_THREADS)
             std::this_thread::sleep_for(std::chrono::milliseconds(50u));
+#endif
             continue;
         }
 
@@ -129,7 +135,9 @@
         });
 
         // Wait the indicated capture period (microseconds)
+#if !defined(ARMNN_DISABLE_THREADS)
         std::this_thread::sleep_for(std::chrono::microseconds(capturePeriod));
+#endif
     }
     while (m_KeepRunning.load());
 }
diff --git a/profiling/client/src/PeriodicCounterCapture.hpp b/profiling/client/src/PeriodicCounterCapture.hpp
index 8808417..35ceb0c 100644
--- a/profiling/client/src/PeriodicCounterCapture.hpp
+++ b/profiling/client/src/PeriodicCounterCapture.hpp
@@ -17,8 +17,11 @@
 #include <common/include/Packet.hpp>
 
 #include <atomic>
+
+#if !defined(ARMNN_DISABLE_THREADS)
 #include <mutex>
 #include <thread>
+#endif
 
 namespace arm
 {
@@ -34,7 +37,7 @@
                            IReadCounterValues& readCounterValue,
                            const ICounterMappings& counterIdMap,
                            const std::unordered_map<std::string,
-                               std::shared_ptr<IBackendProfilingContext>>& backendProfilingContexts)
+                           std::shared_ptr<IBackendProfilingContext>>& backendProfilingContexts)
             : m_CaptureDataHolder(data)
             , m_IsRunning(false)
             , m_KeepRunning(false)
@@ -58,7 +61,9 @@
     const Holder&             m_CaptureDataHolder;
     bool                      m_IsRunning;
     std::atomic<bool>         m_KeepRunning;
+#if !defined(ARMNN_DISABLE_THREADS)
     std::thread               m_PeriodCaptureThread;
+#endif
     IReadCounterValues&       m_ReadCounterValues;
     ISendCounterPacket&       m_SendCounterPacket;
     const ICounterMappings&   m_CounterIdMap;
diff --git a/profiling/client/src/ProfilingService.cpp b/profiling/client/src/ProfilingService.cpp
index 3a5c74b..b8e0348 100644
--- a/profiling/client/src/ProfilingService.cpp
+++ b/profiling/client/src/ProfilingService.cpp
@@ -10,6 +10,11 @@
 #include <common/include/ProfilingGuid.hpp>
 #include <common/include/SocketConnectionException.hpp>
 
+#if defined(ARMNN_BUILD_BARE_METAL)
+#include <common/include/IgnoreUnused.hpp>
+#endif
+
+
 #include <fmt/format.h>
 
 namespace arm
@@ -33,6 +38,9 @@
         // Reset the profiling service
         Reset();
     }
+#else
+    IgnoreUnused(options);
+    IgnoreUnused(resetProfilingService);
 #endif // ARMNN_BUILD_BARE_METAL
 }
 
@@ -94,6 +102,10 @@
                 return m_StateMachine.GetCurrentState();
         }
     }
+#else
+    IgnoreUnused(options);
+    IgnoreUnused(resetProfilingService);
+    return ProfilingState::Uninitialised;
 #endif // ARMNN_BUILD_BARE_METAL
 }
 
@@ -212,6 +224,9 @@
     // Register the backend counters
     m_MaxGlobalCounterId = profilingContext->RegisterCounters(m_MaxGlobalCounterId);
     m_BackendProfilingContexts.emplace(backendId, std::move(profilingContext));
+#else
+    IgnoreUnused(backendId);
+    IgnoreUnused(profilingContext);
 #endif // ARMNN_BUILD_BARE_METAL
 }
 const ICounterDirectory& ProfilingService::GetCounterDirectory() const
@@ -348,6 +363,8 @@
     // Register the new counter to the counter index for quick access
     std::atomic<uint32_t>* counterValuePtr = &(m_CounterValues.back());
     m_CounterIndex.at(counterUid) = counterValuePtr;
+#else
+    IgnoreUnused(counterUid);
 #endif // ARMNN_BUILD_BARE_METAL
 }
 
@@ -404,6 +421,8 @@
     {
         throw arm::pipe::InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid));
     }
+#else
+    IgnoreUnused(counterUid);
 #endif // ARMNN_BUILD_BARE_METAL
 }
 
@@ -454,7 +473,8 @@
         ss << "Timed out waiting on profiling service activation for " << elapsed.count() << " ms";
         ARM_PIPE_LOG(warning) << ss.str();
     }
-    return;
+#else
+    IgnoreUnused(timeout);
 #endif // ARMNN_BUILD_BARE_METAL
 }
 
diff --git a/profiling/client/src/ProfilingService.hpp b/profiling/client/src/ProfilingService.hpp
index b84b39d..588bcd2 100644
--- a/profiling/client/src/ProfilingService.hpp
+++ b/profiling/client/src/ProfilingService.hpp
@@ -261,8 +261,10 @@
     uint16_t                    m_MaxGlobalCounterId;
 
     // Signalling to let external actors know when service is active or not
+#if !defined(ARMNN_DISABLE_THREADS)
     std::mutex m_ServiceActiveMutex;
     std::condition_variable m_ServiceActiveConditionVariable;
+#endif
     bool m_ServiceActive;
 
     IInitialiseProfilingService& m_Initialiser;
diff --git a/profiling/client/src/ProfilingUtils.cpp b/profiling/client/src/ProfilingUtils.cpp
index 2963a98..4426d41 100644
--- a/profiling/client/src/ProfilingUtils.cpp
+++ b/profiling/client/src/ProfilingUtils.cpp
@@ -13,6 +13,7 @@
 
 #include <armnn/Version.hpp>
 
+#include <chrono>
 #include <fstream>
 #include <iostream>
 #include <limits>
@@ -593,11 +594,7 @@
 
 uint64_t GetTimestamp()
 {
-#if USE_CLOCK_MONOTONIC_RAW
-    using clock = armnn::MonotonicClockRaw;
-#else
     using clock = std::chrono::steady_clock;
-#endif
 
     // Take a timestamp
     auto timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(clock::now().time_since_epoch());
diff --git a/profiling/client/src/SendThread.cpp b/profiling/client/src/SendThread.cpp
index 7fb8e65..9a13dae 100644
--- a/profiling/client/src/SendThread.cpp
+++ b/profiling/client/src/SendThread.cpp
@@ -9,6 +9,10 @@
 #include <common/include/NumericCast.hpp>
 #include <common/include/ProfilingException.hpp>
 
+#if defined(ARMNN_DISABLE_THREADS)
+#include <common/include/IgnoreUnused.hpp>
+#endif
+
 #include <cstring>
 
 namespace arm
@@ -36,11 +40,15 @@
 {
     // We need to wait for the send thread to release its mutex
     {
+#if !defined(ARMNN_DISABLE_THREADS)
         std::lock_guard<std::mutex> lck(m_WaitMutex);
+#endif
         m_ReadyToRead = true;
     }
     // Signal the send thread that there's something to read in the buffer
+#if !defined(ARMNN_DISABLE_THREADS)
     m_WaitCondition.notify_one();
+#endif
 }
 
 void SendThread::Start(IProfilingConnection& profilingConnection)
@@ -52,10 +60,12 @@
         return;
     }
 
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_SendThread.joinable())
     {
         m_SendThread.join();
     }
+#endif
 
     // Mark the send thread as running
     m_IsRunning.store(true);
@@ -70,7 +80,11 @@
     m_PacketSent = false;
 
     // Start the send thread
+#if !defined(ARMNN_DISABLE_THREADS)
     m_SendThread = std::thread(&SendThread::Send, this, std::ref(profilingConnection));
+#else
+    IgnoreUnused(profilingConnection);
+#endif
 }
 
 void SendThread::Stop(bool rethrowSendThreadExceptions)
@@ -79,6 +93,7 @@
     m_KeepRunning.store(false);
 
     // Check that the send thread is running
+#if !defined(ARMNN_DISABLE_THREADS)
     if (m_SendThread.joinable())
     {
         // Kick the send thread out of the wait condition
@@ -86,6 +101,7 @@
         // Wait for the send thread to complete operations
         m_SendThread.join();
     }
+#endif
 
     // Check if the send thread exception has to be rethrown
     if (!rethrowSendThreadExceptions)
@@ -147,17 +163,19 @@
 
             // Wait condition lock scope - Begin
             {
+#if !defined(ARMNN_DISABLE_THREADS)
                 std::unique_lock<std::mutex> lock(m_WaitMutex);
 
                 bool timeout = m_WaitCondition.wait_for(lock,
                                                         std::chrono::milliseconds(std::max(m_Timeout, 1000)),
                                                         [&]{ return m_ReadyToRead; });
                 // If we get notified we need to flush the buffer again
-                if(timeout)
+                if (timeout)
                 {
                     // Otherwise if we just timed out don't flush the buffer
                     continue;
                 }
+#endif
                 //reset condition variable predicate for next use
                 m_ReadyToRead = false;
             }
@@ -167,20 +185,25 @@
         default:
             // Wait condition lock scope - Begin
             {
+#if !defined(ARMNN_DISABLE_THREADS)
                 std::unique_lock<std::mutex> lock(m_WaitMutex);
-
+#endif
                 // Normal working state for the send thread
                 // Check if the send thread is required to enforce a timeout wait policy
                 if (m_Timeout < 0)
                 {
                     // Wait indefinitely until notified that something to read has become available in the buffer
+#if !defined(ARMNN_DISABLE_THREADS)
                     m_WaitCondition.wait(lock, [&] { return m_ReadyToRead; });
+#endif
                 }
                 else
                 {
                     // Wait until the thread is notified of something to read from the buffer,
                     // or check anyway after the specified number of milliseconds
+#if !defined(ARMNN_DISABLE_THREADS)
                     m_WaitCondition.wait_for(lock, std::chrono::milliseconds(m_Timeout), [&] { return m_ReadyToRead; });
+#endif
                 }
 
                 //reset condition variable predicate for next use
@@ -246,25 +269,33 @@
     {
         // Wait for the parent thread to release its mutex if necessary
         {
+#if !defined(ARMNN_DISABLE_THREADS)
             std::lock_guard<std::mutex> lck(m_PacketSentWaitMutex);
+#endif
             m_PacketSent = true;
         }
         // Notify to any watcher that something has been sent
+#if !defined(ARMNN_DISABLE_THREADS)
         m_PacketSentWaitCondition.notify_one();
+#endif
     }
 }
 
 bool SendThread::WaitForPacketSent(uint32_t timeout = 1000)
 {
+#if !defined(ARMNN_DISABLE_THREADS)
     std::unique_lock<std::mutex> lock(m_PacketSentWaitMutex);
     // Blocks until notified that at least a packet has been sent or until timeout expires.
     bool timedOut = m_PacketSentWaitCondition.wait_for(lock,
                                                        std::chrono::milliseconds(timeout),
                                                        [&] { return m_PacketSent; });
-
     m_PacketSent = false;
 
     return timedOut;
+#else
+    IgnoreUnused(timeout);
+    return false;
+#endif
 }
 
 } // namespace pipe
diff --git a/profiling/client/src/SendThread.hpp b/profiling/client/src/SendThread.hpp
index b96a6d5..f462ae0 100644
--- a/profiling/client/src/SendThread.hpp
+++ b/profiling/client/src/SendThread.hpp
@@ -17,9 +17,11 @@
 #include <common/include/ICounterDirectory.hpp>
 
 #include <atomic>
+#if !defined(ARMNN_DISABLE_THREADS)
 #include <condition_variable>
 #include <mutex>
 #include <thread>
+#endif
 #include <type_traits>
 
 namespace arm
@@ -57,9 +59,11 @@
     IBufferManager& m_BufferManager;
     ISendCounterPacket& m_SendCounterPacket;
     int m_Timeout;
+#if !defined(ARMNN_DISABLE_THREADS)
     std::mutex m_WaitMutex;
     std::condition_variable m_WaitCondition;
     std::thread m_SendThread;
+#endif
     std::atomic<bool> m_IsRunning;
     std::atomic<bool> m_KeepRunning;
     // m_ReadyToRead will be protected by m_WaitMutex
@@ -67,9 +71,10 @@
     // m_PacketSent will be protected by m_PacketSentWaitMutex
     bool m_PacketSent;
     std::exception_ptr m_SendThreadException;
+#if !defined(ARMNN_DISABLE_THREADS)
     std::mutex m_PacketSentWaitMutex;
     std::condition_variable m_PacketSentWaitCondition;
-
+#endif
 };
 
 } // namespace pipe
diff --git a/profiling/client/src/SocketProfilingConnection.cpp b/profiling/client/src/SocketProfilingConnection.cpp
index a211567..b924f8d 100644
--- a/profiling/client/src/SocketProfilingConnection.cpp
+++ b/profiling/client/src/SocketProfilingConnection.cpp
@@ -20,6 +20,7 @@
 
 SocketProfilingConnection::SocketProfilingConnection()
 {
+#if !defined(ARMNN_DISABLE_SOCKETS)
     arm::pipe::Initialize();
     memset(m_Socket, 0, sizeof(m_Socket));
     // Note: we're using Linux specific SOCK_CLOEXEC flag.
@@ -59,15 +60,21 @@
             m_Socket[0].fd,
             errno);
     }
+#endif
 }
 
 bool SocketProfilingConnection::IsOpen() const
 {
+#if !defined(ARMNN_DISABLE_SOCKETS)
     return m_Socket[0].fd > 0;
+#else
+    return false;
+#endif
 }
 
 void SocketProfilingConnection::Close()
 {
+#if !defined(ARMNN_DISABLE_SOCKETS)
     if (arm::pipe::Close(m_Socket[0].fd) != 0)
     {
         throw arm::pipe::SocketConnectionException(
@@ -77,6 +84,7 @@
     }
 
     memset(m_Socket, 0, sizeof(m_Socket));
+#endif
 }
 
 bool SocketProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length)
@@ -85,12 +93,16 @@
     {
         return false;
     }
-
+#if !defined(ARMNN_DISABLE_SOCKETS)
     return arm::pipe::Write(m_Socket[0].fd, buffer, length) != -1;
+#else
+    return false;
+#endif
 }
 
 arm::pipe::Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
 {
+#if !defined(ARMNN_DISABLE_SOCKETS)
     // Is there currently at least a header worth of data waiting to be read?
     int bytes_available = 0;
     arm::pipe::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
@@ -156,10 +168,16 @@
 
         return ReceivePacket();
     }
+#else
+    IgnoreUnused(timeout);
+    throw arm::pipe::TimeoutException(
+        "SocketProfilingConnection: Cannot use ReadPacket function with sockets disabled");
+#endif
 }
 
 arm::pipe::Packet SocketProfilingConnection::ReceivePacket()
 {
+#if !defined(ARMNN_DISABLE_SOCKETS)
     char header[8] = {};
     long receiveResult = arm::pipe::Read(m_Socket[0].fd, &header, sizeof(header));
     // We expect 8 as the result here. 0 means EOF, socket is closed. -1 means there been some other kind of error.
@@ -219,6 +237,10 @@
     }
 
     return arm::pipe::Packet(metadataIdentifier, dataLength, packetData);
+#else
+    throw arm::pipe::TimeoutException(
+        "SocketProfilingConnection: Cannot use ReceivePacket function with sockets disabled");
+#endif
 }
 
 } // namespace pipe
diff --git a/profiling/client/src/SocketProfilingConnection.hpp b/profiling/client/src/SocketProfilingConnection.hpp
index 52616c9..db6b512 100644
--- a/profiling/client/src/SocketProfilingConnection.hpp
+++ b/profiling/client/src/SocketProfilingConnection.hpp
@@ -35,7 +35,9 @@
     // MACOSX does not support abstract UDS
     const char* m_GatorNamespace = "/tmp/gatord_namespace";
 #endif
+#if !defined(ARMNN_DISABLE_SOCKETS)
     arm::pipe::PollFd m_Socket[1]{};
+#endif
 };
 
 } // namespace pipe