Explorar el Código

'--dev-*=' options added

hk hace 5 años
padre
commit
fbe443f7ea

+ 1 - 1
src/include_h/oclh_h_base_log.h

@@ -27,7 +27,7 @@ typedef struct _GHT_LOGFILE {
 
 
 _GHT_LOG _ghf_declLog(void);
 _GHT_LOG _ghf_declLog(void);
 int32_t  _ghf_genrLog(_GHT_LOG* const pLog, const char* const pcFileName);
 int32_t  _ghf_genrLog(_GHT_LOG* const pLog, const char* const pcFileName);
-int32_t  _ghf_isLogValid(const _GHT_LOG Log);
+int32_t  _ghf_isLog_Valid(const _GHT_LOG Log);
 int32_t  _ghf_wipeLog(_GHT_LOG* const pLog);
 int32_t  _ghf_wipeLog(_GHT_LOG* const pLog);
 
 
 #endif /* OCLH_H_BASE_LOG_H_ */
 #endif /* OCLH_H_BASE_LOG_H_ */

+ 23 - 22
src/include_h/oclh_h_errors.h

@@ -6,28 +6,29 @@
 #ifndef OCLH_H_ERROR_CODES_H_
 #ifndef OCLH_H_ERROR_CODES_H_
 #define OCLH_H_ERROR_CODES_H_ 1
 #define OCLH_H_ERROR_CODES_H_ 1
 
 
-#define _GHM_OK                                     0
-#define _GHM_HOST_MEMALLOC_ERROR                 -150
-#define _GHM_DEVICE_MEMALLOC_ERROR               -151
-#define _GHM_UNKNOWN_SYNC_TYPE_ERROR             -152
-#define _GHM_OPEN_FILE_ERROR                     -153
-#define _GHM_SEEK_FILE_ERROR                     -154
-#define _GHM_READ_FILE_ERROR                     -155
-#define _GHM_WRITE_FILE_ERROR                    -156
-#define _GHM_EMPTY_STRING_RECEIVED_ERROR         -157
-#define _GHM_DECONSTRUCTION_OF_WORKSET_ERROR     -158
-#define _GHM_COMMAND_QUEUE_FLUSH_ERROR           -159
-#define _GHM_COMMAND_QUEUE_FINISH_ERROR          -160
-#define _GHM_UNAVALABLE_KERNEL_ERROR             -161
-#define _GHM_NO_PLATFORMS_AVAILABLE              -162
-#define _GHM_NO_DEVICES_AVAILABLE                -163
-#define _GHM_CREATING_KERNELS_ERROR              -164
-#define _GHM_INCONSISTED_LOG_ERROR               -165
-#define _GHM_NULL_POINTER_RECEIVED_ERROR         -166
-#define _GHM_ZERO_SIZE_RECEIVED_ERROR            -167
-#define _GHM_UNKNOWN_PROGRAM_SOURCE_ERROR        -168
-#define _GHM_INVALID_MAXSIZE_OF_WORK_GROUP_ERROR -169
-#define _GHM_INVALID_NUMBER_OF_CMP_UNITS_ERROR   -170
+#define _GHM_OK                                      0
+#define _GHM_HOST_MEMALLOC_ERROR                  -150
+#define _GHM_DEVICE_MEMALLOC_ERROR                -151
+#define _GHM_UNKNOWN_SYNC_TYPE_ERROR              -152
+#define _GHM_OPEN_FILE_ERROR                      -153
+#define _GHM_SEEK_FILE_ERROR                      -154
+#define _GHM_READ_FILE_ERROR                      -155
+#define _GHM_WRITE_FILE_ERROR                     -156
+#define _GHM_EMPTY_STRING_RECEIVED_ERROR          -157
+#define _GHM_DECONSTRUCTION_OF_WORKSET_ERROR      -158
+#define _GHM_COMMAND_QUEUE_FLUSH_ERROR            -159
+#define _GHM_COMMAND_QUEUE_FINISH_ERROR           -160
+#define _GHM_UNAVALABLE_KERNEL_ERROR              -161
+#define _GHM_NO_PLATFORMS_AVAILABLE               -162
+#define _GHM_NO_DEVICES_AVAILABLE                 -163
+#define _GHM_CREATING_KERNELS_ERROR               -164
+#define _GHM_INCONSISTED_LOG_ERROR                -165
+#define _GHM_NULL_POINTER_RECEIVED_ERROR          -166
+#define _GHM_ZERO_SIZE_RECEIVED_ERROR             -167
+#define _GHM_UNKNOWN_PROGRAM_SOURCE_ERROR         -168
+#define _GHM_INVALID_MAXSIZE_OF_WORK_GROUP_ERROR  -169
+#define _GHM_INVALID_NUMBER_OF_CMP_UNITS_ERROR    -170
+#define _GHM_INCONSISTED_DEV_DESCRIPTION_ERROR    -171
 
 
 #define _GHM_IMPOSSIBLE_SITUATION_ERROR      4030  /* the first weird four-digit
 #define _GHM_IMPOSSIBLE_SITUATION_ERROR      4030  /* the first weird four-digit
                                                       (decimal) number */
                                                       (decimal) number */

+ 8 - 0
src/include_h/oclh_h_internals.h

@@ -8,8 +8,16 @@
 #define OCLH_INTERNALS_H_ 1
 #define OCLH_INTERNALS_H_ 1
 #include <oclh_hd_std_types.clh>
 #include <oclh_hd_std_types.clh>
 
 
+typedef enum __GHE_CASE_SENSITIVITY {
+    __GHE_CASE_SENSITIVE=0,
+    __GHE_CASE_INSENSITIVE=1
+} __GHE_CASE_SENS;
+
 uint64_t __ghf_removePreNPostSpacesFromCharPtr(     char* const pcStr);
 uint64_t __ghf_removePreNPostSpacesFromCharPtr(     char* const pcStr);
 uint64_t __ghf_replaceSpacesWithUnderscoreInCharPtr(char* const pcStr);
 uint64_t __ghf_replaceSpacesWithUnderscoreInCharPtr(char* const pcStr);
 int32_t __ghf_concatHeapStrAndCharPtr(char** ppcDst, const char* const pcStr);
 int32_t __ghf_concatHeapStrAndCharPtr(char** ppcDst, const char* const pcStr);
+int32_t __ghf_cmpCharPtrAndWC(const char*           pcStr,
+                              const char*           pcPattern,
+                              const __GHE_CASE_SENS CaseSensFlag);
 
 
 #endif
 #endif

+ 25 - 7
src/include_h/oclh_h_ws_base.h

@@ -89,6 +89,23 @@ int32_t         _ghf_wdcChkWS_APIErr (  _GHT_WRKSET wSet,
 int32_t         _ghf_wdcChkWS_KerErr(   _GHT_WRKSET wSet,
 int32_t         _ghf_wdcChkWS_KerErr(   _GHT_WRKSET wSet,
                                   const cl_kernel   clKer);
                                   const cl_kernel   clKer);
 int32_t         _ghf_wdcSetWS_KerErrToZero(_GHT_WRKSET wSet);
 int32_t         _ghf_wdcSetWS_KerErrToZero(_GHT_WRKSET wSet);
+
+#pragma pack(push,1)
+typedef struct _GHT_LIST_OF_DEVICES_DESCRIPTION {
+    cl_uint* pcluIdxs;
+    char*    pcWC;
+} _GHT_DEVLIST_DESC;
+#pragma pack(pop)
+
+_GHT_DEVLIST_DESC _ghf_declDevLstDesc(void);
+int32_t _ghf_isDevLstDesc_Valid(const _GHT_DEVLIST_DESC DevLstDesc);
+int32_t _ghf_addDevIdxToDevLstDesc(   _GHT_DEVLIST_DESC* const pDevLstDesc,
+                                      const cl_uint            cluIdx);
+int32_t _ghf_setDevLstDesc_DevNameWC( _GHT_DEVLIST_DESC* const pDevLstDesc,
+                                      const char* const pcWC);
+int32_t _ghf_wipeDevLstDesc(          _GHT_DEVLIST_DESC* const pDevLstDesc);
+
+
 #pragma pack(push,1)
 #pragma pack(push,1)
 typedef struct _GHT_ALL_OF_WORKING_SETS {
 typedef struct _GHT_ALL_OF_WORKING_SETS {
     _GHT_WRKSET* pWSet;
     _GHT_WRKSET* pWSet;
@@ -100,16 +117,16 @@ typedef struct _GHT_ALL_OF_WORKING_SETS {
     const _GHE_BUILD_LOG_MODE BuildLogMode;
     const _GHE_BUILD_LOG_MODE BuildLogMode;
 } _GHT_AWSS;
 } _GHT_AWSS;
 #pragma pack(pop)
 #pragma pack(pop)
-
 _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL  LogLvl,
 _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL  LogLvl,
                         const _GHE_BUILD_LOG_MODE BuildLogMode);
                         const _GHE_BUILD_LOG_MODE BuildLogMode);
-int32_t _ghf_genrAWSs(      _GHT_AWSS* const pAWSs,
-                      const _GHT_LOG         Log,
-                      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 void*       const pvCLProgramSources,
+                      const _GHE_SRCTYPE      SourceType,
+                      const char*       const OCLBuildOpts
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_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) */
@@ -124,6 +141,7 @@ int32_t _ghf_wipeDevList(cl_device_id** ppDevLst);
 
 
 
 
 
 
+
 int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
 int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
                                   char* const pcDst,
                                   char* const pcDst,
                                   char* const pcOutputPrefix);
                                   char* const pcOutputPrefix);

