added the experimental mpi_reduce() and MPI_REDUCE_XXXs to awk. MPI_REDUCE_XXXs are added as a global variable. it'd be more efficient to turn MPI_REUDCE_XXXs to constants. this may need something like qse_awk_addconst(). consider adding this new API function

This commit is contained in:
hyung-hwan 2012-08-12 06:09:16 +00:00
parent 5e5ed8b3f6
commit b795f0d53e
9 changed files with 217 additions and 109 deletions

View File

@ -20,15 +20,15 @@ endif
#####################################################################3
if HAVE_C_MPI
bin_PROGRAMS += qseawkp
bin_PROGRAMS += qseawkmp
qseawkp_SOURCES = mpi.c
qseawkp_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
qseawkp_LDFLAGS = -L../../lib/awk -L../../lib/cmn -L$(libdir) $(MPI_CLDFLAGS)
qseawkp_LDADD = -lqseawkp -lqseawk -lqsecmn $(LIBM)
qseawkmp_SOURCES = mpi.c
qseawkmp_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
qseawkmp_LDFLAGS = -L../../lib/awk -L../../lib/cmn -L$(libdir) $(MPI_CLDFLAGS)
qseawkmp_LDADD = -lqseawkmp -lqseawk -lqsecmn $(LIBM)
if WIN32
qseawkp_LDADD += $(UNICOWS_LIBS)
qseawkmp_LDADD += $(UNICOWS_LIBS)
endif
endif

View File

