code d'erreur (-11) :: quelles sont toutes les raisons possibles d'obtenir l'erreur "cl_build_program_failure" dans OpenCL?
Je suis en utilisant ATI RV770 carte graphique, OpenCl 1.0 et ati stream sdk v2.3-lnx64 sur linux.
Lors de l'exécution de mon code d'hôte qui comprend deux sections suivantes pour construire le noyau du programme, j'obtiens le code d'erreur (-11) c'est à dire cl_build_program_failure
. Ce n'est que le noyau du programme compilé, si non, alors comment est-il compilé et débogué?
const char* KernelPath = "abc_kernel.cl"; //kernel program is in separate file but in same directory of host code..
/* Créer un objet de Programme de la source du noyau *******/
char* sProgramSource = readKernelSource(KernelPath);
size_t sourceSize = strlen(sProgramSource) ;
program = clCreateProgramWithSource(context, 1,(const char **) &sProgramSource,&sourceSize, &err);
checkStatus("error while creating program",err);
/* Construire (compiler & Lien ) Programme *******/
char* options = (char* )malloc(10*sizeof(char));
strcpy(options, "-g");
err = clBuildProgram(program, num_devices, devices_id, options, NULL, NULL);
checkStatus("Build Program Failed", err); //This line throwing the error....
fonction pour lire noyau programme est comme suit::
/* lecture de programme fichier source*/
char* readKernelSource(const char* kernelSourcePath){
FILE *fp = NULL;
size_t sourceLength;
char *sourceString ;
fp = fopen( kernelSourcePath , "r");
if(fp == 0)
{
printf("failed to open file");
return NULL;
}
//get the length of the source code
fseek(fp, 0, SEEK_END);
sourceLength = ftell(fp);
rewind(fp);
//allocate a buffer for the source code string and read it in
sourceString = (char *)malloc( sourceLength + 1);
if( fread( sourceString, 1, sourceLength, fp) !=sourceLength )
{
printf("\n\t Error : Fail to read file ");
return 0;
}
sourceString[sourceLength+1]='char* readKernelSource(const char* kernelSourcePath){
FILE *fp = NULL;
size_t sourceLength;
char *sourceString ;
fp = fopen( kernelSourcePath , "r");
if(fp == 0)
{
printf("failed to open file");
return NULL;
}
//get the length of the source code
fseek(fp, 0, SEEK_END);
sourceLength = ftell(fp);
rewind(fp);
//allocate a buffer for the source code string and read it in
sourceString = (char *)malloc( sourceLength + 1);
if( fread( sourceString, 1, sourceLength, fp) !=sourceLength )
{
printf("\n\t Error : Fail to read file ");
return 0;
}
sourceString[sourceLength+1]='\0';
fclose(fp);
return sourceString;
';
fclose(fp);
return sourceString;
}//fin de la readKernelSource
Si quelqu'un peut dire comment le réparer?
Signifie qu'il est OpenCl erreur de compilation lors de l'exécution ou de quelque chose d'autre?
//Impression build_log info à l'aide de clGetProgramBuildInfo() comme ci-dessous, Mais pourquoi n'est pas l'impression de quelque chose?
char* build_log;
size_t log_size;
//First call to know the proper size
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
build_log = (char* )malloc((log_size+1));
//Second call to get the log
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
build_log[log_size] = '//First call to know the proper size
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
build_log = (char* )malloc((log_size+1));
//Second call to get the log
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
build_log[log_size] = '\0';
printf("--- Build log ---\n ");
fprintf(stderr, "%s\n", build_log);
free(build_log);
';
printf("--- Build log ---\n ");
fprintf(stderr, "%s\n", build_log);
free(build_log);
source d'informationauteur Gopal
Vous devez vous connecter pour publier un commentaire.
Cette erreur est généralement causée par une erreur de syntaxe dans ton code du noyau. Vous pouvez appeler l'OpenCL fonction clGetProgramBuildInfo avec le drapeau CL_PROGRAM_BUILD_LOG pour accéder au fichier journal généré par le compilateur. Ce journal contient la sortie que vous êtes probablement habitué lors de la compilation sur la ligne de commande (erreurs, avertissements, etc.).
Par exemple, vous pouvez ajouter quelque chose de semblable au suivant lorsque vous appelez clBuildProgram:
Vous pouvez également voir la fonction buildOpenCLProgram() dans SDKCommon.cpp dans le AMD APP SDK pour un exemple réel.