Results 1 to 8 of 8

Thread: program hangs on clBuildProgram with an empty kernel or takes > 1 hour

  1. #1
    Junior Member
    Join Date
    Mar 2012

    program hangs on clBuildProgram with an empty kernel or takes > 1 hour

    My program hangs on a clBuildProgram call, with no specific parameters, and with an empty kernel. My program is successfully created but not built!
    It happens on a Tesla S1070...

    Sometimes, it takes more than 1hour to succeed in the build......
    NVIDIA driver version : 304.54

    Any Idea?

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Please, HELP!

  3. #3
    Administrator khronos's Avatar
    Join Date
    Jun 2002

    Your question is vague, and contains now code or examples for anyone to be able to help you. Please heed my suggestions from email and read the forum posting guidelines and add complete information about your issue with specific details, code etc.


  4. #4
    Junior Member
    Join Date
    Mar 2012
    Sorry, here is a piece of code hanging on clBuildProgram call...

    #include <stdio.h>
    #include <string.h>
    #include <CL/cl.h>

    int main(void) {

    char *source_str = "__kernel void emptyKernel() {}";
    size_t source_size = strlen(source_str);

    // Get platform and device information
    cl_platform_id platform_id = NULL;
    cl_device_id device_id = NULL;
    clGetPlatformIDs(1, &platform_id, NULL);
    clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, NULL);

    // print device name
    size_t valueSize;
    clGetDeviceInfo(device_id, CL_DEVICE_NAME, 0, NULL, &valueSize);
    char* value = (char*) malloc(valueSize);
    clGetDeviceInfo(device_id, CL_DEVICE_NAME, valueSize, value, NULL);
    printf("Device: %s\n", value);

    // Create an OpenCL context
    cl_context context = clCreateContext( NULL, 1, &device_id, NULL, NULL, NULL);

    // Create a program from the kernel source
    cl_int ciErr;
    cl_program program = clCreateProgramWithSource(context, 1,(const char **)&source_str, (const size_t *)&source_size, &ciErr);
    if (ciErr != CL_SUCCESS)
    printf("clCreateProgramWithSource failed");
    return 1;

    // Build the program
    clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
    printf("AFTER\n");// Randomly appears

    // Clean up

    return 0;

  5. #5
    If it helps, I don't think there is anything wrong with your program. I ran it on a GeForce 480 GTX and it runs in about a second. So it seems more likely to be some sort of system problem. Since it's a Tesla I assume this might be in a cluster rather than a PC - is it possible that another user is using the card and thus preventing your program from accessing it?

  6. #6
    Junior Member
    Join Date
    Mar 2012
    Hi !
    It cannot be possible.. There are no conflict when accessing the Tesla..
    I traced system calls :

    open("/home/mbenguigui/.nv/ComputeCache/index", O_RDWR) = 19
    fcntl(19, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}

  7. #7
    Senior Member
    Join Date
    Dec 2011
    Clever idea to trace system calls. The ".nv/ComputeCache" is where the NVIDIA driver stores information about kernels that have been compiled already (cached for speed). It seems odd that the driver can't read (or lock?) a file from the user folder. Do you have sufficient admin rights?

  8. #8
    Junior Member
    Join Date
    Mar 2012
    Ok, it seems that comes from the cuda cache directory, which is locked bu multiple threads.. (my application lanches as many threads as GPUs on the cluster).. And the directory was shared by all oh them.. Setting it to a local directory for each thread tackel the problem....

    Thank you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean