oclh_h_ws_base.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * oclh_h_ws_base.h
  3. * Author: havock
  4. */
  5. #ifndef OCLH_H_WS_BASE_H_
  6. #define OCLH_H_WS_BASE_H_ 1
  7. #include <sys/types.h>
  8. #include <stdlib.h>
  9. #include <stdarg.h>
  10. #include <CL/opencl.h>
  11. #include <oclh_h_base_log.h>
  12. #define __GHM_U64STRIPTO2B(___GHMARG_U64STRIPTO2B) \
  13. (((uint64_t)(___GHMARG_U64STRIPTO2B))&((uint64_t)0x000000000000ffff))
  14. typedef enum _GHE_SOURCE_TYPE {
  15. _GHE_HL_LISTINGS = 0,
  16. _GHE_IR_LISTINGS = 1,
  17. _GHE_SEPARATED_OBJECTS = 2,
  18. _GHE_LINKED_OBJECTS = 3
  19. } _GHE_SRCTYPE;
  20. typedef enum _GHE_BUILD_LOG_MODE {
  21. _GHE_NO_BUILD_LOG = 0,
  22. _GHE_BUILD_LOG_IN_WRKSET_LOG = 1,
  23. _GHE_BUILD_LOG_IN_SEPARATED_FILES = 2
  24. } _GHE_BUILD_LOG_MODE;
  25. typedef enum _GHE_OUTPUT_NAME_TYPE {
  26. _GHE_VOLATILE_OUTPUT_NAME = 0,
  27. _GHE_VERBATIM_OUTPUT_NAME = 1
  28. } _GHE_OUTNAME_TYPE;
  29. #pragma pack(push,1)
  30. typedef struct _GHT_WORKINGSET {
  31. void* pwSetAddr; /* self */
  32. cl_command_queue Queue; /* key pointer */
  33. cl_program Program;
  34. size_t szNofCmpUnits;/* number of computational units
  35. (a.k.a. processor core) */
  36. size_t szNofRPThrds; /* number of real parallel threads */
  37. size_t szMaxWGsz; /* max number of work-items in a work-group
  38. it represents the number of virtual
  39. threads executed on a computational unit
  40. (a.k.a. processor core) */
  41. size_t szNofWIinWG;
  42. size_t szNofAllWI;
  43. size_t* pszMemBytes;
  44. _GHT_LOG Log;
  45. int32_t i32EigenLogFlag;
  46. cl_int APIErr;
  47. cl_kernel* pKernels;
  48. int32_t KerErr;
  49. cl_mem d_pKerErr;
  50. void* pvDat;
  51. int32_t (*pfnDatCleaner)(const struct _GHT_WORKINGSET);
  52. } _GHT_WRKSET;
  53. #pragma pack(pop)
  54. _GHT_WRKSET _ghf_declWS(void);
  55. int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
  56. const _GHT_LOG Log,
  57. const int32_t i32ExclusiveLogFlag,
  58. const cl_device_id clWrkDev,
  59. char** const ppcCLProgramSources,
  60. const _GHE_SRCTYPE SourceType,
  61. const char* const pcOCLBuildOpts,
  62. const _GHE_LOGLVL LogLvl,
  63. const _GHE_BUILD_LOG_MODE BuildLogMode
  64. #if defined(__OCLH_BUILDER_FLAG) || \
  65. defined(__OCLH_COMPILER_ONLY_FLAG) || \
  66. defined(__OCLH_LINKER_ONLY_FLAG)
  67. , char* const pcOutputPrefix
  68. #endif /* defined(__OCLH_BUILDER_FLAG) ||
  69. defined(__OCLH_COMPILER_ONLY_FLAG) ||
  70. defined(__OCLH_LINKER_ONLY_FLAG) */
  71. );
  72. int32_t _ghf_wipeWS(_GHT_WRKSET* const pwSet);
  73. int32_t _ghf_isWS_LogValid(const _GHT_WRKSET wSet);
  74. int32_t _ghf_recalcWS_WIWG_1x1( _GHT_WRKSET* const pwSet);
  75. int32_t _ghf_recalcWS_WIWG_dense(_GHT_WRKSET* const pwSet,
  76. const size_t szNofAllTasks);
  77. int32_t _ghf_flfnWS(_GHT_WRKSET wSet);
  78. cl_device_id _ghf_getWS_Dev( _GHT_WRKSET wSet);
  79. cl_context _ghf_getWS_Ctx( _GHT_WRKSET wSet);
  80. cl_build_status _ghf_getWS_BuildStatus(_GHT_WRKSET wSet);
  81. cl_kernel _ghf_getWS_KernByName( _GHT_WRKSET wSet,const char* pcKernName);
  82. cl_uint _ghf_getWS_RefCntOfMem(_GHT_WRKSET wSet,const cl_mem clMem);
  83. size_t _ghf_getWS_MaxWIinWG( _GHT_WRKSET wSet);
  84. cl_uint _ghf_getWS_MaxCmpUnits(_GHT_WRKSET wSet);
  85. int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
  86. char* const pcOutputName,
  87. _GHE_OUTNAME_TYPE OutNameType);
  88. int32_t _ghf_wdcChkWS_APIErr( _GHT_WRKSET wSet,
  89. const char* const pcAPICall,
  90. const int32_t i32FlashFlag);
  91. int32_t _ghf_wdcChkWS_KerErr( _GHT_WRKSET wSet,
  92. const cl_kernel clKer);
  93. int32_t _ghf_wdcSetWS_KerErrToZero(_GHT_WRKSET wSet);
  94. int32_t _ghf_wdcSetWS_KernArgs( _GHT_WRKSET wSet,
  95. const cl_kernel kr, ...);
  96. int32_t _ghf_wdcBExecWS_Kern( _GHT_WRKSET wSet,
  97. const char* const pcKernName, ...);
  98. #pragma pack(push,1)
  99. typedef struct _GHT_LIST_OF_DEVICES_DESCRIPTION {
  100. cl_uint* pcluIdxs;
  101. char* pcWC;
  102. } _GHT_DEVLIST_DESC;
  103. #pragma pack(pop)
  104. _GHT_DEVLIST_DESC _ghf_declDevLstDesc(void);
  105. int32_t _ghf_isDevLstDesc_Valid(const _GHT_DEVLIST_DESC DevLstDesc);
  106. int32_t _ghf_addDevIdxToDevLstDesc( _GHT_DEVLIST_DESC* const pDevLstDesc,
  107. const cl_uint cluIdx);
  108. int32_t _ghf_setDevLstDesc_DevNameWC( _GHT_DEVLIST_DESC* const pDevLstDesc,
  109. const char* const pcWC);
  110. int32_t _ghf_wipeDevLstDesc( _GHT_DEVLIST_DESC* const pDevLstDesc);
  111. #pragma pack(push,1)
  112. typedef struct _GHT_ALL_OF_WORKING_SETS {
  113. _GHT_WRKSET* pWSet;
  114. uint64_t u64NofWSs;
  115. _GHT_LOG Log;
  116. const void* const pvCLProgramSource;
  117. const _GHE_SRCTYPE SourceType;
  118. const _GHE_LOGLVL LogLevel;
  119. const _GHE_BUILD_LOG_MODE BuildLogMode;
  120. } _GHT_AWSS;
  121. #pragma pack(pop)
  122. _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL LogLvl,
  123. const _GHE_BUILD_LOG_MODE BuildLogMode);
  124. int32_t _ghf_genrAWSs( _GHT_AWSS* const pAWSs,
  125. const _GHT_LOG Log,
  126. const _GHT_DEVLIST_DESC DevLstDesc,
  127. char** const ppcCLProgramSources,
  128. const _GHE_SRCTYPE SourceType,
  129. const char* const OCLBuildOpts
  130. #if defined(__OCLH_BUILDER_FLAG) || \
  131. defined(__OCLH_COMPILER_ONLY_FLAG) || \
  132. defined(__OCLH_LINKER_ONLY_FLAG)
  133. , char* const pcOutputPrefix
  134. #endif /* defined(__OCLH_BUILDER_FLAG) ||
  135. defined(__OCLH_COMPILER_ONLY_FLAG) ||
  136. defined(__OCLH_LINKER_ONLY_FLAG) */
  137. );
  138. int32_t _ghf_wipeAWSs(_GHT_AWSS* const pAWSs);
  139. int32_t _ghf_buildDevList(_GHT_WRKSET wSet, cl_device_id** ppDevLst);
  140. int32_t _ghf_wipeDevList(cl_device_id** ppDevLst);
  141. int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
  142. char* const pcDst,
  143. char* const pcOutputPrefix);
  144. #endif /* OCLH_H_WS_BASE_H_ */