Wrong return value for clCompileProgram

I’m running on Arch Linux with opencl-nvidia 530.41.03-1 drivers, I got CL_BUILD_PROGRAM_FAILURE instead of the documented CL_COMPILE_PROGRAM_FAILURE in the latest version of the OpenCL spec.

Here’s a minimal code snippet + output showcasing that behavior.

#include <stdio.h>
#include <stdlib.h>

#define CL_TARGET_OPENCL_VERSION 300
#include <CL/opencl.h>

const char *source = "invalid source code";

int main(void) {
    cl_platform_id platform;
    clGetPlatformIDs(1, &platform, NULL);

    char platform_version[50], platform_name[50], platform_vendor[50];
    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 50 * sizeof(char), platform_version, NULL);
    clGetPlatformInfo(platform, CL_PLATFORM_VENDOR, 50 * sizeof(char), platform_vendor, NULL);
    clGetPlatformInfo(platform, CL_PLATFORM_NAME, 50 * sizeof(char), platform_name, NULL);

    printf(
        "platform info:\n"
        "\tname: %s\n"
        "\tvendor: %s\n"
        "\tversion: %s\n",
        platform_name, platform_vendor, platform_version
    );

    cl_device_id device;
    clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL);

    cl_context context = clCreateContext(NULL, 1, &device, NULL, NULL, NULL);
    cl_command_queue queue = clCreateCommandQueueWithProperties(context, device, NULL, NULL);

    cl_program program = clCreateProgramWithSource(context, 1, &source, NULL, NULL);
    cl_int compile_status = clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL);

    printf(
        "CL_COMPILE_PROGRAM_FAILURE: %u\n"
        "CL_BUILD_PROGRAM_FAILURE: %u\n"
        "compile_status: %u\n",
        CL_COMPILE_PROGRAM_FAILURE, CL_BUILD_PROGRAM_FAILURE, compile_status
    );

    clReleaseProgram(program);
    clReleaseCommandQueue(queue);
    clReleaseContext(context);
}

Output:

λ ~ ls /etc/OpenCL/vendors
nvidia.icd
λ bug gcc src/main.c `pkg-config --libs OpenCL` && ./a.out
platform info:
	name: NVIDIA CUDA
	vendor: NVIDIA Corporation
	version: OpenCL 3.0 CUDA 12.1.98
2 errors generated.
CL_COMPILE_PROGRAM_FAILURE: 4294967281
CL_BUILD_PROGRAM_FAILURE: 4294967285
compile_status: 4294967285

I suggest filing a bug.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.