aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/core')
-rw-r--r--arm_compute/core/CL/CLCoreRuntimeContext.h20
-rw-r--r--arm_compute/core/CL/CLHelpers.h2
-rw-r--r--arm_compute/core/CL/CLKernelLibrary.h2
-rw-r--r--arm_compute/core/CL/OpenCL.h6
-rw-r--r--arm_compute/core/GLES_COMPUTE/GCCoreRuntimeContext.h63
-rw-r--r--arm_compute/core/GLES_COMPUTE/GCHelpers.h18
-rw-r--r--arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h55
-rw-r--r--arm_compute/core/GLES_COMPUTE/kernels/GCActivationLayerKernel.h18
8 files changed, 128 insertions, 56 deletions
diff --git a/arm_compute/core/CL/CLCoreRuntimeContext.h b/arm_compute/core/CL/CLCoreRuntimeContext.h
index 6e2bd43d53..c5d81778b5 100644
--- a/arm_compute/core/CL/CLCoreRuntimeContext.h
+++ b/arm_compute/core/CL/CLCoreRuntimeContext.h
@@ -28,8 +28,10 @@
namespace arm_compute
{
+// Forward declarations
class CLKernelLibrary;
-/** Core runtime context */
+
+/** Core runtime context for OpenCL */
class CLCoreRuntimeContext final
{
public:
@@ -48,10 +50,20 @@ public:
CLCoreRuntimeContext &operator=(const CLCoreRuntimeContext &) = default;
/** Default move assignment operator */
CLCoreRuntimeContext &operator=(CLCoreRuntimeContext &&) = default;
- /** CPU Scheduler setter */
-
+ /** Kernel Library accessor
+ *
+ * @return The kernel library instance used by the core context
+ */
CLKernelLibrary *kernel_library() const;
- cl::Context context();
+ /** OpenCL context accessor
+ *
+ * @return The OpenCL context used by the core context
+ */
+ cl::Context context();
+ /** OpenCL command queue accessor
+ *
+ * @return The OpenCL queue used by the core context
+ */
cl::CommandQueue queue();
private:
diff --git a/arm_compute/core/CL/CLHelpers.h b/arm_compute/core/CL/CLHelpers.h
index 9130e05121..8801af579e 100644
--- a/arm_compute/core/CL/CLHelpers.h
+++ b/arm_compute/core/CL/CLHelpers.h
@@ -182,5 +182,5 @@ bool preferred_dummy_work_items_support(const cl::Device &device);
* @return An opencl kernel
*/
cl::Kernel create_opencl_kernel(CLCoreRuntimeContext *ctx, const std::string &kernel_name, const CLBuildOptions &build_opts);
-}
+} // namespace arm_compute
#endif /* __ARM_COMPUTE_CLHELPERS_H__ */
diff --git a/arm_compute/core/CL/CLKernelLibrary.h b/arm_compute/core/CL/CLKernelLibrary.h
index f2282692f9..4f5aa76a03 100644
--- a/arm_compute/core/CL/CLKernelLibrary.h
+++ b/arm_compute/core/CL/CLKernelLibrary.h
@@ -327,5 +327,5 @@ private:
static const std::map<std::string, std::string> _program_source_map; /**< Contains sources for all programs.
Used for compile-time kernel inclusion. >*/
};
-}
+} // namespace arm_compute
#endif /* __ARM_COMPUTE_CLKERNELLIBRARY_H__ */
diff --git a/arm_compute/core/CL/OpenCL.h b/arm_compute/core/CL/OpenCL.h
index b1d50e73b1..9b402abe2f 100644
--- a/arm_compute/core/CL/OpenCL.h
+++ b/arm_compute/core/CL/OpenCL.h
@@ -61,9 +61,13 @@ bool opencl_is_available();
class CLSymbols final
{
public:
+ /** Default Constructor */
CLSymbols() = default;
+ /** Load OpenCL symbols from handle
+ *
+ * @param[in] handle Handle to load symbols from
+ */
void load_symbols(void *handle);
-
/** Get the static instance of CLSymbols.
*
* @return The static instance of CLSymbols.
diff --git a/arm_compute/core/GLES_COMPUTE/GCCoreRuntimeContext.h b/arm_compute/core/GLES_COMPUTE/GCCoreRuntimeContext.h
new file mode 100644
index 0000000000..be47bfd61c
--- /dev/null
+++ b/arm_compute/core/GLES_COMPUTE/GCCoreRuntimeContext.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 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.
+ */
+#ifndef __ARM_COMPUTE_GCCORERUNTIME_CONTEXT_H__
+#define __ARM_COMPUTE_GCCORERUNTIME_CONTEXT_H__
+
+#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
+
+namespace arm_compute
+{
+// Forward declarations
+class GCKernelLibrary;
+
+/** Core runtime context for OpenGL ES */
+class GCCoreRuntimeContext final
+{
+public:
+ /** Legacy constructor */
+ GCCoreRuntimeContext();
+
+ /** Constructor */
+ GCCoreRuntimeContext(GCKernelLibrary *kernel_lib);
+ /** Destructor */
+ ~GCCoreRuntimeContext() = default;
+ /** Default copy constructor */
+ GCCoreRuntimeContext(const GCCoreRuntimeContext &) = default;
+ /** Default move constructor */
+ GCCoreRuntimeContext(GCCoreRuntimeContext &&) = default;
+ /** Default copy assignment */
+ GCCoreRuntimeContext &operator=(const GCCoreRuntimeContext &) = default;
+ /** Default move assignment operator */
+ GCCoreRuntimeContext &operator=(GCCoreRuntimeContext &&) = default;
+ /** Kernel Library accessor
+ *
+ * @return The kernel library instance used by the core context
+ */
+ GCKernelLibrary *kernel_library() const;
+
+private:
+ GCKernelLibrary *_kernel_lib{ nullptr };
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_GCCORERUNTIME_CONTEXT_H__ */
diff --git a/arm_compute/core/GLES_COMPUTE/GCHelpers.h b/arm_compute/core/GLES_COMPUTE/GCHelpers.h
index 1422afe2b5..ccab6c53d5 100644
--- a/arm_compute/core/GLES_COMPUTE/GCHelpers.h
+++ b/arm_compute/core/GLES_COMPUTE/GCHelpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 ARM Limited.
+ * Copyright (c) 2017-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -24,13 +24,20 @@
#ifndef __ARM_COMPUTE_GCHELPERS_H__
#define __ARM_COMPUTE_GCHELPERS_H__
+#include "arm_compute/core/GLES_COMPUTE/IGCKernel.h"
#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
#include "arm_compute/core/GPUTarget.h"
#include "arm_compute/core/Helpers.h"
#include "support/ToolchainSupport.h"
+#include <set>
+#include <string>
+
namespace arm_compute
{
+// Forward declarations
+class GCCoreRuntimeContext;
+
/** Max vector width of an GLES vector */
static constexpr unsigned int max_gc_vector_width = 16;
@@ -39,5 +46,14 @@ static constexpr unsigned int max_gc_vector_width = 16;
* @return the GPU target
*/
GPUTarget get_target_from_device();
+/** Creates an GLES kernel
+ *
+ * @param[in] ctx A context to be used to create the GLES kernel.
+ * @param[in] kernel_name The kernel name.
+ * @param[in] build_opts The build options to be used for the GLES kernel compilation.
+ *
+ * @return A GLES kernel
+ */
+GCKernel create_opengl_kernel(GCCoreRuntimeContext *ctx, const std::string &kernel_name, const std::set<std::string> &build_opts);
} // namespace arm_compute
#endif /* __ARM_COMPUTE_GCHELPERS_H__ */
diff --git a/arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h b/arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h
index 89d6d17eb5..92e6bee4ef 100644
--- a/arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h
+++ b/arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h
@@ -36,7 +36,7 @@
namespace arm_compute
{
/** GCProgram class */
-class GCProgram
+class GCProgram final
{
public:
/** Default constructor. */
@@ -84,7 +84,7 @@ private:
};
/** GCKernel class */
-class GCKernel
+class GCKernel final
{
public:
/** Default Constructor. */
@@ -184,22 +184,21 @@ private:
};
/** GCKernelLibrary class */
-class GCKernelLibrary
+class GCKernelLibrary final
{
using StringSet = std::set<std::string>;
-private:
+public:
/** Default Constructor. */
GCKernelLibrary();
+ /** Default Destructor */
~GCKernelLibrary();
-
-public:
/** Prevent instances of this class from being copied */
GCKernelLibrary(const GCKernelLibrary &) = delete;
/** Prevent instances of this class from being copied */
const GCKernelLibrary &operator=(const GCKernelLibrary &) = delete;
/** Get the static instance of @ref GCKernelLibrary.
- *
+ * This method has been deprecated and will be removed in the next release.
* @return The static instance of GCKernelLibrary.
*/
static GCKernelLibrary &get();
@@ -209,40 +208,18 @@ public:
* @param[in] dpy (Optional) EGLdisplay set by external application.
* @param[in] ctx (Optional) EGLContext set by external application.
*/
- void init(std::string shader_path = "./", EGLDisplay dpy = EGL_NO_DISPLAY, EGLContext ctx = EGL_NO_CONTEXT)
- {
- //TODO: deal with old display and context.
- _shader_path = std::move(shader_path);
-
- _display = dpy;
- _context = ctx;
-
- eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, _context);
- setup_dummy_fbo();
- }
-
+ void init(std::string shader_path = "./", EGLDisplay dpy = EGL_NO_DISPLAY, EGLContext ctx = EGL_NO_CONTEXT);
/** Sets the path that the shaders reside in.
*
* @param[in] shader_path Path of the shader.
*/
- void set_shader_path(const std::string &shader_path)
- {
- _shader_path = shader_path;
- };
+ void set_shader_path(const std::string &shader_path);
/** Sets display and context to create kernel.
*
* @param[in] dpy EGLdisplay set by external application.
* @param[in] ctx EGLContext set by external application.
*/
- void set_context(EGLDisplay dpy, EGLContext ctx)
- {
- //TODO: deal with old display and context.
- _display = dpy;
- _context = ctx;
-
- eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
- setup_dummy_fbo();
- };
+ void set_context(EGLDisplay dpy, EGLContext ctx);
/** Creates a kernel from the kernel library.
*
* @param[in] shader_name Shader name.
@@ -251,17 +228,11 @@ public:
* @return The created kernel.
*/
GCKernel create_kernel(const std::string &shader_name, const StringSet &build_options_set = {}) const;
- /** Serializes and saves programs to a binary.
- *
- */
+ /** Serializes and saves programs to a binary. */
void save_binary();
- /** Load serialized binary with all the programs.
- *
- */
+ /** Load serialized binary with all the programs. */
void load_binary();
- /** Setup a dummy fbo to workaround an issue on Galaxy S8.
- *
- */
+ /** Setup a dummy fbo to workaround an issue on Galaxy S8. */
void setup_dummy_fbo();
private:
@@ -296,5 +267,5 @@ private:
static const std::map<std::string, std::string> _program_source_map; /**< Contains sources for all programs.
Used for compile-time shader inclusion. */
};
-}
+} // namespace arm_compute
#endif /* __ARM_COMPUTE_GCKERNELLIBRARY_H__ */
diff --git a/arm_compute/core/GLES_COMPUTE/kernels/GCActivationLayerKernel.h b/arm_compute/core/GLES_COMPUTE/kernels/GCActivationLayerKernel.h
index fc1d52f455..8388222455 100644
--- a/arm_compute/core/GLES_COMPUTE/kernels/GCActivationLayerKernel.h
+++ b/arm_compute/core/GLES_COMPUTE/kernels/GCActivationLayerKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,14 +28,19 @@
namespace arm_compute
{
+// Forward declarations
class IGCTensor;
+class GCCoreRuntimeContext;
/** Interface for the activation layer kernel. */
class GCActivationLayerKernel : public IGCKernel
{
public:
- /** Default constructor */
- GCActivationLayerKernel();
+ /** Default constructor
+ *
+ * @param[in, out] ctx Core context to use
+ */
+ explicit GCActivationLayerKernel(GCCoreRuntimeContext *ctx = nullptr);
/** Prevent instances of this class from being copied (As this class contains pointers) */
GCActivationLayerKernel(const GCActivationLayerKernel &) = delete;
/** Prevent instances of this class from being copied (As this class contains pointers) */
@@ -61,8 +66,9 @@ public:
void run(const Window &window) override;
private:
- IGCTensor *_input;
- IGCTensor *_output;
+ IGCTensor *_input;
+ IGCTensor *_output;
+ GCCoreRuntimeContext *_ctx;
};
-}
+} // namespace arm_compute
#endif /*__ARM_COMPUTE_GCACTIVATIONLAYERKERNEL_H__ */