[cgma-dev] r3263 - in cgm/trunk: . geom/parallel m4

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Nov 2 16:18:42 CST 2009


Author: kraftche
Date: 2009-11-02 16:18:42 -0600 (Mon, 02 Nov 2009)
New Revision: 3263

Added:
   cgm/trunk/geom/parallel/CGMmpi.h
   cgm/trunk/geom/parallel/CGMmpi_config.h.in
   cgm/trunk/m4/macro_val.m4
   cgm/trunk/m4/mpi.m4
Modified:
   cgm/trunk/configure.ac
   cgm/trunk/geom/parallel/CGMParallelComm.cpp
   cgm/trunk/geom/parallel/CGMParallelComm.hpp
   cgm/trunk/geom/parallel/Makefile.am
   cgm/trunk/geom/parallel/ProcData.hpp
Log:
copy MPI config from MOAB

Modified: cgm/trunk/configure.ac
===================================================================
--- cgm/trunk/configure.ac	2009-11-02 22:13:26 UTC (rev 3262)
+++ cgm/trunk/configure.ac	2009-11-02 22:18:42 UTC (rev 3263)
@@ -11,7 +11,6 @@
 EXTRA_GNU_FLAGS="-Wall -pipe -pedantic"
 SNL_CHECK_COMPILERS
 AC_PROG_LIBTOOL
-AM_CONDITIONAL(build_parallel, [test "x$WITH_MPI" != "xno"])
 LIBS="-lm"
 AC_PROG_SED
 AC_C_BIGENDIAN( [LITTLE_ENDIAN=], [LITTLE_ENDIAN=-DLITTLE_ENDIAN=BYTE_ORDER] )
@@ -40,6 +39,9 @@
 #                              MPI OPTIONS
 ################################################################################
 
+AM_CONDITIONAL(build_parallel, [test "x$WITH_MPI" != "xno"])
+FATHOM_CHECK_MPI
+FATHOM_CONFIG_MPI_EXEC
 if test "x$WITH_MPI" != "xno"; then
   CXXFLAGS="$CXXFLAGS -DUSE_MPI"
   CGM_PARALLEL_INCLUDE='-I${CGM_DIR}/geom/parallel'
@@ -50,6 +52,14 @@
 AC_SUBST(CGM_PARALLEL_INCLUDE)
 AC_SUBST(CGM_PARALLEL_LIB)
 AC_SUBST(CGM_PARALLEL_LIB_FILE)
+# Used to generate CGMmpi.h
+if test "xyes" = "x$MPI_CXX_HELP_NEEDED"; then
+  AC_DEFINE( [CGM_MPI_CXX_CONFLICT], [1], 
+    [MPICH_IGNORE_CXX_SEEK is not sufficient to avoid conflicts] )
+  AC_DEFINE_UNQUOTED([CGM_SEEK_SET],[$SEEK_SET],["Value of C SEEK_SET"])
+  AC_DEFINE_UNQUOTED([CGM_SEEK_CUR],[$SEEK_CUR],["Value of C SEEK_CUR"])
+  AC_DEFINE_UNQUOTED([CGM_SEEK_END],[$SEEK_END],["Value of C SEEK_END"])
+fi
 
 ################################################################################
 #                           CGM-specific Checks