+ 45 - 8
src/oclh_cc.c

@@ -16,23 +16,49 @@ int32_t main(int32_t argc, char *argv[]) {
     _GHT_LOG Log=_ghf_declLog();
     _GHT_LOG Log=_ghf_declLog();
     _GHT_AWSS AWSs=_ghf_declAWSs(_GHE_LOG_ALL,
     _GHT_AWSS AWSs=_ghf_declAWSs(_GHE_LOG_ALL,
                                  _GHE_BUILD_LOG_IN_SEPARATED_FILES);
                                  _GHE_BUILD_LOG_IN_SEPARATED_FILES);
+    _GHT_DEVLIST_DESC DevLstDesc=_ghf_declDevLstDesc();
     {
     {
         uint64_t i=1ul;
         uint64_t i=1ul;
         for(i=1ul; i<(uint64_t)argc; i++) {
         for(i=1ul; i<(uint64_t)argc; i++) {
             if(argv[i][0]=='-') { /* key-value */
             if(argv[i][0]=='-') { /* key-value */
-                if(argv[i][1]=='o') { /* output prefix */
-                    if(!argv[i][2]) { pcOutputPrefix=argv[++i]; }
-                    else { pcOutputPrefix=argv[i]+2ul; }
+                if(argv[i][1]=='o' ||
+                   !strncmp(argv[i],"--dev-idxs=",11ul) ||
+                   !strncmp(argv[i],"--dev-name=",11ul)) {
+                    if(argv[i][1]=='o') { /* output prefix */
+                        if(!argv[i][2]) { pcOutputPrefix=argv[++i]; }
+                        else { pcOutputPrefix=argv[i]+2ul; }
+                    }
+                    if(!strncmp(argv[i],"--dev-idxs=",11ul)) {
+                        uint64_t b=0ul, e=1ul;
+                        char cPrev='s', *pcDevIdxs=NULL;
+                        if(argv[i][11]) { pcDevIdxs=&argv[i][11]; }
+                        else { pcDevIdxs=argv[++i]; }
+                        while(cPrev) {
+                            while(pcDevIdxs[e] && pcDevIdxs[e]!=',') e++;
+                            cPrev=pcDevIdxs[e];
+                            pcDevIdxs[e]='\0';
+                            err|=_ghf_addDevIdxToDevLstDesc(&DevLstDesc,
+                                                  (cl_uint)atoi(&pcDevIdxs[b]));
+                            b=e+1; e=b;
+                        }
+                    }
+                    if(!strncmp(argv[i],"--dev-name=",11ul)) {
+                        if(argv[i][11]) {
+                            err|=_ghf_setDevLstDesc_DevNameWC(&DevLstDesc,
+                                                              &argv[i][11]);
+                        } else {
+                            err|=_ghf_setDevLstDesc_DevNameWC(&DevLstDesc,
+                                                              argv[++i]);
+                        }
+                    }
                 } else { /* compiler and linker options */
                 } else { /* compiler and linker options */
                     err=__ghf_concatHeapStrAndCharPtr(&pcOCLBuildOpts,
                     err=__ghf_concatHeapStrAndCharPtr(&pcOCLBuildOpts,
                                                        argv[i]);
                                                        argv[i]);
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG)
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG)
-                    if((argv[i][1]=='D' || argv[i][1]=='I') && !argv[i][2])
-                        err|=__ghf_concatHeapStrAndCharPtr(&pcOCLBuildOpts,
-                                                           argv[++i]);
-                    if(!strncmp(argv[i],"-cl-std=",8ul) && !argv[i][8])
+                    if((argv[i][1]=='D' || argv[i][1]=='I') && !argv[i][2]) {
                         err|=__ghf_concatHeapStrAndCharPtr(&pcOCLBuildOpts,
                         err|=__ghf_concatHeapStrAndCharPtr(&pcOCLBuildOpts,
                                                            argv[++i]);
                                                            argv[++i]);
+                    }
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
                 }
                 }
             } else err=_ghf_addCharPtrToCharPtrList(&ppcSrcFilenames,argv[i]);
             } else err=_ghf_addCharPtrToCharPtrList(&ppcSrcFilenames,argv[i]);
@@ -40,12 +66,20 @@ int32_t main(int32_t argc, char *argv[]) {
                 fprintf(stderr,
                 fprintf(stderr,
                         "Unable to add item \"%s\" to compiler options list\n",
                         "Unable to add item \"%s\" to compiler options list\n",
                         argv[i]);
                         argv[i]);
+                _ghf_wipeDevLstDesc(&DevLstDesc);
                 _ghf_wipeCharPtrList(&ppcSrcFilenames);
                 _ghf_wipeCharPtrList(&ppcSrcFilenames);
                 _ghf_freeHostZ(&pcOCLBuildOpts);
                 _ghf_freeHostZ(&pcOCLBuildOpts);
                 return(err);
                 return(err);
             }
             }
         }
         }
     }
     }
