static const char * available_ocl_device_name(QSP_ARG_DECL const char *name,char *scratch_string, int scratch_len) { Platform_Device *pdp; const char *s; int n=1; s=name; // Why should we care how many devices there are? // Why have statically-allocated structures? while(n<=MAX_OCL_DEVICES){ pdp = pfdev_of(s); if( pdp == NULL ) return(s); // This name is in use n++; if( strlen(name)+1+MAX_DIGIT_CHARS+1 > scratch_len ) error1("available_ocl_device_name: size of scratch_string is insufficient!?"); sprintf(scratch_string,"%s_%d",name,n); s=scratch_string; } sprintf(ERROR_STRING,"Number of %s OpenCL devices exceed configured maximum %d!?", name,MAX_OCL_DEVICES); warn(ERROR_STRING); error1(ERROR_STRING); return(NULL); // NOTREACHED - quiet compiler }
// BUG move to platform support file! static const char * available_pfdev_name(QSP_ARG_DECL const char *name,char *scratch_string, Compute_Platform *cpp, int max_devices) { Platform_Device *pdp; const char *s; int n=1; s=name; while(n<=max_devices){ pdp = pfdev_of(QSP_ARG s); if( pdp == NO_PFDEV ) return(s); // This name is in use n++; sprintf(scratch_string,"%s_%d",name,n); s=scratch_string; } sprintf(ERROR_STRING,"Number of %s %s devices exceed configured maximum %d!?", name,PLATFORM_NAME(cpp),max_devices); WARN(ERROR_STRING); ERROR1(ERROR_STRING); return(NULL); // NOTREACHED - quiet compiler }