Hi Michael, Brad - If I am calling C routines, it seems like this pragma is necessary all the time. (BTW, thanks for the reference. I assume you mean the stuff on Page 27. Nice presentation by the way. Looks like GPU stuff is moving ahead in leaps and bounds - nice work)
As an example, consider the computation of the complex projection (of a point in the complex plane onto the surface of a Riemann Sphere) as an attribute of a variable. If I write this naively, it could be:
inline proc (complex(?w)).proj : real(w / 2)
{
extern proc cprojf(z: complex(64)): real(32);
extern proc cproj(z: complex(128)): real(64);
return if w == 64 then cprojf(this) else cproj(this);
}
Referring to the routine cproj() in Math.chpl that does the same function, both those C routines are prefixed by
pragma "fn synchronization free"
It seems that I need to put this in front of every simple C routine that I use to tell the Chapel compiler that it is not doing task synchronization. Or am I incorrect?
For completeness, but totally aside from the pragma issue ....,
I could avoid C altogether and use current features of Chapel to write (although I have not debugged this)
inline proc (complex(?w)).proj
{
const z = this;
const re = z.re, im = z.im;
type R = re.type, C = z.type;
param inf = INFINITY:R, zero = 0:R;
return if abs(re) == inf || abs(im) == inf then
(inf, if im < zero then +zero else -zero):C
else
z;
}
In practice, that has IEEE 754 exception issues so I might even use my own ieee754 module which resolves them and avoids that cast seen above.