blob: dd6699a0c99bce43981254d2c7d89d4650a0a614 [file] [log] [blame]
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00001/*
2 * Copyright (c) 2021 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000024#ifndef SRC_GPU_CLCONTEXT_H
25#define SRC_GPU_CLCONTEXT_H
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000026
27#include "src/common/IContext.h"
28#include "src/runtime/CL/mlgo/MLGOHeuristics.h"
29
30#include "arm_compute/core/CL/OpenCL.h"
31
32namespace arm_compute
33{
34namespace gpu
35{
36namespace opencl
37{
38/** OpenCL context implementation class */
39class ClContext final : public IContext
40{
41public:
42 /** Default Constructor
43 *
44 * @param[in] options Creational options
45 */
46 explicit ClContext(const AclContextOptions *options);
47 /** Extract MLGO heuristics
48 *
49 * @return Heuristics tree
50 */
51 const mlgo::MLGOHeuristics &mlgo() const;
52
53 /** Underlying cl context accessor
54 *
55 * @return the cl context used
56 */
57 ::cl::Context cl_ctx();
58 /** Update/inject an underlying cl context object
59 *
60 * @warning Context will be able to set if the object doesn't have any pending reference to other objects
61 *
62 * @param[in] ctx Underlying cl context to be used
63 *
64 * @return true if the context was set successfully else falseS
65 */
66 bool set_cl_ctx(::cl::Context ctx);
67
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000068 // Inherrited methods overridden
69 ITensorV2 *create_tensor(const AclTensorDescriptor &desc, bool allocate) override;
70
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000071private:
72 mlgo::MLGOHeuristics _mlgo_heuristics;
73 ::cl::Context _cl_context;
74};
75} // namespace opencl
76} // namespace gpu
77} // namespace arm_compute
78
Georgios Pinitas3f26ef42021-02-23 10:01:33 +000079#endif /* SRC_GPU_CLCONTEXT_H */