+    {
+        cl_uint c=0u;
+        printf("dev lst idxs: ");
+        for(c=0u;DevLstDesc.pcluIdxs && DevLstDesc.pcluIdxs[c]!=(cl_uint)(-1);c++)
+            printf("%u ", DevLstDesc.pcluIdxs[c]);
+        printf("\ndev lst mask: |%s|\n",DevLstDesc.pcWC?DevLstDesc.pcWC:"");
+    }
     if(pcOutputPrefix) {
     if(pcOutputPrefix) {
         __ghf_removePreNPostSpacesFromCharPtr(pcOutputPrefix);
         __ghf_removePreNPostSpacesFromCharPtr(pcOutputPrefix);
         __ghf_replaceSpacesWithUnderscoreInCharPtr(pcOutputPrefix);
         __ghf_replaceSpacesWithUnderscoreInCharPtr(pcOutputPrefix);
@@ -55,6 +89,7 @@ int32_t main(int32_t argc, char *argv[]) {
         for(i=0ul; ppcSrcFilenames[i]; i++)
         for(i=0ul; ppcSrcFilenames[i]; i++)
             __ghf_removePreNPostSpacesFromCharPtr(ppcSrcFilenames[i]);
             __ghf_removePreNPostSpacesFromCharPtr(ppcSrcFilenames[i]);
     } else {
     } else {
+        _ghf_wipeDevLstDesc(&DevLstDesc);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_freeHostZ(&pcOCLBuildOpts);
         _ghf_freeHostZ(&pcOCLBuildOpts);
         fprintf(stderr, "No source files specified\n");
         fprintf(stderr, "No source files specified\n");
@@ -62,6 +97,7 @@ int32_t main(int32_t argc, char *argv[]) {
     }
     }
     err=_ghf_genrLog(&Log,_GHM_OCLH_BUILDER_LOG_FILENAME);
     err=_ghf_genrLog(&Log,_GHM_OCLH_BUILDER_LOG_FILENAME);
     if(err) {
     if(err) {
+        _ghf_wipeDevLstDesc(&DevLstDesc);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_freeHostZ(&pcOCLBuildOpts);
         _ghf_freeHostZ(&pcOCLBuildOpts);
         _ghf_wipeLog(&Log);
         _ghf_wipeLog(&Log);
@@ -81,7 +117,7 @@ int32_t main(int32_t argc, char *argv[]) {
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
             i++;
             i++;
         }
         }
-        err=_ghf_genrAWSs(&AWSs,Log,ppcSources,
+        err=_ghf_genrAWSs(&AWSs, Log, DevLstDesc, ppcSources,
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG)
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG)
                           _GHE_HL_LISTINGS,
                           _GHE_HL_LISTINGS,
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
 #endif /* defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) */
@@ -97,6 +133,7 @@ int32_t main(int32_t argc, char *argv[]) {
           defined(__OCLH_COMPILER_ONLY_FLAG) ||
           defined(__OCLH_COMPILER_ONLY_FLAG) ||
           defined(__OCLH_LINKER_ONLY_FLAG) */
           defined(__OCLH_LINKER_ONLY_FLAG) */
                                           );
                                           );
+        _ghf_wipeDevLstDesc(&DevLstDesc);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_wipeCharPtrList(&ppcSrcFilenames);
         _ghf_wipeCharPtrList(&ppcSources);
         _ghf_wipeCharPtrList(&ppcSources);
         _ghf_freeHostZ(&pcOCLBuildOpts);
         _ghf_freeHostZ(&pcOCLBuildOpts);

+ 1 - 1
src/oclh_h_base_log.c

@@ -27,7 +27,7 @@ int32_t _ghf_genrLog(_GHT_LOG* const pLog, const char* const pcFileName) {
     return(_GHM_OK);
     return(_GHM_OK);
 }
 }
 
 
-int32_t _ghf_isLogValid(const _GHT_LOG Log) {
+int32_t _ghf_isLog_Valid(const _GHT_LOG Log) {
     return(Log.pMtx && Log.pfOut);
     return(Log.pMtx && Log.pfOut);
 }
 }
 
 

+ 26 - 1
src/oclh_h_internals.c

@@ -8,7 +8,6 @@
 #include <oclh_h_internals.h>
 #include <oclh_h_internals.h>
 #include <oclh_h_errors.h>
 #include <oclh_h_errors.h>
 
 
-
 uint64_t __ghf_removePreNPostSpacesFromCharPtr(char* const pcStr) {
 uint64_t __ghf_removePreNPostSpacesFromCharPtr(char* const pcStr) {
     if(!pcStr || !pcStr[0]) return(0ul);
     if(!pcStr || !pcStr[0]) return(0ul);
     uint64_t u64NofRemovedSpaces=0ul;
     uint64_t u64NofRemovedSpaces=0ul;
@@ -57,3 +56,29 @@ int32_t  __ghf_concatHeapStrAndCharPtr(char** ppcDst, const char* const pcStr) {
         return(_GHM_OK);
         return(_GHM_OK);
     } else return(_GHM_NULL_POINTER_RECEIVED_ERROR);
     } else return(_GHM_NULL_POINTER_RECEIVED_ERROR);
 }
 }
