| 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_rt.h |
| 24 |
//! \brief Declaration of CmTaskRT. |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKRT_H_ |
| 28 |
#define MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKRT_H_ |
| 29 |
|
| 30 |
#include "cm_task.h" |
| 31 |
#include "cm_hal.h" |
| 32 |
#include "cm_log.h" |
| 33 |
|
| 34 |
namespace CMRT_UMD |
| 35 |
{ |
| 36 |
class CmKernelRT; |
| 37 |
class CmDeviceRT; |
| 38 |
|
| 39 |
class CmTaskRT: public CmTask |
| 40 |
{ |
| 41 |
public: |
| 42 |
static int32_t Create(CmDeviceRT *device, |
| 43 |
uint32_t index, |
| 44 |
uint32_t maxKernelCount, |
| 45 |
CmTaskRT* &kernelArray); |
| 46 |
|
| 47 |
static int32_t Destroy(CmTaskRT *&kernelArray); |
| 48 |
|
| 49 |
CM_RT_API int32_t AddKernel(CmKernel *kernel); |
| 50 |
|
| 51 |
CM_RT_API int32_t Reset(); |
| 52 |
|
| 53 |
CM_RT_API int32_t AddSync(); |
| 54 |
|
| 55 |
CM_RT_API int32_t AddSyncEx(const CM_KERNEL_SYNC_CONFIG *config) { return CM_SUCCESS; } |
| 56 |
|
| 57 |
CM_RT_API int32_t SetPowerOption(PCM_POWER_OPTION powerOption); |
| 58 |
|
| 59 |
CM_RT_API int32_t AddConditionalEnd(SurfaceIndex *conditionalSurfaceIndex, |
| 60 |
uint32_t offset, |
| 61 |
CM_CONDITIONAL_END_PARAM *conditionalParam); |
| 62 |
|
| 63 |
CM_RT_API int32_t SetProperty(const CM_TASK_CONFIG &taskConfig); |
| 64 |
CM_RT_API int32_t GetProperty(CM_TASK_CONFIG &taskConfig); |
| 65 |
|
| 66 |
CM_RT_API int32_t AddKernelWithConfig(CmKernel *kernel, const CM_EXECUTION_CONFIG *config); |
| 67 |
|
| 68 |
virtual uint32_t GetKernelCount(); |
| 69 |
|
| 70 |
virtual CmKernelRT *GetKernelPointer(uint32_t index); |
| 71 |
|
| 72 |
virtual uint32_t GetIndexInTaskArray(); |
| 73 |
|
| 74 |
bool IntegrityCheckKernelThreadspace(); |
| 75 |
|
| 76 |
uint64_t GetSyncBitmap(); |
| 77 |
|
| 78 |
uint64_t GetConditionalEndBitmap(); |
| 79 |
|
| 80 |
CM_HAL_CONDITIONAL_BB_END_INFO *GetConditionalEndInfo(); |
| 81 |
|
| 82 |
int32_t SetConditionalEndInfo(SurfaceIndex *index, |
| 83 |
uint32_t offset, |
| 84 |
CM_CONDITIONAL_END_PARAM *conditionalParam); |
| 85 |
|
| 86 |
PCM_POWER_OPTION GetPowerOption(); |
| 87 |
|
| 88 |
int32_t AddKernelInternal( CmKernel *kernel, const CM_EXECUTION_CONFIG *config); |
| 89 |
|
| 90 |
const CM_EXECUTION_CONFIG* GetKernelExecuteConfig() { return m_kernelExecuteConfig; }; |
| 91 |
|
| 92 |
#if CM_LOG_ON |
| 93 |
std::string Log(); |
| 94 |
|
| 95 |
CM_HAL_STATE* GetHalState(); |
| 96 |
#endif // #if CM_LOG_ON |
| 97 |
|
| 98 |
protected: |
| 99 |
CmTaskRT(CmDeviceRT *device, |
| 100 |
uint32_t index, |
| 101 |
uint32_t maxKernelCount); |
| 102 |
|
| 103 |
~CmTaskRT(); |
| 104 |
|
| 105 |
int32_t Initialize(); |
| 106 |
|
| 107 |
#if USE_EXTENSION_CODE |
| 108 |
void AddKernelForGTPin(CmKernel *kernel); |
| 109 |
#endif |
| 110 |
|
| 111 |
CmKernelRT **m_kernelArray; |
| 112 |
|
| 113 |
CmDeviceRT *m_device; |
| 114 |
|
| 115 |
uint32_t m_kernelCount; |
| 116 |
|
| 117 |
uint32_t m_maxKernelCount; |
| 118 |
|
| 119 |
uint32_t m_indexTaskArray; |
| 120 |
|
| 121 |
// Reserve a 64-bit variable to indicate if synchronization is insert for kernels. |
| 122 |
// 1 bit per kernel, 0 -- No sync, 1 -- Need sync |
| 123 |
// Up to 64 kernels supported |
| 124 |
uint64_t m_syncBitmap; |
| 125 |
|
| 126 |
// 64-bit variable to indicate if a conditional batch buffer end is inserted between kernels |
| 127 |
// 1 bit per kernel, 0 -- No conditional end, 1 -- Insert conditional end |
| 128 |
// Up to 64 kernels supported |
| 129 |
uint64_t m_conditionalEndBitmap; |
| 130 |
|
| 131 |
CM_HAL_CONDITIONAL_BB_END_INFO |
| 132 |
m_conditionalEndInfo[CM_MAX_CONDITIONAL_END_CMDS]; |
| 133 |
|
| 134 |
CM_POWER_OPTION m_powerOption; |
| 135 |
|
| 136 |
CM_TASK_CONFIG m_taskConfig; |
| 137 |
|
| 138 |
CM_EXECUTION_CONFIG m_kernelExecuteConfig[CM_MAX_KERNELS_PER_TASK]; // replace numOfWalkers in CM_TASK_CONFIG. |
| 139 |
|
| 140 |
private: |
| 141 |
CmTaskRT(const CmTaskRT &other); |
| 142 |
CmTaskRT &operator=(const CmTaskRT &other); |
| 143 |
}; |
| 144 |
}; // namespace; |
| 145 |
|
| 146 |
#endif // #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKRT_H_ |