[Halld-offline] Multi-threading in ANALYSIS
David Lawrence
davidl at jlab.org
Thu Mar 7 08:52:03 EST 2013
Hi Paul,
I just wanted to drop you a note explaining a change I just
committed to your ANALYSIS library. This fixes a problem
Simon noticed in not getting the same results when multiple
threads are used as when 1 thread is used.
The problem is due to a bug you exposed in JANA where it
does not handle NaN values in configuration parameters
properly. The first thread to call SetDefaultParameter with
a NaN value will have it's value unaltered. Subsequent threads
will get the value after it has undergone a conversion to and
from a string. This works fine, except NaN values come back
as "0" after the conversion. Since you basically test for the
value not being NaN, the "0" value passes this test and sets
flag to true for all but the first thread. I fixed it by substituting
code like this:
locParamValue = numeric_limits<double>::quiet_NaN();
gPARMS->SetDefaultParameter("COMBO:MAXPHOTONRFDELTAT", locParamValue);
if((locParamValue > -1.0) || (locParamValue < 1.0))
{
//not NaN: user set the value on the command line
dMaxPhotonRFDeltaT.first = true;
dMaxPhotonRFDeltaT.second = locParamValue;
}
for this:
try{
gPARMS->GetParameter("COMBO:MAXPHOTONRFDELTAT",
dMaxPhotonRFDeltaT.second);
dMaxPhotonRFDeltaT.first = true;
}catch(...){}
The GetParameter method will throw an exception if the parameter
doesn't exist, bypassing the call to set the corresponding flag to "true".
This seems to work now with multiple threads giving identical histograms.
Update to the latest version of the trunk to get the change.
This did expose a bug in JANA where the first call to SetDefaultParameter
is not doing the conversion to/from a string so its value can be different
from that in subsequent threads (mainly at the level of round-off errors,
but a difference nonetheless). I'll fix this for the next release.
Regards,
-David
More information about the Halld-offline
mailing list