From 244cb3d17cf6fca960613b7a1990bf4e15633666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 18 Nov 2011 17:02:09 +0000 Subject: [PATCH 1/4] compile prism. --- Makefile.in | 7 +++++ configure | 72 ++++++++++++++++++++++++++++++++-------------------- configure.in | 11 ++++++++ 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/Makefile.in b/Makefile.in index e77d99a0c..7a538b294 100644 --- a/Makefile.in +++ b/Makefile.in @@ -709,6 +709,7 @@ all: startup.yss @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE)) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE)) @ENABLE_CPLINT@ (cd packages/cplint/slipcase; $(MAKE)) + @ENABLE_PRISM@ (cd packages/prism/src/c; $(MAKE)) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE)) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE)) @ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE)) @@ -785,6 +786,8 @@ install_unix: startup.yss libYap.a $(INSTALL) YapTermConfig.h $(DESTDIR)$(INCLUDEDIR) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install) @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) install) + @ENABLE_PRISM@ (cd packages/prism/src/c; $(MAKE) install) + @ENABLE_PRISM@ (cd packages/prism/src/prolog; $(MAKE) install) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) install) @@ -835,6 +838,8 @@ install_win32: startup.yss @ENABLE_WINCONSOLE@ pl-yap@EXEC_SUFFIX@ @ENABLE_JPL@ (cd packages/jpl ; $(MAKE) install) @ENABLE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install) + @ENABLE_PRISM@ (cd packages/prism/src/c; $(MAKE) install) + @ENABLE_PRISM@ (cd packages/prism/src/prolog; $(MAKE) install) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) install) @@ -894,6 +899,8 @@ clean: clean_docs @ENABLE_MINISAT@ (cd packages/swi-minisat2; $(MAKE) clean) @ENABLE_CLPBN_BP@ (cd packages/CLPBN/clpbn/bp; $(MAKE) clean) @ENABLE_ZLIB@ @INSTALL_DLLS@ (cd packages/zlib; $(MAKE) clean) + @ENABLE_PRISM@ (cd packages/prism/src/c; $(MAKE) clean) + @ENABLE_PRISM@ (cd packages/prism/src/prolog; $(MAKE) clean) @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) clean) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) clean) diff --git a/configure b/configure index b44db2e59..4d2109dbd 100755 --- a/configure +++ b/configure @@ -615,6 +615,7 @@ IN_SWI IN_YAP PROLOG_SYSTEM M4GENABSMI +INSTALL_PRISM MATLAB_INCLUDE INSTALL_MATLAB EXTRA_LIBS_FOR_R @@ -790,6 +791,7 @@ enable_max_memory enable_debug_yap enable_eam enable_cygwin +enable_prism enable_dynamic_loading enable_static_compilation enable_use_malloc @@ -1463,6 +1465,7 @@ Optional Features: --enable-debug-yap enable C-debugging for YAP --enable-eam enable EAM on YAP --enable-cygwin use cygwin library in WIN32 + --enable-prism use PRISM system in YAP --enable-dynamic-loading compile YAP as a DLL --enable-static-compilation compile YAP statically --enable-use-malloc use malloc to allocate memory @@ -2528,7 +2531,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2925,7 +2928,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3040,7 +3043,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3083,7 +3086,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3142,7 +3145,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3194,7 +3197,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3774,7 +3777,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -3807,7 +3810,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -3840,7 +3843,7 @@ fi $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -4013,7 +4016,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -4486,6 +4489,13 @@ else cygwin=no fi +# Check whether --enable-prism was given. +if test "${enable_prism+set}" = set; then : + enableval=$enable_prism; prism="$enableval" +else + prism=yes +fi + # Check whether --enable-dynamic_loading was given. if test "${enable_dynamic_loading+set}" = set; then : enableval=$enable_dynamic_loading; dynamic_loading="$enableval" @@ -4922,6 +4932,13 @@ _ACEOF fi +if test "$yap_cv_prism" = no +then + INSTALL_PRISM="@# " +else + INSTALL_PRISM="" +fi + if test "$yap_cv_matlab" = no then INSTALL_MATLAB="@# " @@ -6238,7 +6255,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "--with-readline was given, but test for readline failed -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi fi @@ -6990,7 +7007,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -7054,7 +7071,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7660,19 +7677,19 @@ if test "$threads" = "yes" { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "--or-parallelism=sba incompatible with threads -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } ;; a-cow) { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "--or-parallelism=a-cow incompatible with threads -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } ;; copy) { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "--or-parallelism=copy incompatible with threads -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } ;; yes|threads) YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1" @@ -8408,7 +8425,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int_p=0 fi @@ -8441,7 +8458,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short int) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short_int=0 fi @@ -8474,7 +8491,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi @@ -8507,7 +8524,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long int) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_int=0 fi @@ -8540,7 +8557,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long long int) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_long_int=0 fi @@ -8573,7 +8590,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (float) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_float=0 fi @@ -8606,7 +8623,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (double) -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_double=0 fi @@ -8784,6 +8801,7 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc threaded code" >&5 @@ -10966,7 +10984,7 @@ do "packages/prism/src/c/Makefile") CONFIG_FILES="$CONFIG_FILES packages/prism/src/c/Makefile" ;; "packages/prism/src/prolog/Makefile") CONFIG_FILES="$CONFIG_FILES packages/prism/src/prolog/Makefile" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -11283,7 +11301,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -11311,7 +11329,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -11338,7 +11356,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac diff --git a/configure.in b/configure.in index 929668adb..6598b1197 100755 --- a/configure.in +++ b/configure.in @@ -153,6 +153,9 @@ AC_ARG_ENABLE(eam, AC_ARG_ENABLE(cygwin, [ --enable-cygwin use cygwin library in WIN32 ], cygwin="$enableval", cygwin=no) +AC_ARG_ENABLE(prism, + [ --enable-prism use PRISM system in YAP ], + prism="$enableval", prism=yes) AC_ARG_ENABLE(dynamic_loading, [ --enable-dynamic-loading compile YAP as a DLL ], dynamic_loading="$enableval", dynamic_loading=no) @@ -453,6 +456,13 @@ else fi +if test "$yap_cv_prism" = no +then + INSTALL_PRISM="@# " +else + INSTALL_PRISM="" +fi + dnl condor does not like dynamic linking on Linux, DEC, and HP-UX platforms. if test "$yap_cv_matlab" = no then @@ -1711,6 +1721,7 @@ AC_SUBST(YAPR_INCLUDES) AC_SUBST(EXTRA_LIBS_FOR_R) AC_SUBST(INSTALL_MATLAB) AC_SUBST(MATLAB_INCLUDE) +AC_SUBST(INSTALL_PRISM) dnl check for threaded code AC_MSG_CHECKING(for gcc threaded code) From e33712403f25a0c01e91ee528e8b026afeaac71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 18 Nov 2011 18:33:22 +0000 Subject: [PATCH 2/4] fix prism compilation and PRISM overflow handling. --- packages/prism/src/c/Makefile.in | 8 +++++--- packages/prism/src/c/up/graph.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/prism/src/c/Makefile.in b/packages/prism/src/c/Makefile.in index 96ada7b1e..b3d80ef7b 100644 --- a/packages/prism/src/c/Makefile.in +++ b/packages/prism/src/c/Makefile.in @@ -16,6 +16,7 @@ BINDIR = $(EROOTDIR)/bin # # where YAP should look for libraries # +TARGETS= prism.@SO@ LIBDIR=@libdir@ YAPLIBDIR=@libdir@/Yap YAP_EXTRAS=@YAP_EXTRAS@ -D_YAP_NOT_INSTALLED_=1 -D__YAP_PROLOG__=1 @@ -38,6 +39,7 @@ SO=@SO@ #4.1VPATH=@srcdir@:@srcdir@/OPTYap CWD=$(PWD) # +RM=rm -f ##---------------------------------------------------------------------- @@ -71,9 +73,9 @@ mp/%.o: $(srcdir)/mp/%.c @DO_SECOND_LD@prism.@SO@: $(OBJS) @DO_SECOND_LD@ @SHLIB_LD@ $(LDFLAGS) -o $@ $(OBJS) @EXTRA_LIBS_FOR_DLLS@ -all: $(TARGET) +all: $(TARGETS) -install: $(TARGET) +install: $(TARGETS) $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR) clean: clean_subdirs @@ -81,7 +83,7 @@ clean: clean_subdirs clean_subdirs: for i in $(SUBDIRS); do \ - ($(MAKE) -f $(MAKEFILE) -C $$i clean ) \ + $(RM) $$i/*.o; \ done ##---------------------------------------------------------------------- diff --git a/packages/prism/src/c/up/graph.c b/packages/prism/src/c/up/graph.c index 153316e5c..385e25cc4 100644 --- a/packages/prism/src/c/up/graph.c +++ b/packages/prism/src/c/up/graph.c @@ -797,7 +797,7 @@ int pc_import_occ_switches_3(void) /* running out of stack */ extern int Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop); - Yap_gcl(4*64*1024, 3, ENV, P); + Yap_gcl(4*64*1024, 3, ENV, CP); goto restart; } #endif From 749a5103a1248c4dc7b475a63d8f66b805103811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 18 Nov 2011 22:16:33 +0000 Subject: [PATCH 3/4] fix empty slots in unnumbervars. --- C/utilpreds.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/C/utilpreds.c b/C/utilpreds.c index 3a3cdbb6a..e2945b4a4 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -4514,17 +4514,27 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow, int share if (ASP-(max+1) <= H) { goto overflow; } - /* we found this before */ - *ptf++ = ASP[-id-1]; + /* we found this before? */ + if (ASP[-id-1]) + *ptf++ = ASP[-id-1]; + else { + RESET_VARIABLE(ptf); + ASP[-id-1] = (CELL)ptf; + ptf++; + } continue; } - max = id; - if (ASP-(max+1) <= H) { + /* alloc more space */ + if (ASP-(id+1) <= H) { goto overflow; } + while (id > max) { + ASP[-(id+1)] = 0L; + max++; + } /* new variable */ RESET_VARIABLE(ptf); - ASP[-id-1] = (CELL)ptf; + ASP[-(id+1)] = (CELL)ptf; ptf++; continue; } From 6c1cf7ea39c123a07aedb1632e36ec899d3be12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 18 Nov 2011 22:24:46 +0000 Subject: [PATCH 4/4] update to OSX support. --- packages/YapR | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/YapR b/packages/YapR index f218eaacc..27b398187 160000 --- a/packages/YapR +++ b/packages/YapR @@ -1 +1 @@ -Subproject commit f218eaacc9ef3922829ff4a8c5cd64cca9c19dc7 +Subproject commit 27b398187116aaa5c6b687d1abe79b0a270381bb