0

I'm trying to play around widh CUDA (in C on VS 2013, with Cuda 7.5).

I have been trying for hours to make a specific procedure run, without success. So I reduced it to its simplest expression, and I still have problems...

The following code runs smoothly with only 2 loops in the kernel: the "p" value goes up and reaches 14000. But with 3 loops, p stops at around 600 (instead of 14000) and the kernel gives back the floor to the Main program without any kind of notice.

#include <stdio.h>

__global__ void kernelLoops(long imax, long jmax, long pmax)
{
    long p, q, r;

// the loops generating problems are p, q, r. 
    for (p = 0; p< pmax; ++p){
        printf(" %d /%d\n", p, pmax);
        for (q = 0; q < imax; ++q){
            for (r = 0; r < jmax; ++r){
            }
        }
    }
}


void main()
{
    long imax = 200;
    long jmax = 200;
    long pmax = 14000;

    setbuf(stdout, NULL); // to get the printf output without delay

    kernelLoops <<< 1, 1 >>>( imax, jmax, pmax);

    printf("%s\n", cudaGetErrorString   (cudaGetLastError()));
    // This gives me "no error" on top of my screen. Then I see the numbers of the Kernel running...

    cudaDeviceSynchronize();
    printf("%s\n", cudaGetErrorString   (cudaGetLastError()));
    // This gives me "unspecified launch failure"
    printf("end of sync\n");

    getchar();
}

Can anyone help??? What may be happening? Thanks

Charlie Echo
  • 87
  • 1
  • 5
  • 1
    probably you are running into the WDDM timeout/watchdog. You indicate that " the kernel gives back the floor to the Main program without any kind of notice" but this is only because you are not doing [proper cuda error checking](http://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api), which is recommended any time you are having trouble with a CUDA code, *before* asking for help. – Robert Crovella Oct 27 '16 at 21:43
  • I modified the code to add two lines with : printf("%s\n", cudaGetErrorString (cudaGetLastError()));. I get "no error" and then "unspecified launch failure"... – Charlie Echo Oct 27 '16 at 21:59
  • So now, with proper cuda error checking, you're not getting a silent error. The kernel is not giving the floor back to the main program without any kind of notice. It is actually giving notice, but you were ignoring it. – Robert Crovella Oct 27 '16 at 22:04
  • Well, I tried to get the Error but removed it when I reduced the code to the minimum, because the Error just after launching the kernel was "no error". Anyway, thanks for the WDDM timeout hint, I'll look into this. – Charlie Echo Oct 27 '16 at 22:29
  • I run your code in linux and it is working. The problem might be your system. First comment is a good hint. – Aznaveh Oct 29 '16 at 17:24

0 Answers0