Hi all,
I’m retooling a program to run on GPUs and suddenly while bugshooting some kernel failures, my code started segfaulting on a file I wasn’t working on. I have my code rigged so that I can run the program without the CUDA implementation depending on my ./configure flags, and the file fun_function.c (which is the same with/without CUDA) runs just fine if compiled with gcc… compiling with nvcc seems to cause a segfault when I run the program. Here’s the relevant code and the output when it fails… I think you will agree with me that this is very strange (nothing GPU-based is actually called here):
fun_function.c (fun_function() is called from main.c)
fun_function()
{
int fin = 2;
int start;
for (start=1; start<=fin; start++)
{
printf("loop commenced\n");
[blah blah blah]
printf("JUST finished loop\n");
printf("endloop: start = %i, fin = %i\n", start, fin);
}
printf("end function");
}
and the terminal output:
loop commenced
JUST finished loop
endloop: start = 1, fin = 2
loop commenced
JUST finished loop
endloop: start = 2, fin = 2
Segmentation fault
There is absolutely no code between printf(“endloop: start = %i, fin = %i\n”, start, fin); and printf(“end function”); so the program seems to be segfaulting on its return to the FOR loop? And again, this piece of code runs perfectly when compiled as
gcc -O3 -c fun_function.c
instead of
nvcc -O3 -arch=sm_20 -c fun_function.c
Is this a bug with nvcc? If anyone has seen anything similar, is there something behind the scenes that could be breaking or do you think I could just reinstall everything CUDA to get rid of this? (I’m running CUDA 4.0 on Ubuntu 10.10 with a GTX 460, using the most up-to-date drivers from the NVIDIA website, 275 or something instead of the 270 something given on the CUDA-specific webpage.)
Thanks!
S