IVGCVSW-5101 Add a SOL/EOL and a process ID label to Network

Change-Id: I6261f46404a3aab5c069bca40586994d31d26fe8
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
index 69ebe33..f9df633 100644
--- a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
+++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
@@ -114,39 +114,40 @@
         std::vector<std::string> desc = GetModelDescription(model);
         std::vector<std::string> expectedOutput;
         expectedOutput.push_back("Entity [0] name = input type = layer");
-        expectedOutput.push_back("   connection [14] from entity [0] to entity [1]");
-        expectedOutput.push_back("   child: Entity [23] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("   connection [17] from entity [0] to entity [1]");
+        expectedOutput.push_back("   child: Entity [26] backendId = " + backend.Get() + " type = workload");
         expectedOutput.push_back("Entity [1] name = Rsqrt type = layer");
-        expectedOutput.push_back("   connection [22] from entity [1] to entity [2]");
-        expectedOutput.push_back("   child: Entity [15] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("   connection [25] from entity [1] to entity [2]");
+        expectedOutput.push_back("   child: Entity [18] backendId = " + backend.Get() + " type = workload");
         expectedOutput.push_back("Entity [2] name = output type = layer");
-        expectedOutput.push_back("   child: Entity [27] backendId = " + backend.Get() + " type = workload");
-        expectedOutput.push_back("Entity [6] type = network");
+        expectedOutput.push_back("   child: Entity [30] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("Entity [6] processId = [processId] type = network");
         expectedOutput.push_back("   child: Entity [0] name = input type = layer");
         expectedOutput.push_back("   child: Entity [1] name = Rsqrt type = layer");
         expectedOutput.push_back("   child: Entity [2] name = output type = layer");
-        expectedOutput.push_back("   execution: Entity [31] type = inference");
-        expectedOutput.push_back("Entity [15] backendId = " + backend.Get() + " type = workload");
-        expectedOutput.push_back("   execution: Entity [44] type = workload_execution");
-        expectedOutput.push_back("Entity [23] backendId = " + backend.Get() + " type = workload");
-        expectedOutput.push_back("   execution: Entity [36] type = workload_execution");
-        expectedOutput.push_back("Entity [27] backendId = " + backend.Get() + " type = workload");
-        expectedOutput.push_back("   execution: Entity [52] type = workload_execution");
-        expectedOutput.push_back("Entity [31] type = inference");
-        expectedOutput.push_back("   child: Entity [36] type = workload_execution");
-        expectedOutput.push_back("   child: Entity [44] type = workload_execution");
-        expectedOutput.push_back("   child: Entity [52] type = workload_execution");
-        expectedOutput.push_back("   event: [34] class [start_of_life]");
-        expectedOutput.push_back("   event: [60] class [end_of_life]");
-        expectedOutput.push_back("Entity [36] type = workload_execution");
-        expectedOutput.push_back("   event: [40] class [start_of_life]");
-        expectedOutput.push_back("   event: [42] class [end_of_life]");
-        expectedOutput.push_back("Entity [44] type = workload_execution");
-        expectedOutput.push_back("   event: [48] class [start_of_life]");
-        expectedOutput.push_back("   event: [50] class [end_of_life]");
-        expectedOutput.push_back("Entity [52] type = workload_execution");
-        expectedOutput.push_back("   event: [56] class [start_of_life]");
-        expectedOutput.push_back("   event: [58] class [end_of_life]");
+        expectedOutput.push_back("   execution: Entity [34] type = inference");
+        expectedOutput.push_back("   event: [8] class [start_of_life]");
+        expectedOutput.push_back("Entity [18] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("   execution: Entity [47] type = workload_execution");
+        expectedOutput.push_back("Entity [26] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("   execution: Entity [39] type = workload_execution");
+        expectedOutput.push_back("Entity [30] backendId = " + backend.Get() + " type = workload");
+        expectedOutput.push_back("   execution: Entity [55] type = workload_execution");
+        expectedOutput.push_back("Entity [34] type = inference");
+        expectedOutput.push_back("   child: Entity [39] type = workload_execution");
+        expectedOutput.push_back("   child: Entity [47] type = workload_execution");
+        expectedOutput.push_back("   child: Entity [55] type = workload_execution");
+        expectedOutput.push_back("   event: [37] class [start_of_life]");
+        expectedOutput.push_back("   event: [63] class [end_of_life]");
+        expectedOutput.push_back("Entity [39] type = workload_execution");
+        expectedOutput.push_back("   event: [43] class [start_of_life]");
+        expectedOutput.push_back("   event: [45] class [end_of_life]");
+        expectedOutput.push_back("Entity [47] type = workload_execution");
+        expectedOutput.push_back("   event: [51] class [start_of_life]");
+        expectedOutput.push_back("   event: [53] class [end_of_life]");
+        expectedOutput.push_back("Entity [55] type = workload_execution");
+        expectedOutput.push_back("   event: [59] class [start_of_life]");
+        expectedOutput.push_back("   event: [61] class [end_of_life]");
         BOOST_TEST(CompareOutput(desc, expectedOutput));
     }
 }
diff --git a/src/profiling/test/ProfilingTestUtils.cpp b/src/profiling/test/ProfilingTestUtils.cpp
index 2dae5cf..8050eaa 100644
--- a/src/profiling/test/ProfilingTestUtils.cpp
+++ b/src/profiling/test/ProfilingTestUtils.cpp
@@ -8,8 +8,9 @@
 
 #include <armnn/Descriptors.hpp>
 #include <LabelsAndEventClasses.hpp>
-#include <Threads.hpp>
+#include <Processes.hpp>
 #include <ProfilingService.hpp>
+#include <Threads.hpp>
 
 #include <test/TestUtils.hpp>
 
@@ -438,11 +439,9 @@
     profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
     auto readableBuffer = bufferManager.GetReadableBuffer();
 
-    // Profiling is enable, the post-optimisation structure should be created
+    // Profiling is enabled, the post-optimisation structure should be created
     BOOST_CHECK(readableBuffer != nullptr);
-
     unsigned int size = readableBuffer->GetSize();
-    BOOST_CHECK(size == 1124);
 
     const unsigned char* readableData = readableBuffer->GetReadableData();
     BOOST_CHECK(readableData != nullptr);
@@ -450,7 +449,7 @@
     unsigned int offset = 0;
 
     // Verify Header
-    VerifyTimelineHeaderBinary(readableData, offset, 1116);
+    VerifyTimelineHeaderBinary(readableData, offset, size - 8);
     BOOST_TEST_MESSAGE("HEADER OK");
 
     // Post-optimisation network
@@ -468,6 +467,42 @@
                                                offset);
     BOOST_TEST_MESSAGE("NETWORK TYPE RELATIONSHIP OK");
 
+    // Network - START OF LIFE
+    ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(EmptyOptional(),
+                                                                        EmptyOptional(),
+                                                                        EmptyOptional(),
+                                                                        readableData,
+                                                                        offset);
+    BOOST_TEST_MESSAGE("NETWORK START OF LIFE EVENT OK");
+
+    // Network - START OF LIFE event relationship
+    VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
+                                               EmptyOptional(),
+                                               optNetGuid,
+                                               networkSolEventGuid,
+                                               LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
+                                               readableData,
+                                               offset);
+    BOOST_TEST_MESSAGE("NETWORK START OF LIFE RELATIONSHIP OK");
+
+    // Process ID Label
+    int processID = armnnUtils::Processes::GetCurrentId();
+    std::stringstream ss;
+    ss << processID;
+    std::string processIdLabel = ss.str();
+    VerifyTimelineLabelBinaryPacketData(EmptyOptional(), processIdLabel, readableData, offset);
+    BOOST_TEST_MESSAGE("PROCESS ID LABEL OK");
+
+    // Entity - Process ID relationship
+    VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
+                                               EmptyOptional(),
+                                               optNetGuid,
+                                               EmptyOptional(),
+                                               LabelsAndEventClasses::PROCESS_ID_GUID,
+                                               readableData,
+                                               offset);
+    BOOST_TEST_MESSAGE("NETWORK PROCESS ID RELATIONSHIP OK");
+
     // Input layer
     // Input layer entity
     VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
