On 12/01/15 12:42:48, Richard Biener wrote:
> On Mon, 30 Nov 2015, Gary Funck wrote:
> [...]
> > +  get_lc_mode_name (mname, (op_mode));
> > +  sprintf (libfunc_name, "__get%s%s%s%s",
> > +           strict_mode ? "s" : "",
> > +           doprofcall ? "g" : "",
> > +      mname,
> > +      (op_mode == BLKmode)
> > +        ? (doprofcall ? "5" : "3")
> > +        : (doprofcall ? "3" : "2"));
> > +  libfunc = identifier_global_value (get_identifier (libfunc_name));
> > +  if (!libfunc)
> > +    internal_error ("UPC runtime function %s not found", libfunc_name);
> 
> I think for all these you should use builtins.  You definitely shouldn't
> ICE here if it is an error to not include upc.h (or whatever is required
> to make above lookup succeed).

For UPC, although a reference via a pointer-to-shared will often
access data on another node, fairly often the reference will be
on node or will be local to the current process.  It is a worthwhile
optimization to inline the runtime call because the number of instructions
to test if a reference is on-node or local and to then load/store
directly to that location is small/short relative to the overhead of
making the call.  On some micro-benchmarks, inlining is 30% faster
for get/put accesses.

Inlining is implemented with a pre-include of "gcc-upc.h", which
in turn includes "gcc-upc-lib.h", which defines the API to
the libgupc runtime library.  At optimization levels greater than 0,
gcc-upc-lib.h will implement many UPC runtime procedures as
inline procedures.  This inlining can be disabled with -fupc-no-inline-lib.
The pre-include can be disabled with -fupc-no-pre-include, but
this is typically only done by certain tests.  The pre-include
will be enabled by default if -fupc is asserted.

Thus,

- We need to bring in the inlined runtime procedures via
  the pre-include.

- If we're compiling UPC, then the runtime header file
  will be pre-included, unless explicitly disabled via
  -fupc-no-pre-include (which is ill-advised for regular users).

It is effectively an internal error, if we can't find
the runtime procedures.

Regarding builtins, if we were to contemplate generating
code that makes this locality check and then issuing
a direct access for local/on-node accesses, it would
likely be impractical because different runtime libraries
will implement this locality check and local reference
differently.

- Gary

Reply via email to