a first take at an MPE interface

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@371 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
stasinos 2002-02-22 14:31:45 +00:00
parent 22ab6fafd4
commit dcbba128ff
9 changed files with 6986 additions and 2739 deletions

View File

@ -657,6 +657,9 @@ YapInit(yap_init_args *yap_init)
#if HAVE_MPI
InitMPI ();
#endif
#if HAVE_MPE
InitMPE ();
#endif
if (yap_init->YapPrologBootFile != NULL) {
/*

View File

@ -54,6 +54,7 @@ YAP_EXTRAS=@YAP_EXTRAS@
# for c_interface.c
#
CC=@CC@
MPI_CC=@MPI_CC@
CPPFLAGS=@CPPFLAGS@ -I. -I$(srcdir)/H -I$(srcdir)/OPTYap
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
C_INTERF_FLAGS= @C_INTERF_FLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) -I$(srcdir)/include
@ -76,7 +77,7 @@ INSTALL_PROGRAM=@INSTALL_PROGRAM@
M4GENHDRS=$(srcdir)/@M4GENHDRS@
M4GENABSMI=$(srcdir)/@M4GENABSMI@
INDENT=@INDENT@
SHELL=/bin/sh
SHELL=@SHELL@
RANLIB=@RANLIB@
AR=@AR@
srcdir=@srcdir@
@ -146,7 +147,7 @@ C_SOURCES= \
$(srcdir)/OPTYap/or.cowengine.c $(srcdir)/OPTYap/or.sbaengine.c \
$(srcdir)/OPTYap/or.scheduler.c $(srcdir)/OPTYap/or.cut.c \
$(srcdir)/OPTYap/tab.tries.c $(srcdir)/OPTYap/tab.suspend.c \
$(srcdir)/library/mpi/mpi.c
$(srcdir)/library/mpi/mpi.c $(srcdir)/library/mpi/mpe.c
PL_SOURCES= \
$(srcdir)/pl/arith.yap $(srcdir)/pl/arrays.yap $(srcdir)/pl/boot.yap \
@ -170,9 +171,10 @@ ENGINE_OBJECTS = \
cdmgr.o cmppreds.o compiler.o computils.o \
corout.o dbase.o errors.o eval.o bignum.o \
exec.o grow.o heapgc.o index.o init.o \
iopreds.o depth_bound.o mavar.o modules.o mpi.o other.o \
iopreds.o depth_bound.o mavar.o modules.o other.o \
parser.o save.o scanner.o sort.o stdpreds.o sysbits.o tracer.o \
unify.o userpreds.o utilpreds.o write.o ypsocks.o ypstdio.o
unify.o userpreds.o utilpreds.o write.o ypsocks.o ypstdio.o \
mpi.o mpe.o
C_INTERFACE_OBJECTS = \
load_foreign.o load_dl.o load_dld.o \
@ -432,8 +434,10 @@ tab.suspend.o: $(srcdir)/OPTYap/tab.suspend.c
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.suspend.c -o $@
mpi.o: $(srcdir)/library/mpi/mpi.c
$(CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpi.c -o $@
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpi.c -o $@
mpe.o: $(srcdir)/library/mpi/mpe.c
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpe.c -o $@
## CPP'ed files (for macro debugging)
@ -455,7 +459,7 @@ startup: yap $(PL_SOURCES)
echo "['$(srcdir)/pl/init.yap']. save_program(startup)." | @CROSS_SIMULATOR@ ./yap -b $(srcdir)/pl/boot.yap
yap: $(HEADERS) yap.o @YAPLIB@
$(CC) $(STANDARD_CFLAGS) $(LDFLAGS) -o yap yap.o @YAPLIB@ $(LIBS)
$(MPI_CC) $(STANDARD_CFLAGS) $(LDFLAGS) -o yap yap.o @YAPLIB@ $(LIBS)
libYap.a: $(LIB_OBJECTS)
-rm -f libYap.a

13
README
View File

@ -13,7 +13,7 @@ Yap is and for instructions on how to build it.
YAP 4.2 is known to build with many versions of gcc (<= gcc-2.7.2, >=
gcc-2.8.1, >= egcs-1.0.1, gcc-2.95.*) and on a variety of Unix'es:
SunOS 4.1, Solaris 2.*, Irix 5.2, HP-UX 10, Dec Alpha Unix, Linux 1.2
SunOS 4.1, Solaris 2.*, Irix 5.2, HP-UX 10.20, Dec Alpha Unix, Linux 1.2
and Linux 2.* (RedHat 4.0 through 5.2, Debian 2.*) in both the x86 and
alpha platforms. It has been built on Windows NT 4.0 using Cygwin from
Cygnus Solutions (see README.cygwin) and using Visual C++ 6.0.
@ -31,9 +31,9 @@ distribute these packages.
If you have a question about this software, desire to add code, found
a bug, want to request a feature, or wonder how to get further
assistance, please send e-mail to yappers@ncc.up.pt. To subscribe to
the mailing list, send a request to majordomo@ncc.up.pt with body
"subscribe yappers".
assistance, please send e-mail to yap-users@lists.sourceforge.net. To
subscribe to the mailing list or access the list archives, please see
http://lists.sourceforge.net/lists/listinfo/yap-users
Online documentation is available for Yap at:
@ -88,10 +88,11 @@ To compile YAP just do:
(7) Happy? make install
(8) "make install-info" will create the info files in the standard info directory.
(8) "make install_info" will create the info files in the standard
info directory.
(9) "make html" will create documentation in html format in the
current directory.
current directory.
In most systems you will need to be superuser in order to do "make
install" and "make info" on the standard directories.

View File

@ -12,15 +12,27 @@
#undef HAVE_LIBGMP
/* What MPI libraries are there? */
#undef HAVE_LIBMPICH
#define HAVE_LIBMPI 0
#define HAVE_LIBMPICH 0
/* Should we use MPI ? */
#if HAVE_LIBMPICH
#if HAVE_LIBMPI
#define HAVE_MPI 1
#else
#define HAVE_MPI 0
#endif
/* Is there an MPE library? */
#define HAVE_LIBMPE 0
/* Should we use MPE ? */
#if HAVE_LIBMPE && HAVE_MPI
#define HAVE_MPE 1
#else
#define HAVE_MPE 0
#endif
/* does the compiler support inline ? */
#undef inline

9410
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -69,18 +69,31 @@ AC_ARG_WITH(readline,
fi,
[yap_cv_readline=yes])
AC_ARG_WITH(mpich,
[ --with-mpich[=DIR] use MPICH library in DIR],
AC_ARG_WITH(mpi,
[ --with-mpi[=DIR] use MPI library in DIR],
if test $withval = yes; then
yap_cv_mpich=yes
yap_cv_mpi=yes
elif test $withval = no; then
yap_cv_mpich=no
yap_cv_mpi=no
else
yap_cv_mpich=$with_mpich
LDFLAGS="$LDFLAGS -L${yap_cv_mpich}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpich}/include"
yap_cv_mpi=$with_mpi
LDFLAGS="$LDFLAGS -L${yap_cv_mpi}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpi}/include"
fi,
[yap_cv_mpich=yes])
[yap_cv_mpi=yes])
AC_ARG_WITH(mpe,
[ --with-mpe[=DIR] use MPE library in DIR],
if test $withval = yes; then
yap_cv_mpe=yes
elif test $withval = no; then
yap_cv_mpe=no
else
yap_cv_mpe=$with_mpe
LDFLAGS="$LDFLAGS -L${yap_cv_mpe}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpe}/include"
fi,
[yap_cv_mpe=yes])
AC_ARG_WITH(heap-space,
[ --with-heap-space[=space] default heap size in Kbytes],
@ -216,9 +229,11 @@ dnl Checks for programs.
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_CHECK_TOOL(INDENT,indent,true)
AC_CHECK_TOOL(AR,ar,true)
AC_CHECK_TOOL(INDENT,indent,:)
AC_CHECK_TOOL(AR,ar,:)
AC_CHECK_TOOL(MPI_CC,mpicc,:)
AC_PATH_PROG(INSTALL_INFO,install-info,true,$PATH:/sbin:/usr/sbin:/usr/etc:/usr/local/sbin)
AC_PATH_PROG(SHELL,sh)
AC_SUBST(INSTALL_COMMAND)
AC_SUBST(CROSS_SIMULATOR)
@ -262,15 +277,39 @@ if test "$yap_cv_gmp" != "no"
then
AC_CHECK_LIB(gmp,main)
fi
if test "$yap_cv_mpich" != "no"
if test "$yap_cv_mpi" != "no"
then
AC_CHECK_LIB(mpich,MPI_Init)
if test "$ac_cv_lib_mpich_MPI_Init" = yes
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpi,MPI_Init)
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
#LIBS="$LIBS -lpmpich"
YAPMPILIB=YapMPI.a
else
AC_CHECK_LIB(mpich,MPI_Init)
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
LIBS="$LIBS -lpmpich"
YAPMPILIB=YapMPI.a
else
YAPMPILIB=
fi
fi
CC=${OLD_CC}
fi
if test "$yap_cv_mpe" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpe,MPE_Init_log)
CC=${OLD_CC}
fi
AC_SUBST(YAPMPILIB)
AC_PROG_CPP
if test "$cross_compiling" = "yes"
@ -755,10 +794,11 @@ fi
mkdir -p library/regex
mkdir -p library/system
mkdir -p library/mpi
mkdir -p CHR
mkdir -p CLPQR
AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile .depend library/Makefile CHR/Makefile CLPQR/Makefile)
AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile library/mpi/Makefile .depend library/Makefile CHR/Makefile CLPQR/Makefile)
make depend

