From 37a83be7d8621347a16f7ce967ba49160e665711 Mon Sep 17 00:00:00 2001 From: Patrick Lavin Date: Wed, 31 Jul 2024 15:13:37 -0600 Subject: [PATCH] add new configure files for Ariel API --- config/acx_mpi.m4 | 240 +++++++++++++++++++++++ config/sst_check_ariel_mpi.m4 | 36 ++++ configure.ac | 2 + src/sst/elements/ariel/mpi/libarielapi.c | 35 ---- 4 files changed, 278 insertions(+), 35 deletions(-) create mode 100644 config/acx_mpi.m4 create mode 100644 config/sst_check_ariel_mpi.m4 delete mode 100644 src/sst/elements/ariel/mpi/libarielapi.c diff --git a/config/acx_mpi.m4 b/config/acx_mpi.m4 new file mode 100644 index 0000000000..6c552e30bf --- /dev/null +++ b/config/acx_mpi.m4 @@ -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 +# Copyright (c) 2008 Julian C. Cummings +# +# 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 . +# +# 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 +@%:@else +@%:@ include +@%:@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 ]])], + [# 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 ]],[])],[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 ]],[])],[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 diff --git a/config/sst_check_ariel_mpi.m4 b/config/sst_check_ariel_mpi.m4 new file mode 100644 index 0000000000..73ba9a3235 --- /dev/null +++ b/config/sst_check_ariel_mpi.m4 @@ -0,0 +1,36 @@ +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 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 Ensure Core was compiled without MPI + dnl todo + dnl + + AX_OPENMP() + ARIEL_CFLAGS = $OPENMP_CFLAGS + ARIEL_CXXFLAGS = $OPENMP_CXXFLAGS + $OPENMP_CFLAGS + + ARIEL_MPICC=$MPICC + ARIEL_MPICXX=$MPICXX + AM_CONDITIONAL([SST_USE_ARIEL_MPI], [test "$sst_check_ariel_mpi_happy" = "yes"]) +]) + diff --git a/configure.ac b/configure.ac index feed6f19ba..57e5639367 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,7 @@ m4_include([config/sst_elements_include.m4]) AM_PROG_AS +SST_CHECK_ARIEL_MPI([], [AC_MSG_ERROR([Can't enable Ariel MPI])]) AC_PROG_CC AM_PROG_CC_C_O m4_if(m4_defn([AC_AUTOCONF_VERSION]), 2.71,, m4_defn([AC_AUTOCONF_VERSION]), 2.70,, [AC_PROG_CC_C99]) @@ -45,6 +46,7 @@ SST_CORE_CHECK_INSTALL() SST_CHECK_OSX() + SST_CHECK_SPINLOCK() SST_ELEMENT_CONFIG_OUTPUT() diff --git a/src/sst/elements/ariel/mpi/libarielapi.c b/src/sst/elements/ariel/mpi/libarielapi.c deleted file mode 100644 index 4079d19eb8..0000000000 --- a/src/sst/elements/ariel/mpi/libarielapi.c +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2009-2015 Sandia Corporation. Under the terms -// of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. -// Government retains certain rights in this software. -// -// Copyright (c) 2009-2015, Sandia Corporation -// All rights reserved. -// -// This file is part of the SST software package. For license -// information, see the LICENSE file in the top level directory of the -// distribution. - - -#include -#include -#include - -void ariel_enable() { - printf("ARIEL-CLIENT: Library enabled.\n"); -} - -void ariel_disable() { - printf("ARIEL-CLIENT: Library disabled.\n"); -} - -uint64_t ariel_cycles() { - return 0; -} - -void ariel_output_stats() { - printf("ARIEL-CLIENT: Printing statistics.\n"); -} - -void ariel_malloc_flag(int64_t id, int count, int level) { - printf("ARIEL-CLIENT: flagging next %d mallocs at id %" PRId64 "\n", count, id); -}