I want to save the binary (after my clBuildProgram) on a file, so this is my code :
err = clBuildProgram(plan->program, 1, &devices, "-cl-mad-enable", NULL, NULL); //build the program
err = clGetProgramInfo(plan->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(plan->program, CL_PROGRAM_BINARY_SIZES, 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; // I know... it's bad... but if i use new char[np[i]], i have a segfault... :/
err = clGetProgramInfo(plan->program, CL_PROGRAM_BINARIES, nb_devices, bn, &nbread); //Load the binary itself
printf("%s\n", bn); //Print the first binary. But here, I have some curious characters
fp = fopen("binar.bin", "wb"); fwrite(bn, sizeof(char*), 70000, fp); // Save the binary, but my file stay empty
I don't know how to retrieve the binary, my clBuildProgram work (and my binary too), but i think i'm doing something wrong on my program.
If someone can help me, thank you !