@@ -423,6 +433,7 @@
 dnl AC_OUTPUT_COMMANDS( [if test -f util/CubitUtilConfigure.h; then true; else echo "#define CUBIT_UTIL_EXPORT" > util/CubitUtilConfigure.h; fi],
 dnl                     [if test -f geom/CubitGeomConfigure.h; then true; else echo "#define CUBIT_GEOM_EXPORT" > geom/CubitGeomConfigure.h; fi] )
 AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS([geom/parallel/CGMmpi_config.h])
 AC_CONFIG_HEADERS(itaps/iBase_FCDefs.h)
 AC_CONFIG_FILES(Makefile 
            util/Makefile

Modified: cgm/trunk/geom/parallel/CGMParallelComm.cpp
===================================================================
--- cgm/trunk/geom/parallel/CGMParallelComm.cpp	2009-11-02 22:13:26 UTC (rev 3262)
+++ cgm/trunk/geom/parallel/CGMParallelComm.cpp	2009-11-02 22:18:42 UTC (rev 3263)
@@ -9,7 +9,7 @@
 #include <sstream>
 
 #ifdef USE_MPI
-#include "mpi.h"
+#include "CGMmpi.h"
 #endif
 
 #define INITIAL_BUFF_SIZE 1024

Modified: cgm/trunk/geom/parallel/CGMParallelComm.hpp
===================================================================
--- cgm/trunk/geom/parallel/CGMParallelComm.hpp	2009-11-02 22:13:26 UTC (rev 3262)
+++ cgm/trunk/geom/parallel/CGMParallelComm.hpp	2009-11-02 22:18:42 UTC (rev 3263)
@@ -19,37 +19,9 @@
 #include <set>
 #include <vector>
 #include "math.h"
+#include "CGMmpi.h"
 
-#ifdef SEEK_SET
-#  define SEEK_SET_OLD SEEK_SET
-#  undef SEEK_SET
-#endif
-#ifdef SEEK_CUR
-#  define SEEK_CUR_OLD SEEK_CUR
-#  undef SEEK_CUR
-#endif
-#ifdef SEEK_END
-#  define SEEK_END_OLD SEEK_END
-#  undef SEEK_END
-#endif
-#include "mpi.h"
-#ifdef SEEK_SET_OLD
-#  undef SEEK_SET
-#  define SEEK_SET SEEK_SET_OLD
-#  undef SEEK_SET_OLD
-#endif
-#ifdef SEEK_CUR_OLD
-#  undef SEEK_CUR
-#  define SEEK_CUR SEEK_CUR_OLD
-#  undef SEEK_CUR_OLD
-#endif
-#ifdef SEEK_END_OLD
-#  undef SEEK_END
-#  define SEEK_END SEEK_END_OLD
-#  undef SEEK_END_OLD
-#endif
 
-
 extern "C" {
   struct tuple_list;
 }

Added: cgm/trunk/geom/parallel/CGMmpi.h
===================================================================
--- cgm/trunk/geom/parallel/CGMmpi.h	                        (rev 0)
+++ cgm/trunk/geom/parallel/CGMmpi.h	2009-11-02 22:18:42 UTC (rev 3263)
@@ -0,0 +1,48 @@
+#ifndef CGM_MPI_H
+#define CGM_MPI_H
+#include "CGMmpi_config.h"
+
+#ifndef __cplusplus
+#  include <mpi.h>
+#elif !defined(CGM_MPI_CXX_CONFLICT)
+#  ifndef MPICH_IGNORE_CXX_SEEK
+#    define MPICH_IGNORE_CXX_SEEK
+#  endif
+#  include <mpi.h>
+#else
+#  include <stdio.h>
+#  ifdef SEEK_SET
+#    undef SEEK_SET
+#    ifdef CGM_SEEK_SET
+#      define CGM_RESTORE_SEEK_SET
+#    endif
+#  endif
+#  ifdef SEEK_CUR
+#    undef SEEK_CUR
+#    ifdef CGM_SEEK_CUR
+#      define CGM_RESTORE_SEEK_CUR
+#    endif
+#  endif
+#  ifdef SEEK_END
+#    undef SEEK_END
+#    ifdef CGM_SEEK_END
+#      define CGM_RESTORE_SEEK_END
+#    endif
+#  endif
+#  include <mpi.h>
+#  ifdef CGM_RESTORE_SEEK_SET
+#    undef CGM_RESTORE_SEEK_SET
+#    define SEEK_SET CGM_SEEK_SET
+#  endif
+#  ifdef CGM_RESTORE_SEEK_CUR
+#    undef CGM_RESTORE_SEEK_CUR
+#    define SEEK_CUR CGM_SEEK_CUR
+#  endif
+#  ifdef CGM_RESTORE_SEEK_END
+#    undef CGM_RESTORE_SEEK_END
+#    define SEEK_END CGM_SEEK_END
+#  endif
+#endif
+
+
+#endif


Property changes on: cgm/trunk/geom/parallel/CGMmpi.h
___________________________________________________________________
Added: svn:mergeinfo
   + 

Added: cgm/trunk/geom/parallel/CGMmpi_config.h.in
===================================================================
--- cgm/trunk/geom/parallel/CGMmpi_config.h.in	                        (rev 0)
+++ cgm/trunk/geom/parallel/CGMmpi_config.h.in	2009-11-02 22:18:42 UTC (rev 3263)
@@ -0,0 +1,11 @@
+/* MPICH_IGNORE_CXX_SEEK is not sufficient to avoid conflicts */
+#undef CGM_MPI_CXX_CONFLICT
+
+/* "Value of C SEEK_CUR" */
+#undef CGM_SEEK_CUR
+
+/* "Value of C SEEK_END" */
+#undef CGM_SEEK_END
+
+/* "Value of C SEEK_SET" */
+#undef CGM_SEEK_SET


Property changes on: cgm/trunk/geom/parallel/CGMmpi_config.h.in
___________________________________________________________________
Added: svn:mergeinfo
   + 

Modified: cgm/trunk/geom/parallel/Makefile.am
===================================================================
--- cgm/trunk/geom/parallel/Makefile.am	2009-11-02 22:13:26 UTC (rev 3262)
+++ cgm/trunk/geom/parallel/Makefile.am	2009-11-02 22:18:42 UTC (rev 3263)
@@ -30,6 +30,8 @@
 # If any of these do not need to be installed, move them
 # to the _SOURCES list above.
 libcubit_parallel_la_include_HEADERS = \
+    CGMmpi.h \
+    CGMmpi_config.h \
     CGMProcConfig.hpp \
     CGMParallelComm.hpp \
     FileOptions.hpp \

Modified: cgm/trunk/geom/parallel/ProcData.hpp
===================================================================
--- cgm/trunk/geom/parallel/ProcData.hpp	2009-11-02 22:13:26 UTC (rev 3262)
+++ cgm/trunk/geom/parallel/ProcData.hpp	2009-11-02 22:18:42 UTC (rev 3263)
@@ -2,7 +2,7 @@
 #define PROBDATA_HPP
 
 #ifdef USE_MPI
-#include "mpi.h"
+#include "CGMmpi.h"
 #endif
 
 class ProcData 

Added: cgm/trunk/m4/macro_val.m4
===================================================================
--- cgm/trunk/m4/macro_val.m4	                        (rev 0)
+++ cgm/trunk/m4/macro_val.m4	2009-11-02 22:18:42 UTC (rev 3263)
@@ -0,0 +1,38 @@
+# Macro to determine the unsigned integer value of a 
+# preprocessor macro.  Arguments are:
+#   header, macro, variable, upper bound
+# where 'header' is the header in which the macro value
+# is defined, 'macro' is the name of the preprocessor macro
+# for which the value is to be determined, 'variable' is the
+# name of the shell variable in which to store the value,
+# and 'upper bound' is the largest value up to which to search
+AC_DEFUN([FATHOM_MACRO_VALUE],[
+  header="$1"
+  macro="$2"
+  upper="$4"
+  lower="0"
+  while test "$lower" -lt "$upper"; do
+    curr=$(( ($lower + $upper)/2 ))
+    AC_PREPROC_IFELSE(
+      [AC_LANG_PROGRAM([#include <${header}>
+                        #if $macro >= $curr
+                        # error choke me
+                        #endif],[])],
+      [upper=$curr],
+      [AC_PREPROC_IFELSE(
+        [AC_LANG_PROGRAM([#include <${header}>
+                          #if $macro < $curr
+                          # error choke me
+                          #endif],[])],
+        [break],
+        [lower=$curr])])
+  done
+  AC_PREPROC_IFELSE(
+    [AC_LANG_PROGRAM([#include <${header}>
+                      #if $curr != $macro
+                      # error choke me
+                      #endif],[])],
+    [$3=$curr],
+    [AC_MSG_ERROR([Unable to determine value of $macro defined in $header])])
+])
+

Added: cgm/trunk/m4/mpi.m4
===================================================================
--- cgm/trunk/m4/mpi.m4	                        (rev 0)
+++ cgm/trunk/m4/mpi.m4	2009-11-02 22:18:42 UTC (rev 3263)
@@ -0,0 +1,79 @@
+# Macros for MPI configuration.
+
+# NOTE: The macro to enable/disable MPI support entirely is 
+#       in compilers.m4, as it also affects the choice of compiler.
+#       That code is expected to have set WITH_MPI to either 'yes',
+#       'no' or the directory where MPI is installed BEFORE these 
+#       macros are called.
+
+# Options and configuration for mpiexec.  Sets
+# the following variables:
+#   USE_MPIEXEC - AM_CONDITIONAL, true if MPIEXEC is valid
+#   MPIEXEC     - mpiexec binary
+#   MPIEXEC_NP  - mpiexec CLI flag to specify number of procs (e.g. '-np')
+#   NP          - number of procs to use during testing
+AC_DEFUN([FATHOM_CONFIG_MPI_EXEC],[
+  AC_ARG_VAR(MPIEXEC,[Program to use to run parallel tests (default: mpiexec or mpirun)])
+  AC_ARG_VAR(MPIEXEC_NP,[Command line flag to specify number of processors to use (default: -np)])
+  AC_ARG_VAR(NP,[Number of processors to on which to run parallel tests (default: 2)])
+  if test "x$WITH_MPI" != "xno"; then
+    if test "x$MPIEXEC" = "x"; then
+      if test "x$WITH_MPI" != "xyes"; then
+        AC_CHECK_PROGS([MPIEXEC],[mpiexec mpirun],[true],[${WITH_MPI}:${WITH_MPI}/bin])
+      else
+        AC_CHECK_PROGS([MPIEXEC],[mpiexec mpirun],[true])
+      fi
+    fi
+    if test "x$MPIEXEC_NP" = "x"; then
+      MPIEXEC_NP="-np"
+    fi
+    if test "x$NP" = "x"; then
+      NP=2
+    fi
+  fi
+  AM_CONDITIONAL(USE_MPIEXEC, [test "xtrue" != "x$MPIEXEC"])
+])
+
+# Check for MPI library and MPI.h
+# Error if not found.
+# Defines MPI_CXX_HELP_NEEDED to yes if, when parsed with a c++ compiler,
+# mpi.h conflicts with the C standard library for the definition of SEEK_SET,
+# etc. and defining MPICH_IGNORE_CXX_SEEK is not sufficient to work around
+# the problem.
+AC_DEFUN([FATHOM_CHECK_MPI], [
+  if test "x$WITH_MPI" != "xno"; then
+    AC_LANG_PUSH([C])
+    AC_CHECK_HEADER([mpi.h],[],[AC_MSG_ERROR([mpi.h not found or not working])])
+    AC_LANG_POP([C])
+    
+    AC_MSG_CHECKING([If mpi.h conflicts with C headers in C++])
+    AC_LANG_PUSH([C++])
+    AC_PREPROC_IFELSE(
+      [AC_LANG_PROGRAM([#include <stdio.h>
+                        #include <mpi.h>],[])],
+      [MPI_CXX_HELP_NEEDED=no; AC_MSG_RESULT([no])],
+      [AC_PREPROC_IFELSE(
+        [AC_LANG_PROGRAM([#include <stdio.h>
+                          #define MPICH_IGNORE_CXX_SEEK
+                          #include <mpi.h>],[])],
+        [MPI_CXX_HELP_NEEDED=no; AC_MSG_RESULT([MPICH_IGNORE_CXX_SEEK])],
+        [MPI_CXX_HELP_NEEDED=yes
+         AC_MSG_RESULT([yes])
+
+         AC_MSG_CHECKING([value of SEEK_SET])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_SET],[SEEK_SET],[16])
+         AC_MSG_RESULT([$SEEK_SET])
+
+         AC_MSG_CHECKING([value of SEEK_CUR])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_CUR],[SEEK_CUR],[16])
+         AC_MSG_RESULT([$SEEK_CUR])
+
+         AC_MSG_CHECKING([value of SEEK_END])
+         FATHOM_MACRO_VALUE([stdio.h],[SEEK_END],[SEEK_END],[16])
+         AC_MSG_RESULT([$SEEK_END])
+       ])
+    ])
+    AC_LANG_POP([C++])
+  fi
+])
+



More information about the cgma-dev mailing list