This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, driver] Ignore -ftree-parallelize-loops={0,1}


On 07/07/15 09:53, Tom de Vries wrote:
Hi,

currently, we have these spec strings in gcc/gcc.c involving
ftree-parallelize-loops:
...
%{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}

%{fopenacc|fopenmp|ftree-parallelize-loops=*:-pthread}"
...

Actually, ftree-parallelize-loops={0,1} means that no parallelization is
done, but these spec strings still get activated for these values.


Attached patch fixes that, by introducing a spec function gt (short for
greather than), and using it in the spec lines.


Attached (untested) patch manages the same, without introducing the spec function 'gt'. But the solution is a bit convoluted, so I prefer the one with the gt function.

Thanks,
- Tom

Ignore -ftree-parallelize-loops={0,1}

2015-07-13  Tom de Vries  <tom@codesourcery.com>

	* gcc.c (LINK_COMMAND_SPEC_GOMP_STRING, GOMP_SELF_SPEC_STRING): Define.
	(LINK_COMMAND_SPEC_GOMP_STRING, GOMP_SELF_SPECS): Ignore
	ftree-parallelize-loops={0,1}.
---
 gcc/gcc.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 858ff37..c5694c7 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -860,6 +860,8 @@ proper position among the other output files.  */
 #define CHKP_SPEC ""
 #endif
 
+#define LINK_COMMAND_SPEC_GOMP_STRING "%:include(libgomp.spec)%(link_gomp)"
+
 /* -u* was put back because both BSD and SysV seem to support it.  */
 /* %{static:} simply prevents an error message if the target machine
    doesn't handle -static.  */
@@ -881,7 +883,12 @@ proper position among the other output files.  */
     %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \
     %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
     " CHKP_SPEC " \
-    %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
+    %{!ftree-parallelize-loops=0:%{!ftree-parallelize-loops=1:\
+      %{fopenacc|fopenmp|ftree-parallelize-loops=*:" \
+	LINK_COMMAND_SPEC_GOMP_STRING "}}}\
+    %{ftree-parallelize-loops=0|ftree-parallelize-loops=1: \
+      %{fopenacc|fopenmp:" \
+	LINK_COMMAND_SPEC_GOMP_STRING "}} \
     %{fcilkplus:%:include(libcilkrts.spec)%(link_cilkrts)}\
     %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
     %(mflib) " STACK_SPLIT_SPEC "\
@@ -1039,11 +1046,18 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS;
 #define DRIVER_SELF_SPECS ""
 #endif
 
+#define GOMP_SELF_SPEC_STRING "-pthread"
+
 /* Linking to libgomp implies pthreads.  This is particularly important
    for targets that use different start files and suchlike.  */
 #ifndef GOMP_SELF_SPECS
-#define GOMP_SELF_SPECS "%{fopenacc|fopenmp|ftree-parallelize-loops=*: " \
-  "-pthread}"
+#define GOMP_SELF_SPECS \
+  "%{!ftree-parallelize-loops=0:%{!ftree-parallelize-loops=1:\
+     %{fopenacc|fopenmp|ftree-parallelize-loops=*: " \
+       GOMP_SELF_SPEC_STRING "}}}\
+   %{ftree-parallelize-loops=0|ftree-parallelize-loops=1:\
+     %{fopenacc|fopenmp: " \
+       GOMP_SELF_SPEC_STRING "}}"
 #endif
 
 /* Likewise for -fgnu-tm.  */
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]