This content has been marked as final. Show 2 replies
you can try this.
err = clBuildProgram(program, 1, &devices, "-cl-mad-enable", NULL, NULL); //build the program err = clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES, sizeof(size_t), &nb_devices, &nbread);// Return 1 devices size_t *np = new size_t[nb_devices];//Create size array err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*nb_devices, np, &nbread);//Load in np the size of my binary char** bn = new char* [nb_devices]; //Create the binary array for(int i =0; i < nb_devices;i++) bn[i] = new char[np[i]]; // I know... it's bad... but if i use new char[np[i]], i have a segfault... :/ err = clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char *)*nb_devices, bn, &nbread); //Load the binary itself printf("%s\n", bn); //Print the first binary. But here, I have some curious characters FILE *fp = fopen("binar.bin", "wb"); fwrite(bn, sizeof(char), np, fp); // Save the binary, but my file stay empty fclose(fp);
and you can use clCreateProgramWithBinary to build program with binary.
Thanks, it works !
(I have the same problem with "new char[np[i]]" because np in undefined, but the rest of the algo works