|
17 | 17 | #define VX_CONTEXT_H |
18 | 18 |
|
19 | 19 | #include <memory> |
| 20 | +#include <vector> |
20 | 21 |
|
21 | 22 | #include "vx_event_queue.hpp" |
22 | 23 | #include "vx_internal.h" |
|
25 | 26 | /*! |
26 | 27 | * \file |
27 | 28 | * \brief |
28 | | - * \author Erik Rainey <[email protected]> |
29 | 29 | * |
30 | 30 | * \defgroup group_int_context Internal Context API |
31 | 31 | * \ingroup group_internal |
@@ -53,6 +53,150 @@ class Context : public Reference |
53 | 53 | */ |
54 | 54 | ~Context(); |
55 | 55 |
|
| 56 | + /** |
| 57 | + * @brief Get vendor id |
| 58 | + * |
| 59 | + * @return vx_uint16 The vendor id. |
| 60 | + * @ingroup group_int_context |
| 61 | + */ |
| 62 | + vx_uint16 vendorId() const; |
| 63 | + |
| 64 | + /** |
| 65 | + * @brief Get version number |
| 66 | + * |
| 67 | + * @return vx_uint16 The version number. |
| 68 | + * @ingroup group_int_context |
| 69 | + */ |
| 70 | + vx_uint16 version() const; |
| 71 | + |
| 72 | + /** |
| 73 | + * @brief Get number of loaded modules |
| 74 | + * |
| 75 | + * @return vx_uint32 The number of loaded modules. |
| 76 | + * @ingroup group_int_context |
| 77 | + */ |
| 78 | + vx_uint32 numModules() const; |
| 79 | + |
| 80 | + /** |
| 81 | + * @brief Get number of references |
| 82 | + * |
| 83 | + * @return vx_uint32 The number of tracked references. |
| 84 | + * @ingroup group_int_context |
| 85 | + */ |
| 86 | + vx_uint32 numReferences() const; |
| 87 | + |
| 88 | + /** |
| 89 | + * @brief Get the implementation name |
| 90 | + * |
| 91 | + * @return const vx_char* The implementation name. |
| 92 | + * @ingroup group_int_context |
| 93 | + */ |
| 94 | + const vx_char* implName() const; |
| 95 | + |
| 96 | + /** |
| 97 | + * @brief Get the names of the extensions supported |
| 98 | + * |
| 99 | + * @return const vx_char* The names of the extensions supported |
| 100 | + * @ingroup group_int_context |
| 101 | + */ |
| 102 | + const vx_char* extensions() const; |
| 103 | + |
| 104 | + /** |
| 105 | + * @brief Get the max dimensions of a convolution supported |
| 106 | + * |
| 107 | + * @return vx_size The max dimensions of a convolution supported. |
| 108 | + * @ingroup group_int_context |
| 109 | + */ |
| 110 | + vx_size convolutionMaxDim() const; |
| 111 | + |
| 112 | + /** |
| 113 | + * @brief Get the max dimensions of a non linear supported |
| 114 | + * |
| 115 | + * @return vx_size The max dimensions of a non linear supported. |
| 116 | + * @ingroup group_int_context |
| 117 | + */ |
| 118 | + vx_size nonLinearMaxDim() const; |
| 119 | + |
| 120 | + /** |
| 121 | + * @brief Get the optical flow max window dimension supported |
| 122 | + * |
| 123 | + * @return vx_size The optical flow max window dimension supported. |
| 124 | + * @ingroup group_int_context |
| 125 | + */ |
| 126 | + vx_size opticalFlowMaxWindowDim() const; |
| 127 | + |
| 128 | + /** |
| 129 | + * @brief Get the immediate border |
| 130 | + * |
| 131 | + * @return vx_border_t The immediate border. |
| 132 | + * @ingroup group_int_context |
| 133 | + */ |
| 134 | + vx_border_t immediateBorder() const; |
| 135 | + |
| 136 | + /** |
| 137 | + * @brief Get the immediate border policy |
| 138 | + * |
| 139 | + * @return vx_enum The immediate border policy. |
| 140 | + * @ingroup group_int_context |
| 141 | + */ |
| 142 | + vx_enum immediateBorderPolicy() const; |
| 143 | + |
| 144 | + /** |
| 145 | + * @brief Get the number of unique kernels |
| 146 | + * |
| 147 | + * @return vx_uint32 The number of unique kernels. |
| 148 | + * @ingroup group_int_context |
| 149 | + */ |
| 150 | + vx_uint32 numUniqueKernels() const; |
| 151 | + |
| 152 | + /** |
| 153 | + * @brief Get the max tensor dimensions supported |
| 154 | + * |
| 155 | + * @return vx_size The max tensor dimensions supported. |
| 156 | + * @ingroup group_int_context |
| 157 | + */ |
| 158 | + vx_size maxTensorDims() const; |
| 159 | + |
| 160 | + /** |
| 161 | + * @brief Get the unique kernel information |
| 162 | + * |
| 163 | + * @return std::vector<vx_kernel_info_t> The unique kernel information table. |
| 164 | + * @ingroup group_int_context |
| 165 | + */ |
| 166 | + std::vector<vx_kernel_info_t> uniqueKernelTable(); |
| 167 | + |
| 168 | + /** |
| 169 | + * @brief Get the OpenCL context |
| 170 | + * |
| 171 | + * @return cl_context The OpenCL context. |
| 172 | + * @ingroup group_int_context |
| 173 | + */ |
| 174 | + cl_context clContext() const; |
| 175 | + |
| 176 | + /** |
| 177 | + * @brief Get the OpenCL command queue |
| 178 | + * |
| 179 | + * @return cl_command_queue The OpenCL command queue. |
| 180 | + * @ingroup group_int_context |
| 181 | + */ |
| 182 | + cl_command_queue clCommandQueue() const; |
| 183 | + |
| 184 | + /** |
| 185 | + * @brief Set the logging enabled state |
| 186 | + * |
| 187 | + * @param flag vx_bool indicating whether to enable or disable logging |
| 188 | + * @ingroup group_int_context |
| 189 | + */ |
| 190 | + void setLoggingEnabled(vx_bool flag); |
| 191 | + |
| 192 | + /** |
| 193 | + * @brief Set the perf enabled state |
| 194 | + * |
| 195 | + * @param flag vx_bool indicating whether to enable or disable performance tracking |
| 196 | + * @ingroup group_int_context |
| 197 | + */ |
| 198 | + void setPerfEnabled(vx_bool flag); |
| 199 | + |
56 | 200 | /*! \brief This determines if a context is valid. |
57 | 201 | * \param [in] context The pointer to the context to test. |
58 | 202 | * \retval vx_true_e The context is valid. |
@@ -106,12 +250,8 @@ class Context : public Reference |
106 | 250 | * will allocate memory if needed. |
107 | 251 | * \ingroup group_int_context |
108 | 252 | */ |
109 | | - vx_bool addAccessor(vx_size size, |
110 | | - vx_enum usage, |
111 | | - void*& ptr, |
112 | | - vx_reference ref, |
113 | | - vx_uint32 *pIndex, |
114 | | - void *extra_data); |
| 253 | + vx_bool addAccessor(vx_size size, vx_enum usage, void*& ptr, vx_reference ref, |
| 254 | + vx_uint32* pIndex, void* extra_data); |
115 | 255 |
|
116 | 256 | /*! \brief Finds and removes an accessor from the list. |
117 | 257 | * \ingroup group_int_context |
@@ -174,21 +314,101 @@ class Context : public Reference |
174 | 314 | /** |
175 | 315 | * @brief Launch worker graph thread |
176 | 316 | * |
177 | | - * @param arg |
178 | | - * @return vx_value_t |
| 317 | + * @param arg Optional argument to pass as parameter. |
| 318 | + * @return vx_value_t Thread return value. |
179 | 319 | * @ingroup group_int_context |
180 | 320 | */ |
181 | 321 | static vx_value_t workerGraph(void *arg); |
182 | 322 |
|
183 | 323 | /** |
184 | | - * @brief Launch worker node thread |
| 324 | + * @brief Launch worker node |
185 | 325 | * |
186 | | - * @param worker |
187 | | - * @return vx_bool |
| 326 | + * @param worker The threadpool of the worker. |
| 327 | + * @return vx_bool vx_true_e if ran successful, vx_false_e otherwise |
188 | 328 | * @ingroup group_int_context |
189 | 329 | */ |
190 | 330 | static vx_bool workerNode(vx_threadpool_worker_t *worker); |
191 | 331 |
|
| 332 | + /** |
| 333 | + * @brief Register a user struct with a certain number of bytes |
| 334 | + * |
| 335 | + * @param size The size in bytes of the user struct. |
| 336 | + * @return vx_enum The user struct enumeration. |
| 337 | + * @ingroup group_int_context |
| 338 | + */ |
| 339 | + vx_enum registerUserStruct(vx_size size); |
| 340 | + |
| 341 | + /** |
| 342 | + * @brief Get the User Struct By Name object |
| 343 | + * |
| 344 | + * @param name The user struct name. |
| 345 | + * @return vx_enum The user struct enumeration. |
| 346 | + * @ingroup group_int_context |
| 347 | + */ |
| 348 | + vx_enum getUserStructByName(const vx_char* name); |
| 349 | + |
| 350 | + /** |
| 351 | + * @brief Get the User Struct Name By Enum object |
| 352 | + * |
| 353 | + * @param user_struct_type Enumeration for user struct type. |
| 354 | + * @param type_name Name of user struct type. |
| 355 | + * @param name_size Size of user struct name. |
| 356 | + * @return vx_status VX_SUCCESS if successful, otherwise a return status with an error |
| 357 | + * code. |
| 358 | + * @ingroup group_int_context |
| 359 | + */ |
| 360 | + vx_status getUserStructNameByEnum(vx_enum user_struct_type, vx_char* type_name, |
| 361 | + vx_size name_size); |
| 362 | + |
| 363 | + /** |
| 364 | + * @brief Get the User Struct Enum By Name object |
| 365 | + * |
| 366 | + * @param type_name The user struct name. |
| 367 | + * @param user_struct_type The user struct type enumeration. |
| 368 | + * @return vx_status VX_SUCCESS if successful, otherwise a return status with an error |
| 369 | + * code. |
| 370 | + * @ingroup group_int_context |
| 371 | + */ |
| 372 | + vx_status getUserStructEnumByName(const vx_char* type_name, vx_enum* user_struct_type); |
| 373 | + |
| 374 | + /** |
| 375 | + * @brief Register user struct with name |
| 376 | + * |
| 377 | + * @param size Size of user struct name. |
| 378 | + * @param type_name The user struct name. |
| 379 | + * @return vx_enum Enumeration of registered user struct |
| 380 | + * @ingroup group_int_context |
| 381 | + */ |
| 382 | + vx_enum registerUserStructWithName(vx_size size, const vx_char* type_name); |
| 383 | + |
| 384 | + /** |
| 385 | + * @brief Allocate a unique kernel id |
| 386 | + * |
| 387 | + * @param pKernelEnumId Pointer to allocated kernel id by the framework. |
| 388 | + * @return vx_status VX_SUCCESS if successful, otherwise a return status with an error code. |
| 389 | + * @ingroup group_int_context |
| 390 | + */ |
| 391 | + vx_status allocateKernelId(vx_enum* pKernelEnumId); |
| 392 | + |
| 393 | + /** |
| 394 | + * @brief Allocate a unique library id |
| 395 | + * |
| 396 | + * @param pLibraryId Pointer to allocated library id by the framework. |
| 397 | + * @return vx_status VX_SUCCESS if successful, otherwise a return status with an error code. |
| 398 | + * @ingroup group_int_context |
| 399 | + */ |
| 400 | + vx_status allocateLibraryId(vx_enum* pLibraryId); |
| 401 | + |
| 402 | + /** |
| 403 | + * @brief Set the Immediate Mode Target |
| 404 | + * |
| 405 | + * @param target_enum The target enumeration. |
| 406 | + * @param target_string The target string. |
| 407 | + * @return vx_status VX_SUCCESS if successful, otherwise a return status with an error code. |
| 408 | + * @ingroup group_int_context |
| 409 | + */ |
| 410 | + vx_status setImmediateModeTarget(vx_enum target_enum, const char* target_string); |
| 411 | + |
192 | 412 | /*! \brief The pointer to process global lock */ |
193 | 413 | vx_sem_t* p_global_lock; |
194 | 414 | /*! \brief The reference table which contains the handle for later garage collection if needed */ |
@@ -275,6 +495,14 @@ class Context : public Reference |
275 | 495 | vx_value_set_t graph_queue[VX_INT_MAX_QUEUE_DEPTH]; |
276 | 496 | /*! \brief The number of graphs in the queue */ |
277 | 497 | vx_size numGraphsQueued; |
| 498 | + /*! \brief The vendor id */ |
| 499 | + const vx_uint16 vendor_id; |
| 500 | + /*! \brief The version number this implements */ |
| 501 | + const vx_uint16 version_number; |
| 502 | + /*! \brief The name of this impleemntation */ |
| 503 | + const vx_char implementation[VX_MAX_IMPLEMENTATION_NAME]; |
| 504 | + /*! \brief The name of additional extensions in this impleemntation */ |
| 505 | + const vx_char* extension; |
278 | 506 | }; |
279 | 507 |
|
280 | 508 | #endif /* VX_CONTEXT_H */ |
0 commit comments