Andrey Turetskiy
2014-09-17 11:16:52 UTC
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?
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
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?
Ping.
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg00616.html
How about passing target-specific options from the command-line? Will it behttps://gcc.gnu.org/ml/gcc-patches/2014-06/msg00616.html
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?
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?
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
Best regards,
Andrey Turetskiy