[gomp4] Expand OpenACC thread builtins inline

Julian Brown julian@codesourcery.com
Thu May 28 11:51:00 GMT 2015


For partitioned loops, we're currently calling library functions (in
libgcc) to determine the cardinality of the set of threads a particular
loop is distributed over (given a set of gang/worker/vector toggles),
and the index of the current thread within that set.

This patch reimplements those two functions in terms of the
(PTX-specific!) builtins that Bernd has recently added in order to
implement vector-single/worker-single predication, which expand
directly to machine instructions on the target (or to constant zero/one
on the host). It also makes use of the same "gwv" bitfields that are set
up by that new code.

The previous BUILT_IN_GOACC_GET_THREAD_NUM and
BUILT_IN_GOACC_GET_NUM_THREADS builtins are removed entirely.

This works reasonably well, but there are some regressions caused by
middle-end optimisers having extra freedom to manipulate the CFG in
ways that PTX cannot support without the "optimisation barrier" of the
calls to the thread builtins being present. This will be addressed by a
follow-on patch.

Pre-approved for gomp4, but I'll wait for comments on the follow-on
patch before applying so as not to leave the branch in a "broken" state.

Thanks,

Julian

ChangeLog

    gcc/
    * builtins.c (expand_oacc_builtin): Return const1_rtx for
    ntid/nctaid builtins when the associated patterns are not present.
    * omp-builtins.def (BUILT_IN_GOACC_GET_THREAD_NUM)
    (BUILT_IN_GOACC_GET_NUM_THREADS): Remove.
    * omp-low.c (struct omp_for_data): Remove gang, worker, vector
    fields.
    (extract_omp_for_data): Don't initialise deleted gang, worker,
    vector fields.
    (expand_oacc_get_num_threads, expand_oacc_get_thread_num): New
    functions.
    (lower_reduction_clauses): Use above functions.
    (expand_omp_for_static_nochunk): Likewise.
    (expand_omp_for_static_chunk): Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oacc-thread-builtins-3.diff
Type: text/x-patch
Size: 11718 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/97b5a549/attachment.bin>


More information about the Gcc-patches mailing list