View File

@ -23,20 +23,35 @@ calc( From, To, Acc, Res ) :- !,
do(0, Num) :-
!,
mpe_create_event(Ev1),
mpe_create_event(Ev2),
format( "Ev1 == ~q, Ev2 == ~q~n", [Ev1,Ev2] ),
mpe_create_state(Ev1,Ev2),
format( "1 AA~n", [] ),
mpe_log(Ev1),
format( "2 AA~n", [] ),
mpi_bcast( Num, 0 ),
format( 'Proc 0: broadcast ~q.~n', [Num] ).
format( 'Proc 0: broadcast ~q.~n', [Num] ),
mpe_log(Ev2).
do(Rank, _) :-
!,
mpe_create_event(Ev1),
mpe_create_event(Ev2),
format( "Ev1 == ~q, Ev2 == ~q~n", [Ev1,Ev2] ),
mpe_log(Ev1),
mpi_bcast( Num, 0 ),
format( 'Proc ~q: had ~q broadcast from 0.~n', [Rank, Num] ).
format( 'Proc ~q: had ~q broadcast from 0.~n', [Rank, Num] ),
mpe_log(Ev2).
%%
%% This is the entry point
%%
start(Num) :-
start(Msg) :-
mpi_open( Rank, NumProc, ProcName ),
format( 'Rank: ~q NumProc: ~q, ProcName: ~q~n', [Rank,NumProc,ProcName] ),
do( Rank, Num ),
format( 'Rank ~q finished!~n', [Rank] ).
mpe_open,
do(Rank, Msg),
format( 'Rank ~q finished!~n', [Rank] ),
mpe_close.

