Skip to content

Commit

Permalink
Merge pull request #2399 from sstsimulator/devel
Browse files Browse the repository at this point in the history
Automatically Merged using SST Master Branch Merger
  • Loading branch information
sst-autotester authored Sep 26, 2024
2 parents 6353292 + 617ffb1 commit e703cdd
Show file tree
Hide file tree
Showing 37 changed files with 2,105 additions and 403 deletions.
240 changes: 240 additions & 0 deletions config/acx_mpi.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
# ===========================================================================
# http://autoconf-archive.cryp.to/acx_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
# ACX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile programs that use MPI
# (Message Passing Interface), a standard API for parallel process
# communication (see http://www-unix.mcs.anl.gov/mpi/)
#
# On success, it sets the MPICC, MPICXX, MPIF77, or MPIFC output variable
# to the name of the MPI compiler, depending upon the current language.
# (This may just be $CC/$CXX/$F77/$FC, but is more often something like
# mpicc/mpiCC/mpif77/mpif90.) It also sets MPILIBS to any libraries that
# are needed for linking MPI (e.g. -lmpi or -lfmpi, if a special
# MPICC/MPICXX/MPIF77/MPIFC was not found).
#
# If you want to compile everything with MPI, you should set:
#
# CC="MPICC" #OR# CXX="MPICXX" #OR# F77="MPIF77" #OR# FC="MPIFC"
# LIBS="$MPILIBS $LIBS"
#
# NOTE: The above assumes that you will use $CC (or whatever) for linking
# as well as for compiling. (This is the default for automake and most
# Makefiles.)
#
# The user can force a particular library/compiler by setting the
# MPICC/MPICXX/MPIF77/MPIFC and/or MPILIBS environment variables.
#
# ACTION-IF-FOUND is a list of shell commands to run if an MPI library is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run if it is not
# found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_MPI.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <[email protected]>
# Copyright (c) 2008 Julian C. Cummings <[email protected]>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

AC_DEFUN([AX_PROG_PREPROC_WORKS_IFELSE],
[ax_preproc_ok=false
_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
@%:@ include <limits.h>
@%:@else
@%:@ include <assert.h>
@%:@endif
Syntax error]])],
[],
[# Broken: fails on valid input.
continue])
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
_AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ax_nonexistent.h>]])],
[# Broken: success on invalid input.
continue],
[# Passes both tests.
ac_preproc_ok=true
break])
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
AS_IF([test "x$ac_preproc_ok" = xtrue], [$1], [$2])
])

AC_DEFUN([AX_PROG_MPICXXCPP],
[
dnl This is heavily stolen from autoconf's AC_PROG_CPP
AC_ARG_VAR(MPICXXCPP,[MPI C++ preprocessor command])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([how to run the MPI C++ preprocessor])
AS_IF([test -n "$MPICXXCPP" && test -d "$MPICXXCPP"],
[MPICXXCPP=])
AS_IF([test "x$MPICXXCPP" = "x"],
[AC_CACHE_VAL([ax_cv_prog_MPICXXCPP],
[dnl
CXXCPP_save="$CXXCPP"
# Double quotes because CPP needs to be expanded
for CXXCPP in "$MPICXX -E" "$MPICXX -E -traditional-cpp" "$MPICC -E" "$MPICC -E -traditional-cpp" "/lib/cpp"
do
AX_PROG_PREPROC_WORKS_IFELSE([break])
done
ax_cv_prog_MPICXXCPP="$CXXCPP"
CXXCPP="$CXXCPP_save"
])dnl
MPICXXCPP="$ax_cv_prog_MPICXXCPP"],
[ac_cv_prog_MPICXXCPP="$CXXCPP"])
AC_MSG_RESULT([$MPICXXCPP])
AX_PROG_PREPROC_WORKS_IFELSE([],
[AC_MSG_FAILURE([MPI C++ preprocessor "$MPICXXCPP" fails sanity check])])
AC_SUBST(MPICXXCPP)
AC_LANG_POP([C++])
])

