| 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 CMRTKernelBase.h |
| 24 |
//! \brief HEVC FEI MDF structure base class for GEN9 SKL. |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef _CMRTKERNELBASE_ |
| 28 |
#define _CMRTKERNELBASE_ |
| 29 |
|
| 30 |
#include <stdio.h> |
| 31 |
|
| 32 |
#ifdef ENABLE_CMRT_KERNEL_ULT |
| 33 |
#include "cm_rt.h" |
| 34 |
#include <cm/cm.h> |
| 35 |
#else |
| 36 |
#include "cm_rt_umd.h" |
| 37 |
#endif |
| 38 |
|
| 39 |
#define CM_CHK_STATUS_RETURN(stmt) \ |
| 40 |
{ \ |
| 41 |
CM_RETURN_CODE hr = (CM_RETURN_CODE)(stmt); \ |
| 42 |
if (hr != CM_SUCCESS) \ |
| 43 |
{ \ |
| 44 |
printf("the error is %d, %d, %s\n",hr, __LINE__,__FILE__); \ |
| 45 |
return CM_FAILURE; \ |
| 46 |
} \ |
| 47 |
} \ |
| 48 |
|
| 49 |
class CMRTKernelBase { |
| 50 |
public: |
| 51 |
CmDevice *m_cmDev; |
| 52 |
CmProgram *m_cmProgram; |
| 53 |
CmQueue *m_cmQueue; |
| 54 |
CmTask *m_cmTask; //Can be reused for each kernel |
| 55 |
CmThreadSpace *m_cmThreadSpace; |
| 56 |
CmKernel *m_cmKernel; |
| 57 |
CmSurface2D **m_cmSurface2D; |
| 58 |
CmSurface2D **m_cmSurfaceRef0; |
| 59 |
CmSurface2D **m_cmSurfaceRef1; |
| 60 |
CmBuffer **m_cmBuffer; |
| 61 |
SurfaceIndex **m_cmVmeSurf; |
| 62 |
SurfaceIndex **m_surfIndex; |
| 63 |
|
| 64 |
uint32_t m_cmSurface2DCount; |
| 65 |
uint32_t m_cmSurfaceRef0Count; |
| 66 |
uint32_t m_cmSurfaceRef1Count; |
| 67 |
uint32_t m_cmBufferCount; |
| 68 |
uint32_t m_cmVmeSurfCount; |
| 69 |
void *m_curbe; |
| 70 |
|
| 71 |
const uint32_t *m_isaName; |
| 72 |
uint32_t m_isaSize; |
| 73 |
const char *m_kernelName; |
| 74 |
|
| 75 |
CMRTKernelBase(); |
| 76 |
virtual ~CMRTKernelBase(); |
| 77 |
|
| 78 |
CM_RETURN_CODE LoadProgramISA(const uint32_t *isaCode, uint32_t isaSize, CmProgram * &program); |
| 79 |
CM_RETURN_CODE AddKernel(CmEvent *&cmEvent, bool destroyEvent, bool isEnqueue); |
| 80 |
CM_RETURN_CODE WaitAndDestroyEvent(CmEvent *&cmEvent); |
| 81 |
int32_t CreateThreadSpace(uint32_t threadSpaceWidth, uint32_t threadSpaceHeight); |
| 82 |
virtual CM_RETURN_CODE Init(void *osContext = nullptr, CmDevice *cmDev = nullptr, CmQueue *cmQueue = nullptr, CmTask *cmTask = nullptr, CmProgram *cmProgram = nullptr); |
| 83 |
virtual CM_RETURN_CODE SetupCurbe(void *curbe) = 0; |
| 84 |
virtual CM_RETURN_CODE AllocateSurfaces(void *params) = 0; |
| 85 |
virtual CM_RETURN_CODE CreateAndDispatchKernel(CmEvent *&cmEvent, bool destroyEvent, bool isEnqueue) = 0;//(EventList[i]); |
| 86 |
|
| 87 |
virtual void DestroySurfResources(); |
| 88 |
virtual void DestroyKernelResources(); |
| 89 |
virtual void DestroyProgramResources(); |
| 90 |
virtual void Destroy(); |
| 91 |
|
| 92 |
}; |
| 93 |
|
| 94 |
#endif |