Hi gys…
I am trying to remove the atomicMin instruction from the following code. I replaced it with gpuMin function but it always gives me segmentation fault error. Are the threads being deadlocked in any way?
__device__ bool flag = true;
inline __device__ void gpuMin( int *temp, int newLabel)
{
while( flag !=true){}
flag = false;
*temp = min( *temp, newLabel);
flag = true;
}
inline __device__ void union(int* buf, unsigned char *buf_uchar, unsigned char seg1, unsigned char seg2, int reg1, int reg2, int* changed)
{
if(seg1 == seg2)
{
int newReg1 = findRoot(buf, reg1);
int newReg2 = findRoot(buf, reg2);
if(newReg1 > newReg2) {
//atomicMin(buf+newReg1, newReg2);
gpuMin(buf+newReg1,newReg2);
buf_uchar[newReg1] = min( buf_uchar[newReg1], newReg2);
changed[0] = 1;
} else if(newReg2 > newReg1) {
//atomicMin(buf+newReg2, newReg1);
gpuMin(buf+newReg2,newReg2);
buf_uchar[newReg2] = min( buf_uchar[newReg2], newReg2);
changed[0] = 1;
}
}
}
If there is anything wrong with my approach please point it out. Also what will be thee best way to remove atomicMin function…
Thanks…