I don’t know if this is a bug or it just happened in emulation mode.
I have those two small functions :
ad2.c
[codebox]
#include <stdio.h>
main()
{
int n = 10 ;
float q = 1e-10;
ad2 ( n , q );
printf (" ad2 n q %d %e \n",n,q);
}
[/codebox]
and
ad2.cu
[codebox]
#include <stdio.h>
extern “C”
{
void ad2 ( int n , float q )
{
printf (" inside ad2 n q %d %e \n",n,q);
}
}
[/codebox]
this is compiled with -deviceemu -lcudartemu
When I run my debugger , I got this :
[codebox]
Breakpoint 1, main () at ad2.c:5
5 int n = 10 ;
(gdb) s
6 float q = 1e-10;
(gdb) s
8 ad2 ( n , q );
(gdb) s
ad2 (n=10, q=-3.68934881e+19) at ad2.cu:6
6 printf (" inside ad2 n q %d %e \n",n,q);
Current language: auto; currently c++
(gdb) s
inside ad2 n q 10 -3.689349e+19
7 }
(gdb) s
main () at ad2.c:10
10 printf (" ad2 n q %d %e \n",n,q);
Current language: auto; currently c
(gdb) s
ad2 n q 10 1.000000e-10
13 }
[/codebox]
You can see that in one case ( inside .cu) the value of q is -3.689349e+19, which does not make sense, and it is 1.000000e-10 in the main .c program.
What’s up with that?