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_internal.h 24 //! \brief Contains Class CmTaskInternal definitions 25 //! 26 27 #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKINTERNAL_H_ 28 #define MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKINTERNAL_H_ 29 30 #include "cm_def.h" 31 #include "cm_array.h" 32 #include "cm_event.h" 33 #include "cm_hal.h" 34 #include "cm_hal_vebox.h" 35 #include "cm_log.h" 36 37 enum CM_INTERNAL_TASK_TYPE 38 { 39 CM_INTERNAL_TASK_WITH_THREADSPACE, 40 CM_INTERNAL_TASK_WITH_THREADGROUPSPACE, 41 CM_INTERNAL_TASK_VEBOX, 42 CM_INTERNAL_TASK_ENQUEUEWITHHINTS 43 }; 44 45 #define CM_TASK_TYPE_DEFAULT CM_INTERNAL_TASK_WITH_THREADSPACE 46 47 //*----------------------------------------------------------------------------- 48 //| CM Task Profiling Information 49 //*----------------------------------------------------------------------------- 50 struct CM_PROFILING_INFO 51 { 52 uint32_t taskID; 53 uint32_t threadID; 54 uint32_t kernelCount; 55 uint32_t kernelNameLen; 56 char *kernelNames; 57 uint32_t *localWorkWidth; 58 uint32_t *localWorkHeight; 59 uint32_t *globalWorkWidth; 60 uint32_t *globalWorkHeight; 61 62 LARGE_INTEGER enqueueTime; 63 LARGE_INTEGER flushTime; 64 LARGE_INTEGER hwStartTime; 65 LARGE_INTEGER hwEndTime; 66 LARGE_INTEGER completeTime; 67 }; 68 69 namespace CMRT_UMD 70 { 71 class CmKernelRT; 72 class CmEventRT; 73 class CmKernelData; 74 class CmThreadSpaceRT; 75 class CmThreadGroupSpace; 76 class CmDeviceRT; 77 class CmVeboxRT; 78 class CmVeboxData; 79 class CmBufferUP; 80 81 class CmTaskInternal: public CmDynamicArray 82 { 83 public: 84 85 static int32_t Create( const uint32_t kernelCount, const uint32_t totalThreadCount, 86 CmKernelRT* kernelArray[], const CmThreadSpaceRT* threadSpace, 87 CmDeviceRT* device, const uint64_t syncBitmap, CmTaskInternal*& task, 88 const uint64_t conditionalEndBitmap, 89 PCM_HAL_CONDITIONAL_BB_END_INFO conditionalEndInfo ); 90 static int32_t Destroy( CmTaskInternal* &task ); 91 static int32_t Create( const uint32_t kernelCount, const uint32_t totalThreadCount, 92 CmKernelRT* kernelArray[], const CmThreadGroupSpace* threadGroupSpace, 93 CmDeviceRT* device, const uint64_t syncBitmap, CmTaskInternal*& task, 94 const uint64_t conditionalEndBitmap, 95 PCM_HAL_CONDITIONAL_BB_END_INFO conditionalEndInfo, 96 const CM_EXECUTION_CONFIG* krnExecCfg); 97 static int32_t Create( CmDeviceRT* device, CmVeboxRT* vebox, CmTaskInternal*& task ); 98 static int32_t Create( const uint32_t kernelCount, const uint32_t totalThreadCount, 99 CmKernelRT* kernelArray[], CmTaskInternal*& task, 100 uint32_t numGeneratedTasks, bool isLastTask, uint32_t hints, 101 CmDeviceRT* device); 102 103 virtual int32_t GetKernelCount( uint32_t& count ); 104 virtual int32_t GetKernel( const uint32_t index, CmKernelRT* & kernel ); 105 virtual int32_t GetKernelData( const uint32_t index, CmKernelData* & kernelData ); 106 int32_t GetKernelDataSize( const uint32_t index, uint32_t & size ); 107 uint32_t GetKernelCurbeOffset( const uint32_t index ); 108 int32_t GetTotalThreadCount( uint32_t& totalThreadCount ); 109 110 int32_t SetTaskEvent( CmEventRT* event ); 111 int32_t GetTaskEvent( CmEventRT* & event ); 112 113 int32_t CreateThreadSpaceData(const CmThreadSpaceRT* threadSpace); 114 int32_t GetKernelCoordinates(const uint32_t index, void *&kernelCoordinates); 115 int32_t GetKernelDependencyMasks(const uint32_t index, void *&kernelDependencyMasks); 116 int32_t GetDependencyPattern(CM_DEPENDENCY_PATTERN &dependencyPattern); 117 int32_t GetWalkingPattern(CM_WALKING_PATTERN &walkingPattern); 118 int32_t GetWalkingParameters(CM_WALKING_PARAMETERS &walkingParameters); 119 int32_t GetDependencyVectors(CM_HAL_DEPENDENCY &dependencyVector); 120 bool CheckWalkingParametersSet(); 121 bool CheckDependencyVectorsSet(); 122 #if _DEBUG 123 int32_t DisplayThreadSpaceData(uint32_t width, uint32_t height); 124 #endif 125 int32_t GetThreadSpaceSize(uint32_t& width, uint32_t& height ); 126 int32_t GetThreadGroupSpaceSize(uint32_t& threadSpaceWidth, uint32_t& threadSpaceHeight, 127 uint32_t& threadSpaceDepth, uint32_t& groupSpaceWidth, 128 uint32_t& groupSpaceHeight, uint32_t& groupSpaceDepth); 129 int32_t GetSLMSize(uint32_t& slmSize); 130 int32_t GetSpillMemUsed(uint32_t& spillMemUsed); 131 int32_t GetColorCountMinusOne(uint32_t& colorCount); 132 int32_t GetMediaWalkerGroupSelect(CM_MW_GROUP_SELECT& groupSelect); 133 int32_t GetHints(uint32_t& hints); 134 int32_t GetNumTasksGenerated(uint32_t& numTasksGenerated); 135 int32_t GetLastTask(bool& isLastTask); 136 137 bool IsThreadGroupSpaceCreated(void); 138 bool IsThreadSpaceCreated(void ); 139 bool IsThreadCoordinatesExisted(void); 140 141 int32_t AllocateKernelSurfInfo(); 142 int32_t GetKernelSurfInfo(CM_HAL_SURFACE_ENTRY_INFO_ARRAYS & surfEntryInfoArray); 143 int32_t ClearKernelSurfInfo(); 144 int32_t ResetKernelDataStatus(); 145 146 int32_t GetTaskType(uint32_t& taskType); 147 148 int32_t GetVeboxState(CM_VEBOX_STATE & veboxState); 149 int32_t GetVeboxParam(CmBufferUP * &veboxParam); 150 int32_t GetVeboxSurfaceData(CM_VEBOX_SURFACE_DATA &veboxSurfaceData); 151 152 int32_t GetTaskSurfaces( bool *&surfArray ); 153 154 uint64_t GetSyncBitmap(); 155 uint64_t GetConditionalEndBitmap(); 156 CM_HAL_CONDITIONAL_BB_END_INFO* GetConditionalEndInfo(); 157 158 int32_t SetPowerOption( PCM_POWER_OPTION powerOption ); 159 PCM_POWER_OPTION GetPowerOption(); 160 int32_t GetTaskStatus(CM_STATUS & taskStatus); 161 int32_t SetProperty(CM_TASK_CONFIG * taskConfig); 162 int32_t GetProperty(CM_TASK_CONFIG &taskConfig); GetKernelExecuteConfig()163 const CM_EXECUTION_CONFIG* GetKernelExecuteConfig() { return m_krnExecCfg; }; 164 void *GetMediaStatePtr(); 165 #if CM_LOG_ON 166 std::string Log(); 167 168 CM_HAL_STATE *GetHalState(); 169 #endif 170 171 void SurfaceDump(int32_t taskId); 172 173 int32_t VtuneInitProfilingInfo(const CmThreadGroupSpace *perTaskThreadGroupSpace); 174 int32_t VtuneInitProfilingInfo(const CmThreadSpaceRT *perTaskThreadSpace); 175 int32_t VtuneSetFlushTime(); 176 177 protected: 178 179 CmTaskInternal(const uint32_t kernelCount, const uint32_t totalThreadCount, 180 CmKernelRT* kernelArray[], CmDeviceRT* device, const uint64_t syncBitmap, 181 const uint64_t conditionalEndBitmap, 182 PCM_HAL_CONDITIONAL_BB_END_INFO conditionalEndInfo, 183 const CM_EXECUTION_CONFIG* krnExecCfg); 184 ~CmTaskInternal( void ); 185 186 int32_t Initialize(const CmThreadSpaceRT* threadSpace, bool isWithHints); 187 int32_t Initialize(const CmThreadGroupSpace* threadGroupSpace); 188 189 int32_t Initialize(CmVeboxRT* vebox); 190 int32_t Initialize(uint32_t hints, uint32_t numTasksGenerated, bool isLastTask); 191 192 int32_t VtuneWriteEventInfo(); 193 int32_t VtuneReleaseProfilingInfo(); 194 195 int32_t UpdateSurfaceStateOnTaskCreation(); 196 197 CmDynamicArray m_kernels; 198 CmDynamicArray m_kernelData; // one CmKernelData* per kernel 199 uint32_t *m_kernelCurbeOffsetArray; // Array to record each kernel's curbe offset. Even the same kernel could have different curbe offset. 200 uint32_t m_kernelCount; 201 202 uint32_t m_totalThreadCount; //total thread count per task 203 204 CmEventRT* m_taskEvent; 205 206 //ThreadSpaceInformation from CreateThreadSpace() or CreateThreadGroupSpace() 207 bool m_isThreadSpaceCreated; 208 bool m_isThreadCoordinatesExisted; 209 uint32_t m_threadSpaceWidth; 210 uint32_t m_threadSpaceHeight; 211 uint32_t m_threadSpaceDepth; 212 213 PCM_HAL_SCOREBOARD *m_threadCoordinates; 214 CM_DEPENDENCY_PATTERN m_dependencyPattern; 215 CM_WALKING_PATTERN m_walkingPattern; 216 uint32_t m_walkingParameters[CM_NUM_DWORD_FOR_MW_PARAM]; 217 bool m_mediaWalkerParamsSet; 218 CM_HAL_DEPENDENCY m_dependencyVectors; 219 bool m_dependencyVectorsSet; 220 PCM_HAL_MASK_AND_RESET *m_dependencyMasks; 221 CM_MW_GROUP_SELECT m_mediaWalkerGroupSelect; 222 223 bool m_isThreadGroupSpaceCreated; 224 uint32_t m_groupSpaceWidth; 225 uint32_t m_groupSpaceHeight; 226 uint32_t m_groupSpaceDepth; 227 uint32_t m_slmSize; //SLM size per thread group in 1KB unit 228 uint32_t m_spillMemUsed; 229 230 uint32_t m_colorCountMinusOne; 231 uint32_t m_hints; 232 uint32_t m_numTasksGenerated; 233 bool m_isLastTask; 234 235 uint64_t m_ui64SyncBitmap; 236 uint64_t m_ui64ConditionalEndBitmap; 237 CM_HAL_CONDITIONAL_BB_END_INFO m_conditionalEndInfo[CM_MAX_CONDITIONAL_END_CMDS]; 238 239 CM_HAL_SURFACE_ENTRY_INFO_ARRAYS m_kernelSurfInfo; 240 CmDeviceRT* m_cmDevice; 241 bool *m_surfaceArray; // vector-flag of surfaces R/W by this CM Task (containing multi-kernel) 242 bool m_isSurfaceUpdateDone; 243 244 uint32_t m_taskType; //0 - Task with thread space, 1 - Task with thread group space, 2 - Task for VEBOX 245 246 CmBufferUP * m_veboxParam; 247 CM_VEBOX_STATE m_veboxState; 248 CM_VEBOX_SURFACE_DATA m_veboxSurfaceData; 249 250 CM_POWER_OPTION m_powerOption; 251 CM_PROFILING_INFO m_taskProfilingInfo; 252 CM_TASK_CONFIG m_taskConfig; 253 CM_EXECUTION_CONFIG m_krnExecCfg[CM_MAX_KERNELS_PER_TASK]; 254 void *m_mediaStatePtr; 255 private: 256 CmTaskInternal (const CmTaskInternal& other); 257 CmTaskInternal& operator= (const CmTaskInternal& other); 258 }; 259 }; //namespace 260 261 #endif // #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTASKINTERNAL_H_ 262