@ -38,7 +38,7 @@ bin_PROGRAMS = qseawk$(EXEEXT) $(am__EXEEXT_1)
@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
#####################################################################3
@HAVE_C_MPI_TRUE@am__append_2 = qseawkp
@HAVE_C_MPI_TRUE@am__append_2 = qseawkmp
@HAVE_C_MPI_TRUE@@WIN32_TRUE@am__append_3 = $(UNICOWS_LIBS)
subdir = cmd/awk
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@ -54,7 +54,7 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_C_MPI_TRUE@am__EXEEXT_1 = qseawkp$(EXEEXT)
@HAVE_C_MPI_TRUE@am__EXEEXT_1 = qseawkmp$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_qseawk_OBJECTS = awk.$(OBJEXT)
@ -65,15 +65,15 @@ qseawk_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
qseawk_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(qseawk_LDFLAGS) \
$(LDFLAGS) -o $@
am__qseawkp_SOURCES_DIST = mpi.c
@HAVE_C_MPI_TRUE@am_qseawkp_OBJECTS = qseawkp-mpi.$(OBJEXT)
qseawkp_OBJECTS = $(am_qseawkp_OBJECTS)
am__qseawkmp_SOURCES_DIST = mpi.c
@HAVE_C_MPI_TRUE@am_qseawkmp_OBJECTS = qseawkmp-mpi.$(OBJEXT)
qseawkmp_OBJECTS = $(am_qseawkmp_OBJECTS)
@HAVE_C_MPI_TRUE@@WIN32_TRUE@am__DEPENDENCIES_3 = \
@HAVE_C_MPI_TRUE@@WIN32_TRUE@ $(am__DEPENDENCIES_1)
@HAVE_C_MPI_TRUE@qseawkp_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@HAVE_C_MPI_TRUE@qseawkmp_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@HAVE_C_MPI_TRUE@ $(am__DEPENDENCIES_3)
qseawkp_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(qseawkp_LDFLAGS) \
qseawkmp_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(qseawkmp_LDFLAGS) \
$(LDFLAGS) -o $@
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
@ -88,8 +88,8 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(qseawk_SOURCES) $(qseawkp_SOURCES)
DIST_SOURCES = $(qseawk_SOURCES) $(am__qseawkp_SOURCES_DIST)
SOURCES = $(qseawk_SOURCES) $(qseawkmp_SOURCES)
DIST_SOURCES = $(qseawk_SOURCES) $(am__qseawkmp_SOURCES_DIST)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -251,10 +251,10 @@ AM_CPPFLAGS = \
qseawk_SOURCES = awk.c
qseawk_LDFLAGS = -L../../lib/awk -L../../lib/cmn -L$(libdir)
qseawk_LDADD = -lqseawk -lqsecmn $(LIBM) $(am__append_1)
@HAVE_C_MPI_TRUE@qseawkp_SOURCES = mpi.c
@HAVE_C_MPI_TRUE@qseawkp_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
@HAVE_C_MPI_TRUE@qseawkp_LDFLAGS = -L../../lib/awk -L../../lib/cmn -L$(libdir) $(MPI_CLDFLAGS)
@HAVE_C_MPI_TRUE@qseawkp_LDADD = -lqseawkp -lqseawk -lqsecmn $(LIBM) \
@HAVE_C_MPI_TRUE@qseawkmp_SOURCES = mpi.c
@HAVE_C_MPI_TRUE@qseawkmp_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
@HAVE_C_MPI_TRUE@qseawkmp_LDFLAGS = -L../../lib/awk -L../../lib/cmn -L$(libdir) $(MPI_CLDFLAGS)
@HAVE_C_MPI_TRUE@qseawkmp_LDADD = -lqseawkmp -lqseawk -lqsecmn $(LIBM) \
@HAVE_C_MPI_TRUE@ $(am__append_3)
all: all-am
@ -336,9 +336,9 @@ clean-binPROGRAMS:
qseawk$(EXEEXT): $(qseawk_OBJECTS) $(qseawk_DEPENDENCIES)
@rm -f qseawk$(EXEEXT)
$(qseawk_LINK) $(qseawk_OBJECTS) $(qseawk_LDADD) $(LIBS)
qseawkp$(EXEEXT): $(qseawkp_OBJECTS) $(qseawkp_DEPENDENCIES)
@rm -f qseawkp$(EXEEXT)
$(qseawkp_LINK) $(qseawkp_OBJECTS) $(qseawkp_LDADD) $(LIBS)
qseawkmp$(EXEEXT): $(qseawkmp_OBJECTS) $(qseawkmp_DEPENDENCIES)
@rm -f qseawkmp$(EXEEXT)
$(qseawkmp_LINK) $(qseawkmp_OBJECTS) $(qseawkmp_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -347,7 +347,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qseawkp-mpi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qseawkmp-mpi.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@ -370,19 +370,19 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
qseawkp-mpi.o: mpi.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT qseawkp-mpi.o -MD -MP -MF $(DEPDIR)/qseawkp-mpi.Tpo -c -o qseawkp-mpi.o `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/qseawkp-mpi.Tpo $(DEPDIR)/qseawkp-mpi.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='qseawkp-mpi.o' libtool=no @AMDEPBACKSLASH@
qseawkmp-mpi.o: mpi.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT qseawkmp-mpi.o -MD -MP -MF $(DEPDIR)/qseawkmp-mpi.Tpo -c -o qseawkmp-mpi.o `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/qseawkmp-mpi.Tpo $(DEPDIR)/qseawkmp-mpi.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='qseawkmp-mpi.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qseawkp-mpi.o `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qseawkmp-mpi.o `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
qseawkp-mpi.obj: mpi.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT qseawkp-mpi.obj -MD -MP -MF $(DEPDIR)/qseawkp-mpi.Tpo -c -o qseawkp-mpi.obj `if test -f 'mpi.c'; then $(CYGPATH_W) 'mpi.c'; else $(CYGPATH_W) '$(srcdir)/mpi.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/qseawkp-mpi.Tpo $(DEPDIR)/qseawkp-mpi.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='qseawkp-mpi.obj' libtool=no @AMDEPBACKSLASH@
qseawkmp-mpi.obj: mpi.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT qseawkmp-mpi.obj -MD -MP -MF $(DEPDIR)/qseawkmp-mpi.Tpo -c -o qseawkmp-mpi.obj `if test -f 'mpi.c'; then $(CYGPATH_W) 'mpi.c'; else $(CYGPATH_W) '$(srcdir)/mpi.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/qseawkmp-mpi.Tpo $(DEPDIR)/qseawkmp-mpi.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='qseawkmp-mpi.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qseawkp-mpi.obj `if test -f 'mpi.c'; then $(CYGPATH_W) 'mpi.c'; else $(CYGPATH_W) '$(srcdir)/mpi.c'; fi`
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(qseawkmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o qseawkmp-mpi.obj `if test -f 'mpi.c'; then $(CYGPATH_W) 'mpi.c'; else $(CYGPATH_W) '$(srcdir)/mpi.c'; fi`
mostlyclean-libtool:
-rm -f *.lo

View File

@ -1102,13 +1102,24 @@ int qse_main (int argc, qse_achar_t* argv[])
#endif
#if defined(ENABLE_MPI)
MPI_Init (&argc, &argv);
/* I didn't manage to find a good way to change the
* default error handler to MPI_ERRORS_RETURN.
* so MPI_Init() will simply abort the program if it fails */
if (MPI_Init (&argc, &argv) != MPI_SUCCESS)
{
print_error (QSE_T("Failed to initialize MPI\n"));
ret = -1;
goto oops;
}
MPI_Comm_set_errhandler (MPI_COMM_WORLD, MPI_ERRORS_RETURN);
#endif
ret = qse_runmain (argc, argv, awk_main);
#if defined(ENABLE_MPI)
MPI_Finalize ();
oops:
#endif
#if defined(_WIN32)

View File

@ -18,9 +18,9 @@ libqseawkxx_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
endif
if HAVE_C_MPI
lib_LTLIBRARIES += libqseawkp.la
libqseawkp_la_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
libqseawkp_la_SOURCES = mpi.c
libqseawkp_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined $(MPI_CLDFLAGS)
libqseawkp_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
lib_LTLIBRARIES += libqseawkmp.la
libqseawkmp_la_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
libqseawkmp_la_SOURCES = mpi.c
libqseawkmp_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined $(MPI_CLDFLAGS)
libqseawkmp_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
endif

View File

@ -35,7 +35,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@ENABLE_CXX_TRUE@am__append_1 = libqseawkxx.la
@HAVE_C_MPI_TRUE@am__append_2 = libqseawkp.la
@HAVE_C_MPI_TRUE@am__append_2 = libqseawkmp.la
subdir = lib/awk
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -81,14 +81,14 @@ libqseawk_la_OBJECTS = $(am_libqseawk_la_OBJECTS)
libqseawk_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libqseawk_la_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_C_MPI_TRUE@libqseawkp_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__libqseawkp_la_SOURCES_DIST = mpi.c
@HAVE_C_MPI_TRUE@am_libqseawkp_la_OBJECTS = libqseawkp_la-mpi.lo
libqseawkp_la_OBJECTS = $(am_libqseawkp_la_OBJECTS)
libqseawkp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
@HAVE_C_MPI_TRUE@libqseawkmp_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__libqseawkmp_la_SOURCES_DIST = mpi.c
@HAVE_C_MPI_TRUE@am_libqseawkmp_la_OBJECTS = libqseawkmp_la-mpi.lo
libqseawkmp_la_OBJECTS = $(am_libqseawkmp_la_OBJECTS)
libqseawkmp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libqseawkp_la_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_C_MPI_TRUE@am_libqseawkp_la_rpath = -rpath $(libdir)
$(libqseawkmp_la_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_C_MPI_TRUE@am_libqseawkmp_la_rpath = -rpath $(libdir)
@ENABLE_CXX_TRUE@libqseawkxx_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__libqseawkxx_la_SOURCES_DIST = Awk.cpp StdAwk.cpp
@ENABLE_CXX_TRUE@am_libqseawkxx_la_OBJECTS = Awk.lo StdAwk.lo
@ -119,10 +119,10 @@ CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libqseawk_la_SOURCES) $(libqseawkp_la_SOURCES) \
SOURCES = $(libqseawk_la_SOURCES) $(libqseawkmp_la_SOURCES) \
$(libqseawkxx_la_SOURCES)
DIST_SOURCES = $(libqseawk_la_SOURCES) \
$(am__libqseawkp_la_SOURCES_DIST) \
$(am__libqseawkmp_la_SOURCES_DIST) \
$(am__libqseawkxx_la_SOURCES_DIST)
ETAGS = etags
CTAGS = ctags
@ -289,10 +289,10 @@ libqseawk_la_LIBADD = -lqsecmn $(LIBM)
@ENABLE_CXX_TRUE@libqseawkxx_la_SOURCES = Awk.cpp StdAwk.cpp
@ENABLE_CXX_TRUE@libqseawkxx_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined
@ENABLE_CXX_TRUE@libqseawkxx_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
@HAVE_C_MPI_TRUE@libqseawkp_la_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
@HAVE_C_MPI_TRUE@libqseawkp_la_SOURCES = mpi.c
@HAVE_C_MPI_TRUE@libqseawkp_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined $(MPI_CLDFLAGS)
@HAVE_C_MPI_TRUE@libqseawkp_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
@HAVE_C_MPI_TRUE@libqseawkmp_la_CPPFLAGS = $(AM_CPPFLAGS) $(MPI_CFLAGS)
@HAVE_C_MPI_TRUE@libqseawkmp_la_SOURCES = mpi.c
@HAVE_C_MPI_TRUE@libqseawkmp_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined $(MPI_CLDFLAGS)
@HAVE_C_MPI_TRUE@libqseawkmp_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
all: all-am
.SUFFIXES:
@ -360,8 +360,8 @@ clean-libLTLIBRARIES:
done
libqseawk.la: $(libqseawk_la_OBJECTS) $(libqseawk_la_DEPENDENCIES)
$(libqseawk_la_LINK) -rpath $(libdir) $(libqseawk_la_OBJECTS) $(libqseawk_la_LIBADD) $(LIBS)
libqseawkp.la: $(libqseawkp_la_OBJECTS) $(libqseawkp_la_DEPENDENCIES)
$(libqseawkp_la_LINK) $(am_libqseawkp_la_rpath) $(libqseawkp_la_OBJECTS) $(libqseawkp_la_LIBADD) $(LIBS)
libqseawkmp.la: $(libqseawkmp_la_OBJECTS) $(libqseawkmp_la_DEPENDENCIES)
$(libqseawkmp_la_LINK) $(am_libqseawkmp_la_rpath) $(libqseawkmp_la_OBJECTS) $(libqseawkmp_la_LIBADD) $(LIBS)
libqseawkxx.la: $(libqseawkxx_la_OBJECTS) $(libqseawkxx_la_DEPENDENCIES)
$(libqseawkxx_la_LINK) $(am_libqseawkxx_la_rpath) $(libqseawkxx_la_OBJECTS) $(libqseawkxx_la_LIBADD) $(LIBS)
@ -376,7 +376,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawkp_la-mpi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqseawkmp_la-mpi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rec.Plo@am__quote@
@ -407,12 +407,12 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
libqseawkp_la-mpi.lo: mpi.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawkp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawkp_la-mpi.lo -MD -MP -MF $(DEPDIR)/libqseawkp_la-mpi.Tpo -c -o libqseawkp_la-mpi.lo `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libqseawkp_la-mpi.Tpo $(DEPDIR)/libqseawkp_la-mpi.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='libqseawkp_la-mpi.lo' libtool=yes @AMDEPBACKSLASH@
libqseawkmp_la-mpi.lo: mpi.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawkmp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libqseawkmp_la-mpi.lo -MD -MP -MF $(DEPDIR)/libqseawkmp_la-mpi.Tpo -c -o libqseawkmp_la-mpi.lo `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libqseawkmp_la-mpi.Tpo $(DEPDIR)/libqseawkmp_la-mpi.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpi.c' object='libqseawkmp_la-mpi.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawkp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawkp_la-mpi.lo `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libqseawkmp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libqseawkmp_la-mpi.lo `test -f 'mpi.c' || echo '$(srcdir)/'`mpi.c
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<

View File

@ -149,8 +149,8 @@ int StdAwk::open ()
qse_ntime_t now;
if (qse_gettime(&now) == -1) this->seed = 0;
else this->seed = (unsigned int)now;
this->seed = (qse_gettime(&now) <= -1)? 0u: (unsigned int)now;
this->seed += (qse_uintptr_t)&now;
::srand (this->seed);
this->cmgrtab_inited = false;
@ -409,19 +409,20 @@ int StdAwk::srand (Run& run, Value& ret, const Value* args, size_t nargs,
{
unsigned int prevSeed = this->seed;
if (nargs == 0)
if (nargs <= 0)
{
qse_ntime_t now;
if (qse_gettime (&now) == -1)
this->seed = (unsigned int)now;
else this->seed >>= 1;
this->seed = (qse_gettime (&now) <= -1)?
(this->seed >> 1): (unsigned int)now;
this->seed += (qse_uintptr_t)&now;
}
else
{
this->seed = (unsigned int)args[0].toInt();
}
::srand (this->seed);
return ret.setInt ((long_t)prevSeed);
}

View File

@ -26,8 +26,7 @@ typedef struct xtn_t xtn_t;
struct xtn_t
{
int gbl_mpi_rank;
int gbl_mpi_size;
int gbl_mpi[8];
};
typedef struct rxtn_t rxtn_t;
@ -41,6 +40,8 @@ qse_awk_t* qse_awk_openmpi (qse_size_t xtnsize)
return qse_awk_openmpiwithmmgr (QSE_MMGR_GETDFL(), xtnsize);
}
static int add_functions (qse_awk_t* awk);
qse_awk_t* qse_awk_openmpiwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
{
qse_awk_t* awk;
@ -51,13 +52,31 @@ qse_awk_t* qse_awk_openmpiwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
if (awk)
{
xtn_t* xtn;
qse_size_t i;
xtn = (xtn_t*) qse_awk_getxtnstd (awk);
QSE_MEMSET (xtn, 0, QSE_SIZEOF(*xtn));
xtn->gbl_mpi_rank = qse_awk_addgbl (awk, QSE_T("MPI_RANK"), 8);
xtn->gbl_mpi_size = qse_awk_addgbl (awk, QSE_T("MPI_SIZE"), 8);
if (xtn->gbl_mpi_rank <= -1 || xtn->gbl_mpi_size <= -1)
xtn->gbl_mpi[0] = qse_awk_addgbl (awk, QSE_T("MPI_RANK"), 8);
xtn->gbl_mpi[1] = qse_awk_addgbl (awk, QSE_T("MPI_SIZE"), 8);
xtn->gbl_mpi[2] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_MIN"), 14);
xtn->gbl_mpi[3] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_MAX"), 14);
xtn->gbl_mpi[4] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_SUM"), 14);
xtn->gbl_mpi[5] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_PROD"), 15);
xtn->gbl_mpi[6] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_LAND"), 15);
xtn->gbl_mpi[7] = qse_awk_addgbl (awk, QSE_T("MPI_REDUCE_LOR"), 14);
for (i = 0; i < QSE_COUNTOF(xtn->gbl_mpi); i++)
{
if (xtn->gbl_mpi[i] <= -1)
{
qse_awk_close (awk);
return QSE_NULL;
}
}
if (add_functions (awk) <= -1)
{
qse_awk_close (awk);
return QSE_NULL;
@ -92,21 +111,48 @@ qse_awk_rtx_t* qse_awk_rtx_openmpi (
awk, QSE_SIZEOF(rxtn_t) + xtnsize, id, icf, ocf, cmgr);
if (rtx)
{
int rank, size;
xtn_t* xtn;
rxtn_t* rxtn;
qse_awk_val_t* v_tmp;
qse_size_t i;
xtn = (xtn_t*) qse_awk_getxtnstd (awk);
rxtn = (rxtn_t*) qse_awk_rtx_getxtnstd (rtx);
QSE_MEMSET (rxtn, 0, QSE_SIZEOF(*rxtn));
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
MPI_Comm_size (MPI_COMM_WORLD, &size);
/* set the value of some MPI constants */
for (i = 0; i < QSE_COUNTOF(xtn->gbl_mpi); i++)
{
int iv;
qse_long_t lv;
qse_awk_val_t* v_tmp;
v_tmp = qse_awk_rtx_makeintval (rtx, rank);
switch (i)
{
case 0: /* MPI_RANK */
if (MPI_Comm_rank (MPI_COMM_WORLD, &iv) != MPI_SUCCESS)
{
qse_awk_rtx_close (rtx);
return QSE_NULL;
}
lv = iv;
break;
case 1: /* MPI_SIZE */
if (MPI_Comm_size (MPI_COMM_WORLD, &iv) != MPI_SUCCESS)
{
qse_awk_rtx_close (rtx);
return QSE_NULL;
}
lv = iv;
break;
default: /* MPI_REDUCE_XXXX */
lv = i - 2;
break;
}
v_tmp = qse_awk_rtx_makeintval (rtx, lv);
if (v_tmp == QSE_NULL)
{
qse_awk_rtx_close (rtx);
@ -114,19 +160,9 @@ qse_awk_rtx_t* qse_awk_rtx_openmpi (
}
qse_awk_rtx_refupval (rtx, v_tmp);
qse_awk_rtx_setgbl (rtx, xtn->gbl_mpi_rank, v_tmp);
qse_awk_rtx_setgbl (rtx, xtn->gbl_mpi[i], v_tmp);
qse_awk_rtx_refdownval (rtx, v_tmp);
v_tmp = qse_awk_rtx_makeintval (rtx, size);
if (v_tmp == QSE_NULL)
{
qse_awk_rtx_close (rtx);
return QSE_NULL;
}
qse_awk_rtx_refupval (rtx, v_tmp);
qse_awk_rtx_setgbl (rtx, xtn->gbl_mpi_size, v_tmp);
qse_awk_rtx_refdownval (rtx, v_tmp);
}
return rtx;
@ -143,3 +179,63 @@ qse_cmgr_t* qse_awk_rtx_getcmgrmpi (
return qse_awk_rtx_getcmgrstd (rtx, ioname);
}
static int fnc_reduce (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* tmp, * a0, * a1;
qse_long_t opidx, lv;
qse_flt_t rv;
int ret = 0, n;
static MPI_Op optab[] =
{
MPI_MIN,
MPI_MAX,
MPI_SUM,
MPI_PROD,
MPI_LAND,
MPI_LOR
};
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs == 2);
a0 = qse_awk_rtx_getarg (rtx, 0);
a1 = qse_awk_rtx_getarg (rtx, 1);
if (qse_awk_rtx_valtolong (rtx, a1, &opidx) <= -1 ||
(opidx < 0 || opidx >= QSE_COUNTOF(optab)) ||
(n = qse_awk_rtx_valtonum (rtx, a0, &lv, &rv)) <= -1) return -1;
/* TODO: determine it to be MPI_LONG or MPI_INT, OR MPI_LONG_LONG_INT depending on the size of qse_long_t */
/* TODO: how to tell normal -1 from the soft failure??? */
if (n == 0)
{
qse_long_t lout;
if (MPI_Allreduce (&lv, &lout, 1, MPI_LONG_LONG_INT, optab[opidx], MPI_COMM_WORLD) != MPI_SUCCESS) goto softfail;
tmp = qse_awk_rtx_makeintval (rtx, lout);
}
else
{
qse_flt_t fout;
if (MPI_Allreduce (&rv, &fout, 1, MPI_LONG_DOUBLE, optab[opidx], MPI_COMM_WORLD) != MPI_SUCCESS) goto softfail;
tmp = qse_awk_rtx_makefltval (rtx, fout);
}
if (tmp == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, tmp);
return 0;
softfail:
tmp = qse_awk_rtx_makeintval (rtx, (qse_long_t)-1);
if (tmp == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, tmp);
return 0;
}
static int add_functions (qse_awk_t* awk)
{
if (qse_awk_addfnc (awk, QSE_T("mpi_reduce"), 10, 0, 2, 2, QSE_NULL, fnc_reduce) == QSE_NULL) return -1;
return 0;
}

View File

@ -1921,8 +1921,8 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
qse_awk_rtx_pushrcb (rtx, &rcb);
if (qse_gettime (&now) <= -1) rxtn->seed = 0;
else rxtn->seed = (unsigned int) now;
rxtn->seed = (qse_gettime (&now) <= -1)? 0u: (unsigned int)now;
rxtn->seed += (qse_uintptr_t)&now;
srand (rxtn->seed);
rxtn->c.in.files = icf;
@ -2004,20 +2004,20 @@ static int fnc_srand (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
prev = rxtn->seed;
if (nargs == 1)
if (nargs <= 0)
{
qse_ntime_t now;
rxtn->seed = (qse_gettime (&now) <= -1)?
(rxtn->seed >> 1): (unsigned int)now;
rxtn->seed += (qse_uintptr_t)&now;
}
else
{
a0 = qse_awk_rtx_getarg (rtx, 0);
n = qse_awk_rtx_valtolong (rtx, a0, &lv);
if (n <= -1) return -1;
rxtn->seed = lv;
}
else
{
qse_ntime_t now;
if (qse_gettime(&now) <= -1) rxtn->seed >>= 1;
else rxtn->seed = (unsigned int)now;
}
srand (rxtn->seed);

View File

@ -23,7 +23,7 @@
/* Park-Miller "minimal standard" 31 bit
* pseudo-random number generator, implemented
* with David G. Carta's optimisation: with
* 32 bit math and wihtout division.
* 32 bit math and without division.
*/
qse_uint32_t qse_rand31 (qse_uint32_t seed)
{