for review: independent AND parallelism [the rest]
Thomas Charles CONWAY
conway at cs.mu.OZ.AU
Mon Apr 27 21:30:20 AEST 1998
Hi
Here are the remainder of the changes for independent AND parallelism.
--
Thomas Conway || conway at cs.mu.oz.au
AD DEUM ET VINUM || Nail here [] for new monitor.
cvs diff: Diffing .
Index: configure.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/configure.in,v
retrieving revision 1.122
diff -u -r1.122 configure.in
--- configure.in 1998/02/26 09:42:24 1.122
+++ configure.in 1998/03/18 04:01:57
@@ -714,6 +714,37 @@
BYTES_PER_WORD=$mercury_cv_bytes_per_word
AC_SUBST(BYTES_PER_WORD)
#-----------------------------------------------------------------------------#
+AC_MSG_CHECKING(the number of words in a synchronization term)
+AC_CACHE_VAL(mercury_cv_sync_term_size,
+ AC_TRY_RUN([
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <pthread.h>
+ int main() {
+ struct {
+ pthread_mutex_t lock;
+ int count;
+ void *parent;
+ } x;
+ FILE *fp;
+
+ fp = fopen("conftest.syncsize", "w");
+ if (fp == NULL)
+ exit(1);
+ fprintf(fp, "%d\n", (sizeof(void *) - 1 + sizeof(x))/
+ sizeof(void *));
+
+ exit(0);
+ }],
+ [mercury_cv_sync_term_size=`cat conftest.syncsize`],
+ [mercury_cv_sync_term_size=0],
+ [mercury_cv_sync_term_size=0])
+)
+AC_MSG_RESULT($mercury_cv_sync_term_size)
+AC_DEFINE_UNQUOTED(SYNC_TERM_SIZE, $mercury_cv_sync_term_size)
+BYTES_PER_WORD=$mercury_cv_sync_term_size
+AC_SUBST(SYNC_TERM_SIZE)
+#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(the number of bits per word)
AC_CACHE_VAL(mercury_cv_bits_per_word,
AC_TRY_RUN([
@@ -1093,10 +1124,9 @@
AC_TRY_RUN([
#define USE_GCC_NONLOCAL_GOTOS
#define USE_GCC_GLOBAL_REGISTERS
- #include "mercury_regs.h"
- #include "mercury_memory.h"
+ #include "runtime/mercury_engine.h"
changequote(<<,>>)
- Word fake_reg[MAX_FAKE_REG];
+ MercuryEngine MR_engine_base;
changequote([,])
main() {
mr0 = 20;
@@ -1154,10 +1184,9 @@
AC_CACHE_VAL(mercury_cv_gcc_model_reg,
AC_TRY_RUN([
#define USE_GCC_GLOBAL_REGISTERS
-#include "mercury_regs.h"
-#include "mercury_memory.h"
+#include "mercury_engine.h"
changequote(<<,>>)
-Word fake_reg[MAX_FAKE_REG];
+MercuryEngine MR_engine_base;
changequote([,])
main() {
mr0 = 20;
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
Index: boehm_gc/gc.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/boehm_gc/gc.h,v
retrieving revision 1.18
diff -u -r1.18 gc.h
--- gc.h 1997/12/10 06:29:31 1.18
+++ gc.h 1998/03/11 04:49:52
@@ -653,7 +653,7 @@
GC_PTR GC_malloc_many(size_t lb);
#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
/* in returned list. */
-extern void GC_thr_init(); /* Needed for Solaris/X86 */
+extern void GC_thr_init(void); /* Needed for Solaris/X86 */
#endif /* SOLARIS_THREADS */
Index: boehm_gc/solaris_pthreads.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/boehm_gc/solaris_pthreads.c,v
retrieving revision 1.1
diff -u -r1.1 solaris_pthreads.c
--- solaris_pthreads.c 1997/11/21 08:44:46 1.1
+++ solaris_pthreads.c 1998/03/11 04:49:54
@@ -36,6 +36,10 @@
# define _CLASSIC_XOPEN_TYPES
# include <unistd.h>
# include <errno.h>
+# include "solaris_threads.h"
+
+#include <stdio.h>
+#include <assert.h>
#undef pthread_join
#undef pthread_create
@@ -79,9 +83,12 @@
size_t stack_size;
int n;
struct sched_param schedparam;
+ int err;
- (void)pthread_attr_getstacksize(attr_in, &stack_size);
- (void)pthread_attr_getstackaddr(attr_in, &stack);
+ err = pthread_attr_getstacksize(attr_in, &stack_size);
+ assert(err == 0);
+ err = pthread_attr_getstackaddr(attr_in, &stack);
+ assert(err == 0);
(void)pthread_attr_init(&attr);
LOCK();
@@ -136,6 +143,7 @@
#endif
result =
pthread_create(&my_new_thread, &attr, thread_execp, arg);
+ fprintf(stderr, "%d %s\n", result, strerror(result));
#if 0
#ifdef I386
LOCK();
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
Index: library/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/Mmakefile,v
retrieving revision 1.23
diff -u -r1.23 Mmakefile
--- Mmakefile 1998/03/04 05:10:14 1.23
+++ Mmakefile 1998/03/11 04:52:18
@@ -80,7 +80,9 @@
--cflags "-I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) $(EXTRA_CFLAGS)" \
$(INTERMODULE_OPTS) $(CHECK_TERM_OPTS)
MGNUC = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
-MGNUCFLAGS = -I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) \
+
+# --no-ansi is needed to avoid syntax errors in Solaris pthread.h :-(
+MGNUCFLAGS = --no-ansi -I$(RUNTIME_DIR) -I$(BOEHM_GC_DIR) \
$(DLL_CFLAGS) $(EXTRA_CFLAGS)
LDFLAGS = -L$(BOEHM_GC_DIR) -L$(RUNTIME_DIR)
LDLIBS = -lmer \
Index: library/benchmarking.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/benchmarking.m,v
retrieving revision 1.12
diff -u -r1.12 benchmarking.m
--- benchmarking.m 1998/02/02 02:49:57 1.12
+++ benchmarking.m 1998/03/11 04:52:18
@@ -139,6 +139,7 @@
ML_report_stats(void)
{
int time_at_prev_stat;
+ MercuryEngine *eng;
#ifdef PROFILE_MEMORY
int num_table_entries;
ML_memprof_report_entry table[MEMORY_PROFILE_SIZE];
@@ -151,12 +152,16 @@
time_at_prev_stat = time_at_last_stat;
time_at_last_stat = MR_get_user_cpu_miliseconds();
+ eng = MR_get_engine();
+
fprintf(stderr,
""[Time: +%.3fs, %.3fs, D Stack: %.3fk, ND Stack: %.3fk, "",
(time_at_last_stat - time_at_prev_stat) / 1000.0,
(time_at_last_stat - time_at_start) / 1000.0,
- ((char *) sp - (char *) detstack_zone->min) / 1024.0,
- ((char *) maxfr - (char *) nondetstack_zone->min) / 1024.0
+ ((char *) sp - (char *)
+ eng->context.detstack_zone->min) / 1024.0,
+ ((char *) maxfr - (char *)
+ eng->context.nondetstack_zone->min) / 1024.0
);
/*
@@ -173,8 +178,8 @@
);
#else
fprintf(stderr,
- ""Heap: %.3fk"",
- ((char *) hp - (char *) heap_zone->min) / 1024.0
+ ""Heap: %.3fk]\\n"",
+ ((char *) hp - (char *) eng->heap_zone->min) / 1024.0
);
#endif
Index: library/nc_builtin.nl
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/nc_builtin.nl,v
retrieving revision 1.20
diff -u -r1.20 nc_builtin.nl
--- nc_builtin.nl 1998/03/04 16:54:07 1.20
+++ nc_builtin.nl 1998/03/11 04:52:22
@@ -50,6 +50,8 @@
:- op(1179, xfy, (--->)).
:- op(1175, xfx, (::)).
+:- op(1025, xfy, (&)).
+
:- op(950, fxy, (lambda)).
:- $setOpField((pred), []). % remove `pred' as an operator
Index: library/sp_builtin.nl
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/sp_builtin.nl,v
retrieving revision 1.16
diff -u -r1.16 sp_builtin.nl
--- sp_builtin.nl 1998/03/04 16:53:20 1.16
+++ sp_builtin.nl 1998/03/11 04:52:24
@@ -53,6 +53,7 @@
:- op(1199, fx, (mode)).
:- op(1199, fx, (inst)).
:- op(1179, xfy, (--->)).
+:- op(1025, xfy, (&)).
:- op(975, xfx, ('::')).
:- op(700, xfx, ( \= ) ).
:- op(500, fx, ( \ ) ).
Index: library/std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.115
diff -u -r1.115 std_util.m
--- std_util.m 1998/01/30 02:15:04 1.115
+++ std_util.m 1998/03/11 04:52:24
@@ -600,9 +600,9 @@
#define swap_heap_and_solutions_heap() \
do { \
Word temp; \
- temp = (Word) heap_zone; \
- heap_zone = solutions_heap_zone; \
- LVALUE_CAST(Word, solutions_heap_zone) = temp; \
+ temp = (Word) MR_ENGINE(heap_zone); \
+ MR_ENGINE(heap_zone) = MR_ENGINE(solutions_heap_zone); \
+ LVALUE_CAST(Word, MR_ENGINE(solutions_heap_zone)) = temp; \
temp = (Word) MR_hp; \
MR_hp = MR_sol_hp; \
LVALUE_CAST(Word, MR_sol_hp) = temp; \
@@ -689,7 +689,8 @@
*/
save_transient_registers();
copied_solution = deep_copy(r1, (Word *) element_type_info_fv,
- (Word *) saved_hp_fv, solutions_heap_zone->top);
+ (Word *) saved_hp_fv,
+ MR_ENGINE(solutions_heap_zone)->top);
restore_transient_registers();
/* call the collector closure */
@@ -744,7 +745,8 @@
save_transient_registers();
copied_collection = deep_copy(sofar_fv,
(Word *) collection_type_info_fv,
- (Word *) saved_solhp_fv, solutions_heap_zone->top);
+ (Word *) saved_solhp_fv,
+ MR_ENGINE(solutions_heap_zone)->top);
restore_transient_registers();
builtin_aggregate_output = copied_collection;
cvs diff: Diffing scripts
Index: scripts/init_grade_options.sh-subr
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/init_grade_options.sh-subr,v
retrieving revision 1.3
diff -u -r1.3 init_grade_options.sh-subr
--- init_grade_options.sh-subr 1998/01/09 03:10:03 1.3
+++ init_grade_options.sh-subr 1998/03/11 04:52:41
@@ -23,6 +23,7 @@
use_trail=false
args_method=compact
debug=false
+thread_safe=true
case $# in
0) set - "--grade $DEFAULT_GRADE" ;;
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/mgnuc.in,v
retrieving revision 1.47
diff -u -r1.47 mgnuc.in
--- mgnuc.in 1998/03/03 06:12:28 1.47
+++ mgnuc.in 1998/03/11 04:52:41
@@ -63,7 +63,7 @@
case "$CC" in
*gcc*)
- ANSI_OPTS="-ansi"
+ ANSI_OPTS="" # --no-ansi to avoid syntax errors in Solaris pthread.h
CHECK_OPTS="
-Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wtraditional
-Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused"
@@ -218,6 +218,11 @@
false) TRAIL_OPTS="" ;;
esac
+case $thread_safe in
+ true) THREAD_OPTS="-DMR_THREAD_SAFE -DSOLARIS_THREADS -D_SOLARIS_PTHREADS -D_REENTRANT";;
+ false) THREAD_OPTS="" ;;
+esac
+
case $args_method in
simple) ARG_OPTS="" ;;
compact) ARG_OPTS="-DCOMPACT_ARGS" ;;
@@ -356,13 +361,13 @@
0) exec $CC $ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS \
$GRADE_OPTS $GC_OPTS \
$PROF_TIME_OPTS $PROF_CALLS_OPTS $PROF_MEMORY_OPTS \
- $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
+ $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS $THREAD_OPTS \
$PICREG_OPTS $ARCH_OPTS $ARG_OPTS \
$OVERRIDE_OPTS ;;
*) exec $CC $ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS \
$GRADE_OPTS $GC_OPTS \
$PROF_TIME_OPTS $PROF_CALLS_OPTS $PROF_MEMORY_OPTS \
- $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
+ $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS $THREAD_OPTS \
$PICREG_OPTS $ARCH_OPTS $ARG_OPTS \
"$@" $OVERRIDE_OPTS ;;
esac
Index: scripts/ml.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/ml.in,v
retrieving revision 1.39
diff -u -r1.39 ml.in
--- ml.in 1998/03/06 03:20:57 1.39
+++ ml.in 1998/03/11 04:52:41
@@ -313,18 +313,28 @@
false) STRIP_OPTS="" ;;
esac
+case $thread_safe in
+ true)
+ case "$FULLARCH" in
+ *alpha*) THREAD_LIBS="-lpthreads -lc_r" ;;
+ *linux*) THREAD_LIBS="-lpthread" ;;
+ *sparc*) THREAD_LIBS="-lpthread -ldl" ;;
+ esac ;;
+ false) THREAD_LIBS="" ;;
+esac
+
case $make_shared_lib in
true)
LINKER="$LINK_SHARED_OBJ"
RPATH_OPT="$SHLIB_RPATH_OPT"
RPATH_SEP="$SHLIB_RPATH_SEP"
- STDLIBS="$SHARED_LIBS"
+ STDLIBS="$SHARED_LIBS $THREAD_LIBS"
;;
false)
LINKER="$CC"
RPATH_OPT="$EXE_RPATH_OPT"
RPATH_SEP="$EXE_RPATH_SEP"
- STDLIBS="-lm"
+ STDLIBS="-lm $THREAD_LIBS"
;;
esac
Index: scripts/parse_grade_options.sh-subr
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/parse_grade_options.sh-subr,v
retrieving revision 1.2
diff -u -r1.2 parse_grade_options.sh-subr
--- parse_grade_options.sh-subr 1997/12/05 15:58:34 1.2
+++ parse_grade_options.sh-subr 1998/03/11 04:52:41
@@ -183,6 +183,14 @@
esac
case "$grade" in
+ *.par) thread_safe=true
+ grade="` expr $grade : '\(.*\).par' `"
+ ;;
+ *) thread_safe=false
+ ;;
+ esac
+
+ case "$grade" in
asm_fast)
global_regs=true
non_local_gotos=true
cvs diff: Diffing tools
cvs diff: Diffing trial
cvs diff: Diffing util
More information about the developers
mailing list