0

I try to experiment with OpenCL on a MacBook Pro (on a built-in Gen 11 Iris Plus Graphics card) and use the following example code. The code compiles (gcc hello.c -framework OpenCL -DAPPLE -o hello) and runs fine, but ever so often when some modifications of the program cause an error, it seems as if the GPU somehow stays in that errors state. Even after rolling back my changes in the hello.c and reverting to the example code, recompiling and executing, I keep getting the same error:

Failed to build program executable!
buffer: Compile Server Error

I modified the code to:

// Build the program executable
//
err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
if (err != CL_SUCCESS)
{
    size_t len;
    char buffer[2048];

    printf("Error: Failed to build program executable!\n");
    clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
    printf("buffer: %s\n", buffer);

    // Determine the size of the log
    size_t log_size;
    clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);

    // Allocate memory for the log
    char *log = (char *) malloc(log_size);

    // Get the log
    clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, log_size, log, NULL);

    // Print the log
    printf("%s\n", log);

    exit(1);
}

I also subsequently printed the error code of clBuildProgram which is -11 (CL_BUILD_PROGRAM_FAILURE).

https://developer.apple.com/library/archive/samplecode/OpenCL_Hello_World_Example/Introduction/Intro.html

When I restart the computer, and rerun the example, it works as it did before. Is there anything I need to do to "reset" the GPU? It seems as if runs into some sort of error state which it doesn't leave until a reboot, which is kind of annoying as I will most likely make lots of mistakes...

orange
  • 7,755
  • 14
  • 75
  • 139

0 Answers0