148
library/mpi/mpe.c Normal file
View File

@ -0,0 +1,148 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright S. Konstantopoulos and Universidade do Porto 2002 *
* *
**************************************************************************
* *
* File: mpe.c *
* Last rev: $Date: 2002-02-22 14:31:45 $ *
* mods: *
* comments: Interface to an MPE library *
* *
*************************************************************************/
#ifndef lint
static char *rcsid = "$Header: ";
#endif
#include "Yap.h"
#if HAVE_MPE
#if 0
/* for AtomEof */
#include "Heap.h"
#include "yapio.h"
#include <stdlib.h>
#include <string.h>
#endif
#include "Yatom.h"
#include <mpe.h>
STATIC_PROTO (Int p_init, (void));
STATIC_PROTO (Int p_start, (void));
STATIC_PROTO (Int p_close, (void));
STATIC_PROTO (Int p_create_event, (void));
STATIC_PROTO (Int p_create_state, (void));
STATIC_PROTO (Int p_log, (void));
/*
* Auxiliary Data and Functions
*/
/*
* C Predicates
*/
static Int
p_init() /* mpe_open */
{
int retv;
retv = MPE_Init_log();
printf( "MPE_Init_log(): %d\n", retv );
return TRUE;
}
static Int
p_start() /* mpe_start */
{
int retv;
retv = MPE_Start_log();
printf( "MPE_Start_log(): %d\n", retv );
return TRUE;
}
static Int /* mpe_close(+FileName) */
p_close()
{
int retv;
retv = MPE_Finish_log( "test.log" );
printf( "MPE_Finish_log(): %d\n", retv );
return TRUE;
}
static Int /* mpe_create_event(-Event) */
p_create_event()
{
Int event_id;
event_id = MPE_Log_get_event_number();
return unify(ARG1, MkIntegerTerm(event_id));
}
static Int /* mpe_create_state(+Event,+Event,+Text,+Colour) */
p_create_state()
{
Int start_id, end_id;
char *descr, *colour;
start_id = IntOfTerm(ARG1);
end_id = IntOfTerm(ARG2);
descr = "State";
colour = "red";
MPE_Describe_state( start_id, end_id, descr, colour );
return TRUE;
}
static Int
p_log() /* mpe_log(+Event) */
{
Int event_id;
event_id = IntOfTerm(ARG1);
MPE_Log_event( event_id, 0, "Event" );
return TRUE;
}
/*
* Init
*/
void
InitMPE(void)
{
MPE_Init_log();
InitCPred( "mpe_open", 0, p_init, SafePredFlag );
InitCPred( "mpe_start", 0, p_start, SafePredFlag );
InitCPred( "mpe_close", 0, p_close, SafePredFlag );
InitCPred( "mpe_create_event", 1, p_create_event, SafePredFlag );
InitCPred( "mpe_create_state", 2, p_create_state, SafePredFlag );
InitCPred( "mpe_log", 1, p_log, SafePredFlag );
}
#endif /* HAVE_MPE */