diff --git a/src/profiling/test/TimelineModel.cpp b/src/profiling/test/TimelineModel.cpp
index d16a300..2e4fd06 100644
--- a/src/profiling/test/TimelineModel.cpp
+++ b/src/profiling/test/TimelineModel.cpp
@@ -359,7 +359,13 @@
     ss << "Entity [" << entity.GetGuid() << "]";
     for (auto& attributeEntry : entity.GetAttributes())
     {
-        ss << " " << attributeEntry.second.first << " = " << attributeEntry.second.second;
+        if (profiling::LabelsAndEventClasses::PROCESS_ID_LABEL == attributeEntry.second.first)
+        {
+            ss << " " << attributeEntry.second.first << " = [processId]";
+        }
+        else {
+            ss << " " << attributeEntry.second.first << " = " << attributeEntry.second.second;
+        }
     }
     return ss.str();
 }
diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp
index 720b8b4..cbe3b79 100644
--- a/src/profiling/test/TimelineUtilityMethodsTests.cpp
+++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp
@@ -82,7 +82,7 @@
     auto readableBuffer = mockBufferManager.GetReadableBuffer();
     BOOST_CHECK(readableBuffer != nullptr);
     unsigned int size = readableBuffer->GetSize();
-    BOOST_TEST(size == 432);
+    BOOST_TEST(size == 460);
     const unsigned char* readableData = readableBuffer->GetReadableData();
     BOOST_CHECK(readableData != nullptr);
 
@@ -90,7 +90,7 @@
     unsigned int offset = 0;
 
     // Verify Header
-    VerifyTimelineHeaderBinary(readableData, offset, 424);
+    VerifyTimelineHeaderBinary(readableData, offset, 452);
 
     // First "well-known" label: NAME
     VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::NAME_GUID,
@@ -128,6 +128,12 @@
                                         readableData,
                                         offset);
 
+    // Seventh "well-known" label: PROCESS_ID_LABEL
+    VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::PROCESS_ID_GUID,
+                                        LabelsAndEventClasses::PROCESS_ID_LABEL,
+                                        readableData,
+                                        offset);
+
     // Well-known types
     // Layer
     VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::LAYER_GUID,