Strange results

Hello again…

I have setup two kernels and, depending on the options on the host, one of them will be executed. The problem is that if I run one kernel, and then I run again the application and choose to execute the other one, the results I get (for the first time the different kernel runs) are similar to the results of the first one. So, I have to run a kernel 2 times to get the “real” results… Could it be any problem related to initialization of variables inside the kernel, or something related to buffers I could be missing, or something related to flushing?

Thanks a lot

Still haven’t figured this out… can anyone give ideas of what may be happening? Code’s following, if it helps:

(Array “count” is the only local one)


// Some arrays initialization
count[localID] = 0;

if(idx==0)
        covered_points[idy]=0;


// Make some calculations here, and count[i] has 0 or 1


if(localID == 0)
{
	for(i=0; i<N; i++)
	{	
		if(count[i]==1)
		aux ++; 		
	}
	
	i = get_group_id(0);
	cvs[i] = aux;		
}


if(idx==0)
{       
	for(i=idy*1681;i<idy*1681+1681;i++) 
        {		
		covered_points[idy] += cvs[i];
	}
		
	c = (100.0*covered_points[idy])/(GRID_SIZE);
	fi = (c*c)/N;	
}

if(globaID==0)
	*f=fi;

I’ve try to setup several barriers/mem fences, but with no success.

I can’t really tell what’s going on here since I don’t know where localID or idx come from, but I’d suspect you have a bunch of data races. You have some loops that are walking over aux and setting cvs, but I suspect other work-items could be modifying them at the same time. If that’s the case your results will depend on the order in which the work-items are executed.