+
+int32_t __ghf_cmpCharPtrAndWC(const char*           pcStr,
+                              const char*           pcPattern,
+                              const __GHE_CASE_SENS CaseSensFlag) {
+    const char* pcPatternPos=NULL;
+    const char* pcStrPos=NULL;
+    while(*pcStr) {
+        if((*pcPattern)=='*') {
+            pcPatternPos=(++pcPattern);
+            pcStrPos=pcStr;
+            if(!*pcPattern) return(1);
+            continue;
+        }
+        if( ((CaseSensFlag==__GHE_CASE_SENSITIVE)?
+                (*pcStr!=(*pcPattern)):(tolower(*pcStr)!=tolower(*pcPattern)))
+            && (*pcPattern)!='?') {
+            if(!pcPatternPos) return(0);
+            pcStr=(++pcStrPos);
+            pcPattern=pcPatternPos;
+            continue;
+        }
+        pcPattern++, pcStr++;
+    }
+    while((*pcPattern)=='*') pcPattern++;
+    return((*pcPattern)=='\0');
+}

+ 129 - 27
src/oclh_h_ws_base.c

@@ -37,19 +37,21 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                     const char*        const  pcOCLBuildOpts,
                     const char*        const  pcOCLBuildOpts,
                     const _GHE_LOGLVL         LogLvl,
                     const _GHE_LOGLVL         LogLvl,
                     const _GHE_BUILD_LOG_MODE BuildLogMode
                     const _GHE_BUILD_LOG_MODE BuildLogMode
