diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..075eae7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +*.in +Makefile + +autom4te.cache + +config.log +config.status +config.guess +config.sub + +aclocal.m4 +configure +libtool +stamp-h? + +.libs +.deps + +*.o +*.lo +*.la diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..166a95b --- /dev/null +++ b/LICENSE @@ -0,0 +1,34 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..87eb04c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,10 @@ +# Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + +SUBDIRS = \ + config \ + c \ + cxx \ + fortran-mpifh \ + fortran-usempi \ + fortran-usempif08 \ + examples diff --git a/README.md b/README.md new file mode 100644 index 0000000..e872da3 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +This is a dummy, no-op MPI implementation that is an example of +[MPI Forum issue +#137](https://github.com/mpi-forum/mpi-issues/issues/137). + +Specifically: the API calls in these libraries do nothing other than +print out that they were called. The intent is to show how ticket +#137 could be implemented, and what the resulting symbols will look +like. It also gives a platform for real experimentation with +different compilers, options, run-time environments, etc. + +Froozle MPI provides only a few MPI API functions, just to give a +flavor of how things will look with ticket #137: + +* MPI_INIT, MPI_FINALIZE, MPI_COMM_RANK, MPI_COMM_SIZE +* MPI_SEND, MPI_RECV +* MPI_ALLGATHER + +5 flavors of the APIs are available: + +1. C: in the c/ directory. Both "int" and "MPI_Count" versions of the +send, receive, and allgather APIs are implemented. +2. C++: in the cxx/ directory. The C symbols are used for everything +except for the send, receive, and allgather APIs. +3. Fortran mpif.h: in the fortran-mpifh/ directory. The "glue" APIs +(init, finalize, comm_rank, comm_size) are implemented in Fortran. +The others are implemented in C, but per ticket #137, only "integer" +versions are available. +4. Fortran mpi module: in the fortran-usempi/ directory. ...more to +write here. +5. Fortran mpi_f08 module: in the fortran-usempif08/ directory. +...more to write here. + +You must have a C, C++, and Fortran compiler available to compile +Froozle. + +Build Froozle with the following: + +```sh +# If running from a git clone, you must have the GNU Autotools +# installed, and then run: +$ ./autogen.sh + +# If you are building from a bootstrapped tarball, you can skip the +# above autogen.sh step proceed directly to the next steps. + +# Run the configure script: +$ ./configure |& tee config.out + +# Build Froozle +$ make -j 8 |& tee make.out + +# Optionally install Froozle +$ make install +``` + +A few example applications are in the examples/ directory. + +Comments are welcome. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..5c8e1c0 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set +x + +autoreconf -ivf diff --git a/c/.gitignore b/c/.gitignore new file mode 100644 index 0000000..bc587c6 --- /dev/null +++ b/c/.gitignore @@ -0,0 +1 @@ +mpi-config.h diff --git a/c/Makefile.am b/c/Makefile.am new file mode 100644 index 0000000..b12caf3 --- /dev/null +++ b/c/Makefile.am @@ -0,0 +1,19 @@ +# Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + +lib_LTLIBRARIES = libmpi.la + +libmpi_la_SOURCES = \ + mpi.h \ + mpi-config.h \ + mpi-common.h \ + globals.c \ + allgather_int.c \ + allgather_count.c \ + comm_rank.c \ + comm_size.c \ + finalize.c \ + init.c \ + recv_int.c \ + recv_count.c \ + send_int.c \ + send_count.c diff --git a/c/allgather_count.c b/c/allgather_count.c new file mode 100644 index 0000000..e3eeb50 --- /dev/null +++ b/c/allgather_count.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Allgather_count(const void *sendbuf, MPI_Count sendcount, + MPI_Datatype sendtype, + void *recvbuf, MPI_Count recvcount, + MPI_Datatype recvtype, MPI_Comm comm) +{ + printf("This is C MPI_Allgather_count\n"); + + return MPI_SUCCESS; +} diff --git a/c/allgather_int.c b/c/allgather_int.c new file mode 100644 index 0000000..e71c64c --- /dev/null +++ b/c/allgather_int.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Allgather(const void *sendbuf, int sendcount, + MPI_Datatype sendtype, + void *recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm) +{ + printf("This is C MPI_Allgather_count\n"); + + return MPI_SUCCESS; +} diff --git a/c/comm_rank.c b/c/comm_rank.c new file mode 100644 index 0000000..618ea86 --- /dev/null +++ b/c/comm_rank.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Comm_rank(MPI_Comm comm, int *rank) +{ + printf("This is C MPI_Comm_rank\n"); + + return MPI_SUCCESS; +} diff --git a/c/comm_size.c b/c/comm_size.c new file mode 100644 index 0000000..611e762 --- /dev/null +++ b/c/comm_size.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Comm_size(MPI_Comm comm, int *size) +{ + printf("This is C MPI_Comm_size\n"); + + return MPI_SUCCESS; +} diff --git a/c/finalize.c b/c/finalize.c new file mode 100644 index 0000000..db26251 --- /dev/null +++ b/c/finalize.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Finalize(void) +{ + printf("This is C MPI_Finalize\n"); + + return MPI_SUCCESS; +} diff --git a/c/globals.c b/c/globals.c new file mode 100644 index 0000000..c16f5bd --- /dev/null +++ b/c/globals.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + +struct froozle_comm { + int bogus; +}; + +struct froozle_datatype { + int bogus; +}; + + +static struct froozle_comm froozle_comm_world = {0}; + +static struct froozle_datatype froozle_int = {0}; +static struct froozle_datatype froozle_char = {0}; + +MPI_Comm MPI_COMM_WORLD = &froozle_comm_world; + +MPI_Datatype MPI_INT = &froozle_int; +MPI_Datatype MPI_CHAR = &froozle_char; diff --git a/c/init.c b/c/init.c new file mode 100644 index 0000000..b4dea2a --- /dev/null +++ b/c/init.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Init(int *argc, char ***argv) +{ + printf("This is C MPI_Init\n"); + +#if FROOZLE_HAVE_C11_GENERIC + printf("NOTE: This Froozle built with C11 _Generic support. Yay!\n"); +#else + printf("NOTE: This Froozle was built without C11 _Generic support. Bummer.\n"); +#endif + + return MPI_SUCCESS; +} diff --git a/c/mpi-common.h b/c/mpi-common.h new file mode 100644 index 0000000..4e423cc --- /dev/null +++ b/c/mpi-common.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#ifndef MPI_COMMON_H +#define MPI_COMMON_H + +/***************************************************************/ + +struct froozle_comm; +struct froozle_datatype; +struct froozle_status; + +typedef struct froozle_comm *MPI_Comm; +typedef struct froozle_datatype *MPI_Datatype; + +typedef struct froozle_status MPI_Status; + +typedef long MPI_Count; + +enum { + MPI_SUCCESS +}; + +extern MPI_Comm MPI_COMM_WORLD; + +extern MPI_Datatype MPI_INT; +extern MPI_Datatype MPI_CHAR; + +/***************************************************************/ + +// These functions do not have count arguments, and are therefore +// shared between both C and C++ interfaces. + +int MPI_Init(int *argc, char ***argv); +int MPI_Comm_rank(MPI_Comm comm, int *rank); +int MPI_Comm_size(MPI_Comm comm, int *size); +int MPI_Finalize(void); + +#endif // !MPI_COMMON_H diff --git a/c/mpi.h b/c/mpi.h new file mode 100644 index 0000000..a70c3ba --- /dev/null +++ b/c/mpi.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#ifndef MPI_H +#define MPI_H + +/***************************************************************/ + +#include "mpi-config.h" +#include "mpi-common.h" + +/***************************************************************/ + +#ifndef FROOZLE_BUILDING +#define FROOZLE_BUILDING 0 +#endif + +/***************************************************************/ + +// Always declare the _int versions + +int MPI_Send(const void *buf, int count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm); +int MPI_Recv(void *buf, int count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status); +int MPI_Allgather(const void *sendbuf, int sendcount, + MPI_Datatype sendtype, + void *recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm); + +#if FROOZLE_HAVE_C11_GENERIC && !FROOZLE_BUILDING + +#define MPI_Send(buf, count, dt, rank, tag, comm) \ + _Generic(count, \ + default: MPI_Send, \ + int: MPI_Send, \ + MPI_Count: MPI_Send_count \ + )(buf, count, dt, rank, tag, comm) + +#define MPI_Recv(buf, count, dt, rank, tag, comm) \ + _Generic(count, \ + default: MPI_Recv, \ + int: MPI_Recv, \ + MPI_Count: MPI_Recv_count \ + )(buf, count, dt, rank, tag, comm) + +#define MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) \ + _Generic(sendcount, \ + default: MPI_Allgather, \ + int: MPI_Allgather, \ + MPI_Count: MPI_Allgather_count \ + )(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm) + +int MPI_Send_count(const void *buf, MPI_Count count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm); +int MPI_Recv_count(void *buf, MPI_Count count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status); +int MPI_Allgather_count(const void *sendbuf, MPI_Count sendcount, + MPI_Datatype sendtype, + void *recvbuf, MPI_Count recvcount, + MPI_Datatype recvtype, MPI_Comm comm); + +#endif // FROOZLE_HAVE_C11_GENERIC && !FROOZLE_BUILDING + +#endif // MPI_H diff --git a/c/recv_count.c b/c/recv_count.c new file mode 100644 index 0000000..d002a40 --- /dev/null +++ b/c/recv_count.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Recv_count(void *buf, MPI_Count count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status) +{ + printf("This is C MPI_Recv_count\n"); + + return MPI_SUCCESS; +} diff --git a/c/recv_int.c b/c/recv_int.c new file mode 100644 index 0000000..3a828cd --- /dev/null +++ b/c/recv_int.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Recv(void *buf, int count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status) +{ + printf("This is C MPI_Recv_int\n"); + + return MPI_SUCCESS; +} diff --git a/c/send_count.c b/c/send_count.c new file mode 100644 index 0000000..f5ea08a --- /dev/null +++ b/c/send_count.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Send_count(const void *buf, MPI_Count count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm) +{ + printf("This is C MPI_Send_count\n"); + + return MPI_SUCCESS; +} diff --git a/c/send_int.c b/c/send_int.c new file mode 100644 index 0000000..13fe11a --- /dev/null +++ b/c/send_int.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#define FROOZLE_BUILDING 1 + +#include "mpi.h" + + +int MPI_Send(const void *buf, int count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm) +{ + printf("This is C MPI_Send_int\n"); + + return MPI_SUCCESS; +} diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..b55611f --- /dev/null +++ b/config/.gitignore @@ -0,0 +1,13 @@ +compile +depcomp +install-sh +libtool.m4 +ltmain.sh +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +lt~obsolete.m4 +missing +stamp-h? + +froozle_config.h* diff --git a/config/Makefile.am b/config/Makefile.am new file mode 100644 index 0000000..1a67e36 --- /dev/null +++ b/config/Makefile.am @@ -0,0 +1,5 @@ +# Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + +EXTRA_DIST = \ + froozle_config_top.h \ + froozle_config_bottom.h diff --git a/config/froozle_check_cc_c11.m4 b/config/froozle_check_cc_c11.m4 new file mode 100644 index 0000000..d8b2681 --- /dev/null +++ b/config/froozle_check_cc_c11.m4 @@ -0,0 +1,118 @@ +dnl -*- shell-script -*- +dnl +dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +dnl University Research and Technology +dnl Corporation. All rights reserved. +dnl Copyright (c) 2004-2006 The University of Tennessee and The University +dnl of Tennessee Research Foundation. All rights +dnl reserved. +dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, +dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2004-2006 The Regents of the University of California. +dnl All rights reserved. +dnl Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. +dnl Copyright (c) 2008-2019 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2015-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +AC_DEFUN([FROOZLE_CC_HELPER],[ + AC_MSG_CHECKING([$1]) + + AC_LINK_IFELSE([AC_LANG_PROGRAM([$3],[$4])], + [$2=1 + froozle_cc_helper_result=yes], + [$2=0 + froozle_cc_helper_result=no]) + + AC_MSG_RESULT([$froozle_cc_helper_result]) +]) + +dnl --------------------------------------------------------------------- + +AC_DEFUN([FROOZLE_PROG_CC_C11_HELPER],[ + froozle_prog_cc_c11_helper_CFLAGS_save=$CFLAGS + CFLAGS="$CFLAGS $1" + + FROOZLE_CC_HELPER([if $CC $1 supports C11 _Generic keyword], [froozle_prog_cc_c11_helper__Generic_available], + [[#define FOO(x) (_Generic (x, int: 1))]], [[static int x, y; y = FOO(x);]]) + + AS_IF([test $froozle_prog_cc_c11_helper__Generic_available -eq 1], + [$2], + [$3]) + + CFLAGS=$froozle_prog_cc_c11_helper_CFLAGS_save +]) + +dnl --------------------------------------------------------------------- + +AC_DEFUN([FROOZLE_CHECK_CC_C11_BACKEND],[ + AC_MSG_CHECKING([if $CC requires a flag for C11]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if __STDC_VERSION__ < 201112L +#error "Without any CLI flags, this compiler does not support C11" +#endif + ]],[])], + [froozle_cv_c11_flag_required=no], + [froozle_cv_c11_flag_required=yes]) + AC_MSG_RESULT([$froozle_cv_c11_flag_required]) + + if test "x$froozle_cv_c11_flag_required" = "xno" ; then + AC_MSG_NOTICE([verifying $CC supports C11 without a flag]) + FROOZLE_PROG_CC_C11_HELPER([], [], [froozle_cv_c11_flag_required=yes]) + fi + + if test "x$froozle_cv_c11_flag_required" = "xyes" ; then + froozle_prog_cc_c11_flags="-std=gnu11 -std=c11 -c11" + + AC_MSG_NOTICE([checking if $CC supports C11 with a flag]) + froozle_cv_c11_flag= + for flag in $(echo $froozle_prog_cc_c11_flags | tr ' ' '\n') ; do + FROOZLE_PROG_CC_C11_HELPER([$flag],[froozle_cv_c11_flag=$flag],[]) + if test "x$froozle_cv_c11_flag" != "x" ; then + CFLAGS="$CFLAGS $froozle_cv_c11_flag" + AC_MSG_NOTICE([using $flag to enable C11 support]) + froozle_cv_c11_supported=yes + break + fi + done + else + AC_MSG_NOTICE([no flag required for C11 support]) + froozle_cv_c11_supported=yes + fi + + AC_MSG_CHECKING([if compiler supports C11 at all]) + AS_IF([test "$froozle_cv_c11_supported" = "yes"], + [FROOZLE_HAVE_C11_GENERIC=1]) + AC_MSG_RESULT([$froozle_cv_c11_supported]) +]) + +dnl --------------------------------------------------------------------- + +AC_DEFUN([FROOZLE_CHECK_CC_C11],[ + AC_REQUIRE([AC_PROG_CC]) + + froozle_cv_c11_supported=no + FROOZLE_HAVE_C11_GENERIC=0 + + AC_ARG_ENABLE([c11-generic], + [AC_HELP_STRING([--disable-c11-generic], + [disable the use of C11 _Generic (i.e., pretend that this C compiler does not support _Generic)])]) + + AC_MSG_CHECKING([if want to use C11 _Generic]) + AS_IF([test "$enable_c11_generic" != "no"], + [AC_MSG_RESULT([yes]) + FROOZLE_CHECK_CC_C11_BACKEND], + [AC_MSG_RESULT([no])]) + + AC_DEFINE_UNQUOTED([FROOZLE_HAVE_C11_GENERIC], + [$FROOZLE_HAVE_C11_GENERIC], + [Whether the C compiler supports C11 _Generic or not]) +]) diff --git a/config/froozle_config_bottom.h b/config/froozle_config_bottom.h new file mode 100644 index 0000000..e69de29 diff --git a/config/froozle_config_top.h b/config/froozle_config_top.h new file mode 100644 index 0000000..e69de29 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..c5a16ef --- /dev/null +++ b/configure.ac @@ -0,0 +1,104 @@ +# Copyright (c) 2019 Cisco Systems, Inc. +# +# This is a sample / no-op 6-function MPI to demonstrate BigCount +# symbols. It is intended for the MPI tools community so that they +# can see what the impact will be for the proposed BigCount changes +# for MPI-4.0. +# + +AC_INIT([froozle-mpi], + [1.0], + [https://mpi-forum.org/]) +AC_PREREQ(2.60) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_MACRO_DIR(config) + +AC_LANG([C]) + +dnl ---------------------------------------------------------------- + +AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define 1.13.4]) +AM_SILENT_RULES([yes]) + +dnl ---------------------------------------------------------------- + +LT_INIT + +AM_ENABLE_SHARED +AM_DISABLE_STATIC + +dnl ---------------------------------------------------------------- + + +AH_TOP([/* -*- c -*- + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#ifndef FROOZLE_CONFIG_H +#define FROOZLE_CONFIG_H + +#include "froozle_config_top.h" +]) +AH_BOTTOM([ +#include "froozle_config_bottom.h" +#endif /* FROOZLE_CONFIG_H */ +]) + +AC_CONFIG_HEADER([config/froozle_config.h]) + +dnl ---------------------------------------------------------------- + +CFLAGS_save=$CFLAGS +CXXFLAGS_save=$CXXFLAGS +FCFLAGS_save=$FCFLAGS + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_FC + +# Make sure we got all 3 compilers. Because this is a demo project, +# we'll just refuse to continue if we didn't get all 3. +AS_IF([test -z "$CC" -o -z "$CXX" -o -z "$FC"], + [AC_MSG_WARN([Froozle MPI requires C, C++, and Fortran compilers.]) + AC_MSG_ERROR([Cannot continue])]) + +dnl ---------------------------------------------------------------- + +TOP_BUILDDIR=`pwd` + +cd "$srcdir" +TOP_SRCDIR=`pwd` +cd "$TOP_BUILDDIR" + +AC_SUBST(TOP_SRCDIR) +AC_SUBST(TOP_BUILDDIR) + +config="-I$TOP_SRCDIR/config -I$TOP_BUILDDIR/config" +c="-I$TOP_SRCDIR/c -I$TOP_BUILDDIR/c" +cxx="-I$TOP_SRCDIR/c -I$TOP_SRCDIR/cxx -I$TOP_BUILDDIR/cxx" +fc_mpifh="-I$TOP_SRCDIR/fortran-mpifh" + +CFLAGS="$CFLAGS_save $config $c" +CXXFLAGS="$CXXFLAGS_save $config $c $cxx" +FCFLAGS="$FCFLAGS_save $fc_mpifh" + +dnl ---------------------------------------------------------------- + +FROOZLE_CHECK_CC_C11 + +dnl ---------------------------------------------------------------- + +AC_CONFIG_HEADER([c/mpi-config.h]) + +AC_OUTPUT([ + Makefile + config/Makefile + + c/Makefile + fortran-mpifh/Makefile + fortran-usempi/Makefile + fortran-usempif08/Makefile + cxx/Makefile + + examples/Makefile +]) diff --git a/cxx/Makefile.am b/cxx/Makefile.am new file mode 100644 index 0000000..4596166 --- /dev/null +++ b/cxx/Makefile.am @@ -0,0 +1,14 @@ +# Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + +lib_LTLIBRARIES = libmpi_cxx.la + +libmpi_cxx_la_SOURCES = \ + mpi.hpp \ + allgather_int.cc \ + allgather_count.cc \ + recv_int.cc \ + recv_count.cc \ + send_int.cc \ + send_count.cc + +libmpi_cxx_la_LIBADD = $(TOP_BUILDDIR)/c/libmpi.la diff --git a/cxx/allgather_count.cc b/cxx/allgather_count.cc new file mode 100644 index 0000000..ceca174 --- /dev/null +++ b/cxx/allgather_count.cc @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Allgather(const void *sendbuf, MPI_Count sendcount, + MPI_Datatype sendtype, + void *recvbuf, MPI_Count recvcount, + MPI_Datatype recvtype, MPI_Comm comm) +{ + printf("This is C++ MPI_Allgather_count\n"); + + return MPI_SUCCESS; +} diff --git a/cxx/allgather_int.cc b/cxx/allgather_int.cc new file mode 100644 index 0000000..32a90e6 --- /dev/null +++ b/cxx/allgather_int.cc @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Allgather(const void *sendbuf, int sendcount, + MPI_Datatype sendtype, + void *recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm) +{ + printf("This is C++ MPI_Allgather_count\n"); + + return MPI_SUCCESS; +} diff --git a/cxx/mpi.hpp b/cxx/mpi.hpp new file mode 100644 index 0000000..19f3111 --- /dev/null +++ b/cxx/mpi.hpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#ifndef MPI_HPP +#define MPI_HPP + +/***************************************************************/ + +#include "mpi-config.h" +extern "C" { +#include "mpi-common.h" +} + +/***************************************************************/ + +// MPI_Count variants + +int MPI_Send(const void *buf, MPI_Count count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm); +int MPI_Recv(void *buf, MPI_Count count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status); +int MPI_Allgather(const void *sendbuf, MPI_Count sendcount, + MPI_Datatype sendtype, + void *recvbuf, MPI_Count recvcount, + MPI_Datatype recvtype, MPI_Comm comm); + +// int variants + +int MPI_Send(const void *buf, int count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm); +int MPI_Recv(void *buf, int count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status); +int MPI_Allgather(const void *sendbuf, int sendcount, + MPI_Datatype sendtype, + void *recvbuf, int recvcount, + MPI_Datatype recvtype, MPI_Comm comm); + +#endif // MPI_HPP diff --git a/cxx/recv_count.cc b/cxx/recv_count.cc new file mode 100644 index 0000000..5a668bd --- /dev/null +++ b/cxx/recv_count.cc @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Recv(void *buf, MPI_Count count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status) +{ + printf("This is C++ MPI_Recv_count\n"); + + return MPI_SUCCESS; +} diff --git a/cxx/recv_int.cc b/cxx/recv_int.cc new file mode 100644 index 0000000..c394b55 --- /dev/null +++ b/cxx/recv_int.cc @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Recv(void *buf, int count, + MPI_Datatype datatype, + int source, int tag, MPI_Comm comm, + MPI_Status *status) +{ + printf("This is C++ MPI_Recv_int\n"); + + return MPI_SUCCESS; +} diff --git a/cxx/send_count.cc b/cxx/send_count.cc new file mode 100644 index 0000000..e32fe4a --- /dev/null +++ b/cxx/send_count.cc @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Send(const void *buf, MPI_Count count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm) +{ + printf("This is C++ MPI_Send_count\n"); + + return MPI_SUCCESS; +} diff --git a/cxx/send_int.cc b/cxx/send_int.cc new file mode 100644 index 0000000..0bbe90a --- /dev/null +++ b/cxx/send_int.cc @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include "froozle_config.h" + +#include + +#include "mpi.hpp" + + +int MPI_Send(const void *buf, int count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm) +{ + printf("This is C++ MPI_Send_int\n"); + + return MPI_SUCCESS; +} diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..8d30fa2 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1,2 @@ +example_c +example_cxx diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..dd52a77 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,10 @@ +# Copyright (c) 2019 Cisco Systems. All rights reserved. + +bin_PROGRAMS = \ + example_c \ + example_cxx + +example_c_LDADD = $(TOP_BUILDDIR)/c/libmpi.la + +example_cxx_SOURCES = example_cxx.cc +example_cxx_LDADD = $(TOP_BUILDDIR)/cxx/libmpi_cxx.la diff --git a/examples/example_c.c b/examples/example_c.c new file mode 100644 index 0000000..4df6d27 --- /dev/null +++ b/examples/example_c.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include + +#include + +#define SIZE 32 + + +// +// JMS Also add example in here showing what happens with function pointers. +// + +typedef int (*foo)(const void *buf, int count, + MPI_Datatype datatype, + int dest, int tag, MPI_Comm comm); + +int main(int argc, char **argv) +{ + MPI_Init(NULL, NULL); + + int rank, size; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + printf(">> The following functions should call MPI_Send (with int params)\n"); + char buffer[SIZE]; + int i = SIZE; + MPI_Send(buffer, i, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + MPI_Send(buffer, 32, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + // Deliberately use a wrong-sized variable + short smallI = 16; + MPI_Send(buffer, smallI, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + printf(">> The following functions should call MPI_Send_count\n"); + MPI_Count bigI = 8589934592; + MPI_Send(buffer, bigI, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + // This one will generate a compiler warning (or error!) if you + // have no C11 _Generic support. + MPI_Send(buffer, 8589934592, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + MPI_Send(buffer, (MPI_Count) 32, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + MPI_Finalize(); + + return 0; +} diff --git a/examples/example_cxx.cc b/examples/example_cxx.cc new file mode 100644 index 0000000..0af6621 --- /dev/null +++ b/examples/example_cxx.cc @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Cisco Systems, Inc. All rights reserved. + */ + +#include + +#include + +#define SIZE 32 + + +int main(int argc, char **argv) +{ + MPI_Init(NULL, NULL); + + int rank, size; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + printf(">> The following functions should call MPI_Send (with int params)\n"); + char buffer[SIZE]; + int i = SIZE; + MPI_Send(buffer, i, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + MPI_Send(buffer, 32, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + // Deliberately use a wrong-sized variable + short smallI = 16; + MPI_Send(buffer, smallI, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + printf(">> The following functions should call MPI_Send (with MPI_Count params)\n"); + MPI_Count bigI = 8589934592; + MPI_Send(buffer, bigI, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + MPI_Send(buffer, 8589934592, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + MPI_Send(buffer, (MPI_Count) 32, MPI_CHAR, 0, 0, MPI_COMM_WORLD); + + MPI_Finalize(); + + return 0; +} diff --git a/fortran-mpifh/Makefile.am b/fortran-mpifh/Makefile.am new file mode 100644 index 0000000..e69de29 diff --git a/fortran-usempi/Makefile.am b/fortran-usempi/Makefile.am new file mode 100644 index 0000000..e69de29 diff --git a/fortran-usempif08/Makefile.am b/fortran-usempif08/Makefile.am new file mode 100644 index 0000000..e69de29