APPBROWSER-359: Sync tensor in GC benchmark tests

Change-Id: I22c1aa92e70d6143bbcec90e9e7de9f1ce1c1e55
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114635
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
diff --git a/tests/benchmark/fixtures/ActivationLayerFixture.h b/tests/benchmark/fixtures/ActivationLayerFixture.h
index 9ded063..11fabf8 100644
--- a/tests/benchmark/fixtures/ActivationLayerFixture.h
+++ b/tests/benchmark/fixtures/ActivationLayerFixture.h
@@ -66,6 +66,12 @@
         act_layer.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/AlexNetFixture.h b/tests/benchmark/fixtures/AlexNetFixture.h
index 961f4e8..a543ba2 100644
--- a/tests/benchmark/fixtures/AlexNetFixture.h
+++ b/tests/benchmark/fixtures/AlexNetFixture.h
@@ -65,6 +65,11 @@
         network.run();
     }
 
+    void sync()
+    {
+        network.sync();
+    }
+
     void teardown()
     {
         network.clear();
diff --git a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
index 55411a4..5f32e77 100644
--- a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
+++ b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
@@ -29,12 +29,6 @@
 #include "tests/Globals.h"
 #include "tests/Utils.h"
 #include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
 
 namespace arm_compute
 {
@@ -82,12 +76,12 @@
     void run()
     {
         batch_norm_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/ConvolutionLayerFixture.h b/tests/benchmark/fixtures/ConvolutionLayerFixture.h
index b526cc3..4031607 100644
--- a/tests/benchmark/fixtures/ConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/ConvolutionLayerFixture.h
@@ -30,13 +30,6 @@
 #include "tests/Utils.h"
 #include "tests/framework/Fixture.h"
 
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
 namespace arm_compute
 {
 namespace test
@@ -78,12 +71,12 @@
     void run()
     {
         conv_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h b/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
index 221f34c..523a41b 100644
--- a/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
@@ -123,6 +123,12 @@
         _depth_concat.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(_dst);
+    }
+
     void teardown()
     {
         for(auto &src : _srcs)
diff --git a/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
index 19ebb4e..d505ba3 100644
--- a/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
@@ -72,6 +72,12 @@
         depth_conv.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
index fa15440..c841996 100644
--- a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
@@ -83,6 +83,12 @@
         depth_sep_conv_layer.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/DequantizationLayerFixture.h b/tests/benchmark/fixtures/DequantizationLayerFixture.h
index 30e05f9..4251a96 100644
--- a/tests/benchmark/fixtures/DequantizationLayerFixture.h
+++ b/tests/benchmark/fixtures/DequantizationLayerFixture.h
@@ -73,6 +73,12 @@
         dequantization_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FlattenLayerFixture.h b/tests/benchmark/fixtures/FlattenLayerFixture.h
index 67f5f01..f6e44a2 100644
--- a/tests/benchmark/fixtures/FlattenLayerFixture.h
+++ b/tests/benchmark/fixtures/FlattenLayerFixture.h
@@ -68,6 +68,12 @@
         flatten_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FloorFixture.h b/tests/benchmark/fixtures/FloorFixture.h
index 8de87b8..b6bb896 100644
--- a/tests/benchmark/fixtures/FloorFixture.h
+++ b/tests/benchmark/fixtures/FloorFixture.h
@@ -62,6 +62,12 @@
         floor_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
index ef08c4a..08c2ef9 100644
--- a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
+++ b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
@@ -30,13 +30,6 @@
 #include "tests/Utils.h"
 #include "tests/framework/Fixture.h"
 
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
 namespace arm_compute
 {
 namespace test
@@ -78,12 +71,12 @@
     void run()
     {
         fc_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/GEMMFixture.h b/tests/benchmark/fixtures/GEMMFixture.h
index 0c41c67..d1eded0 100644
--- a/tests/benchmark/fixtures/GEMMFixture.h
+++ b/tests/benchmark/fixtures/GEMMFixture.h
@@ -69,6 +69,12 @@
         gemm.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         a.allocator()->free();
diff --git a/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h b/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
index e55e092..293ceff 100644
--- a/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
+++ b/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
@@ -69,6 +69,12 @@
         gemm.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(b);
+    }
+
     void teardown()
     {
         a.allocator()->free();
diff --git a/tests/benchmark/fixtures/GEMMLowpFixture.h b/tests/benchmark/fixtures/GEMMLowpFixture.h
index 4bd7dfd..1b64591 100644
--- a/tests/benchmark/fixtures/GEMMLowpFixture.h
+++ b/tests/benchmark/fixtures/GEMMLowpFixture.h
@@ -72,6 +72,12 @@
         gemmlowp.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(c);
+    }
+
     void teardown()
     {
         a.allocator()->free();
diff --git a/tests/benchmark/fixtures/L2NormalizeLayerFixture.h b/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
index 296a2e9..ae5b1a1 100644
--- a/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
+++ b/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
@@ -64,6 +64,12 @@
         l2norm_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/LeNet5Fixture.h b/tests/benchmark/fixtures/LeNet5Fixture.h
index 77a09d3..191daa2 100644
--- a/tests/benchmark/fixtures/LeNet5Fixture.h
+++ b/tests/benchmark/fixtures/LeNet5Fixture.h
@@ -57,6 +57,11 @@
         network.run();
     }
 
+    void sync()
+    {
+        network.sync();
+    }
+
     void teardown()
     {
         network.clear();
diff --git a/tests/benchmark/fixtures/MobileNetFixture.h b/tests/benchmark/fixtures/MobileNetFixture.h
index 660205c..165b269 100644
--- a/tests/benchmark/fixtures/MobileNetFixture.h
+++ b/tests/benchmark/fixtures/MobileNetFixture.h
@@ -58,6 +58,11 @@
         network.run();
     }
 
+    void sync()
+    {
+        network.sync();
+    }
+
     void teardown()
     {
         network.clear();
diff --git a/tests/benchmark/fixtures/MobileNetV1Fixture.h b/tests/benchmark/fixtures/MobileNetV1Fixture.h
index 07333dd..54b0d09 100644
--- a/tests/benchmark/fixtures/MobileNetV1Fixture.h
+++ b/tests/benchmark/fixtures/MobileNetV1Fixture.h
@@ -61,6 +61,11 @@
         network.run();
     }
 
+    void sync()
+    {
+        network.sync();
+    }
+
     void teardown()
     {
         network.clear();
diff --git a/tests/benchmark/fixtures/NormalizationLayerFixture.h b/tests/benchmark/fixtures/NormalizationLayerFixture.h
index 41dd8a7..cbe20d5 100644
--- a/tests/benchmark/fixtures/NormalizationLayerFixture.h
+++ b/tests/benchmark/fixtures/NormalizationLayerFixture.h
@@ -66,6 +66,12 @@
         norm_layer.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h b/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
index 9234353..a84aa26 100644
--- a/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
+++ b/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
@@ -29,12 +29,6 @@
 #include "tests/Globals.h"
 #include "tests/Utils.h"
 #include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
 
 namespace arm_compute
 {
@@ -75,12 +69,12 @@
     void run()
     {
         normalize_planar_yuv_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/PoolingLayerFixture.h b/tests/benchmark/fixtures/PoolingLayerFixture.h
index 2060301..47deda9 100644
--- a/tests/benchmark/fixtures/PoolingLayerFixture.h
+++ b/tests/benchmark/fixtures/PoolingLayerFixture.h
@@ -67,6 +67,12 @@
         pool_layer.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/QuantizationLayerFixture.h b/tests/benchmark/fixtures/QuantizationLayerFixture.h
index 5981f99..0843962 100644
--- a/tests/benchmark/fixtures/QuantizationLayerFixture.h
+++ b/tests/benchmark/fixtures/QuantizationLayerFixture.h
@@ -63,6 +63,12 @@
         quantization_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
index 76c2280..9013218 100644
--- a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
+++ b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
@@ -78,6 +78,12 @@
         roi_pool.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ReshapeLayerFixture.h b/tests/benchmark/fixtures/ReshapeLayerFixture.h
index 4f65e9d..b92377c 100644
--- a/tests/benchmark/fixtures/ReshapeLayerFixture.h
+++ b/tests/benchmark/fixtures/ReshapeLayerFixture.h
@@ -64,6 +64,12 @@
         reshape_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ScaleFixture.h b/tests/benchmark/fixtures/ScaleFixture.h
index 1ba191b..21a6391 100644
--- a/tests/benchmark/fixtures/ScaleFixture.h
+++ b/tests/benchmark/fixtures/ScaleFixture.h
@@ -81,6 +81,12 @@
         scale_func.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ScaleLayerFixture.h b/tests/benchmark/fixtures/ScaleLayerFixture.h
index 94cc678..f34a003 100644
--- a/tests/benchmark/fixtures/ScaleLayerFixture.h
+++ b/tests/benchmark/fixtures/ScaleLayerFixture.h
@@ -31,13 +31,6 @@
 #include "tests/framework/Asserts.h"
 #include "tests/framework/Fixture.h"
 
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
 namespace arm_compute
 {
 namespace test
@@ -83,12 +76,12 @@
     void run()
     {
         scale_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/SoftmaxLayerFixture.h b/tests/benchmark/fixtures/SoftmaxLayerFixture.h
index 50b2726..f3657da 100644
--- a/tests/benchmark/fixtures/SoftmaxLayerFixture.h
+++ b/tests/benchmark/fixtures/SoftmaxLayerFixture.h
@@ -31,13 +31,6 @@
 #include "tests/framework/Asserts.h"
 #include "tests/framework/Fixture.h"
 
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
 namespace arm_compute
 {
 namespace test
@@ -73,12 +66,12 @@
     void run()
     {
         smx_layer.run();
-#ifdef ARM_COMPUTE_GC
-        if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
-        {
-            force_sync_tensor(dst);
-        }
-#endif /* ARM_COMPUTE_GC */
+    }
+
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
     }
 
     void teardown()
diff --git a/tests/benchmark/fixtures/TransposeFixture.h b/tests/benchmark/fixtures/TransposeFixture.h
index 19d2194..bc2d6d6 100644
--- a/tests/benchmark/fixtures/TransposeFixture.h
+++ b/tests/benchmark/fixtures/TransposeFixture.h
@@ -67,6 +67,12 @@
         transpose.run();
     }
 
+    void sync()
+    {
+        sync_if_necessary<TensorType>();
+        sync_tensor_if_necessary<TensorType>(dst);
+    }
+
     void teardown()
     {
         src.allocator()->free();