[gomp4] Offload option handling

Andrey Turetskiy andrey.turetskiy@gmail.com
Wed Sep 17 11:17:00 GMT 2014


Hi,
This patch (attached) contains the prototype of mechanism for passing
options to offload target compiler.
If one need to pass additional options for target compiler, one may
add option ‘–ftarget-options=<target name>=<target options>’ to host
compiler (target name can be skipped, that will append specified
options for every target).

Options preparing takes place in lto-wrapper in several stages:
1. Read (host) options from .gnu.target_lto_.opts section for every
object file and merge them as during lto
2. Remove CL_TARGET, CL_DRIVER and CL_LTO options
3. For every offload target: search for option ‘–ftarget-options’ with
argument corresponding to target triple, parse it and merge with
remained host options

Here is an example of option merging:
./install/bin/gcc -fopenmp -c a.c -O0 -mno-sse -ftarget-options=="-O2 -msse"
./install/bin/gcc -fopenmp -c b.c -O0 -fpack-struct
-ftarget-options=="-O3 -mavx"
./install/bin/gcc -fopenmp a.o b.o
After merging at stage 3 we get: -O3 -fpack-struct
-ftarget-options==”-O2 –msse” -ftarget-options==”-O3 –mavx” –msse
–mavx
These options are passed to mkoffload and thus to target compiler.
-ftarget-options==”…” itself is ignored by target compiler.

However there is an issue: options specified by -ftarget-options  are
not checked for correctness as usual, so incorrect options inside
-ftarget-options==”…”  may lead to GCC crashes. Need to investigate
possibilities of reusing existing option checks to solve the problem.

How does this look? Do you agree with the approach?

On Mon, Sep 15, 2014 at 8:22 PM, Ilya Verbin <iverbin@gmail.com> wrote:
> On 23 Jul 14:51, Bernd Schmidt wrote:
>> Ping.
>>   https://gcc.gnu.org/ml/gcc-patches/2014-06/msg00616.html
>>
>> On 06/06/2014 05:07 PM, Bernd Schmidt wrote:
>> >There's a problem when offloading from a compiler for one target machine
>> >to another: the machine specific options don't necessarily match. This
>> >patch tries to address this.
>> >
>> >The idea is that since we have two options sections anyway, with
>> >different section name prefixes, we can arrange to pass only
>> >target-independent options in the omp_ version of the options section.
>> >However, some target-specific options (specifically the ones specifying
>> >the ABI) need to be preserved somehow, so there's a new target hook for
>> >translating them to common a -foffload-* syntax.
>> >
>> >How does this look? Comments on the approach, and ok for the
>> >gomp-4_0-branch?
>
> How about passing target-specific options from the command-line?  Will it be
> possible with this approach?
>
> We had a patch, that parses options from -foffload-target=<target>=<options> and
> stores them to the environment variable.  Now it is obsolete, but I like the
> idea of having such a user-adjustable options for the accel compilers.
>
> https://gcc.gnu.org/ml/gcc-patches/2013-12/msg01242.html
>
>   -- Ilya

-- 
Best regards,
Andrey Turetskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: offload-option-gomp4.patch
Type: application/octet-stream
Size: 13225 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140917/338d533c/attachment.obj>


More information about the Gcc-patches mailing list