bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_OPENMP broken for IBM xl Fortran compilers


From: Ralf Wildenhues
Subject: Re: AC_OPENMP broken for IBM xl Fortran compilers
Date: Sun, 20 Feb 2011 18:56:49 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

[ dropping autoconf@, adding bug-gnulib@ ]

* Christian Rössel wrote on Sun, Feb 20, 2011 at 11:06:40AM CET:
> Am 2/20/2011 7:55 AM, schrieb Ralf Wildenhues:
> > * Christian Rössel wrote on Fri, Feb 18, 2011 at 03:57:30PM CET:
> >> AC_OPENMP returns "none needed" for the IBM xl Fortran compilers (xlf*,
> >> bgxlf*, mpixlf*). This is wrong, you need to use -qsmp=omp.
> >>
> >> configure tries to compile following program:
[...]
> >> Compilation succeeds without specifying any OpenMP flag. If you modify
> >> the test program to
[...]
> >> the correct flags are detected.
> > 
> > Thanks for the bug report and patch.  I have one question (and I'd still
> > like to do some testing before pushing):  Isn't the '!' line a Fortran
> > 90 comment, and doesn't that have to be written differently for pure
> > Fortran 77?
> 
> you are right, a '!' is usually a comment in Fortran. But in the context
> of OpenMP and combined with the '$' it is interpreted as a conditional
> compilation sentinel, i.e. if no OpenMP flags are passed to the
> compiler, the line is interpreted as a comment, otherwise '!$' is
> replaced by two spaces and the line gets compiled. See 2.2.1 and 2.2.2
> in the OpenMP specification
> (http://www.openmp.org/mp-documents/spec30.pdf). The patch should work
> for Fortran 77 and 90.

Thanks for the explanation and the pointer.  I confirmed that even the
old OpenMP 1.0 specification requires this, so we're quite safe here.

I've pushed your patch, after adding Markus to THANKS, with the
ChangeLog entry as below, to git Autoconf.  The '(tiny change)'
annotations only denote that you haven't done copyright assignment
yet.

Bruno, OK to merge to gnulib as below, in Christian's name?

Thanks,
Ralf

2011-02-20  Christian Rössel  <...>  (tiny change)
            Markus Geimer  <...>  (tiny change)

        Fix OpenMP flag detection for various Fortran compilers.
        * lib/autoconf/c.m4 (_AC_LANG_OPENMP(Fortran 77)): Use '!$'
        OpenMP-conditional compilation construct, to force compile
        failure with missing OpenMP flag.
        (AC_OPENMP): Add flags for Cray CCE and NEC SX compilers.
        * THANKS: Update.



2011-02-20  Christian Rössel  <...>  (tiny change)
            Markus Geimer  <...>  (tiny change)

        Fix OpenMP flag detection for various Fortran compilers.
        * m4/openmp.m4 (_AC_LANG_OPENMP(Fortran 77)): Use '!$'
        OpenMP-conditional compilation construct, to force compile
        failure with missing OpenMP flag.
        (AC_OPENMP): Add flags for Cray CCE and NEC SX compilers.

diff --git a/m4/openmp.m4 b/m4/openmp.m4
index f2424df..cedfb4c 100644
--- a/m4/openmp.m4
+++ b/m4/openmp.m4
@@ -1,4 +1,4 @@
-# openmp.m4 serial 7
+# openmp.m4 serial 8
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,14 @@ m4_copy([_AC_LANG_OPENMP(C)], [_AC_LANG_OPENMP(C++)])
 # _AC_LANG_OPENMP(Fortran 77)
 # ---------------------------
 m4_define([_AC_LANG_OPENMP(Fortran 77)],
-[AC_LANG_FUNC_LINK_TRY([omp_get_num_threads])])
+[
+      program main
+      implicit none
+!$    integer tid
+      tid = 42
+      call omp_set_num_threads(2)
+      end
+])
 
 # _AC_LANG_OPENMP(Fortran)
 # ---------------------------
@@ -70,12 +77,14 @@ AC_DEFUN([AC_OPENMP],
           dnl   SGI C, PGI C         -mp
           dnl   Tru64 Compaq C       -omp
           dnl   IBM C (AIX, Linux)   -qsmp=omp
+          dnl   Cray CCE             -homp
+          dnl   NEC SX               -Popenmp
           dnl If in this loop a compiler is passed an option that it doesn't
           dnl understand or that it misinterprets, the AC_LINK_IFELSE test
           dnl will fail (since we know that it failed without the option),
           dnl therefore the loop will continue searching for an option, and
           dnl no output file called 'penmp' or 'mp' is created.
-          for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
+          for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp 
-Popenmp; do
             ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
             _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
             AC_LINK_IFELSE([_AC_LANG_OPENMP],



reply via email to

[Prev in Thread] Current Thread [Next in Thread]