COMPMID-1086: Optimizing GCGEMM - Add helpers to get target GPU information

This patch moves some of the helper functions in CLHelpers.[h,cpp] to
GPUTarget.[h,cpp] in order to make them avaialable to both CL and GLES backends.

Change-Id: Ib89b05a2084b73eb643b32fac13b8367cc80b6a5
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/128988
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/src/core/GLES_COMPUTE/GCHelpers.cpp b/src/core/GLES_COMPUTE/GCHelpers.cpp
new file mode 100644
index 0000000..8970688
--- /dev/null
+++ b/src/core/GLES_COMPUTE/GCHelpers.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/core/GLES_COMPUTE/GCHelpers.h"
+
+namespace arm_compute
+{
+GPUTarget get_target_from_device()
+{
+    const std::string device_name = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+
+    return get_target_from_name(device_name);
+}
+} // namespace arm_compute
diff --git a/src/core/GLES_COMPUTE/IGCKernel.cpp b/src/core/GLES_COMPUTE/IGCKernel.cpp
index 55b7f0d..ecd63b5 100644
--- a/src/core/GLES_COMPUTE/IGCKernel.cpp
+++ b/src/core/GLES_COMPUTE/IGCKernel.cpp
@@ -62,7 +62,7 @@
 }
 
 IGCKernel::IGCKernel()
-    : _kernel(), _lws_hint(gles::NDRange(1U, 1U, 1U))
+    : _kernel(), _lws_hint(gles::NDRange(1U, 1U, 1U)), _target(GPUTarget::MIDGARD)
 {
 }
 
diff --git a/src/core/GLES_COMPUTE/OpenGLES.cpp b/src/core/GLES_COMPUTE/OpenGLES.cpp
index d2539d0..e93b360 100644
--- a/src/core/GLES_COMPUTE/OpenGLES.cpp
+++ b/src/core/GLES_COMPUTE/OpenGLES.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -66,7 +66,8 @@
 using glMemoryBarrier_func           = void GL_APIENTRY (*)(GLbitfield barriers);
 using glUniform1ui_func              = void GL_APIENTRY (*)(GLint location, GLuint v0);
 using glUnmapBuffer_func             = GLboolean GL_APIENTRY (*)(GLenum target);
-using glGetError_func                = GLenum              GL_APIENTRY (*)();
+using glGetError_func                = GLenum          GL_APIENTRY (*)();
+using glGetString_func               = const GLubyte * GL_APIENTRY (*)(GLenum name);
 using glGetActiveUniformBlockiv_func = void GL_APIENTRY (*)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
 using glUniformBlockBinding_func     = void GL_APIENTRY (*)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
 using glGetUniformBlockIndex_func    = GLuint GL_APIENTRY (*)(GLuint program, const GLchar *uniformBlockName);
@@ -668,6 +669,19 @@
     }
 }
 
+const GLubyte *GL_APIENTRY glGetString(GLenum name)
+{
+    auto func = GLESSymbols::get().glGetString;
+    if(func != nullptr)
+    {
+        return func(name);
+    }
+    else
+    {
+        return nullptr;
+    }
+}
+
 void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params)
 {
     auto func = GLESSymbols::get().glGetActiveUniformBlockiv;
diff --git a/src/core/GLES_COMPUTE/gl_entries.in b/src/core/GLES_COMPUTE/gl_entries.in
index 15ce8ee..17e3aee 100644
--- a/src/core/GLES_COMPUTE/gl_entries.in
+++ b/src/core/GLES_COMPUTE/gl_entries.in
@@ -61,3 +61,4 @@
 GL_ENTRY(glDeleteFramebuffers)
 GL_ENTRY(glBindFramebuffer)
 GL_ENTRY(glFramebufferTexture2D)
+GL_ENTRY(glGetString)
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
index dc86bfb..171fbad 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
@@ -35,7 +35,6 @@
 #include "arm_compute/core/Window.h"
 
 using namespace arm_compute;
-using namespace arm_compute::gles_compute;
 
 GCGEMMInterleave4x4Kernel::GCGEMMInterleave4x4Kernel()
     : _input(nullptr), _output(nullptr)
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
index 43846dc..1a68a62 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -34,7 +34,6 @@
 #include "arm_compute/core/Window.h"
 
 using namespace arm_compute;
-using namespace arm_compute::gles_compute;
 
 GCGEMMMatrixAdditionKernel::GCGEMMMatrixAdditionKernel()
     : _input(nullptr), _output(nullptr)
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
index b4bb547..2bd769c 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
@@ -42,7 +42,6 @@
 #include <string>
 
 using namespace arm_compute;
-using namespace arm_compute::gles_compute;
 using namespace arm_compute::misc::shape_calculator;
 
 namespace
@@ -195,10 +194,13 @@
     _input1 = input1;
     _output = output;
 
+    // Get target architecture
+    GPUTarget gpu_target = get_target();
+
     ElementsProcessed num_elements_processed{};
 
     // Configure kernel window
-    auto win_config = validate_and_configure_window(input0->info(), input1->info(), output->info(), is_interleaved_transposed, reshape_info, GPUTarget::UNKNOWN, num_elements_processed);
+    auto win_config = validate_and_configure_window(input0->info(), input1->info(), output->info(), is_interleaved_transposed, reshape_info, gpu_target, num_elements_processed);
     ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
     IGCKernel::configure(win_config.second);
 
diff --git a/src/core/GLES_COMPUTE/kernels/GCTensorShiftKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCTensorShiftKernel.cpp
index 21946b7..f0057df 100644
--- a/src/core/GLES_COMPUTE/kernels/GCTensorShiftKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCTensorShiftKernel.cpp
@@ -36,7 +36,6 @@
 #include "support/ToolchainSupport.h"
 
 using namespace arm_compute;
-using namespace arm_compute::gles_compute;
 
 GCTensorShiftKernel::GCTensorShiftKernel()
     : _input(nullptr), _lws(gles::NDRange(1U, 1U, 1U)), _left_padding(0)
diff --git a/src/core/GLES_COMPUTE/kernels/GCWeightsReshapeKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCWeightsReshapeKernel.cpp
index 55bf9b7..ccbfaf8 100644
--- a/src/core/GLES_COMPUTE/kernels/GCWeightsReshapeKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCWeightsReshapeKernel.cpp
@@ -36,7 +36,6 @@
 #include "arm_compute/core/GLES_COMPUTE/GCHelpers.h"
 
 using namespace arm_compute;
-using namespace arm_compute::gles_compute;
 using namespace arm_compute::misc::shape_calculator;
 
 GCWeightsReshapeKernel::GCWeightsReshapeKernel()