lam support.

This commit is contained in:
Vítor Santos Costa 2012-02-02 09:58:05 +00:00
parent dddf5bce80
commit 4e6cc28cd3
9 changed files with 14417 additions and 4140 deletions

View File

@ -554,8 +554,8 @@ X_API int STD_PROTO(YAP_NewOpaqueType,(void *));
X_API Term STD_PROTO(YAP_NewOpaqueObject,(int, size_t));
X_API void *STD_PROTO(YAP_OpaqueObjectFromTerm,(Term));
X_API int STD_PROTO(YAP_Argv,(char *** argvp));
X_API YAP_tag_t STD_PROTO(YAP_TagOfTerm,(Term));
X_API int STD_PROTO(YAP_ExportTerm,(Term, char *, size_t));
X_API YAP_tag_t STD_PROTO(YAP_TagOfTerm,(Term));
X_API size_t STD_PROTO(YAP_ExportTerm,(Term, char *, size_t));
X_API Term STD_PROTO(YAP_ImportTerm,(char *));
static int
@ -3006,9 +3006,6 @@ YAP_Init(YAP_init_args *yap_init)
{ BACKUP_MACHINE_REGS();
Yap_InitYaamRegs();
#if HAVE_MPI
Yap_InitMPI ();
#endif
#if HAVE_MPE
Yap_InitMPE ();
#endif
@ -3989,8 +3986,10 @@ YAP_IsNumberedVariable(Term t) {
IsIntegerTerm(ArgOfTerm(1,t));
}
X_API int
X_API size_t
YAP_ExportTerm(Term inp, char * buf, size_t len) {
if (!len)
return 0;
return Yap_ExportTerm(inp, buf, len);
}

View File

@ -1239,15 +1239,14 @@ export_term_to_buffer(Term inpt, char *buf, char *bptr, CELL *t0 , CELL *tf, siz
}
static int
static size_t
export_complex_term(Term tf, CELL *pt0, CELL *pt0_end, char * buf, size_t len0, int newattvs, CELL *ptf, CELL *HLow USES_REGS)
{
struct cp_frame *to_visit0, *to_visit = (struct cp_frame *)Yap_PreAllocCodeSpace();
CELL *HB0 = HB;
tr_fr_ptr TR0 = TR;
int ground = TRUE;
char *bptr = buf+ 3*sizeof(CELL);
char *bptr = buf+ 3*sizeof(CELL), *bptr_end;
size_t len = len0;
HB = HLow;
@ -1505,11 +1504,11 @@ trail_overflow:
return -3;
}
static int
static size_t
ExportTerm(Term inp, char * buf, size_t len, UInt arity, int newattvs USES_REGS) {
Term t = Deref(inp);
tr_fr_ptr TR0 = TR;
int res;
size_t res;
CELL *Hi;
restart:
@ -1523,7 +1522,7 @@ ExportTerm(Term inp, char * buf, size_t len, UInt arity, int newattvs USES_REGS)
return res;
}
int
size_t
Yap_ExportTerm(Term inp, char * buf, size_t len) {
CACHE_REGS
return ExportTerm(inp, buf, len, 0, TRUE PASS_REGS);
@ -1571,17 +1570,20 @@ static CELL *
import_arg(CELL *hp, char *abase, CELL *amax)
{
Term t = *hp;
fprintf(stderr,"t = %lx\n", t);
if (IsVarTerm(t)) {
hp[0] = (CELL)ShiftPtr(t, abase);
} else if (IsAtomTerm(t)) {
hp[0] = MkAtomTerm(AddAtom(AtomOfTerm(t)));
} else if (IsPairTerm(t)) {
fprintf(stderr,"amax = %p newp=%p\n", amax, RepPair(t));
CELL *newp = ShiftPtr((CELL)RepPair(t), abase);
hp[0] = AbsPair(newp);
if (newp > amax) {
amax = import_pair(newp, abase, newp);
}
} else {
} else if (IsApplTerm(t)) {
fprintf(stderr,"amax = %p newp=%p\n", amax, RepAppl(t));
CELL *newp = ShiftPtr((CELL)RepAppl(t), abase);
hp[0] = AbsAppl(newp);
if (newp > amax) {
@ -3472,7 +3474,6 @@ hash_complex_term(register CELL *pt0,
deref_body(d0, ptd0, hash_complex_unk, hash_complex_nvar);
fprintf(stderr,"found variable\n");
if (!variant)
return NULL;
else

View File

@ -389,7 +389,7 @@ void STD_PROTO(Yap_InitUserBacks,(void));
/* utilpreds.c */
Term STD_PROTO(Yap_CopyTerm,(Term));
int STD_PROTO(Yap_Variant,(Term, Term));
int STD_PROTO(Yap_ExportTerm,(Term, char *, size_t));
size_t STD_PROTO(Yap_ExportTerm,(Term, char *, size_t));
Term STD_PROTO(Yap_ImportTerm,(char *));
int STD_PROTO(Yap_IsListTerm,(Term));
Term STD_PROTO(Yap_CopyTermNoShare,(Term));

18395
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -389,7 +389,7 @@ AC_ARG_WITH(lam,
yap_cv_lam=no
else
yap_cv_lam=$with_lam
LDFLAGS="$LDFLAGS -L${yap_cv_lam}/lib/lam"
LDFLAGS="$LDFLAGS -L${yap_cv_lam}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_lam}/include"
fi,
[yap_cv_lam=yes])
@ -1457,73 +1457,76 @@ if test "$tabling" = "yes"
fi
dnl LAM/MPI interface
MPI_OBJS=
LAM_MPI_CC=${MPI_CC}
if test "$yap_cv_lam" = "yes" ; then
if test -e /usr/lib/openmpi; then
if test "$yap_cv_lam" != "no" ; then
if test "$yap_cv_lam" = "yes" ; then
if test -e /usr/lib/openmpi; then
CPPFLAGS="$CPPFLAGS -I/usr/lib/openmpi/include"
LDFLAGS="$LDFLAGS -L/usr/lib/openmpi/lib"
fi
fi
if test "$yap_cv_lam" != "no" ; then
fi
else
LAM_MPI_CC="$yap_cv_lam"/bin/mpicc
MPI_CC="$yap_cv_lam"/bin/mpicc
CPPFLAGS="$CPPFLAGS -I ${yap_cv_lam}/include"
LDFLAGS="$LDFLAGS -L${yap_cv_lam}/lib"
fi
OLD_CC=${CC}
CC=${LAM_MPI_CC}
AC_CHECK_HEADER(mpi.h, LAMOBJS=yap_mpi."$SO", LAMOBJS="")
AC_CHECK_HEADER(mpi.h)
CC=${OLD_CC}
fi
MPI_OBJS=
if test "$yap_cv_mpi" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_HEADERS(mpi.h)
AC_CHECK_LIB(mpi,MPI_Init,
[LAMOBJS=yap_mpi."$SO"
AC_DEFINE(HAVE_LIBMPI, 1)],
[LAMOBJS=""
AC_DEFINE(HAVE_LIBMPI, 0)])
CC=${OLD_CC}
dnl use mpich library
elif test "$yap_cv_mpi" != "no"; then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpi,MPI_Init,
[AC_DEFINE(HAVE_LIBMPI, 1)],
[AC_DEFINE(HAVE_LIBMPI, 0)])
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
AC_CHECK_LIB(mpich,MPI_Init,
[AC_DEFINE(HAVE_LIBMPICH, 1)],
[AC_DEFINE(HAVE_LIBMPICH, 0)])
if test "$ac_cv_lib_mpich_MPI_Init" = yes
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
AC_CHECK_LIB(mpich,MPI_Init,
[AC_DEFINE(HAVE_LIBMPICH, 1)],
[AC_DEFINE(HAVE_LIBMPICH, 0)])
if test "$ac_cv_lib_mpich_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
#YAPMPILIB=
MPI_CC=${CC}
fi
fi
fi
AC_CHECK_HEADERS(mpi.h)
CC=${OLD_CC}
else
# MPI_CC=${MPI_CC}
MPI_CC=${CC}
fi
MPI_LIBS=
if test "$yap_cv_mpi" != "no" -a "$yap_cv_mpe" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpe,MPE_Init_log,
AC_CHECK_HEADERS(mpi.h)
CC=${OLD_CC}
MPI_LIBS=
if test "$yap_cv_mpe" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpe,MPE_Init_log,
[AC_DEFINE(HAVE_LIBMPE, 1)],
[AC_DEFINE(HAVE_LIBMPE, 0)])
if test "$ac_cv_lib_mpe_MPE_Init_log" = yes
then
if test "$ac_cv_lib_mpe_MPE_Init_log" = yes
then
MPI_LIBS="-lmpe"
MPI_OBJS="$MPI_OBJS mpe.o"
fi
AC_CHECK_HEADERS(mpe.h)
CC=${OLD_CC}
fi
AC_CHECK_HEADERS(mpe.h)
CC=${OLD_CC}
fi
else
MPI_CC=${CC}
fi
if test ! "$yap_cv_cplint" = "no"
then
if test ! "$yap_cv_cplint" = "yes"

View File

@ -589,7 +589,7 @@ extern X_API int *PROTO(YAP_Argv,(char ***));
extern X_API YAP_tag_t PROTO(YAP_TagOfTerm,(YAP_Term));
extern X_API int PROTO(YAP_ExportTerm,(YAP_Term, char *, size_t));
extern X_API size_t PROTO(YAP_ExportTerm,(YAP_Term, char *, size_t));
extern X_API YAP_Term PROTO(YAP_ImportTerm,(char *));

View File

@ -23,7 +23,7 @@ YAPLIBDIR=@libdir@/Yap
#
#
CC=@CC@
MPI_CC=mpicc
MPI_CC=@LAM_MPI_CC@
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
#
#

View File

@ -187,23 +187,25 @@ read_term_from_stream(const int fd) {
* copied to ptr if it occupies less than size.
*/
char*
term2string(char *const ptr,size_t *size, const YAP_Term t) {
term2string(char *const ptr, size_t *size, const YAP_Term t) {
char *ret;
size_t needed_bytes = 0;
RESET_BUFFER;
BUFFER_LEN = YAP_ExportTerm( t, ptr, *size );// canonical
if (BUFFER_LEN<=*size) { // user allocated buffer size is ok
memcpy(ptr,BUFFER_PTR,BUFFER_LEN); // copy data to user block
ret=ptr;
*size=BUFFER_LEN;
} else { // user buffer is too small
ret=BUFFER_PTR;
*size=BUFFER_LEN;
//DEL_BUFFER;
}
do {
if (*size <= needed_bytes) {
if (needed_bytes >= BUFFER_SIZE) {
expand_buffer(BLOCK_SIZE);
}
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);
return ret;
}
/*
@ -228,6 +230,7 @@ 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);

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