Compute Library
 21.02
IGCTensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 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  */
24 #ifndef ARM_COMPUTE_IGCTENSOR_H
25 #define ARM_COMPUTE_IGCTENSOR_H
26 
29 
30 #include <cstdint>
31 
32 namespace arm_compute
33 {
34 /** Interface for GLES Compute tensor */
35 class IGCTensor : public ITensor
36 {
37 public:
38  /** Default constructor. */
39  IGCTensor();
40 
41  /** Prevent instances of this class from being copied (As this class contains pointers) */
42  IGCTensor(const IGCTensor &) = delete;
43 
44  /** Prevent instances of this class from being copy assigned (As this class contains pointers) */
45  IGCTensor &operator=(const IGCTensor &) = delete;
46 
47  /** Allow instances of this class to be moved */
48  IGCTensor(IGCTensor &&) = default;
49 
50  /** Allow instances of this class to be moved */
51  IGCTensor &operator=(IGCTensor &&) = default;
52 
53  /** Virtual destructor */
54  virtual ~IGCTensor() = default;
55 
56  /** Map on an allocated buffer.
57  *
58  * @param[in] blocking (Optional) If true, then the mapping will be ready to use by the time
59  * this method returns, else it is the caller's responsibility
60  * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
61  */
62  void map(bool blocking = true);
63  /** Unmap an allocated and mapped buffer.
64  */
65  void unmap();
66  /** Clear the contents of the tensor synchronously.
67  */
68  void clear();
69 
70  // Inherited methods overridden:
71  uint8_t *buffer() const override;
72  /** Interface to be implemented by the child class to return the tensor's gles compute buffer id.
73  *
74  * @return A SSBO buffer id.
75  */
76  virtual GLuint gc_buffer() const = 0;
77 
78  /** Flag indicating whether the tensor has been left aligned by a kernel and therefore needs shifting.
79  *
80  * @return True if the tensor is left aligned.
81  */
82  bool needs_shifting() const;
83  /** Set the flag indicating whether or not a tensor needs shifting.
84  *
85  * @param[in] needs_shifting Indicates if the tensor is left aligned or not.
86  *
87  */
88  void set_needs_shifting(bool needs_shifting);
89 
90 protected:
91  /** Method to be implemented by the child class to map the SSBO.
92  *
93  * @param[in] blocking If true, then the mapping will be ready to use by the time
94  * this method returns, else it is the caller's responsibility
95  * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
96  */
97  virtual uint8_t *do_map(bool blocking) = 0;
98  /** Method to be implemented by the child class to unmap the SSBO.
99  *
100  * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before
101  * the memory is accessed by the device.
102  */
103  virtual void do_unmap() = 0;
104 
105 private:
106  uint8_t *_mapping;
107  bool _needs_shifting;
108 };
109 
110 /** Interface for GLES Compute image */
112 }
113 #endif /*ARM_COMPUTE_IGCTENSOR_H */
void map(bool blocking=true)
Map on an allocated buffer.
Definition: IGCTensor.cpp:33
virtual ~IGCTensor()=default
Virtual destructor.
uint8_t * buffer() const override
Interface to be implemented by the child class to return a pointer to CPU memory. ...
Definition: IGCTensor.cpp:51
void unmap()
Unmap an allocated and mapped buffer.
Definition: IGCTensor.cpp:38
void clear()
Clear the contents of the tensor synchronously.
Definition: IGCTensor.cpp:44
Interface for GLES Compute tensor.
Definition: IGCTensor.h:35
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
virtual GLuint gc_buffer() const =0
Interface to be implemented by the child class to return the tensor&#39;s gles compute buffer id...
void set_needs_shifting(bool needs_shifting)
Set the flag indicating whether or not a tensor needs shifting.
Definition: IGCTensor.cpp:61
bool needs_shifting() const
Flag indicating whether the tensor has been left aligned by a kernel and therefore needs shifting...
Definition: IGCTensor.cpp:56
Wrapper to configure the Khronos EGL and OpenGL ES C header.
IGCTensor()
Default constructor.
Definition: IGCTensor.cpp:28
IGCTensor & operator=(const IGCTensor &)=delete
Prevent instances of this class from being copy assigned (As this class contains pointers) ...