-#if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
+#if defined(__OCLH_BUILDER_FLAG) || \
+    defined(__OCLH_COMPILER_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) */
                                                             ) {
                                                             ) {
 /**/
 /**/
-#define __CLAPI_ERR_ROUTINE_WITH_RET(___CLAPI_CALL)                                     \
-{ const cl_int tmp=pwSet->APIErr;                                              \
-  char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];                                        \
+#define __CLAPI_ERR_ROUTINE_WITH_RET(___CLAPI_CALL) \
+{ const cl_int tmp=pwSet->APIErr; \
+  char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG]; \
   snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG, "%s/%s", __func__, ___CLAPI_CALL); \
   snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG, "%s/%s", __func__, ___CLAPI_CALL); \
-  _ghf_logWS_APIErr(*pwSet, pcLogMsg);                                         \
-  _ghf_wipeWS(pwSet);                                                          \
+  _ghf_logWS_APIErr(*pwSet, pcLogMsg); \
+  _ghf_wipeWS(pwSet); \
   return(tmp); }
   return(tmp); }
 /**/
 /**/
     char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
     char pcLogMsg[_GHM_MAXLEN_OF_LOGMSG];
@@ -278,7 +280,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
 #endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
 #endif /* __OCLH_BUILD_LOG_TO_STDOUT_FLAG */
                     pwSet->APIErr=cliBuildCLAPIErr;
                     pwSet->APIErr=cliBuildCLAPIErr;
                     if(pwSet->APIErr) {
                     if(pwSet->APIErr) {
-                        if(_ghf_isLogValid(TmpLog)) {
+                        if(_ghf_isLog_Valid(TmpLog)) {
                             _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                             _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                             _ghf_wipeLog(&pwSet->Log); }
                             _ghf_wipeLog(&pwSet->Log); }
                         pwSet->Log=TmpLog;
                         pwSet->Log=TmpLog;
@@ -291,7 +293,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                             clCreateKernelsInProgram(pwSet->Program, 0u, NULL,
                             clCreateKernelsInProgram(pwSet->Program, 0u, NULL,
                                                      &cluNofKernels);
                                                      &cluNofKernels);
                         if(pwSet->APIErr) {
                         if(pwSet->APIErr) {
-                            if(_ghf_isLogValid(TmpLog)) {
+                            if(_ghf_isLog_Valid(TmpLog)) {
                                 _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                                 _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                                 _ghf_wipeLog(&pwSet->Log); }
                                 _ghf_wipeLog(&pwSet->Log); }
                             pwSet->Log=TmpLog;
                             pwSet->Log=TmpLog;
@@ -306,7 +308,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                             snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
                             snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
                                      "%s/Host memory allocation failed",
                                      "%s/Host memory allocation failed",
                                      __func__);
                                      __func__);
-                            if(_ghf_isLogValid(TmpLog)) {
+                            if(_ghf_isLog_Valid(TmpLog)) {
                                 _ghf_logWS_Msg(*pwSet, pcLogMsg);
                                 _ghf_logWS_Msg(*pwSet, pcLogMsg);
                                 _ghf_wipeLog(&pwSet->Log); }
                                 _ghf_wipeLog(&pwSet->Log); }
                             pwSet->Log=TmpLog;
                             pwSet->Log=TmpLog;
@@ -329,7 +331,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                              *     ClangFECompilerGetKernelArgInfoTask::
                              *     ClangFECompilerGetKernelArgInfoTask::
                              *         GetKernelArgInfo */
                              *         GetKernelArgInfo */
                             if(pwSet->APIErr) {
                             if(pwSet->APIErr) {
-                                if(_ghf_isLogValid(TmpLog)) {
+                                if(_ghf_isLog_Valid(TmpLog)) {
                                     _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                                     _ghf_logWS_APIErr(*pwSet, pcLogMsg);
                                     _ghf_wipeLog(&pwSet->Log); }
                                     _ghf_wipeLog(&pwSet->Log); }
                                 pwSet->Log=TmpLog;
                                 pwSet->Log=TmpLog;
@@ -344,7 +346,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                                          "%s/The number of created kernels "
                                          "%s/The number of created kernels "
                                          " is not equal to the number "
                                          " is not equal to the number "
                                          "of all kernels", __func__);
                                          "of all kernels", __func__);
-                                if(_ghf_isLogValid(TmpLog)) {
+                                if(_ghf_isLog_Valid(TmpLog)) {
                                     _ghf_logWS_Msg(*pwSet, pcLogMsg);
                                     _ghf_logWS_Msg(*pwSet, pcLogMsg);
                                     _ghf_wipeLog(&pwSet->Log); }
                                     _ghf_wipeLog(&pwSet->Log); }
                                 pwSet->Log=TmpLog;
                                 pwSet->Log=TmpLog;
@@ -398,7 +400,7 @@ int32_t _ghf_genrWS(      _GHT_WRKSET* const  pwSet,
                         _ghf_wipeLog(&pwSet->Log);
                         _ghf_wipeLog(&pwSet->Log);
                         pwSet->Log=TmpLog;
                         pwSet->Log=TmpLog;
                     }
                     }
-                    if(_ghf_isLogValid(TmpLog)) {
+                    if(_ghf_isLog_Valid(TmpLog)) {
                         snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
                         snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
                              "%u kernels registered", cluNofKernels);
                              "%u kernels registered", cluNofKernels);
                         _ghf_logWS_Msg(*pwSet, pcLogMsg);
                         _ghf_logWS_Msg(*pwSet, pcLogMsg);
@@ -542,7 +544,7 @@ int32_t _ghf_wipeWS(_GHT_WRKSET* const pwSet) {
 }
 }
 
 
 int32_t _ghf_isWS_LogValid(const _GHT_WRKSET wSet) {
 int32_t _ghf_isWS_LogValid(const _GHT_WRKSET wSet) {
-    return(_ghf_isLogValid(wSet.Log));
+    return(_ghf_isLog_Valid(wSet.Log));
 }
 }
 
 
 int32_t _ghf_recalcWS_WIWG(_GHT_WRKSET* const pwSet,
 int32_t _ghf_recalcWS_WIWG(_GHT_WRKSET* const pwSet,
@@ -889,6 +891,61 @@ int32_t _ghf_wdcSetWS_KerErrToZero(_GHT_WRKSET wSet) {
     return(_GHM_OK);
     return(_GHM_OK);
 }
 }
 
 
+_GHT_DEVLIST_DESC _ghf_declDevLstDesc(void) {
+    _GHT_DEVLIST_DESC dld={ .pcluIdxs=NULL, .pcWC=NULL };
+    return(dld);
+}
+
+int32_t _ghf_isDevLstDesc_Valid(const _GHT_DEVLIST_DESC DevLstDesc) {
+    if(DevLstDesc.pcluIdxs &&  DevLstDesc.pcWC)        return(0);
+    if(DevLstDesc.pcluIdxs &&  DevLstDesc.pcluIdxs[0]==(cl_uint)(-1)) return(0);
+    if(DevLstDesc.pcWC     && !DevLstDesc.pcWC)        return(0);
+    return(1);
+}
+
+int32_t _ghf_addDevIdxToDevLstDesc(   _GHT_DEVLIST_DESC* const pDevLstDesc,
+                                      const cl_uint            cluIdx) {
+    if(!pDevLstDesc->pcluIdxs) {
+        pDevLstDesc->pcluIdxs=malloc(sizeof(cl_uint));
+        if(!pDevLstDesc->pcluIdxs) return(_GHM_HOST_MEMALLOC_ERROR);
+        pDevLstDesc->pcluIdxs[0]=(cl_uint)(-1);
+    }
+    _ghf_freeHostZ(&pDevLstDesc->pcWC);
+    {
+        uint64_t i=0ul;
+        cl_uint* pTmp=NULL;
+        /* TODO: make faster */
+        for(i=0ul; pDevLstDesc->pcluIdxs[i]!=(cl_uint)(-1); i++ )
+            if(pDevLstDesc->pcluIdxs[i]==cluIdx) return(_GHM_OK);
+        pTmp=realloc(pDevLstDesc->pcluIdxs,i+1);
+        if(!pTmp) return(_GHM_HOST_MEMALLOC_ERROR);
+        pDevLstDesc->pcluIdxs=pTmp;
+        pDevLstDesc->pcluIdxs[i]=cluIdx;
+        pDevLstDesc->pcluIdxs[i+1]=(cl_uint)(-1);
+    }
+    return(_GHM_OK);
+}
+
+int32_t _ghf_setDevLstDesc_DevNameWC(_GHT_DEVLIST_DESC* const pDevLstDesc,
+                                     const char* const pcWC) {
+    char* pTmp=NULL;
+    uint64_t i=0;
+    while(pcWC[i]) i++;
+    pTmp=realloc(pDevLstDesc->pcWC,i+1ul);
+    if(!pTmp) return(_GHM_HOST_MEMALLOC_ERROR);
+    pDevLstDesc->pcWC=pTmp;
+    strncpy(pDevLstDesc->pcWC,pcWC,i);
+    pDevLstDesc->pcWC[i]='\0';
+    _ghf_freeHostZ(&pDevLstDesc->pcluIdxs);
+    return(_GHM_OK);
+}
+
+int32_t _ghf_wipeDevLstDesc(          _GHT_DEVLIST_DESC* const pDevLstDesc) {
+    _ghf_freeHostZ(&pDevLstDesc->pcluIdxs);
+    _ghf_freeHostZ(&pDevLstDesc->pcWC);
+    return(0);
+}
+
 _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL  LogLvl,
 _GHT_AWSS _ghf_declAWSs(const _GHE_LOGLVL  LogLvl,
                         const _GHE_BUILD_LOG_MODE BuildLogMode) {
                         const _GHE_BUILD_LOG_MODE BuildLogMode) {
     _GHT_AWSS AWSs={ .pWSet=NULL, .u64NofWSs=0ul, .Log=_ghf_declLog(),
     _GHT_AWSS AWSs={ .pWSet=NULL, .u64NofWSs=0ul, .Log=_ghf_declLog(),
@@ -898,12 +955,15 @@ _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 void*  const pvCLProgramSources,
-                      const _GHE_SRCTYPE SourceType,
-                      const char*  const OCLBuildOpts
-#if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
+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
+#if defined(__OCLH_BUILDER_FLAG) || \
+    defined(__OCLH_COMPILER_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) ||
@@ -913,7 +973,10 @@ int32_t _ghf_genrAWSs( _GHT_AWSS*  const pAWSs,
     _GHT_WRKSET tmpWS=_ghf_declWS();
     _GHT_WRKSET tmpWS=_ghf_declWS();
     cl_device_id* DevLst=NULL;
     cl_device_id* DevLst=NULL;
     int32_t err=0;
     int32_t err=0;
-    if(!_ghf_isLogValid(Log)) return(_GHM_INCONSISTED_LOG_ERROR);
+    _GHT_DEVLIST_DESC TmpDevLstDesc=_ghf_declDevLstDesc();
+    if(!_ghf_isLog_Valid(Log)) return(_GHM_INCONSISTED_LOG_ERROR);
+    if(!_ghf_isDevLstDesc_Valid(DevLstDesc))
+                               return(_GHM_INCONSISTED_DEV_DESCRIPTION_ERROR);
     pAWSs->Log=Log;
     pAWSs->Log=Log;
     tmpWS.Log=Log; tmpWS.pwSetAddr=&tmpWS;
     tmpWS.Log=Log; tmpWS.pwSetAddr=&tmpWS;
     _ghf_wipeAWSs(pAWSs);
     _ghf_wipeAWSs(pAWSs);
@@ -946,6 +1009,10 @@ int32_t _ghf_genrAWSs( _GHT_AWSS*  const pAWSs,
                          "+++++++ Device 0x%lx description +++++++",
                          "+++++++ Device 0x%lx description +++++++",
                          (uint64_t)DevLst[i]);
                          (uint64_t)DevLst[i]);
                 _ghf_logWS_Msg(tmpWS, pcLogMsg);
                 _ghf_logWS_Msg(tmpWS, pcLogMsg);
+                snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
+                         "dev_0x%04lx | Device index: %u",
+                         __GHM_U64STRIPTO2B(DevLst[i]),i);
+                _ghf_logWS_Msg(tmpWS, pcLogMsg);
                 _ghf_logWS_DevInfo(tmpWS,DevLst[i],pAWSs->LogLevel);
                 _ghf_logWS_DevInfo(tmpWS,DevLst[i],pAWSs->LogLevel);
                 snprintf(pcLogMsg,_GHM_MAXLEN_OF_LOGMSG,
                 snprintf(pcLogMsg,_GHM_MAXLEN_OF_LOGMSG,
                          "------- End of device 0x%lx description -------",
                          "------- End of device 0x%lx description -------",
@@ -954,21 +1021,56 @@ int32_t _ghf_genrAWSs( _GHT_AWSS*  const pAWSs,
             }
             }
     }
     }
     {
     {
-        cl_uint i=0u;
-        cl_uint cluNofDevs=0u;
+        cl_uint i=0u,
+                cluNofDevs=0u,
+                cluNofWS=0u;
+        err=0;
         while(DevLst[cluNofDevs]) cluNofDevs++;
         while(DevLst[cluNofDevs]) cluNofDevs++;
+        if(!DevLstDesc.pcluIdxs && !DevLstDesc.pcWC) { cluNofWS=cluNofDevs; }
+        else {
+            if(DevLstDesc.pcluIdxs) {
+                cl_uint j=0u;
+                while(DevLstDesc.pcluIdxs[j]!=(cl_uint)(-1)) {
+                    if(DevLstDesc.pcluIdxs[j]<cluNofDevs) { cluNofWS++; }
+                    j++;
+                }
+            } else { /* подразумевается валидное описание устройств */
+                cl_uint j=0u;
+                while(DevLst[j]) {
+                    if(__ghf_cmpCharPtrAndWC(
+                                _ghf_getDevInf_charptr(DevLst[j],CL_DEVICE_NAME,
+                                                       &tmpWS.APIErr),
+                                DevLstDesc.pcWC, __GHE_CASE_SENSITIVE)) {
+                        err=_ghf_addDevIdxToDevLstDesc(&TmpDevLstDesc,j);
+                        if(err) {
+                            _ghf_wipeDevLstDesc(&TmpDevLstDesc);
+                            _ghf_wipeAWSs(pAWSs);
+                            _ghf_wipeDevList(&DevLst);
+                            _ghf_wipeWS(&tmpWS);
+                            return(err);
+                        }
+                        cluNofWS++;
+                    }
+                    j++;
+                }
+            }
+        }
         err=0;
         err=0;
         pAWSs->u64NofWSs=0;
         pAWSs->u64NofWSs=0;
-        pAWSs->pWSet=malloc(sizeof(_GHT_WRKSET)*cluNofDevs);
+        pAWSs->pWSet=malloc(sizeof(_GHT_WRKSET)*cluNofWS);
         if(!pAWSs->pWSet) {
         if(!pAWSs->pWSet) {
+            _ghf_wipeDevLstDesc(&TmpDevLstDesc);
             _ghf_wipeAWSs(pAWSs);
             _ghf_wipeAWSs(pAWSs);
             _ghf_wipeDevList(&DevLst);
             _ghf_wipeDevList(&DevLst);
             _ghf_wipeWS(&tmpWS);
             _ghf_wipeWS(&tmpWS);
             return(_GHM_HOST_MEMALLOC_ERROR);
             return(_GHM_HOST_MEMALLOC_ERROR);
         }
         }
-        for(i=0u; i<cluNofDevs; i++) {
+        for(i=0u; i<cluNofWS; i++) {
             pAWSs->pWSet[pAWSs->u64NofWSs]=_ghf_declWS();
             pAWSs->pWSet[pAWSs->u64NofWSs]=_ghf_declWS();
-            err=_ghf_genrWS(&pAWSs->pWSet[pAWSs->u64NofWSs], Log, 0, DevLst[i],
+            err=_ghf_genrWS(&pAWSs->pWSet[pAWSs->u64NofWSs], Log, 0,
+                            (TmpDevLstDesc.pcluIdxs)?
+                                DevLst[TmpDevLstDesc.pcluIdxs[i]]:
+                                DevLst[DevLstDesc.pcluIdxs[i]],
                             pvCLProgramSources, SourceType, OCLBuildOpts,
                             pvCLProgramSources, SourceType, OCLBuildOpts,
                             pAWSs->LogLevel, pAWSs->BuildLogMode
                             pAWSs->LogLevel, pAWSs->BuildLogMode
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
 #if defined(__OCLH_BUILDER_FLAG) || defined(__OCLH_COMPILER_ONLY_FLAG) || defined(__OCLH_LINKER_ONLY_FLAG)
@@ -981,12 +1083,14 @@ int32_t _ghf_genrAWSs( _GHT_AWSS*  const pAWSs,
             else pAWSs->u64NofWSs++;
             else pAWSs->u64NofWSs++;
         }
         }
         if(!pAWSs->u64NofWSs) {
         if(!pAWSs->u64NofWSs) {
+            _ghf_wipeDevLstDesc(&TmpDevLstDesc);
             _ghf_wipeAWSs(pAWSs);
             _ghf_wipeAWSs(pAWSs);
             _ghf_wipeDevList(&DevLst);
             _ghf_wipeDevList(&DevLst);
             _ghf_wipeWS(&tmpWS);
             _ghf_wipeWS(&tmpWS);
             return(err);
             return(err);
         }
         }
     }
     }
+    _ghf_wipeDevLstDesc(&TmpDevLstDesc);
     _ghf_wipeDevList(&DevLst);
     _ghf_wipeDevList(&DevLst);
     if(pAWSs->LogLevel>=_GHE_LOG_ALL) {
     if(pAWSs->LogLevel>=_GHE_LOG_ALL) {
         snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
         snprintf(pcLogMsg, _GHM_MAXLEN_OF_LOGMSG,
@@ -1127,8 +1231,6 @@ int32_t _ghf_wipeDevList(cl_device_id** const ppDevLst) {
 
 
 
 
 
 
-
-
 int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
 int32_t __ghf_setWS_TextProgramId(_GHT_WRKSET wSet,
                                   char* const pcDst,
                                   char* const pcDst,
                                   char* const pcOutputPrefix) {
                                   char* const pcOutputPrefix) {

+ 1 - 1
src/oclh_h_ws_base_log.c

@@ -27,7 +27,7 @@ int32_t __ghf_logWS_MsgIgnoringLock(const _GHT_WRKSET wSet,
 }
 }
 
 
 int32_t _ghf_logWS_Msg(const _GHT_WRKSET wSet, const char* const pcLogMsg) {
 int32_t _ghf_logWS_Msg(const _GHT_WRKSET wSet, const char* const pcLogMsg) {
-    if(_ghf_isLogValid(wSet.Log)) {
+    if(_ghf_isLog_Valid(wSet.Log)) {
         pthread_mutex_lock(wSet.Log.pMtx);
         pthread_mutex_lock(wSet.Log.pMtx);
             __ghf_logWS_MsgIgnoringLock(wSet, pcLogMsg);
             __ghf_logWS_MsgIgnoringLock(wSet, pcLogMsg);
         pthread_mutex_unlock(wSet.Log.pMtx);
         pthread_mutex_unlock(wSet.Log.pMtx);