AC_DEFUN([AX_PROG_MPICPP],
[
dnl This is heavily stolen from autoconf's AC_PROG_CPP
AC_ARG_VAR(MPICPP,[MPI C preprocessor command])
AC_LANG_PUSH(C)
AC_MSG_CHECKING([how to run the MPI C preprocessor])
AS_IF([test -n "$MPICPP" && test -d "$MPICPP"],
[MPICPP=])
AS_IF([test "x$MPICPP" = "x"],
[AC_CACHE_VAL([ax_cv_prog_MPICPP],
[dnl
CPP_save="$CPP"
# Double quotes because CPP needs to be expanded
for CPP in "$MPICC -E" "$MPICC -E -traditional-cpp" "/lib/cpp"
do
AX_PROG_PREPROC_WORKS_IFELSE([break])
done
ax_cv_prog_MPICPP="$CPP"
CPP="$CPP_save"
])dnl
MPICPP="$ax_cv_prog_MPICPP"],
[ac_cv_prog_MPICPP="$CPP"])
AC_MSG_RESULT([$MPICPP])
AX_PROG_PREPROC_WORKS_IFELSE([],
[AC_MSG_FAILURE([MPI C preprocessor "$MPICPP" fails sanity check])])
AC_SUBST(MPICPP)
AC_LANG_POP(C)
])

AC_DEFUN([ACX_MPI], [
AC_PREREQ(2.50) dnl for AC_LANG_CASE
AC_LANG_CASE([C], [
AC_REQUIRE([AC_PROG_CC])
AC_ARG_VAR(MPICC,[MPI C compiler command])
AC_CHECK_PROGS(MPICC, mpicc hcc mpxlc_r mpxlc mpcc cmpicc, $CC)
acx_mpi_save_CC="$CC"
CC="$MPICC"
AX_PROG_MPICPP()
AC_SUBST(MPICC)
],
[C++], [
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
AC_CHECK_PROGS(MPICXX, mpic++ mpicxx mpiCC hcp mpxlC_r mpxlC mpCC cmpic++, $CXX)
acx_mpi_save_CXX="$CXX"
CXX="$MPICXX"
AX_PROG_MPICXXCPP()
AC_SUBST(MPICXX)
])
if test x = x"$MPILIBS"; then
AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
[C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
fi
dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
AC_LANG_CASE([C], [AS_IF([test x != x"$MPILIBS"],
[AC_MSG_CHECKING([for C mpi.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],[])],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])])],
[C++], [AS_IF([test x != x"$MPILIBS"],
[AC_MSG_CHECKING([for C++ mpi.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],[])],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])])])
AC_LANG_CASE([C], [CC="$acx_mpi_save_CC"],
[C++], [CXX="$acx_mpi_save_CXX"],
[Fortran 77], [F77="$acx_mpi_save_F77"],
[Fortran], [FC="$acx_mpi_save_FC"])
AC_SUBST(MPILIBS)
# try to figure out include directory. We only need the C API, so only do it once.
if test "$MPI_CPPFLAGS" = "" ; then
MPI_CPPFLAGS=
# Open MPI
incdir=`${MPICC} -showme:incdirs 2>/dev/null`
if test $? -eq 0 ; then
for flag in $incdir ; do
MPI_CPPFLAGS="$MPI_CPPFLAGS -I${flag}"
done
else
# MPICH2
flags=`${MPICC} -compile-info 2>/dev/null`
if test $? -eq 0 ; then
for flag in $flags ; do
if echo $flag | grep -q '^\-I' ; then
MPI_CPPFLAGS="$MPI_CPPFLAGS $flag"
fi
done
fi
fi
AC_SUBST(MPI_CPPFLAGS)
fi
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x = x"$MPILIBS"; then
$2
:
else
ifelse([$1],,[AC_DEFINE(SST_CONFIG_HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
:
fi
])dnl ACX_MPI

dnl vim:set expandtab
53 changes: 53 additions & 0 deletions config/sst_check_ariel_mpi.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
AC_DEFUN([SST_CHECK_ARIEL_MPI], [
sst_check_ariel_mpi_happy="no"
AC_ARG_ENABLE([ariel-mpi],
[AS_HELP_STRING([--enable-ariel-mpi],
[Enable MPI support in Ariel [default=no]])])
AS_IF([test "$enable_ariel_mpi" = "yes"], [sst_check_ariel_mpi_happy="yes"])
dnl Ensure Core was compiled without MPI
dnl Regrettably, this runs before we have checked whether sst-config exists,
dnl as that config file overwrites the MPICXX and MPICC variables needed by
dnl the ACX_MPI macro. We plan to remove this check altogether in the future.
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
AC_MSG_CHECKING([whether sst-core was compilied without MPI])
sst_config_out=$(sst-config --MPI_CPPFLAGS)
if test -z "$sst_config_out"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_WARN([SST-Core appears to have been compiled with MPI support. Disabling Ariel MPI support.])
sst_check_ariel_mpi_happy="no"
fi
])
dnl Find the MPI compilers and put them in MPICC and MIPCXX
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
AC_LANG_PUSH([C])
ACX_MPI([], [sst_check_ariel_mpi_happy="no"])
AC_LANG_POP([C])
])
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
AC_LANG_PUSH([C++])
ACX_MPI([], [sst_check_ariel_mpi_happy="no"])
AC_LANG_POP([C++])
])
dnl Elements will overwrite these with the values used for compiling Core. We
dnl will save them in new variables.
ARIEL_MPICC=$MPICC
ARIEL_MPICXX=$MPICXX
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
ARIEL_MPI_CFLAGS=$($MPICC -showme:compile)
ARIEL_MPI_LIBS=$($MPICC -showme:link)
])
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
AC_DEFINE([ENABLE_ARIEL_MPI], [1], [Enable Ariel MPI features])
])
AM_CONDITIONAL([SST_USE_ARIEL_MPI], [test "$sst_check_ariel_mpi_happy" = "yes"])
])

