Sheri Zhang | d813bab | 2021-04-30 16:53:41 +0100 | [diff] [blame^] | 1 | /// |
| 2 | /// Copyright (c) 2017-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 | /// |
| 24 | namespace arm_compute |
| 25 | { |
| 26 | /** |
| 27 | @page programming_model Programming Model |
| 28 | |
| 29 | @tableofcontents |
| 30 | |
| 31 | @section programming_model_functions Functions |
| 32 | |
| 33 | Functions will automatically allocate the temporary buffers mentioned above, and will automatically multi-thread kernels' executions using the very basic scheduler described in the previous section. |
| 34 | |
| 35 | Simple functions only call a single kernel (e.g NEConvolution3x3), while more complex ones consist of several kernels pipelined together (e.g @ref NEFullyConnectedLayer ). Check their documentation to find out which kernels are used by each function. |
| 36 | |
| 37 | @code{.cpp} |
| 38 | //Create a function object: |
| 39 | MyFunction function; |
| 40 | // Initialize the function with the input/output and options you want to use: |
| 41 | function.configure( input, output, option0, option1); |
| 42 | // Execute the function: |
| 43 | function.run(); |
| 44 | @endcode |
| 45 | |
| 46 | @warning The Compute Library requires Arm® Mali™ OpenCL DDK r8p0 or higher (OpenCL kernels are compiled using the -cl-arm-non-uniform-work-group-size flag) |
| 47 | |
| 48 | @note All OpenCL functions and objects in the runtime library use the command queue associated with CLScheduler for all operations, a real implementation would be expected to use different queues for mapping operations and kernels in order to reach a better GPU utilization. |
| 49 | |
| 50 | @section programming_model_scheduler OpenCL Scheduler |
| 51 | |
| 52 | The Compute Library runtime uses a single command queue and context for all the operations. |
| 53 | |
| 54 | The user can get / set this context and command queue through CLScheduler's interface. |
| 55 | |
| 56 | The user can get / set the target GPU device through the CLScheduler's interface. |
| 57 | |
| 58 | @attention Make sure the application is using the same context as the library as in OpenCL it is forbidden to share objects across contexts. This is done by calling @ref CLScheduler::init() or @ref CLScheduler::default_init() at the beginning of your application. |
| 59 | |
| 60 | @attention Make sure the scheduler's target is not changed after function classes are created. |
| 61 | |
| 62 | @section programming_model__events_sync OpenCL events and synchronization |
| 63 | |
| 64 | In order to block until all the jobs in the CLScheduler's command queue are done executing the user can call @ref CLScheduler::sync() or create a sync event using @ref CLScheduler::enqueue_sync_event() |
| 65 | |
| 66 | @section programming_model_cl_neon OpenCL / Arm® Neon™ interoperability |
| 67 | |
| 68 | You can mix OpenCL and Arm® Neon™ kernels and functions. However it is the user's responsibility to handle the mapping/unmapping of OpenCL objects. |
| 69 | */ |
| 70 | } // namespace arm_compute |