This is killing me.
I’m getting variables that actually are changing values when passed to functions, in both gdb (deviceemu) and cuda-gdb.
The types being passed and received are the exact same type.
See the following for an example:
inside gdb:
1228 macro+=getmicro_t((*neut).energy,Emesh_d,loc)*mat_list_d[i+NUCLIDE_MAX*(*neut).cell].density;
(gdb) s
getmicro_t (E=2, Emesh_d=0x7f3aa3ef2100, loc=1) at main2.cu:1155
1155 if (E<=E0_d[loc])
(gdb) n
1161 unsigned long i=binarySearch(Emesh_d,Emesh_offsets_d[loc],Emesh_offsets_d[loc]-1, E);
(gdb) p Emesh_offsets_d[loc]
$5 = 31839
(gdb) p Emesh_offsets_d[loc+1]-1
$6 = 32066
(gdb) s
binarySearch (sortedArray=0x7f3aa3ef2100, first=0, last=31838, key=2)
at main2.cu:1055
1055 unsigned long mid = (first + last) / 2; // compute mid point.
The code calling this function, and the function are below:
__constant__ unsigned long Emesh_offsets_d[NUCLIDE_MAX];
//the populating of Emesh_offsets_d:
unsigned long* offset_temp=NULL;
offset_temp=(unsigned long*)malloc(((*xs_data).listlength+1)*sizeof(unsigned long));
unsigned long sum=0;
for (int i=0; i<(*xs_data).listlength; i++)
{
offset_temp[i]=sum;
sum+=(*xs_data).cross_sec[i].mesh_length;
}
offset_temp[(*xs_data).listlength]=sum;
cudaMemcpyToSymbol(Emesh_offsets_d,offset_temp,((*xs_data).listlength+1)*sizeof(unsigned int),0,cudaMemcpyHostToDevice);
cudaThreadSynchronize();
function call:
unsigned long i=binarySearch(Emesh_d,Emesh_offsets_d[loc],Emesh_offsets_d[loc]-1, E);
__device__ unsigned long binarySearch(float* sortedArray, unsigned long first, unsigned long last, float key)
{
while (first <= last)
{
unsigned long mid = (first + last) / 2; // compute mid point.
if (key > sortedArray[mid])
first = mid + 1; // repeat search in top half.
else if (key < sortedArray[mid])
last = mid - 1; // repeat search in bottom half.
else
return mid; // found it. return position /////
}
return last+1; // failed to find key
}
EDIT: Also, when I’m stepping through the binarySearch func in gdb, get this, it doesn’t return to the function that called it, but skips ahead to one that calls it way later in the code! What is going on here? Voodoo???
Any help is amazingly appreciated, and if you’re in the DC area, I’ll buy you a beer