[gomp4] Offload option handling
Wed Sep 17 11:17:00 GMT 2014
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
./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
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 <firstname.lastname@example.org> wrote:
> On 23 Jul 14:51, Bernd Schmidt wrote:
>> 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
> 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.
> -- Ilya
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 13225 bytes
Desc: not available
More information about the Gcc-patches