Hello everyone!
I think there might be a bug when combining list iterators with foreach loops when OpenMP is enabled (Basilisk - Basilisk C).
I am attaching a MWE, which shows that if the list iterator loop is nested, the variable is not correctly copied, whereas if the foreach()
loop is nested it is correctly performs the nested loop. The purpose of the MWE is to update the values of the scalar holding the old values (oldVars
) with the new ones (curVars
).
I have also attached the outputs for both cases.
Compilation is done viaqcc test.c -fopenmp -lm
Thank you!
Dear Stephane,
Thanks for the prompt reply. Excluding serializing the entire loop, defining local scalars solves the discrepancy, i.e.event update(i< 2; i++)
{
foreach()
{
scalar curVar, oldVar; // Local scalars solve the problem
for (curVar, oldVar in lc, lo)
{
oldVar[] = curVar[];
}
}
fields_stats();
}
For some reason I was thinking curVar
and oldVar
were scalar fields, but after your comment I realized my mistake.
(Sorry if my reply took some time, I was trying to figure out what the other bug you mentioned was).
Thanks,
Yiannis
Hi Stephane,
I imagine you are referring to a code snippet of this type (?),
event update(i< 2; i++)
{
double x;
foreach()
{
x = sq(f[]);
f[] = x;
}
fields_stats();
}
I just successfully compiled this. I have the latest basilisk/qcc version.
So, should I add this to the report, as well?
Thanks,
Yiannis