The wrong result when calculating using multiple threads

The gas gain was calculated by single thread and multiple threads.
The mean gain by 1000 events from single thread is 315,
but, the mean gain is 23 from multiple threads.

the key codes are:

 #pragma omp parallel for
for(int event=0;event<EventNumber;event++)
{
  AvalancheMicroscopic aval(&sensor);
  
  aval.AvalancheElectron(x0, y0, z0, t0, e0);
 
  ElectronNumber[event]=aval.GetNumberOfElectronEndpoints();
}
for(int i=0;i<EventNumber;i++)
{
  TotalElectronNumber+=ElectronNumber[i];
}

what is the wrong thing with the codes?

Hi,

Have you checked for the absence of data races, for example with helgrind?

Best,
D

@Danilo , no, i will try!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.