[PATCH, PR82428] Add __builtin_goacc_{gang,worker,vector}_{id,size}

Tom de Vries Tom_deVries@mentor.com
Sat Jan 6 08:22:00 GMT 2018


Hi,

this patch adds the following builtins in C/C++:
- __builtin_goacc_gang_id
- __builtin_goacc_worker_id
- __builtin_goacc_vector_id
- __builtin_goacc_gang_size
- __builtin_goacc_worker_size
- __builtin_goacc_vector_size


We have openacc C/C++ test-cases using the following nvptx idiom:
...
       __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
       __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
       __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
...

Typically these asm insns are guarded with acc_on_device 
(acc_device_nvidia), and skipping -O0:
...
/* This code uses nvptx inline assembly guarded with acc_on_device,
    which is not optimized away at -O0, and then confuses the target
    assembler.
    { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
...

This patch replaces those asm statements with the corresponding new 
builtins, allowing the test-cases to work for all offloading targets, 
not just nvptx, and also at O0. [ Note that the proposed fix for PR82391 
at https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01529.html also 
addresses the O0 problem. ]

Bootstrapped and reg-tested on x86_64.
Build and reg-tested on x86_64 with nvptx accelerator.

OK for trunk?

Thanks,
- Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-__builtin_goacc_-gang-worker-vector-_-id-size.patch
Type: text/x-patch
Size: 41558 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180106/41a58f77/attachment.bin>


More information about the Gcc-patches mailing list