oclh_h_ws_base.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 <CL/opencl.h>
  10. #include <oclh_h_base_log.h>
  11. #define __GHM_U64STRIPTO2B(___GHMARG_U64STRIPTO2B) \
  12. (((uint64_t)(___GHMARG_U64STRIPTO2B))&((uint64_t)0x000000000000ffff))
  13. typedef enum _GHE_SOURCE_TYPE {
  14. _GHE_HL_LISTINGS = 0,
  15. _GHE_IR_LISTINGS = 1,
  16. _GHE_SEPARATED_OBJECTS = 2,
  17. _GHE_LINKED_OBJECTS = 3
  18. } _GHE_SRCTYPE;
  19. typedef enum _GHE_BUILD_LOG_MODE {
  20. _GHE_NO_BUILD_LOG = 0,
  21. _GHE_BUILD_LOG_IN_WRKSET_LOG = 1,
  22. _GHE_BUILD_LOG_IN_SEPARATED_FILES = 2
  23. } _GHE_BUILD_LOG_MODE;
  24. #pragma pack(push,1)
  25. typedef struct _GHT_WORKINGSET {
  26. void* pwSetAddr; /* self */
  27. cl_command_queue Queue; /* key pointer */
  28. cl_program Program;
  29. size_t szNofCmpUnits;/* number of computational units
  30. (a.k.a. processor core) */
  31. size_t szNofRPThrds; /* number of real parallel threads */
  32. size_t szMaxWGsz; /* max number of work-items in a work-group
  33. it represents the number of virtual
  34. threads executed on a computational unit
  35. (a.k.a. processor core) */
  36. size_t szNofWIinWG;
  37. size_t szNofAllWI;
  38. size_t* pszMemBytes;
  39. _GHT_LOG Log;
  40. int32_t i32EigenLogFlag;
  41. cl_int APIErr;
  42. cl_kernel* pKernels;
  43. int32_t KerErr;
  44. cl_mem d_pKerErr;
  45. void* pvDat;
  46. int32_t (*pfnDatCleaner)(const struct _GHT_WORKINGSET);
  47. } _GHT_WRKSET;
  48. #pragma pack(pop)
  49. _GHT_WRKSET _ghf_declWS(void);
  50. int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
  51. const _GHT_LOG Log,
  52. const int32_t i32ExclusiveLogFlag,
  53. const cl_device_id clWrkDev,
  54. const void* const pvCLProgramSources,
  55. const _GHE_SRCTYPE SourceType,
  56. const char* const pcOCLBuildOpts,
  57. const _GHE_LOGLVL LogLvl,
  58. const _GHE_BUILD_LOG_MODE BuildLogMode
  59. #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
  60. , char* const pcOutputPrefix
  61. #endif /* defined(__OCLH_BUILDER_FLAG) ||
  62. defined(__OCLH_COMPILER_ONLY_FLAG) ||
  63. defined(__OCLH_LINKER_ONLY_FLAG) */
  64. );
  65. int32_t _ghf_wipeWS(_GHT_WRKSET* const pwSet);
  66. int32_t _ghf_isWS_LogValid(const _GHT_WRKSET wSet);
  67. int32_t _ghf_recalcWS_WIWG(_GHT_WRKSET* const pwSet,
  68. const size_t szNofAllTasks);
  69. int32_t _ghf_flfnWS(_GHT_WRKSET wSet);
  70. cl_device_id _ghf_getWS_Dev( _GHT_WRKSET wSet);
  71. cl_context _ghf_getWS_Ctx( _GHT_WRKSET wSet);
  72. cl_build_status _ghf_getWS_BuildStatus(_GHT_WRKSET wSet);
  73. cl_kernel _ghf_getWS_KernByName( _GHT_WRKSET wSet,const char* pcKernName);
  74. cl_uint _ghf_getWS_RefCntOfMem(_GHT_WRKSET wSet,const cl_mem clMem);
  75. size_t _ghf_getWS_MaxWIinWG( _GHT_WRKSET wSet);
  76. cl_uint _ghf_getWS_MaxCmpUnits(_GHT_WRKSET wSet);
  77. int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
  78. char* const pcOutputPrefix);
  79. int32_t _ghf_wdcChkWS_APIErr ( _GHT_WRKSET wSet,
  80. const char* const pcAPICall,
  81. const int32_t i32FlashFlag);
  82. int32_t _ghf_wdcChkWS_KerErr( _GHT_WRKSET wSet,
  83. const cl_kernel clKer);
  84. int32_t _ghf_wdcSetWS_KerErrToZero(_GHT_WRKSET wSet);
  85. #pragma pack(push,1)
  86. typedef struct _GHT_ALL_OF_WORKING_SETS {
  87. _GHT_WRKSET* pWSet;
  88. uint64_t u64NofWSs;
  89. _GHT_LOG Log;
  90. const void* const pvCLProgramSource;
  91. const _GHE_SRCTYPE SourceType;
  92. const _GHE_LOGLVL LogLevel;
  93. const _GHE_BUILD_LOG_MODE BuildLogMode;
  94. } _GHT_AWSS;
  95. #pragma pack(pop)
  96. _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL LogLvl,
  97. const _GHE_BUILD_LOG_MODE BuildLogMode);
  98. int32_t _ghf_genrAWSs( _GHT_AWSS* const pAWSs,
  99. const _GHT_LOG Log,
  100. const void* const pvCLProgramSources,
  101. const _GHE_SRCTYPE SourceType,
  102. const char* const OCLBuildOpts
  103. #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
  104. , char* const pcOutputPrefix
  105. #endif /* defined(__OCLH_BUILDER_FLAG) ||
  106. defined(__OCLH_COMPILER_ONLY_FLAG) ||
  107. defined(__OCLH_LINKER_ONLY_FLAG) */
  108. );
  109. int32_t _ghf_wipeAWSs(_GHT_AWSS* const pAWSs);
  110. int32_t _ghf_buildDevList(_GHT_WRKSET wSet, cl_device_id** ppDevLst);
  111. int32_t _ghf_wipeDevList(cl_device_id** ppDevLst);
  112. int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
  113. char* const pcDst,
  114. char* const pcOutputPrefix);
  115. #endif /* OCLH_H_WS_BASE_H_ */