View File

@ -9,14 +9,14 @@
**************************************************************************
* *
* File: mpi.c *
* Last rev: $Date: 2002-02-12 17:35:41 $ *
* Last rev: $Date: 2002-02-22 14:31:45 $ *
* mods: *
* comments: Interface to an MPI library *
* *
*************************************************************************/
#ifndef lint
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.2 2002-02-12 17:35:41 stasinos Exp $";
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.3 2002-02-22 14:31:45 stasinos Exp $";
#endif
#include "Yap.h"
@ -173,13 +173,14 @@ mpi_parse(void)
static Int
p_mpi_open(void) /* mpi_open(?rank, ?num_procs, ?proc_name) */
{
Term t_rank = ARG1, t_numprocs = ARG2, t_name = ARG3;
Term t_rank = Deref(ARG1), t_numprocs = Deref(ARG2), t_procname = Deref(ARG3);
Int retv;
unify( MkIntTerm(rank), t_rank );
unify( MkIntTerm(numprocs), t_numprocs );
unify( MkAtomTerm(LookupAtom(processor_name)), t_name );
retv = unify(t_rank, MkIntTerm(rank));
retv = retv && unify(t_numprocs, MkIntTerm(numprocs));
retv = retv && unify(t_procname, MkAtomTerm(LookupAtom(processor_name)));
return TRUE;
return retv;
}
@ -280,9 +281,10 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
/* NULL-terminate the string and add the ". " termination
required by the parser. */
buf[status.count] = 0;
MPI_Get_count( &status, MPI_CHAR, &buflen );
buf[buflen] = 0;
strcat( buf, ". " );
buflen = status.count + 2;
buflen += 2;
bufptr = 0;
/* parse received string into a Prolog term */
@ -388,11 +390,11 @@ InitMPI(void)
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
MPI_Get_processor_name( processor_name, &namelen );
InitCPred( "mpi_open", 3, p_mpi_open, SafePredFlag );
InitCPred( "mpi_open", 3, p_mpi_open, /*SafePredFlag|SyncPredFlag*/ 0 );
InitCPred( "mpi_close", 0, p_mpi_close, SafePredFlag );
InitCPred( "mpi_send", 3, p_mpi_send, SafePredFlag );
InitCPred( "mpi_receive", 3, p_mpi_receive, SafePredFlag );
InitCPred( "mpi_bcast", 2, p_mpi_bcast, SafePredFlag );
InitCPred( "mpi_receive", 3, p_mpi_receive, SyncPredFlag );
InitCPred( "mpi_bcast", 2, p_mpi_bcast, SyncPredFlag );
}
#endif /* HAVE_MPI */