2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ LTDL_INIT([recursive])

AC_CACHE_SAVE

SST_CHECK_ARIEL_MPI([], [AC_MSG_ERROR([Can't enable Ariel MPI])])

SST_CORE_CHECK_INSTALL()

SST_CHECK_OSX()
Expand Down
5 changes: 5 additions & 0 deletions src/sst/elements/ariel/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
fesimple.so
fesimple.dylib.dSYM
fesimple.dylib
tests/testIO/rank_0_thread_0
tests/testMPI/rank_0_thread_0
tests/testopenMP/ompmybarrier/ompmybarrier
frontend/simple/malloc.txt
api/*.a
15 changes: 11 additions & 4 deletions src/sst/elements/ariel/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
SUBDIRS = api
if SST_USE_ARIEL_MPI
SUBDIRS += mpi
endif

AM_CPPFLAGS += \
$(MPI_CPPFLAGS) \
-I$(top_srcdir)/src

if HAVE_SET_PTRACER
Expand Down Expand Up @@ -53,7 +57,6 @@ libariel_la_SOURCES = \
EXTRA_DIST = \
api/arielapi.c \
api/arielapi.h \
api/Makefile \
frontend/pin3/fesimple.cc \
frontend/simple/fesimple.cc \
frontend/simple/examples/multicore.py \
Expand All @@ -76,8 +79,11 @@ EXTRA_DIST = \
frontend/simple/examples/stream/tests/refFiles/test_Ariel_runstreamNB.out \
frontend/simple/examples/stream/tests/refFiles/test_Ariel_runstreamSt.out \
tests/testsuite_default_Ariel.py \
tests/testsuite_testio_Ariel.py \
tests/testsuite_mpi_Ariel.py \
tests/testopenMP/ompmybarrier/ompmybarrier.c \
tests/testopenMP/ompmybarrier/Makefile
tests/testopenMP/ompmybarrier/Makefile \
tests/testMPI/Makefile

libariel_la_LDFLAGS = -module -avoid-version
libariel_la_LIBADD = $(SHM_LIB)
Expand All @@ -102,8 +108,9 @@ endif

libariel_la_CPPFLAGS = \
-DARIEL_TRACE_LIB=$(libdir)/sst \
-DARIEL_TOOL_DIR="$(libexecdir)" \
-DARIEL_TOOL_DIR="$(libexecdir)" \
-DPINTOOL_EXECUTABLE="$(PINTOOL_RUNTIME)" \
-DMPILAUNCHER_EXECUTABLE="$(CURDIR)/mpi/mpilauncher" \
$(AM_CPPFLAGS) $(CPPFLAGS)

sstdir = $(includedir)/sst/elements/ariel
Expand Down
13 changes: 0 additions & 13 deletions src/sst/elements/ariel/api/Makefile

This file was deleted.

21 changes: 21 additions & 0 deletions src/sst/elements/ariel/api/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if SST_USE_ARIEL_MPI
CC_LOCAL = $(ARIEL_MPICC)
CFLAGS_LOCAL = -fopenmp $(ARIEL_MPI_CFLAGS) -DENABLE_ARIEL_MPI=1
else
CC_LOCAL = $(CC)
CFLAGS_LOCAL =
endif

all-local: libarielapi.so libarielapi.a

libarielapi.so: arielapi.c arielapi.h
$(CC_LOCAL) $(CFLAGS_LOCAL) -fPIC -shared -o libarielapi.so $(LDFLAGS) arielapi.c

arielapi.o: arielapi.c arielapi.h
$(CC_LOCAL) $(CFLAGS_LOCAL) -c -o arielapi.o arielapi.c

libarielapi.a: arielapi.o
ar rcs $@ $^

clean-local:
rm -f arielapi.o libarielapi.a libarielapi.so
Loading

0 comments on commit e703cdd

Please sign in to comment.