[Bug other/78808] target_clones not applying to openmp functions

steven at uplinklabs dot net gcc-bugzilla@gcc.gnu.org
Tue Oct 17 04:28:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78808

--- Comment #9 from Steven Noonan <steven at uplinklabs dot net> ---
Actually, I lied. It's not quite working. It's obviously close though.

The following examples of the issue are using my n-body implementation:

https://github.com/tycho/nbody

Each of the variants of n-body have a bunch of link issues:

$ make CFOPTIMIZE="-O3 -march=core2"
[...]
nbody_CPU_SOA.o: In function `_ComputeGravitation_SOA.default.8':
nbody_CPU_SOA.c:(.text+0x1e): undefined reference to
`_ComputeGravitation_SOA._omp_fn.0._GLOBAL___ComputeGravitation_SOA.ifunc'
nbody_CPU_SOA.o: In function `_ComputeGravitation_SOA.arch_skylake.4':
nbody_CPU_SOA.c:(.text+0x59b): undefined reference to
`_ComputeGravitation_SOA._omp_fn.0._GLOBAL___ComputeGravitation_SOA.ifunc'
nbody_CPU_SOA.o: In function `_ComputeGravitation_SOA.arch_haswell.5':
nbody_CPU_SOA.c:(.text+0x63b): undefined reference to
`_ComputeGravitation_SOA._omp_fn.0._GLOBAL___ComputeGravitation_SOA.ifunc'
nbody_CPU_SOA.o: In function `_ComputeGravitation_SOA.arch_sandybridge.6':
nbody_CPU_SOA.c:(.text+0x6db): undefined reference to
`_ComputeGravitation_SOA._omp_fn.0._GLOBAL___ComputeGravitation_SOA.ifunc'
[...]

Symbols in nbody_CPU_SOA.o:

$ nm src/nbody_CPU_SOA.o 
00000000000000a0 t bodyBodyInteraction
0000000000000c00 T ComputeGravitation_SOA
0000000000000610 t _ComputeGravitation_SOA.arch_haswell.5
00000000000006b0 t _ComputeGravitation_SOA.arch_sandybridge.6
0000000000000570 t _ComputeGravitation_SOA.arch_skylake.4
0000000000000000 t _ComputeGravitation_SOA.default.8
0000000000000bb0 i
_ComputeGravitation_SOA._GLOBAL___ComputeGravitation_SOA.ifunc
0000000000000290 t _ComputeGravitation_SOA._omp_fn.0.arch_haswell.2
0000000000000400 t _ComputeGravitation_SOA._omp_fn.0.arch_sandybridge.3
0000000000000120 t _ComputeGravitation_SOA._omp_fn.0.arch_skylake.1
0000000000000750 t _ComputeGravitation_SOA._omp_fn.0.default.7
                 U
_ComputeGravitation_SOA._omp_fn.0._GLOBAL___ComputeGravitation_SOA.ifunc
0000000000000b60 t _ComputeGravitation_SOA._omp_fn.0.resolver
0000000000000bb0 t _ComputeGravitation_SOA.resolver
                 U __cpu_indicator_init
                 U __cpu_model
                 U GOMP_loop_end_nowait
                 U GOMP_loop_ull_guided_next
                 U GOMP_loop_ull_guided_start
                 U GOMP_parallel
0000000000000000 r .LC0
0000000000000004 r .LC1
0000000000000008 r .LC2
0000000000000000 r .LC4
0000000000000010 r .LC5
                 U libtime_cpu_to_wall


There's a second issue as well. If I tell it to build with -march=native, I get
compile errors:

$ make CFOPTIMIZE="-O3 -march=native" V=1
make -C libc11 libc11.a
make -C libtime libtime.a
make -C src nbody
gcc -O3 -march=native -std=gnu11 -fno-strict-aliasing -D_GNU_SOURCE
-DLIBTIME_STATIC -DUSE_OPENMP -DHAVE_SIMD -DNO_CUDA -DUSE_LIBC11
-I../libc11/include -I../libtime/include -Wall -Wdeclaration-after-statement
-Werror=implicit -Werror=undef -Wmissing-declarations -Wmissing-prototypes
-Wno-declaration-after-statement -Wno-long-long -Wno-overlength-strings
-Wno-unknown-pragmas -Wold-style-definition -Wstrict-prototypes -pthread
-fopenmp -MMD -c -o nbody_CPU_AOS.o nbody_CPU_AOS.c
gcc -O3 -march=native -std=gnu11 -fno-strict-aliasing -D_GNU_SOURCE
-DLIBTIME_STATIC -DUSE_OPENMP -DHAVE_SIMD -DNO_CUDA -DUSE_LIBC11
-I../libc11/include -I../libtime/include -Wall -Wdeclaration-after-statement
-Werror=implicit -Werror=undef -Wmissing-declarations -Wmissing-prototypes
-Wno-declaration-after-statement -Wno-long-long -Wno-overlength-strings
-Wno-unknown-pragmas -Wold-style-definition -Wstrict-prototypes -pthread
-fopenmp -MMD -c -o nbody_CPU_AOS_tiled.o nbody_CPU_AOS_tiled.c
gcc -O3 -march=native -std=gnu11 -fno-strict-aliasing -D_GNU_SOURCE
-DLIBTIME_STATIC -DUSE_OPENMP -DHAVE_SIMD -DNO_CUDA -DUSE_LIBC11
-I../libc11/include -I../libtime/include -Wall -Wdeclaration-after-statement
-Werror=implicit -Werror=undef -Wmissing-declarations -Wmissing-prototypes
-Wno-declaration-after-statement -Wno-long-long -Wno-overlength-strings
-Wno-unknown-pragmas -Wold-style-definition -Wstrict-prototypes -pthread
-fopenmp -MMD -c -o nbody_CPU_SOA.o nbody_CPU_SOA.c
gcc -O3 -march=native -std=gnu11 -fno-strict-aliasing -D_GNU_SOURCE
-DLIBTIME_STATIC -DUSE_OPENMP -DHAVE_SIMD -DNO_CUDA -DUSE_LIBC11
-I../libc11/include -I../libtime/include -Wall -Wdeclaration-after-statement
-Werror=implicit -Werror=undef -Wmissing-declarations -Wmissing-prototypes
-Wno-declaration-after-statement -Wno-long-long -Wno-overlength-strings
-Wno-unknown-pragmas -Wold-style-definition -Wstrict-prototypes -pthread
-fopenmp -MMD -c -o nbody_CPU_SOA_tiled.o nbody_CPU_SOA_tiled.c
In file included from nbody_CPU_AOS.c:42:0:
nbody_CPU_AOS.c: In function ‘_ComputeGravitation_AOS.arch_skylake.4’:
nbody_util.h:114:21: error: SSE register return with SSE disabled
  static DECLARE_AOS(_ ## Name)
                     ^
nbody_util.h:96:2: note: in definition of macro ‘DECLARE_AOS’
  Name( \
  ^~~~
nbody_CPU_AOS.c:47:1: note: in expansion of macro ‘DEFINE_AOS’
 DEFINE_AOS(ComputeGravitation_AOS)
 ^~~~~~~~~~
make[2]: *** [GNUmakefile:214: nbody_CPU_AOS.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from nbody_CPU_AOS_tiled.c:42:0:
nbody_CPU_AOS_tiled.c: In function
‘_ComputeGravitation_AOS_tiled.arch_skylake.4’:
nbody_util.h:114:21: error: SSE register return with SSE disabled
  static DECLARE_AOS(_ ## Name)
                     ^
nbody_util.h:96:2: note: in definition of macro ‘DECLARE_AOS’
  Name( \
  ^~~~
nbody_CPU_AOS_tiled.c:49:1: note: in expansion of macro ‘DEFINE_AOS’
 DEFINE_AOS(ComputeGravitation_AOS_tiled)
 ^~~~~~~~~~
make[2]: *** [GNUmakefile:214: nbody_CPU_AOS_tiled.o] Error 1
In file included from nbody_CPU_SOA.c:44:0:
nbody_CPU_SOA.c: In function ‘_ComputeGravitation_SOA.arch_skylake.4’:
nbody_util.h:107:21: error: SSE register return with SSE disabled
  static DECLARE_SOA(_ ## Name)
                     ^
nbody_util.h:87:2: note: in definition of macro ‘DECLARE_SOA’
  Name( \
  ^~~~
nbody_CPU_SOA.c:49:1: note: in expansion of macro ‘DEFINE_SOA’
 DEFINE_SOA(ComputeGravitation_SOA)
 ^~~~~~~~~~
make[2]: *** [GNUmakefile:214: nbody_CPU_SOA.o] Error 1
In file included from nbody_CPU_SOA_tiled.c:42:0:
nbody_CPU_SOA_tiled.c: In function
‘_ComputeGravitation_SOA_tiled.arch_skylake.4’:
nbody_util.h:107:21: error: SSE register return with SSE disabled
  static DECLARE_SOA(_ ## Name)
                     ^
nbody_util.h:87:2: note: in definition of macro ‘DECLARE_SOA’
  Name( \
  ^~~~
nbody_CPU_SOA_tiled.c:49:1: note: in expansion of macro ‘DEFINE_SOA’
 DEFINE_SOA(ComputeGravitation_SOA_tiled)
 ^~~~~~~~~~
make[2]: *** [GNUmakefile:214: nbody_CPU_SOA_tiled.o] Error 1
make[1]: *** [GNUmakefile:50: src/nbody] Error 2
make: *** [GNUmakefile:28: top-level-make] Error 2

This is on a Broadwell host, so I can't imagine why it concluded SSE is
disabled.


More information about the Gcc-bugs mailing list