| 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_event_rt.h |
| 24 |
//! \brief Contains CmEventRT declarations. |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMEVENTRT_H_ |
| 28 |
#define MEDIADRIVER_AGNOSTIC_COMMON_CM_CMEVENTRT_H_ |
| 29 |
|
| 30 |
#include "cm_event.h" |
| 31 |
#include "cm_csync.h" |
| 32 |
#include "cm_hal.h" |
| 33 |
#include "cm_log.h" |
| 34 |
|
| 35 |
namespace CMRT_UMD |
| 36 |
{ |
| 37 |
class CmDeviceRT; |
| 38 |
class CmEventRT; |
| 39 |
class CmQueueRT; |
| 40 |
class CmTaskRT; |
| 41 |
class CmTaskInternal; |
| 42 |
class CmThreadGroupSpace; |
| 43 |
class CmThreadSpaceRT; |
| 44 |
}; |
| 45 |
|
| 46 |
#define CM_CALLBACK __cdecl |
| 47 |
typedef void (CM_CALLBACK *EventCallBackFunction)(CMRT_UMD::CmEventRT*, void*); |
| 48 |
|
| 49 |
namespace CMRT_UMD |
| 50 |
{ |
| 51 |
class CmEventRT: public CmEvent |
| 52 |
{ |
| 53 |
public: |
| 54 |
static int32_t Create(uint32_t index, |
| 55 |
CmQueueRT *queue, |
| 56 |
CmTaskInternal *task, |
| 57 |
int32_t taskDriverId, |
| 58 |
CmDeviceRT *device, |
| 59 |
bool isVisible, |
| 60 |
CmEventRT *&event); |
| 61 |
|
| 62 |
static int32_t Destroy(CmEventRT *&event); |
| 63 |
|
| 64 |
CM_RT_API int32_t GetStatus(CM_STATUS &status); |
| 65 |
|
| 66 |
CM_RT_API int32_t GetExecutionTime(uint64_t &time); |
| 67 |
|
| 68 |
CM_RT_API int32_t |
| 69 |
WaitForTaskFinished(uint32_t timeOutMs = CM_MAX_TIMEOUT_MS); |
| 70 |
|
| 71 |
CM_RT_API int32_t GetSurfaceDetails(uint32_t kernIndex, |
| 72 |
uint32_t surfBTI, |
| 73 |
CM_SURFACE_DETAILS &outDetails); |
| 74 |
|
| 75 |
CM_RT_API int32_t GetProfilingInfo(CM_EVENT_PROFILING_INFO infoType, |
| 76 |
size_t paramSize, |
| 77 |
void *inputValue, |
| 78 |
void *value); |
| 79 |
|
| 80 |
CM_RT_API int32_t GetExecutionTickTime(uint64_t &ticks); |
| 81 |
|
| 82 |
int32_t GetIndex(uint32_t &index); |
| 83 |
|
| 84 |
int32_t SetTaskDriverId(int32_t id); |
| 85 |
|
| 86 |
int32_t GetTaskDriverId(int32_t &id); |
| 87 |
|
| 88 |
int32_t SetTaskOsData(void *data); |
| 89 |
|
| 90 |
int32_t SetSurfaceDetails(CM_HAL_SURFACE_ENTRY_INFO_ARRAYS surfaceInfo); |
| 91 |
|
| 92 |
int32_t Acquire(void); |
| 93 |
|
| 94 |
int32_t SafeRelease(void); |
| 95 |
|
| 96 |
int32_t SetKernelNames(CmTaskRT *task, |
| 97 |
CmThreadSpaceRT *threadSpace, |
| 98 |
CmThreadGroupSpace *threadGroupSpace); |
| 99 |
|
| 100 |
int32_t SetEnqueueTime(LARGE_INTEGER time); |
| 101 |
|
| 102 |
int32_t SetCompleteTime(LARGE_INTEGER time); |
| 103 |
|
| 104 |
int32_t GetSubmitTime(LARGE_INTEGER *time); |
| 105 |
|
| 106 |
int32_t GetHWStartTime(LARGE_INTEGER *time); |
| 107 |
|
| 108 |
int32_t GetHWEndTime(LARGE_INTEGER *time); |
| 109 |
|
| 110 |
int32_t GetCompleteTime(LARGE_INTEGER *time); |
| 111 |
|
| 112 |
uint32_t GetKernelCount(); |
| 113 |
|
| 114 |
int32_t GetEnqueueTime(LARGE_INTEGER *time); |
| 115 |
|
| 116 |
int32_t SetCallBack(EventCallBackFunction function, void *userData); |
| 117 |
|
| 118 |
int32_t GetStatusNoFlush(CM_STATUS &status); |
| 119 |
|
| 120 |
int32_t ModifyStatus(CM_STATUS status, uint64_t elapsedTime); |
| 121 |
|
| 122 |
int32_t GetQueue(CmQueueRT *&queue); |
| 123 |
|
| 124 |
int32_t Query(); |
| 125 |
|
| 126 |
CM_STATUS GetStatusWithoutFlush(); |
| 127 |
|
| 128 |
#if CM_LOG_ON |
| 129 |
std::string Log(const char *callerFuncName); |
| 130 |
|
| 131 |
CM_HAL_STATE* GetHalState(); |
| 132 |
#endif // #if CM_LOG_ON |
| 133 |
|
| 134 |
protected: |
| 135 |
CmEventRT(uint32_t index, |
| 136 |
CmQueueRT *queue, |
| 137 |
CmTaskInternal *task, |
| 138 |
int32_t taskDriverId, |
| 139 |
CmDeviceRT *device, |
| 140 |
bool isVisible); |
| 141 |
|
| 142 |
~CmEventRT(); |
| 143 |
|
| 144 |
int32_t Initialize(); |
| 145 |
|
| 146 |
void UnreferenceIfNeeded(void *pdata); |
| 147 |
|
| 148 |
uint32_t m_index; |
| 149 |
int32_t m_taskDriverId; |
| 150 |
void *m_osData; |
| 151 |
|
| 152 |
CM_STATUS m_status; |
| 153 |
uint64_t m_time; |
| 154 |
uint64_t m_ticks; |
| 155 |
uint64_t m_hwStartTimeStampInTicks; |
| 156 |
uint64_t m_hwEndTimeStampInTicks; |
| 157 |
|
| 158 |
LARGE_INTEGER m_globalSubmitTimeCpu; // The CM task submission time in CPU |
| 159 |
LARGE_INTEGER m_submitTimeGpu; // The CM task submission time in GPU |
| 160 |
LARGE_INTEGER m_hwStartTimeStamp; // The task start execution time in GPU |
| 161 |
LARGE_INTEGER m_hwEndTimeStamp; // The task end execution time in GPU |
| 162 |
LARGE_INTEGER m_completeTime; // The task complete time in CPU |
| 163 |
LARGE_INTEGER m_enqueueTime; // The time when the task is pushed into enqueued |
| 164 |
// queue |
| 165 |
|
| 166 |
char **m_kernelNames; |
| 167 |
uint32_t *m_threadSpace; |
| 168 |
uint32_t m_kernelCount; |
| 169 |
|
| 170 |
CmDeviceRT* m_device; |
| 171 |
CmQueueRT *m_queue; |
| 172 |
|
| 173 |
int32_t m_refCount; |
| 174 |
|
| 175 |
bool m_isVisible; // if the event is Visible to user or not |
| 176 |
|
| 177 |
CM_HAL_SURFACE_ENTRY_INFO_ARRAYS m_surEntryInfoArrays; |
| 178 |
CmTaskInternal *m_task; |
| 179 |
|
| 180 |
CSync m_criticalSectionQuery; |
| 181 |
|
| 182 |
//Vtune call back |
| 183 |
EventCallBackFunction m_callbackFunction; //CallBack Function |
| 184 |
void *m_callbackUserData; //Pdata for Callback |
| 185 |
|
| 186 |
private: |
| 187 |
bool m_osSignalTriggered; |
| 188 |
|
| 189 |
CmEventRT(const CmEventRT& other); |
| 190 |
CmEventRT& operator=(const CmEventRT& other); |
| 191 |
}; |
| 192 |
} |
| 193 |
|
| 194 |
#endif // MEDIADRIVER_AGNOSTIC_COMMON_CM_CMEVENTRT_H_ |