| 1 | /* |
| 2 | * Copyright (c) 2017, Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included |
| 12 | * in all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | */ |
| 22 | //! |
| 23 | //! \file cm_task.h |
| 24 | //! \brief Contains CmTask declatation. |
| 25 | //! |
| 26 | |
| 27 | #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASK_H_ |
| 28 | #define MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASK_H_ |
| 29 | |
| 30 | #include "cm_def.h" |
| 31 | |
| 32 | enum CM_CONDITIONAL_END_OPERATOR_CODE |
| 33 | { |
| 34 | MAD_GREATER_THAN_IDD = 0, |
| 35 | MAD_GREATER_THAN_OR_EQUAL_IDD, |
| 36 | MAD_LESS_THAN_IDD, |
| 37 | MAD_LESS_THAN_OR_EQUAL_IDD, |
| 38 | MAD_EQUAL_IDD, |
| 39 | MAD_NOT_EQUAL_IDD |
| 40 | }; |
| 41 | |
| 42 | //! |
| 43 | //! \brief CM_CONDITIONAL_END_PARAM |
| 44 | //! \details |
| 45 | //! The parameters of conditional batch buffer end command, for platforms |
| 46 | //! till CNL, only opValue and opMask fields are used. |
| 47 | //! |
| 48 | struct CM_CONDITIONAL_END_PARAM |
| 49 | { |
| 50 | uint32_t opValue; //!< operand of comparing operation |
| 51 | CM_CONDITIONAL_END_OPERATOR_CODE opCode; //!< operation type |
| 52 | bool opMask; //!< mask of operand |
| 53 | bool opLevel; //!< batch buffer level to end |
| 54 | }; |
| 55 | |
| 56 | namespace CMRT_UMD |
| 57 | { |
| 58 | class CmKernel; |
| 59 | |
| 60 | //! \brief CmTask Class to manage task parameters. |
| 61 | //! \details CmTask contains one or multiple CmKernels, optional |
| 62 | //! synchronization point between two consecutive kernels, |
| 63 | //! and some execution parameters. CmTask is the unit to |
| 64 | //! enqueue. |
| 65 | //! If there is no synchronization point. kernels will run |
| 66 | //! concurrently. If there is a synchronization point, kernels |
| 67 | //! after the synchronization point will not start until kernels |
| 68 | //! before the synchronization point finishes. |
| 69 | class CmTask |
| 70 | { |
| 71 | public: |
| 72 | //! |
| 73 | //! \brief Add a CmKernel pointer to CmTask. |
| 74 | //! \details Same kernel can appear in the task multiple times as long |
| 75 | //! as all the value of its arguments are the same for multiple |
| 76 | //! copies of the kernel. |
| 77 | //! \param [in] kernel |
| 78 | //! A pointer to CmKernel object. |
| 79 | //! \retval CM_SUCCESS if kernel is added. |
| 80 | //! \retval CM_EXCEED_MAX_KERNEL_PER_ENQUEUE trying to add more kernels |
| 81 | //! than CAP_KERNEL_COUNT_PER_TASK. |
| 82 | //! \retval CM_INVALID_ARG_VALUE if kernel is NULL. |
| 83 | //! |
| 84 | CM_RT_API virtual int32_t AddKernel(CmKernel *kernel) = 0; |
| 85 | |
| 86 | //! |
| 87 | //! \brief Resets a CmTask object |
| 88 | //! \details All contents contained in CmTask get reset. Application need |
| 89 | //! add kernel, optional synchronization points, etc. again to |
| 90 | //! the CmTask. This function is to reuse CmTask for diffrent |
| 91 | //! contents so CmTask creation/destroy overhead can be avoided. |
| 92 | //! \returns CM_SUCCESS. |
| 93 | //! |
| 94 | CM_RT_API virtual int32_t Reset() = 0; |
| 95 | |
| 96 | //! |
| 97 | //! \brief Inserts a synchronization point among kernels. |
| 98 | //! \details Kernels after the synchronization point will not start |
| 99 | //! execution untill kernels before the synchronization |
| 100 | //! point finishes execution. A CmTask can have multiple |
| 101 | //! synchronization points. |
| 102 | //! \returns CM_SUCCESS. |
| 103 | //! |
| 104 | CM_RT_API virtual int32_t AddSync() = 0; |
| 105 | |
| 106 | //! |
| 107 | //! \brief Set a per-task based power option to current task. |
| 108 | //! \details The power option includes the hardware configuration of |
| 109 | //! slice, subslice and EU number. The setting takes effect |
| 110 | //! only for current task; the value needs to be set again if |
| 111 | //! user wants it to take effect for the next task. |
| 112 | //! \param [in] powerOption |
| 113 | //! A pointer to CM_POWER_OPTION struct |
| 114 | //! \retval CM_SUCCESS. |
| 115 | //! \retval CM_EXCEED_MAX_POWER_OPTION_FOR_ PLATFORM if the any of the |
| 116 | //! settings exceeds the limit of current platform |
| 117 | //! configuration. |
| 118 | //! |
| 119 | CM_RT_API virtual int32_t |
| 120 | SetPowerOption(PCM_POWER_OPTION powerOption) = 0; |
| 121 | |
| 122 | //! |
| 123 | //! \brief This API is used for the conditional end feature. |
| 124 | //! \details It adds a conditional batch buffer end command between two |
| 125 | //! kernels in a task. The conditionalSurface + offset is the |
| 126 | //! address storing its data against the dword value provided in |
| 127 | //! conditionalParam. If the data at the compare memory address is |
| 128 | //! greater than the dword set in conditionalParam, the execution of |
| 129 | //! the command buffer will continue. If not, the remaining |
| 130 | //! kernels in the task will be skipped. The user can call this |
| 131 | //! API multiple times to insert multiple conditional ends |
| 132 | //! between different kernels. When opMask in conditionalParam is 1, |
| 133 | //! the actual comparison value is the result of bitwise-and of |
| 134 | //! the value in memory and mask. |
| 135 | //! \param [in] conditionalSurfaceIndex |
| 136 | //! Pointer to the surface used to store comparison |
| 137 | //! dword by kernel. |
| 138 | //! \param [in] offset |
| 139 | //! The offset pointered by pSurface where stores comparison |
| 140 | //! dword value, and mask if opMask in conditionalParam is set to 1. |
| 141 | //! \param [in] conditionalParam |
| 142 | //! Pointer to the parameters of conditional batch buffer end |
| 143 | //! command, for platforms till CNL, only opValue and opMask fields are |
| 144 | //! used. |
| 145 | //! \retval CM_SUCCESS if successfully add a conditional batch buffer |
| 146 | //! end. |
| 147 | //! \retval CM_FAILURE otherwise. |
| 148 | //! |
| 149 | CM_RT_API virtual int32_t |
| 150 | AddConditionalEnd(SurfaceIndex* conditionalSurfaceIndex, |
| 151 | uint32_t offset, |
| 152 | CM_CONDITIONAL_END_PARAM *conditionalParam) = 0; |
| 153 | |
| 154 | //! |
| 155 | //! \brief Expose bitfield for task related property. |
| 156 | //! \details Currently this function can be used to expose the |
| 157 | //! bitfield for turbo boost. |
| 158 | //! \param [out] taskConfig |
| 159 | //! specify which bitfield will be exposed. |
| 160 | //! \returns CM_SUCCESS. |
| 161 | //! |
| 162 | CM_RT_API virtual int32_t SetProperty(const CM_TASK_CONFIG &taskConfig) = 0; |
| 163 | |
| 164 | //! |
| 165 | //! \brief Add a CmKernel pointer to CmTask with customized execution |
| 166 | //! configure. |
| 167 | //! \details Same kernel can appear in the task multiple times as long |
| 168 | //! as all the value of its arguments are the same for multiple |
| 169 | //! copies of the kernel. |
| 170 | //! \param [in] kernel |
| 171 | //! A pointer to CmKernel object. |
| 172 | //! \param [in] config |
| 173 | //! A Pointer to customized kernel execution configure. |
| 174 | //! \retval CM_SUCCESS if kernel is added. |
| 175 | //! \retval CM_EXCEED_MAX_KERNEL_PER_ENQUEUE trying to add more kernels |
| 176 | //! than CAP_KERNEL_COUNT_PER_TASK. |
| 177 | //! \retval CM_INVALID_ARG_VALUE if kernel is NULL. |
| 178 | //! |
| 179 | CM_RT_API virtual int32_t AddKernelWithConfig( CmKernel *pKernel, const CM_EXECUTION_CONFIG *config ) = 0; |
| 180 | |
| 181 | //! |
| 182 | //! \brief Get task related property. |
| 183 | //! \details Currently this function can be used to get the |
| 184 | //! bitfield for turbo boost. |
| 185 | //! \param [out] taskConfig |
| 186 | //! Task related property. |
| 187 | //! \returns CM_SUCCESS. |
| 188 | //! |
| 189 | CM_RT_API virtual int32_t GetProperty(CM_TASK_CONFIG &taskConfig) = 0; |
| 190 | |
| 191 | //! \brief Set a per-kernel based power option to current kernel with dataCacheFlush flag or etc. |
| 192 | //! \details this function can be inserted after kernel added so that pipe_control will be inserted after the |
| 193 | //! walker with dataCacheFlush flag. |
| 194 | //! \param [in] taskConfig |
| 195 | //! A pointer to CM_KERNEL_SYNC_CONFIG object. |
| 196 | //! \retval CM_SUCCESS if CM_KERNEL_SYNC_CONFIG info can be successfully stored in CM_TASK. |
| 197 | //! \retval CM_FAILURE if the pointer is invalid. |
| 198 | //! |
| 199 | CM_RT_API virtual int32_t AddSyncEx(const CM_KERNEL_SYNC_CONFIG *config) = 0; |
| 200 | }; |
| 201 | }; //namespace |
| 202 | |
| 203 | #endif // #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASK_H_ |