LAM MPI interface support.

This commit is contained in:
Vítor Santos Costa 2012-02-02 23:25:31 +00:00
parent 6eea1fe1ea
commit ab33cacf7b
9 changed files with 4023 additions and 14247 deletions

17708
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1461,6 +1461,7 @@ MPI_OBJS=
LAM_MPI_CC=${MPI_CC}
if test "$yap_cv_lam" != "no" ; then
if test "$yap_cv_lam" = "yes" ; then
dnl ubuntu support
if test -e /usr/lib/openmpi; then
CPPFLAGS="$CPPFLAGS -I/usr/lib/openmpi/include"
LDFLAGS="$LDFLAGS -L/usr/lib/openmpi/lib"

View File

@ -13,7 +13,7 @@
mpi_recv/3,
mpi_irecv/3,
mpi_wait/2,
mpi_wait_rcv/3,
mpi_wait_recv/3,
mpi_test/2,
mpi_test_recv/3,
mpi_bcast/2,

View File

@ -51,7 +51,7 @@ SOBJS=@LAMOBJS@
all: $(SOBJS)
yap_mpi.o: $(srcdir)/yap_mpi.c $(srcdir)/yap_mpi.c
$(MPI_CC) $(CFLAGS) $(MPICF) -c $(srcdir)/yap_mpi.c -o yap_mpi.o
$(CC) $(CFLAGS) $(MPICF) -c $(srcdir)/yap_mpi.c -o yap_mpi.o
prologterms2c.o: $(srcdir)/prologterms2c.c $(srcdir)/prologterms2c.h
$(CC) -c $(CFLAGS) $(srcdir)/prologterms2c.c -o prologterms2c.o
@ -59,11 +59,8 @@ prologterms2c.o: $(srcdir)/prologterms2c.c $(srcdir)/prologterms2c.h
hash.o: $(srcdir)/hash.c $(srcdir)/hash.h
$(CC) -c $(CFLAGS) $(srcdir)/hash.c -o hash.o
@DO_SECOND_LD@%.@SO@: %.o
@DO_SECOND_LD@ @SHLIB_LD@ -o $@ $< @EXTRA_LIBS_FOR_DLLS@
@DO_SECOND_LD@yap_mpi.@SO@: $(OBJS)
@DO_SECOND_LD@ @SHLIB_LD@ $(MPILDF) -o yap_mpi.@SO@ $(OBJS) @EXTRA_LIBS_FOR_DLLS@
@DO_SECOND_LD@ @SHLIB_LD@ -o yap_mpi.@SO@ $(OBJS) $(MPILDF) @EXTRA_LIBS_FOR_DLLS@
install: all
@if test "$(SOBJS)" = "no"; then echo ""; else $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR); fi

View File

@ -12,14 +12,31 @@ main :-
do_comm(0) :-
between(1,10,I),
gen_list(I,List),
NI is I*1000,
gen_list(NI,List),
mpi_send(List, 1, I),
T =.. [f|List],
mpi_send(T, 1, I),
writeln(sent:I),
fail.
do_comm(0) :-
between(1,10,I),
NI is 2.3*I,
mpi_send(NI, 1, I),
fail.
do_comm(0).
do_comm(1) :-
between(1,10,I),
mpi_recv(0, I, List),
writeln(I:List),
% writeln(I:List),
mpi_recv(0, I, T),
% writeln(I:T),
writeln(received:I),
fail.
do_comm(1) :-
between(1,10,I),
mpi_recv(0, I, T),
writeln(I:T),
fail.
do_comm(1).

View File

