Message ID | 5454CAB9.3040907@codesourcery.com |
---|---|
State | New |
Headers | show |
On 11/01/14 05:57, Bernd Schmidt wrote: > This is not against current trunk; it applies to gomp-4_0-branch where > it is one of the necessary parts to make offloading x86->nvptx work. The > issue is that the LTO file format depends on the machine_modes enum, it > needs to match between host and offload target. The easiest way to do > this is to just use the host-modes.def when compiling an offload compiler. > > Ports that want to be hosts for offloading may need to modify their > modes.def. The patch below contains changes to i386-modes.def which > modifies XFmode depending on a target switch. I'm not actually entirely > sure what to do about this. Do we want to make this flag an error when > offloading is enabled? Or maybe add float format support to the > -foffload-abi option? > > Thoughts? Ok for the first part of the patch once the other offloading > patches have gone in (bootstrapped and tested on x86_64-linux)? It feels like we've got another real distinction to make. We've had host, build & target and they're all independent. It feels like we need offload target and better separate between target and offload target. Then we need to figure out the places where we've got bleed-out. Not sure how to deal with this any further out than the immediate term than using a hack like this. Though I'd prefer to avoid the #ifdef as it seems to me this shouldn't be baked in at build/configure time. jeff
On Sat, Nov 01, 2014 at 12:57:45PM +0100, Bernd Schmidt wrote: > This is not against current trunk; it applies to gomp-4_0-branch where it is > one of the necessary parts to make offloading x86->nvptx work. The issue is > that the LTO file format depends on the machine_modes enum, it needs to > match between host and offload target. The easiest way to do this is to just > use the host-modes.def when compiling an offload compiler. > > Ports that want to be hosts for offloading may need to modify their > modes.def. The patch below contains changes to i386-modes.def which modifies > XFmode depending on a target switch. I'm not actually entirely sure what to > do about this. Do we want to make this flag an error when offloading is > enabled? Or maybe add float format support to the -foffload-abi option? > > Thoughts? Ok for the first part of the patch once the other offloading > patches have gone in (bootstrapped and tested on x86_64-linux)? I don't like this at all. IMHO instead we should stream in the offloading LTO sections some kind of mode description table (perhaps limited to the modes actually ever streamed), and when reading back the offloading LTO sections, let the offloading compiler remap the modes to its own modes where there is a mapping in between the two, choose some other mapping (e.g. map various vector modes the host has but offloading target does not to say BLKmode), or give up otherwise with offloading (say if you attempt to stream floating point modes the offloading target doesn't support etc.). So perhaps stream for each used mode the mode value, corresponding mode class, size, precision, inner mode, nunits, and for floating point modes supposedly somehow encode the real_format (perhaps just add a name <-> struct real_format mapping for the real.c modes, and map anything else to "unknown"). Jakub
On Wed, Feb 4, 2015 at 12:38 PM, Jakub Jelinek <jakub@redhat.com> wrote: > On Sat, Nov 01, 2014 at 12:57:45PM +0100, Bernd Schmidt wrote: >> This is not against current trunk; it applies to gomp-4_0-branch where it is >> one of the necessary parts to make offloading x86->nvptx work. The issue is >> that the LTO file format depends on the machine_modes enum, it needs to >> match between host and offload target. The easiest way to do this is to just >> use the host-modes.def when compiling an offload compiler. >> >> Ports that want to be hosts for offloading may need to modify their >> modes.def. The patch below contains changes to i386-modes.def which modifies >> XFmode depending on a target switch. I'm not actually entirely sure what to >> do about this. Do we want to make this flag an error when offloading is >> enabled? Or maybe add float format support to the -foffload-abi option? >> >> Thoughts? Ok for the first part of the patch once the other offloading >> patches have gone in (bootstrapped and tested on x86_64-linux)? > > I don't like this at all. > > IMHO instead we should stream in the offloading LTO sections some kind of mode > description table (perhaps limited to the modes actually ever streamed), > and when reading back the offloading LTO sections, let the offloading > compiler remap the modes to its own modes where there is a mapping in > between the two, choose some other mapping (e.g. map various vector modes > the host has but offloading target does not to say BLKmode), or give up > otherwise with offloading (say if you attempt to stream floating point modes > the offloading target doesn't support etc.). > > So perhaps stream for each used mode the mode value, corresponding mode > class, size, precision, inner mode, nunits, and for floating point modes > supposedly somehow encode the real_format (perhaps just add a name <-> > struct real_format mapping for the real.c modes, and map anything else > to "unknown"). I think (also communicated that on IRC) we should instead try not streaming machine-modes at all but generating them at stream-in time via layout_type or layout_decl. Richard. > Jakub
* config.gcc (offload_host_cpu_type): Compute. (extra_modes): Use it to pick the offload host CPU's modes.def when building an offload target. * config/i386/i386-modes.def (XF): Skip adjustments when building an offload compiler. Index: gomp-4_0-branch/gcc/config.gcc =================================================================== --- gomp-4_0-branch.orig/gcc/config.gcc +++ gomp-4_0-branch/gcc/config.gcc @@ -483,15 +483,26 @@ tilepro*-*-*) ;; esac +offload_host_cpu_type=${cpu_type} +if test "x${enable_as_accelerator}" != "xno" +then + offload_host_cpu_type=`echo ${enable_as_accelerator_for} | sed 's/-.*$//'` +fi +case ${offload_host_cpu_type} in +x86_64) + offload_host_cpu_type=i386 + ;; +esac + tm_file=${cpu_type}/${cpu_type}.h if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-protos.h then tm_p_file=${cpu_type}/${cpu_type}-protos.h fi extra_modes= -if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-modes.def +if test -f ${srcdir}/config/${offload_host_cpu_type}/${offload_host_cpu_type}-modes.def then - extra_modes=${cpu_type}/${cpu_type}-modes.def + extra_modes=${offload_host_cpu_type}/${offload_host_cpu_type}-modes.def fi if test -f ${srcdir}/config/${cpu_type}/${cpu_type}.opt then Index: gomp-4_0-branch/gcc/config/i386/i386-modes.def =================================================================== --- gomp-4_0-branch.orig/gcc/config/i386/i386-modes.def +++ gomp-4_0-branch/gcc/config/i386/i386-modes.def @@ -24,6 +24,9 @@ along with GCC; see the file COPYING3. FRACTIONAL_FLOAT_MODE (XF, 80, 12, ieee_extended_intel_96_format); FLOAT_MODE (TF, 16, ieee_quad_format); +/* This file may be used when building a compiler for an offload target. + Assume that no special floating point options are used. */ +#ifndef ACCEL_COMPILER /* In ILP32 mode, XFmode has size 12 and alignment 4. In LP64 mode, XFmode has size and alignment 16. */ ADJUST_FLOAT_FORMAT (XF, (TARGET_128BIT_LONG_DOUBLE @@ -33,6 +36,7 @@ ADJUST_FLOAT_FORMAT (XF, (TARGET_128BIT_ : &ieee_extended_intel_96_format)); ADJUST_BYTESIZE (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 12); ADJUST_ALIGNMENT (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 4); +#endif /* Add any extra modes needed to represent the condition code.