I patched OpenMPI 1.4.2 to fix some problems/warnings when using the PGI compilers.

• openmpi-1.4.2/configure has the libtool patch to correctly parse PGI compiler versions 1 through 5, but the libtool.m4 files do not. I don't know if they are actually used -- I looked for this error before I tried compiling. The fixes to the libtool.m4 files are:

# Fixes to correctly identify PGI compiler versions 1 through 5
mv openmpi-1.4.2/config/libtool.m4{,.original}
sed -e '5899s/\[\[1-5\]\]\*/\[\[1-5\]\].\*/g' \
    openmpi-1.4.2/config/libtool.m4.original \
    >openmpi-1.4.2/config/libtool.m4
mv openmpi-1.4.2/opal/libltdl/m4/libtool.m4{,.original}
sed -e '5899s/\[\[1-5\]\]\*/\[\[1-5\]\].\*/g' \
    openmpi-1.4.2/opal/libltdl/m4/libtool.m4.original \
    >openmpi-1.4.2/opal/libltdl/m4/libtool.m4

• Inline assembly of the atomic operators is explicitly disabled for PGI C in openmpi-1.4.2/configure, but not for PGI C++. I applied the same fix in openmpi-1.4.2/configure for PGI C++. • openmpi-1.4.2/configure tests whether the C and C++ compilers accept #pragma ident. However, PGI C does not perform macro substitution in #pragma ident, which OpenMPI relies on. The fix is to use a more complete test of the #pragma ident feature in openmpi-1.4.2/ configure. The fixes to openmpi-1.4.2/configure are:

# Disable inline assembly for PGI C++, as is done for PGI C (34579), and
# Fix PGI C compiler warning (10393, 26106): Pragma ignored – string
# expected after #pragma ident
mv openmpi-1.4.2/configure{,.original}
sed -e '34579{x;s/^.*$/ if test "$ompi_cv_cxx_compiler_vendor" = "portland group" ; then/;p; s/^.*$/ # PGI seems to have some issues with our inline assembly./;p;
                s/^.*$/        # Disable for now./;p;
                s/^.*$/        asm_result="no (Portland Group)"/;p;
                s/^.*$/    else/;G;}' \
    -e '34702{x;s/^.*$/    fi/;G;}' \
    -e '10393{s/#pragma ident/#define IDENT/;p;
              s/^.*$/#pragma ident \$IDENT/;}' \
    -e '26106{s/#pragma ident/#define IDENT/;p;
              s/^.*$/#pragma ident \$IDENT/;}' \
    openmpi-1.4.2/configure.original \
    >openmpi-1.4.2/configure
chmod +x openmpi-1.4.2/configure

• PGI C issues spurious warnings when an array name is used as the first operand in a conditional expression. This occurs in the definition of the LT_STRLEN() macro in openmpi-1.4.2/opal/libltdl/ ltdl.h: #define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0). Even though I think the PGI compiler is complaining too much, I also find C's use of 0 to mean zero, false, and nil poor programming practice. I changed the guard expression in the definition of LT_STRLEN to simply (s!=NULL), which also eliminated the short-circuit test (s) [0]. The extra test is not required for strlen() to succeed, and only makes sense if zero-length strings are a common occurrence worth hand- optimizing. The fix to openmpi-1.4.2/opal/libltdl/ltdl.h is:

# Fix PGI compiler warning: Array name used in logical expression
mv openmpi-1.4.2/opal/libltdl/ltdl.h{,.original}
sed -e '44s/((s) && (s)\[0\])/(s!=NULL)/' \
    openmpi-1.4.2/opal/libltdl/ltdl.h.original \
    >openmpi-1.4.2/opal/libltdl/ltdl.h

• PGI C issues spurious warnings when 0 is one of the operands in a conditional expression of pointer type. Even though I think the PGI compiler is again complaining too much, I replaced such occurrences of 0 with NULL, which is my preferred programming practice. The fixes to the hooks.c and malloc.c files in openmpi-1.4.2/opal/mca/memory/ ptmalloc2 are:

# Fix PGI compiler warning: Pointer value created from a nonlong integral type
mv openmpi-1.4.2/opal/mca/memory/ptmalloc2/hooks.c{,.original}
sed -e '434s/: 0;/: NULL;/' \
    -e '449s/: 0;/: NULL;/' \
    openmpi-1.4.2/opal/mca/memory/ptmalloc2/hooks.c.original \
    >openmpi-1.4.2/opal/mca/memory/ptmalloc2/hooks.c
mv openmpi-1.4.2/opal/mca/memory/ptmalloc2/malloc.c{,.original}
sed -e '3446s/: 0,/: NULL,/' \
    -e '3664s/: 0,/: NULL,/' \
    -e '3789s/: 0,/: NULL,/' \
    openmpi-1.4.2/opal/mca/memory/ptmalloc2/malloc.c.original \
    >openmpi-1.4.2/opal/mca/memory/ptmalloc2/malloc.c

• The only remaining complaint I get now from the PGI C compiler is for orte_base_log() in openmpi-1.4.2/orte/mca/notifier/base/ notifier_base_open.c:

static void orte_base_log(int priority, const char *msg, ...)
{
   /* just do nothing - it is here just so
    * someone calling it won't segv
    */
}

PGI C issues the following warning:

PGC-W-0155-No va_start() seen  (base/notifier_base_open.c: 85)

This is completely legal C, as far as I can tell from my copy of the 1990 ISO C standard. I didn't bother to fix this; I sent a bug report to PGI.

Larry Baker
US Geological Survey
650-329-5608
ba...@usgs.gov


Reply via email to