@ -83,11 +83,7 @@ write_msg(const char *fun,const char *file, int line,
*/
static void
expand_buffer(const size_t space ) {
char *oldblock;
// BUFFER_PTR = realloc( BUFFER_PTR, BUFFER_SIZE + space );
oldblock= BUFFER_PTR;
BUFFER_PTR = (char*)malloc( BUFFER_SIZE + space );
BUFFER_PTR = realloc( BUFFER_PTR, BUFFER_SIZE + space );
if( BUFFER_PTR == NULL ) {
YAP_Error(0,0,"Prolog2Term: Out of memory.\n");
#ifdef MPI
@ -95,11 +91,6 @@ expand_buffer(const size_t space ) {
#endif
YAP_Exit( 1 );
}
memcpy(BUFFER_PTR,oldblock,BUFFER_SIZE);
if(oldblock!=NULL)
free(oldblock);
BUFFER_SIZE+=space;
}
/*
@ -110,8 +101,9 @@ change_buffer_size(const size_t newsize) {
if ( BUFFER_SIZE>=BLOCK_SIZE && BUFFER_SIZE>newsize)
return;
if(BUFFER_PTR!=NULL)
if(BUFFER_PTR) {
free(BUFFER_PTR);
}
BUFFER_PTR = (char*)malloc(newsize);
if( BUFFER_PTR == NULL ) {
YAP_Error(0,0,"Prolog2Term: Out of memory.\n");
@ -189,23 +181,21 @@ read_term_from_stream(const int fd) {
char*
term2string(char *const ptr, size_t *size, const YAP_Term t) {
char *ret;
size_t needed_bytes = 0;
RESET_BUFFER;
do {
if (*size <= needed_bytes) {
if (needed_bytes >= BUFFER_SIZE) {
expand_buffer(BLOCK_SIZE);
}
if (*size == 0) {
BUFFER_LEN = YAP_ExportTerm( t, BUFFER_PTR, BUFFER_SIZE );// canonical
ret=BUFFER_PTR;
} else {
BUFFER_LEN = YAP_ExportTerm( t, ptr, BUFFER_SIZE );// canonical
ret=ptr;
}
} while (BUFFER_LEN <= 0);
*size = BUFFER_LEN;
fprintf(stderr,"<< ptr=%p size=%ld\n", ret, BUFFER_LEN);
if (BUFFER_LEN == 0) {
expand_buffer(BLOCK_SIZE);
}
} while (BUFFER_LEN <= 0);
return ret;
}
/*
@ -230,7 +220,6 @@ string2term(char *const ptr,const size_t *size) {
}
BUFFER_POS=0;
t = YAP_ImportTerm( BUFFER_PTR );
fprintf(stderr,">> ptr=%p size=%ld\n", ptr, *size);
if ( t==FALSE ) {
write_msg(__FUNCTION__,__FILE__,__LINE__,"FAILED string2term>>>>size:%d %d %s\n",BUFFER_SIZE,strlen(BUFFER_PTR),NULL);
exit(1);

View File

@ -34,7 +34,7 @@ Comments: This file provides a set of functions to convert a prolog term to a C
#include <stdarg.h>
/*
* Converts a term t into a string.
* The ascii representation of t is
* An internal representation of t is
* copied to ptr if it occupies less than size. Otherwise the
* necessary memory is aloccated (dyn_ptr) and the ascii
* representation of the term is copied to there.

View File

@ -411,7 +411,7 @@ mpi_isend(void) {
new_request(handle,str);
USED_BUFFER(); // informs the prologterm2c module that the buffer is now used and should not be messed
PAUSE_TIMER();
RETURN(YAP_Unify(t4,YAP_MkIntTerm(HANDLE2INT(handle))));// it should always succeed
RETURN(YAP_Unify(YAP_ARG4,YAP_MkIntTerm(HANDLE2INT(handle))));// it should always succeed
}
/*
* Blocking communication function. The message is sent immediatly.
@ -995,7 +995,7 @@ init_mpi(void) {
YAP_UserCPredicate( "mpi_recv", mpi_recv,3); // mpi_recv(?Source,?Tag,-Data).
YAP_UserCPredicate( "mpi_irecv", mpi_irecv,3); // mpi_irecv(?Source,?Tag,-Handle).
YAP_UserCPredicate( "mpi_wait", mpi_wait,2); // mpi_wait(+Handle,-Status).
YAP_UserCPredicate( "mpi_wait_rcv", mpi_wait_recv,3); // mpi_wait_recv(+Handle,-Status,-Data).
YAP_UserCPredicate( "mpi_wait_recv", mpi_wait_recv,3); // mpi_wait_recv(+Handle,-Status,-Data).
YAP_UserCPredicate( "mpi_test", mpi_test,2); // mpi_test(+Handle,-Status).
YAP_UserCPredicate( "mpi_test_rcv", mpi_test_recv,3); // mpi_test(+Handle,-Status,-Data).
YAP_UserCPredicate( "mpi_bcast", mpi_bcast,2); // mpi_bcast(Root,Term)

@ -1 +1 @@
Subproject commit 06baa8a9663d092266b174cb9a4628dbc937d253
Subproject commit 2ed717695e1d71e864f943516473cacd3021f1f0