|
@@ -32,7 +32,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
const _GHT_LOG Log,
|
|
const _GHT_LOG Log,
|
|
|
const int32_t i32ExclusiveLogFlag,
|
|
const int32_t i32ExclusiveLogFlag,
|
|
|
const cl_device_id clWrkDev,
|
|
const cl_device_id clWrkDev,
|
|
|
- const void* const pvCLProgramSources,
|
|
|
|
|
|
|
+ const char** const ppcCLProgramSources,
|
|
|
const _GHE_SRCTYPE SourceType,
|
|
const _GHE_SRCTYPE SourceType,
|
|
|
const char* const pcOCLBuildOpts,
|
|
const char* const pcOCLBuildOpts,
|
|
|
const _GHE_LOGLVL LogLvl,
|
|
const _GHE_LOGLVL LogLvl,
|
|
@@ -104,7 +104,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
CL_CONTEXT_INTEROP_USER_SYNC, CL_FALSE, 0l };
|
|
CL_CONTEXT_INTEROP_USER_SYNC, CL_FALSE, 0l };
|
|
|
clCtx=
|
|
clCtx=
|
|
|
clCreateContext(pclCtxProps, 1u, &clWrkDev,
|
|
clCreateContext(pclCtxProps, 1u, &clWrkDev,
|
|
|
- _ghf_CtxEvent, NULL, &pwSet->APIErr);
|
|
|
|
|
|
|
+ _ghf_CtxEvent, pwSet,&pwSet->APIErr);
|
|
|
/* TODO: ^[Valg] 8 bytes in 1 blocks are definitely lost
|
|
/* TODO: ^[Valg] 8 bytes in 1 blocks are definitely lost
|
|
|
* in loss record 12 of 1,583 by Intel library
|
|
* in loss record 12 of 1,583 by Intel library
|
|
|
* Intel::OpenCL::TaskExecutor::TBBTaskExecutor::Init */
|
|
* Intel::OpenCL::TaskExecutor::TBBTaskExecutor::Init */
|
|
@@ -114,7 +114,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
pclCtxProps[2]=(cl_context_properties)0l;
|
|
pclCtxProps[2]=(cl_context_properties)0l;
|
|
|
if(clCtx) pwSet->APIErr=clReleaseContext(clCtx);
|
|
if(clCtx) pwSet->APIErr=clReleaseContext(clCtx);
|
|
|
clCtx=clCreateContext(pclCtxProps, 1u, &clWrkDev,
|
|
clCtx=clCreateContext(pclCtxProps, 1u, &clWrkDev,
|
|
|
- _ghf_CtxEvent, NULL, &pwSet->APIErr);
|
|
|
|
|
|
|
+ _ghf_CtxEvent, pwSet,&pwSet->APIErr);
|
|
|
/* TODO: ^[Valg] 4 bytes in 1 blocks are definitely lost
|
|
/* TODO: ^[Valg] 4 bytes in 1 blocks are definitely lost
|
|
|
* in loss record 1 of 1,587 */
|
|
* in loss record 1 of 1,587 */
|
|
|
if(pwSet->APIErr)
|
|
if(pwSet->APIErr)
|
|
@@ -137,56 +137,172 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
}
|
|
}
|
|
|
if(LogLvl==_GHE_LOG_DEFAULT)
|
|
if(LogLvl==_GHE_LOG_DEFAULT)
|
|
|
_ghf_logWS_DevInfoShort(*pwSet, _ghf_getWS_Dev(*pwSet), NULL);
|
|
_ghf_logWS_DevInfoShort(*pwSet, _ghf_getWS_Dev(*pwSet), NULL);
|
|
|
- if(pvCLProgramSources) { /* program */
|
|
|
|
|
|
|
+ if(ppcCLProgramSources) { /* program */
|
|
|
cl_device_id clWrkDev=_ghf_getWS_Dev(*pwSet);
|
|
cl_device_id clWrkDev=_ghf_getWS_Dev(*pwSet);
|
|
|
switch(SourceType) {
|
|
switch(SourceType) {
|
|
|
case _GHE_HL_LISTINGS:
|
|
case _GHE_HL_LISTINGS:
|
|
|
- {
|
|
|
|
|
- cl_uint cluNofListings=0u;
|
|
|
|
|
- while(((char**)pvCLProgramSources)[cluNofListings]) {
|
|
|
|
|
- if(_GHM_SHOW_PROGRAM_LISTING_IN_LOG) {
|
|
|
|
|
- char pcLogMsg[64];
|
|
|
|
|
- snprintf(pcLogMsg, 64ul,
|
|
|
|
|
- "Program: #%u", cluNofListings);
|
|
|
|
|
- _ghf_logWS_Hdr(*pwSet, pcLogMsg);
|
|
|
|
|
- _ghf_logWS_Raw(*pwSet,
|
|
|
|
|
- ((char**)pvCLProgramSources)[cluNofListings]);
|
|
|
|
|
- _ghf_logWS_Hdr(*pwSet, "End of program");
|
|
|
|
|
- }
|
|
|
|
|
- cluNofListings++;
|
|
|
|
|
|
|
+ { cl_uint cluNofListings=0u;
|
|
|
|
|
+ while(((char**)ppcCLProgramSources)[cluNofListings]) {
|
|
|
|
|
+ if(_GHM_SHOW_PROGRAM_LISTING_IN_LOG) {
|
|
|
|
|
+ char pcLogMsg[64];
|
|
|
|
|
+ snprintf(pcLogMsg, 64ul,
|
|
|
|
|
+ "Program: #%u", cluNofListings);
|
|
|
|
|
+ _ghf_logWS_Hdr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_logWS_Raw(*pwSet,
|
|
|
|
|
+ ((char**)ppcCLProgramSources)[cluNofListings]);
|
|
|
|
|
+ _ghf_logWS_Hdr(*pwSet, "End of program");
|
|
|
}
|
|
}
|
|
|
- pwSet->Program=
|
|
|
|
|
- clCreateProgramWithSource(
|
|
|
|
|
- _ghf_getWS_Ctx(*pwSet),cluNofListings,
|
|
|
|
|
- (const char**)pvCLProgramSources,
|
|
|
|
|
- NULL, &pwSet->APIErr);
|
|
|
|
|
- if(pwSet->APIErr)
|
|
|
|
|
- __CLAPI_ERR_ROUTINE_WITH_RET("clCreateProgramWithSource")
|
|
|
|
|
|
|
+ cluNofListings++;
|
|
|
}
|
|
}
|
|
|
- break;
|
|
|
|
|
|
|
+ pwSet->Program=
|
|
|
|
|
+ clCreateProgramWithSource(
|
|
|
|
|
+ _ghf_getWS_Ctx(*pwSet),cluNofListings,
|
|
|
|
|
+ (const char**)ppcCLProgramSources,
|
|
|
|
|
+ NULL,
|
|
|
|
|
+ /* TODO: стоило бы использовать размеры вместо
|
|
|
|
|
+ * NULL, но по неясной причине передача длин
|
|
|
|
|
+ * исходных текстов препятствует созданию
|
|
|
|
|
+ * ядерных функций. Необходимо разобраться в
|
|
|
|
|
+ * причинах. */
|
|
|
|
|
+ /*((size_t**)ppcCLProgramSources)[cluNofListings+1],*/
|
|
|
|
|
+ &pwSet->APIErr);
|
|
|
|
|
+ if(pwSet->APIErr) {
|
|
|
|
|
+#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
|
|
|
+ {
|
|
|
|
|
+ FILE* pTmpFilePtr=pwSet->Log.pfOut;
|
|
|
|
|
+ pwSet->Log.pfOut=stdout;
|
|
|
|
|
+ _ghf_logWS_DevInfoShort(*pwSet,_ghf_getWS_Dev(*pwSet),
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "clCreateProgramWithSource");
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_logWS_Delim(*pwSet);
|
|
|
|
|
+ pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
|
|
+ __CLAPI_ERR_ROUTINE_WITH_RET("clCreateProgramWithSource")
|
|
|
|
|
+ } }
|
|
|
|
|
+ break;
|
|
|
case _GHE_IR_LISTINGS:
|
|
case _GHE_IR_LISTINGS:
|
|
|
- {
|
|
|
|
|
- _ghf_logWS_Msg(*pwSet, "_GHE_IR_LISTINGS");
|
|
|
|
|
- _ghf_wipeWS(pwSet); return(1);
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ { /* TODO: make IR output and processing */
|
|
|
|
|
+ _ghf_logWS_Msg(*pwSet, "_GHE_IR_LISTINGS");
|
|
|
|
|
+ _ghf_wipeWS(pwSet); return(1); }
|
|
|
|
|
+ break;
|
|
|
case _GHE_SEPARATED_OBJECTS:
|
|
case _GHE_SEPARATED_OBJECTS:
|
|
|
- case _GHE_LINKED_OBJECTS:
|
|
|
|
|
- {
|
|
|
|
|
- _ghf_logWS_Msg(*pwSet,
|
|
|
|
|
- "_GHE_SEPARATED_OBJECTS or _GHE_LINKED_OBJECTS");
|
|
|
|
|
- _ghf_wipeWS(pwSet); return(1);
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ { cl_device_id cldev=_ghf_getWS_Dev(*pwSet);
|
|
|
|
|
+ cl_program* pPrograms=NULL;
|
|
|
|
|
+ cl_uint cluNofBinaries=0u,
|
|
|
|
|
+ i=0u;
|
|
|
|
|
+ while(((char**)ppcCLProgramSources)[cluNofBinaries])
|
|
|
|
|
+ cluNofBinaries++;
|
|
|
|
|
+ pPrograms=malloc(sizeof(cl_program)*cluNofBinaries);
|
|
|
|
|
+ if(!pPrograms) {
|
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
- "Unknown program source");
|
|
|
|
|
- _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
- _ghf_wipeWS(pwSet);
|
|
|
|
|
- return(_GHM_UNKNOWN_PROGRAM_SOURCE_ERROR);
|
|
|
|
|
|
|
+ "%s/Host memory allocation failed", __func__);
|
|
|
|
|
+ _ghf_logWS_Msg(*pwSet, pcLogMsg); _ghf_wipeWS(pwSet);
|
|
|
|
|
+ return(_GHM_HOST_MEMALLOC_ERROR);
|
|
|
|
|
+ }
|
|
|
|
|
+ for(i=0u; i<cluNofBinaries; i++) pPrograms[i]=NULL;
|
|
|
|
|
+ for(i=0u; i<cluNofBinaries; i++) {
|
|
|
|
|
+ cl_int cliBinStatus=CL_SUCCESS;
|
|
|
|
|
+ pPrograms[i]=
|
|
|
|
|
+ clCreateProgramWithBinary(
|
|
|
|
|
+ _ghf_getWS_Ctx(*pwSet),1u,&cldev,
|
|
|
|
|
+ &((size_t**)ppcCLProgramSources)[cluNofBinaries+1][i],
|
|
|
|
|
+ &((const uint8_t**)ppcCLProgramSources)[i],
|
|
|
|
|
+ &cliBinStatus, &pwSet->APIErr);
|
|
|
|
|
+ if(pwSet->APIErr) {
|
|
|
|
|
+ cl_int err=pwSet->APIErr;
|
|
|
|
|
+ for(i=0u; i<cluNofBinaries; i++)
|
|
|
|
|
+ if(pPrograms[i])
|
|
|
|
|
+ pwSet->APIErr=clReleaseProgram(pPrograms[i]);
|
|
|
|
|
+ _ghf_freeHostZ(&pPrograms);
|
|
|
|
|
+ pwSet->APIErr=err;
|
|
|
|
|
+#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
|
|
|
+ {
|
|
|
|
|
+ FILE* pTmpFilePtr=pwSet->Log.pfOut;
|
|
|
|
|
+ pwSet->Log.pfOut=stdout;
|
|
|
|
|
+ _ghf_logWS_DevInfoShort(*pwSet,_ghf_getWS_Dev(*pwSet),
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "clCreateProgramWithBinary");
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_logWS_Delim(*pwSet);
|
|
|
|
|
+ pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
|
|
+ __CLAPI_ERR_ROUTINE_WITH_RET("clCreateProgramWithBinary")
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ pwSet->Program=clLinkProgram(_ghf_getWS_Ctx(*pwSet), 1u, &cldev,
|
|
|
|
|
+ pcOCLBuildOpts?pcOCLBuildOpts:"",
|
|
|
|
|
+ cluNofBinaries, pPrograms,
|
|
|
|
|
+ _ghf_LinkEvent, pwSet,
|
|
|
|
|
+ &pwSet->APIErr);
|
|
|
|
|
+ if(pwSet->APIErr) {
|
|
|
|
|
+ cl_int err=pwSet->APIErr;
|
|
|
|
|
+ for(i=0u; i<cluNofBinaries; i++)
|
|
|
|
|
+ if(pPrograms[i])
|
|
|
|
|
+ pwSet->APIErr=clReleaseProgram(pPrograms[i]);
|
|
|
|
|
+ _ghf_freeHostZ(&pPrograms);
|
|
|
|
|
+ pwSet->APIErr=err;
|
|
|
|
|
+#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
|
|
|
+ {
|
|
|
|
|
+ FILE* pTmpFilePtr=pwSet->Log.pfOut;
|
|
|
|
|
+ pwSet->Log.pfOut=stdout;
|
|
|
|
|
+ _ghf_logWS_DevInfoShort(*pwSet,_ghf_getWS_Dev(*pwSet),
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "clLinkProgram");
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_logWS_Delim(*pwSet);
|
|
|
|
|
+ pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
|
|
+ __CLAPI_ERR_ROUTINE_WITH_RET("clLinkProgram")
|
|
|
|
|
+ }
|
|
|
|
|
+ for(i=0u; i<cluNofBinaries; i++)
|
|
|
|
|
+ if(pPrograms[i])
|
|
|
|
|
+ pwSet->APIErr=clReleaseProgram(pPrograms[i]);
|
|
|
|
|
+ _ghf_freeHostZ(&pPrograms); }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case _GHE_LINKED_OBJECTS:
|
|
|
|
|
+ { cl_device_id cldev=_ghf_getWS_Dev(*pwSet);
|
|
|
|
|
+ cl_uint cluNofBinaries=0u;
|
|
|
|
|
+ cl_int cliBinStatus=CL_SUCCESS;
|
|
|
|
|
+ while(((char**)ppcCLProgramSources)[cluNofBinaries])
|
|
|
|
|
+ cluNofBinaries++;
|
|
|
|
|
+ pwSet->Program=
|
|
|
|
|
+ clCreateProgramWithBinary(
|
|
|
|
|
+ _ghf_getWS_Ctx(*pwSet),1u,&cldev,
|
|
|
|
|
+ ((size_t**)ppcCLProgramSources)[cluNofBinaries+1],
|
|
|
|
|
+ (const uint8_t**)ppcCLProgramSources,
|
|
|
|
|
+ &cliBinStatus, &pwSet->APIErr);
|
|
|
|
|
+ if(pwSet->APIErr) {
|
|
|
|
|
+#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
|
|
|
+ {
|
|
|
|
|
+ FILE* pTmpFilePtr=pwSet->Log.pfOut;
|
|
|
|
|
+ pwSet->Log.pfOut=stdout;
|
|
|
|
|
+ _ghf_logWS_DevInfoShort(*pwSet,_ghf_getWS_Dev(*pwSet),
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "clCreateProgramWithBinary");
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_logWS_Delim(*pwSet);
|
|
|
|
|
+ pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
|
|
+ __CLAPI_ERR_ROUTINE_WITH_RET("clCreateProgramWithBinary")
|
|
|
|
|
+ } }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ { char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "Unknown program source");
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
+ _ghf_wipeWS(pwSet);
|
|
|
|
|
+ return(_GHM_UNKNOWN_PROGRAM_SOURCE_ERROR); }
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
cl_int cliBuildCLAPIErr=CL_SUCCESS;
|
|
cl_int cliBuildCLAPIErr=CL_SUCCESS;
|
|
@@ -226,11 +342,11 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
LogLvl, _GHE_NO_BUILD_LOG);
|
|
LogLvl, _GHE_NO_BUILD_LOG);
|
|
|
{
|
|
{
|
|
|
_GHT_LOG TmpLog=_ghf_declLog();
|
|
_GHT_LOG TmpLog=_ghf_declLog();
|
|
|
- cl_uint cluNofKernels=0u;
|
|
|
|
|
-#ifndef __OCLH_COMPILER_ONLY_FLAG
|
|
|
|
|
|
|
+ /* cl_uint cluNofKernels=0u; */
|
|
|
|
|
+ size_t szNofKernels=0ul;
|
|
|
cl_build_status clBuildStatus=
|
|
cl_build_status clBuildStatus=
|
|
|
_ghf_getWS_BuildStatus(*pwSet);
|
|
_ghf_getWS_BuildStatus(*pwSet);
|
|
|
-#endif /* __OCLH_COMPILER_ONLY_FLAG */
|
|
|
|
|
|
|
+ cl_program_binary_type clBinType=0u;
|
|
|
if(BuildLogMode==_GHE_BUILD_LOG_IN_SEPARATED_FILES) {
|
|
if(BuildLogMode==_GHE_BUILD_LOG_IN_SEPARATED_FILES) {
|
|
|
TmpLog=pwSet->Log;
|
|
TmpLog=pwSet->Log;
|
|
|
int32_t err=0;
|
|
int32_t err=0;
|
|
@@ -283,17 +399,39 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
pwSet->APIErr=cliBuildCLAPIErr;
|
|
pwSet->APIErr=cliBuildCLAPIErr;
|
|
|
if(pwSet->APIErr) {
|
|
if(pwSet->APIErr) {
|
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
|
- _ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
|
|
|
|
|
+#if defined(__OCLH_COMPILER_ONLY_FLAG)
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, "clCompileProgram");
|
|
|
|
|
+#endif
|
|
|
|
|
+#if !defined(__OCLH_COMPILER_ONLY_FLAG) && !defined(__OCLH_LINKER_ONLY_FLAG)
|
|
|
|
|
+ _ghf_logWS_APIErr(*pwSet, "clBuildProgram");
|
|
|
|
|
+#endif
|
|
|
_ghf_wipeLog(&pwSet->Log); }
|
|
_ghf_wipeLog(&pwSet->Log); }
|
|
|
pwSet->Log=TmpLog;
|
|
pwSet->Log=TmpLog;
|
|
|
if(pcBldOpts) { free(pcBldOpts); pcBldOpts=NULL; }
|
|
if(pcBldOpts) { free(pcBldOpts); pcBldOpts=NULL; }
|
|
|
|
|
+#if defined(__OCLH_COMPILER_ONLY_FLAG)
|
|
|
|
|
+ __CLAPI_ERR_ROUTINE_WITH_RET("clCompileProgram")
|
|
|
|
|
+#endif
|
|
|
|
|
+#if !defined(__OCLH_COMPILER_ONLY_FLAG) && !defined(__OCLH_LINKER_ONLY_FLAG)
|
|
|
__CLAPI_ERR_ROUTINE_WITH_RET("clBuildProgram")
|
|
__CLAPI_ERR_ROUTINE_WITH_RET("clBuildProgram")
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
-#ifndef __OCLH_COMPILER_ONLY_FLAG
|
|
|
|
|
- if(!clBuildStatus) {
|
|
|
|
|
- pwSet->APIErr=
|
|
|
|
|
|
|
+ pwSet->APIErr=
|
|
|
|
|
+ clGetProgramBuildInfo(pwSet->Program, clWrkDev,
|
|
|
|
|
+ CL_PROGRAM_BINARY_TYPE,
|
|
|
|
|
+ sizeof(cl_program_binary_type),
|
|
|
|
|
+ &clBinType, NULL);
|
|
|
|
|
+ if(pwSet->APIErr) clBinType=CL_PROGRAM_BINARY_TYPE_NONE;
|
|
|
|
|
+ if(!clBuildStatus &&
|
|
|
|
|
+ (clBinType&CL_PROGRAM_BINARY_TYPE_EXECUTABLE)) {
|
|
|
|
|
+ /* another approach to get the number of kernels */
|
|
|
|
|
+ /* pwSet->APIErr=
|
|
|
clCreateKernelsInProgram(pwSet->Program, 0u, NULL,
|
|
clCreateKernelsInProgram(pwSet->Program, 0u, NULL,
|
|
|
- &cluNofKernels);
|
|
|
|
|
|
|
+ &cluNofKernels); */
|
|
|
|
|
+ pwSet->APIErr=
|
|
|
|
|
+ clGetProgramInfo(pwSet->Program,
|
|
|
|
|
+ CL_PROGRAM_NUM_KERNELS,
|
|
|
|
|
+ sizeof(size_t), &szNofKernels,
|
|
|
|
|
+ NULL);
|
|
|
if(pwSet->APIErr) {
|
|
if(pwSet->APIErr) {
|
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
|
_ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
_ghf_logWS_APIErr(*pwSet, pcLogMsg);
|
|
@@ -301,10 +439,10 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
pwSet->Log=TmpLog;
|
|
pwSet->Log=TmpLog;
|
|
|
if(pcBldOpts) { free(pcBldOpts); pcBldOpts=NULL; }
|
|
if(pcBldOpts) { free(pcBldOpts); pcBldOpts=NULL; }
|
|
|
__CLAPI_ERR_ROUTINE_WITH_RET(
|
|
__CLAPI_ERR_ROUTINE_WITH_RET(
|
|
|
- "clCreateKernelsInProgram")
|
|
|
|
|
|
|
+ "clGetProgramInfo")
|
|
|
}
|
|
}
|
|
|
pwSet->pKernels=malloc(
|
|
pwSet->pKernels=malloc(
|
|
|
- sizeof(cl_kernel)*(cluNofKernels+1));
|
|
|
|
|
|
|
+ sizeof(cl_kernel)*(szNofKernels+1ul));
|
|
|
if(!pwSet->pKernels) {
|
|
if(!pwSet->pKernels) {
|
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
@@ -319,11 +457,12 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
_ghf_wipeWS(pwSet);
|
|
_ghf_wipeWS(pwSet);
|
|
|
return(_GHM_HOST_MEMALLOC_ERROR);
|
|
return(_GHM_HOST_MEMALLOC_ERROR);
|
|
|
}
|
|
}
|
|
|
- {
|
|
|
|
|
|
|
+ pwSet->pKernels[szNofKernels]=NULL;
|
|
|
|
|
+ if(szNofKernels) {
|
|
|
cl_uint ctrlVal=0u;
|
|
cl_uint ctrlVal=0u;
|
|
|
pwSet->APIErr=
|
|
pwSet->APIErr=
|
|
|
clCreateKernelsInProgram(pwSet->Program,
|
|
clCreateKernelsInProgram(pwSet->Program,
|
|
|
- cluNofKernels,
|
|
|
|
|
|
|
+ (cl_uint)szNofKernels,
|
|
|
pwSet->pKernels,
|
|
pwSet->pKernels,
|
|
|
&ctrlVal);
|
|
&ctrlVal);
|
|
|
/* TODO: ^[Valg] 192 (32 direct, 160 indirect) bytes
|
|
/* TODO: ^[Valg] 192 (32 direct, 160 indirect) bytes
|
|
@@ -342,7 +481,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
__CLAPI_ERR_ROUTINE_WITH_RET(
|
|
__CLAPI_ERR_ROUTINE_WITH_RET(
|
|
|
"clCreateKernelsInProgram")
|
|
"clCreateKernelsInProgram")
|
|
|
}
|
|
}
|
|
|
- if(ctrlVal!=cluNofKernels) {
|
|
|
|
|
|
|
+ if(ctrlVal!=(cl_uint)szNofKernels) {
|
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
|
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
"%s/The number of created kernels "
|
|
"%s/The number of created kernels "
|
|
@@ -357,7 +496,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
free(pcBldOpts); pcBldOpts=NULL; }
|
|
free(pcBldOpts); pcBldOpts=NULL; }
|
|
|
return(_GHM_CREATING_KERNELS_ERROR);
|
|
return(_GHM_CREATING_KERNELS_ERROR);
|
|
|
}
|
|
}
|
|
|
- pwSet->pKernels[cluNofKernels]=NULL;
|
|
|
|
|
|
|
+ pwSet->pKernels[szNofKernels]=NULL;
|
|
|
/*
|
|
/*
|
|
|
* TODO: make sort of kernel list for tree search
|
|
* TODO: make sort of kernel list for tree search
|
|
|
* for GetKernelByName
|
|
* for GetKernelByName
|
|
@@ -365,7 +504,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
- "%u kernels registered", cluNofKernels);
|
|
|
|
|
|
|
+ "%lu kernels registered", szNofKernels);
|
|
|
_ghf_logWS_Msg(*pwSet, pcLogMsg);
|
|
_ghf_logWS_Msg(*pwSet, pcLogMsg);
|
|
|
#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
#ifdef __OCLH_BUILD_LOG_TO_STDOUT_FLAG
|
|
|
{
|
|
{
|
|
@@ -375,7 +514,7 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
pwSet->Log.pfOut=pTmpFilePtr;
|
|
pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
}
|
|
}
|
|
|
#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
- {
|
|
|
|
|
|
|
+ if(pwSet->pKernels) {
|
|
|
cl_uint i=0u;
|
|
cl_uint i=0u;
|
|
|
for(i=0u; pwSet->pKernels[i]; i++) {
|
|
for(i=0u; pwSet->pKernels[i]; i++) {
|
|
|
_ghf_logWS_KerInfo(*pwSet,pwSet->pKernels[i]);
|
|
_ghf_logWS_KerInfo(*pwSet,pwSet->pKernels[i]);
|
|
@@ -397,14 +536,13 @@ int32_t _ghf_genrWS( _GHT_WRKSET* const pwSet,
|
|
|
pwSet->Log.pfOut=pTmpFilePtr;
|
|
pwSet->Log.pfOut=pTmpFilePtr;
|
|
|
}
|
|
}
|
|
|
#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
#endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
|
|
|
-#endif /* __OCLH_COMPILER_ONLY_FLAG */
|
|
|
|
|
if(BuildLogMode==_GHE_BUILD_LOG_IN_SEPARATED_FILES) {
|
|
if(BuildLogMode==_GHE_BUILD_LOG_IN_SEPARATED_FILES) {
|
|
|
_ghf_wipeLog(&pwSet->Log);
|
|
_ghf_wipeLog(&pwSet->Log);
|
|
|
pwSet->Log=TmpLog;
|
|
pwSet->Log=TmpLog;
|
|
|
}
|
|
}
|
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
if(_ghf_isLog_Valid(TmpLog)) {
|
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
- "%u kernels registered", cluNofKernels);
|
|
|
|
|
|
|
+ "%lu kernels registered", szNofKernels);
|
|
|
_ghf_logWS_Msg(*pwSet, pcLogMsg);
|
|
_ghf_logWS_Msg(*pwSet, pcLogMsg);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -723,7 +861,8 @@ cl_uint _ghf_getWS_MaxCmpUnits(_GHT_WRKSET wSet) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
|
|
int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
|
|
|
- char* const pcOutputPrefix) {
|
|
|
|
|
|
|
+ char* const pcOutputName,
|
|
|
|
|
+ _GHE_OUTNAME_TYPE OutNameType) {
|
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG]="\0";
|
|
char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG]="\0";
|
|
|
int32_t err=0;
|
|
int32_t err=0;
|
|
|
size_t szRes=0ul,
|
|
size_t szRes=0ul,
|
|
@@ -793,19 +932,53 @@ int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
|
|
|
for(i=0ul; i<u64NofBinsBySizes; i++) {
|
|
for(i=0ul; i<u64NofBinsBySizes; i++) {
|
|
|
FILE* pFile=NULL;
|
|
FILE* pFile=NULL;
|
|
|
char pcBinFileName[_GHM_MAX_PATH_LENGTH]="\0",
|
|
char pcBinFileName[_GHM_MAX_PATH_LENGTH]="\0",
|
|
|
- pcTextProgramID[_GHM_MAX_PATH_LENGTH]="\0";
|
|
|
|
|
- __ghf_setWS_TextProgramId(wSet, pcTextProgramID, pcOutputPrefix);
|
|
|
|
|
- snprintf(pcBinFileName, _GHM_MAX_PATH_LENGTH,
|
|
|
|
|
|
|
+ pcTextProgramID[_GHM_MAX_PATH_LENGTH]="\0",
|
|
|
|
|
+ *pcFileExtension=NULL;
|
|
|
|
|
+ if(OutNameType==_GHE_VOLATILE_OUTPUT_NAME) {
|
|
|
|
|
+ __ghf_setWS_TextProgramId(wSet, pcTextProgramID, pcOutputName);
|
|
|
#if defined(__OCLH_COMPILER_ONLY_FLAG)
|
|
#if defined(__OCLH_COMPILER_ONLY_FLAG)
|
|
|
- "%s/%s.%lu.clo",
|
|
|
|
|
-#else
|
|
|
|
|
- "%s/%s.%lu.clb",
|
|
|
|
|
-#endif /* defined(__OCLH_COMPILER_ONLY_FLAG) */
|
|
|
|
|
- _GHM_LOG_PATH, pcTextProgramID, i);
|
|
|
|
|
|
|
+ pcFileExtension=".clo";
|
|
|
|
|
+#endif
|
|
|
|
|
+#if defined(__OCLH_LINKER_ONLY_FLAG)
|
|
|
|
|
+ {
|
|
|
|
|
+ cl_program_binary_type clBinType=0u;
|
|
|
|
|
+ size_t szRes=0ul;
|
|
|
|
|
+ wSet.APIErr=
|
|
|
|
|
+ clGetProgramBuildInfo(wSet.Program,_ghf_getWS_Dev(wSet),
|
|
|
|
|
+ CL_PROGRAM_BINARY_TYPE,
|
|
|
|
|
+ sizeof(cl_program_binary_type),
|
|
|
|
|
+ &clBinType, &szRes);
|
|
|
|
|
+ if(wSet.APIErr) clBinType=CL_PROGRAM_BINARY_TYPE_NONE;
|
|
|
|
|
+ pcFileExtension=".clout";
|
|
|
|
|
+ if(clBinType&CL_PROGRAM_BINARY_TYPE_LIBRARY)
|
|
|
|
|
+ pcFileExtension=".clso";
|
|
|
|
|
+ if(clBinType&CL_PROGRAM_BINARY_TYPE_EXECUTABLE)
|
|
|
|
|
+ pcFileExtension=".clexe";
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+#if !defined(__OCLH_COMPILER_ONLY_FLAG) && !defined(__OCLH_LINKER_ONLY_FLAG)
|
|
|
|
|
+ /* TODO: It is assumed that by default executable binary
|
|
|
|
|
+ * is built but actually it is not always so */
|
|
|
|
|
+ pcFileExtension=".clexe";
|
|
|
|
|
+#endif
|
|
|
|
|
+ snprintf(pcBinFileName, _GHM_MAX_PATH_LENGTH, "%s/%s.%lu%s",
|
|
|
|
|
+ _GHM_LOG_PATH, pcTextProgramID, i, pcFileExtension);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(OutNameType==_GHE_VERBATIM_OUTPUT_NAME) {
|
|
|
|
|
+ if(pcOutputName && pcOutputName[0]) {
|
|
|
|
|
+ snprintf(pcBinFileName, _GHM_MAX_PATH_LENGTH, "%s/%s",
|
|
|
|
|
+ _GHM_LOG_PATH, pcOutputName);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ snprintf(pcBinFileName, _GHM_MAX_PATH_LENGTH, "%s/%s",
|
|
|
|
|
+ _GHM_LOG_PATH, "a.clout");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
pFile=fopen(pcBinFileName,"wb");
|
|
pFile=fopen(pcBinFileName,"wb");
|
|
|
if(!pFile) {
|
|
if(!pFile) {
|
|
|
- fprintf(stderr,
|
|
|
|
|
- "Unable to open the binary file %s\n", pcBinFileName);
|
|
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "Unable to open the binary file %s", pcBinFileName);
|
|
|
|
|
+ _ghf_logWS_Msg(wSet,pcLogMsg);
|
|
|
|
|
+ fprintf(stderr,"%s\n", pcLogMsg);
|
|
|
perror("");
|
|
perror("");
|
|
|
{ uint64_t i=0ul;
|
|
{ uint64_t i=0ul;
|
|
|
for(i=0; i<u64NofBinsBySizes; i++)
|
|
for(i=0; i<u64NofBinsBySizes; i++)
|
|
@@ -814,8 +987,10 @@ int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
|
|
|
return(_GHM_OPEN_FILE_ERROR);
|
|
return(_GHM_OPEN_FILE_ERROR);
|
|
|
}
|
|
}
|
|
|
if(fwrite(ppcBins[i],pszOfBins[i],1,pFile)!=1) {
|
|
if(fwrite(ppcBins[i],pszOfBins[i],1,pFile)!=1) {
|
|
|
- fprintf(stderr,
|
|
|
|
|
- "Unable to write the binary file %s\n", pcBinFileName);
|
|
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "Unable to write the binary file %s", pcBinFileName);
|
|
|
|
|
+ _ghf_logWS_Msg(wSet,pcLogMsg);
|
|
|
|
|
+ fprintf(stderr,"%s\n", pcLogMsg);
|
|
|
perror("");
|
|
perror("");
|
|
|
{ uint64_t i=0ul;
|
|
{ uint64_t i=0ul;
|
|
|
for(i=0; i<u64NofBinsBySizes; i++)
|
|
for(i=0; i<u64NofBinsBySizes; i++)
|
|
@@ -825,6 +1000,10 @@ int32_t _ghf_saveWS_ProgramBinaries(_GHT_WRKSET wSet,
|
|
|
return(_GHM_WRITE_FILE_ERROR);
|
|
return(_GHM_WRITE_FILE_ERROR);
|
|
|
}
|
|
}
|
|
|
fclose(pFile);
|
|
fclose(pFile);
|
|
|
|
|
+ snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
|
|
|
|
|
+ "The program binary have been written to %s",
|
|
|
|
|
+ pcBinFileName);
|
|
|
|
|
+ _ghf_logWS_Msg(wSet,pcLogMsg);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
{ uint64_t i=0ul;
|
|
{ uint64_t i=0ul;
|
|
@@ -962,16 +1141,16 @@ _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL LogLvl,
|
|
|
return(AWSs);
|
|
return(AWSs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int32_t _ghf_genrAWSs( _GHT_AWSS* const pAWSs,
|
|
|
|
|
- const _GHT_LOG Log,
|
|
|
|
|
- const _GHT_DEVLIST_DESC DevLstDesc,
|
|
|
|
|
- const void* const pvCLProgramSources,
|
|
|
|
|
- const _GHE_SRCTYPE SourceType,
|
|
|
|
|
- const char* const OCLBuildOpts
|
|
|
|
|
|
|
+int32_t _ghf_genrAWSs( _GHT_AWSS* const pAWSs,
|
|
|
|
|
+ const _GHT_LOG Log,
|
|
|
|
|
+ const _GHT_DEVLIST_DESC DevLstDesc,
|
|
|
|
|
+ const char** const ppcCLProgramSources,
|
|
|
|
|
+ const _GHE_SRCTYPE SourceType,
|
|
|
|
|
+ const char* const OCLBuildOpts
|
|
|
#if defined(__OCLH_BUILDER_FLAG) || \
|
|
#if defined(__OCLH_BUILDER_FLAG) || \
|
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) || \
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) || \
|
|
|
defined(__OCLH_LINKER_ONLY_FLAG)
|
|
defined(__OCLH_LINKER_ONLY_FLAG)
|
|
|
- , char* const pcOutputPrefix
|
|
|
|
|
|
|
+ , char* const pcOutputPrefix
|
|
|
#endif /* defined(__OCLH_BUILDER_FLAG) ||
|
|
#endif /* defined(__OCLH_BUILDER_FLAG) ||
|
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) ||
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) ||
|
|
|
defined(__OCLH_LINKER_ONLY_FLAG) */
|
|
defined(__OCLH_LINKER_ONLY_FLAG) */
|
|
@@ -1079,7 +1258,7 @@ int32_t _ghf_genrAWSs( _GHT_AWSS* const pAWSs,
|
|
|
DevLst[TmpDevLstDesc.pcluIdxs[i]]:
|
|
DevLst[TmpDevLstDesc.pcluIdxs[i]]:
|
|
|
DevLst[DevLstDesc.pcluIdxs?
|
|
DevLst[DevLstDesc.pcluIdxs?
|
|
|
DevLstDesc.pcluIdxs[i]:i],
|
|
DevLstDesc.pcluIdxs[i]:i],
|
|
|
- pvCLProgramSources, SourceType, OCLBuildOpts,
|
|
|
|
|
|
|
+ ppcCLProgramSources, SourceType, OCLBuildOpts,
|
|
|
pAWSs->LogLevel, pAWSs->BuildLogMode
|
|
pAWSs->LogLevel, pAWSs->BuildLogMode
|
|
|
#if defined(__OCLH_BUILDER_FLAG) || \
|
|
#if defined(__OCLH_BUILDER_FLAG) || \
|
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) || \
|
|
defined(__OCLH_COMPILER_ONLY_FLAG) || \
|