Improved cache maintenance

Invalidating and cleaning buffers exchanged between Core and remote CPU.

Change-Id: Icd9ce6c916422a6bbcdd42e31651a622240d0ce4
diff --git a/applications/inference_process/src/inference_process.cc b/applications/inference_process/src/inference_process.cc
index 7743f8c..61db73d 100644
--- a/applications/inference_process/src/inference_process.cc
+++ b/applications/inference_process/src/inference_process.cc
@@ -87,6 +87,20 @@
 namespace InferenceProcess {
 DataPtr::DataPtr(void *_data, size_t _size) : data(_data), size(_size) {}
 
+void DataPtr::invalidate() {
+#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
+    printf("Invalidate. data=%p, size=%zu\n", data, size);
+    SCB_InvalidateDCache_by_Addr(reinterpret_cast<uint32_t *>(data), size);
+#endif
+}
+
+void DataPtr::clean() {
+#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
+    printf("Clean. data=%p, size=%zu\n", data, size);
+    SCB_CleanDCache_by_Addr(reinterpret_cast<uint32_t *>(data), size);
+#endif
+}
+
 InferenceJob::InferenceJob() : numBytesToPrint(0) {}
 
 InferenceJob::InferenceJob(const string &_name,
@@ -99,6 +113,38 @@
     networkModel(_networkModel), input(_input), output(_output), expectedOutput(_expectedOutput),
     numBytesToPrint(_numBytesToPrint) {}
 
+void InferenceJob::invalidate() {
+    networkModel.invalidate();
+
+    for (auto &it : input) {
+        it.invalidate();
+    }
+
+    for (auto &it : output) {
+        it.invalidate();
+    }
+
+    for (auto &it : expectedOutput) {
+        it.invalidate();
+    }
+}
+
+void InferenceJob::clean() {
+    networkModel.clean();
+
+    for (auto &it : input) {
+        it.clean();
+    }
+
+    for (auto &it : output) {
+        it.clean();
+    }
+
+    for (auto &it : expectedOutput) {
+        it.clean();
+    }
+}
+
 InferenceProcess::InferenceProcess() : lock(0) {}
 
 // NOTE: Adding code for get_lock & free_lock with some corrections from