separate MAX_WORKERS and MAX_THREADS (obs from Paulo Moura)

MAX_AGENTS can be used in all cases


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2189 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-04-02 15:41:50 +00:00
parent 7aab33a153
commit 70b3438293
8 changed files with 3310 additions and 1037 deletions

View File

@ -83,9 +83,9 @@ ADDR Yap_HeapBase;
#if defined(THREADS) #if defined(THREADS)
struct restore_info rinfo[MAX_WORKERS]; struct restore_info rinfo[MAX_THREADS];
struct thread_globs Yap_thread_gl[MAX_WORKERS]; struct thread_globs Yap_thread_gl[MAX_THREADS];
#else #else
@ -968,7 +968,7 @@ InitCodes(void)
INIT_LOCK(Yap_heap_regs->thread_handles_lock); INIT_LOCK(Yap_heap_regs->thread_handles_lock);
{ {
int i; int i;
for (i=0; i < MAX_WORKERS; i++) { for (i=0; i < MAX_THREADS; i++) {
Yap_heap_regs->thread_handle[i].in_use = FALSE; Yap_heap_regs->thread_handle[i].in_use = FALSE;
Yap_heap_regs->thread_handle[i].zombie = FALSE; Yap_heap_regs->thread_handle[i].zombie = FALSE;
Yap_heap_regs->thread_handle[i].local_preds = NULL; Yap_heap_regs->thread_handle[i].local_preds = NULL;
@ -1001,7 +1001,7 @@ InitCodes(void)
Yap_heap_regs->heap_top_owner = -1; Yap_heap_regs->heap_top_owner = -1;
{ {
int i; int i;
for (i=0; i < MAX_WORKERS; i++) { for (i=0; i < MAX_AGENTS; i++) {
INIT_LOCK(Yap_heap_regs->wl[i].signal_lock); INIT_LOCK(Yap_heap_regs->wl[i].signal_lock);
Yap_heap_regs->wl[i].active_signals = 0; Yap_heap_regs->wl[i].active_signals = 0;
Yap_heap_regs->wl[i].scratchpad.ptr = NULL; Yap_heap_regs->wl[i].scratchpad.ptr = NULL;

View File

@ -43,11 +43,11 @@ allocate_new_tid(void)
{ {
int new_worker_id = 0; int new_worker_id = 0;
LOCK(ThreadHandlesLock); LOCK(ThreadHandlesLock);
while(new_worker_id < MAX_WORKERS && while(new_worker_id < MAX_THREADS &&
(ThreadHandle[new_worker_id].in_use == TRUE || (ThreadHandle[new_worker_id].in_use == TRUE ||
ThreadHandle[new_worker_id].zombie == TRUE) ) ThreadHandle[new_worker_id].zombie == TRUE) )
new_worker_id++; new_worker_id++;
if (new_worker_id < MAX_WORKERS) { if (new_worker_id < MAX_THREADS) {
pthread_mutex_lock(&(ThreadHandle[new_worker_id].tlock)); pthread_mutex_lock(&(ThreadHandle[new_worker_id].tlock));
ThreadHandle[new_worker_id].in_use = TRUE; ThreadHandle[new_worker_id].in_use = TRUE;
} else { } else {
@ -184,7 +184,7 @@ p_thread_new_tid(void)
{ {
int new_worker = allocate_new_tid(); int new_worker = allocate_new_tid();
if (new_worker == -1) { if (new_worker == -1) {
Yap_Error(RESOURCE_ERROR_MAX_THREADS, MkIntegerTerm(MAX_WORKERS), ""); Yap_Error(RESOURCE_ERROR_MAX_THREADS, MkIntegerTerm(MAX_THREADS), "");
return FALSE; return FALSE;
} }
return Yap_unify(MkIntegerTerm(new_worker), ARG1); return Yap_unify(MkIntegerTerm(new_worker), ARG1);
@ -617,7 +617,7 @@ p_nof_threads(void)
{ /* '$nof_threads'(+P) */ { /* '$nof_threads'(+P) */
int i = 0, wid; int i = 0, wid;
LOCK(ThreadHandlesLock); LOCK(ThreadHandlesLock);
for (wid = 0; wid < MAX_WORKERS; wid++) { for (wid = 0; wid < MAX_THREADS; wid++) {
if (ThreadHandle[wid].in_use) if (ThreadHandle[wid].in_use)
i++; i++;
} }
@ -628,7 +628,7 @@ p_nof_threads(void)
static Int static Int
p_max_threads(void) p_max_threads(void)
{ /* '$max_threads'(+P) */ { /* '$max_threads'(+P) */
return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS)); return Yap_unify(ARG1,MkIntegerTerm(MAX_THREADS));
} }
static Int static Int

View File

@ -10,7 +10,7 @@
* File: Heap.h * * File: Heap.h *
* mods: * * mods: *
* comments: Heap Init Structure * * comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.128 2008-04-01 22:28:41 vsc Exp $ * * version: $Id: Heap.h,v 1.129 2008-04-02 15:41:50 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* information that can be stored in Code Space */ /* information that can be stored in Code Space */
@ -98,7 +98,7 @@ typedef struct restore_info {
} restoreinfo; } restoreinfo;
#if defined(THREADS) #if defined(THREADS)
extern struct restore_info rinfo[MAX_WORKERS]; extern struct restore_info rinfo[MAX_THREADS];
#else #else
extern struct restore_info rinfo; extern struct restore_info rinfo;
#endif #endif
@ -224,7 +224,7 @@ typedef struct various_codes {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
lockvar bgl; /* protect long critical regions */ lockvar bgl; /* protect long critical regions */
lockvar free_blocks_lock; /* protect the list of free blocks */ lockvar free_blocks_lock; /* protect the list of free blocks */
worker_local wl[MAX_WORKERS]; worker_local wl[MAX_AGENTS];
#else #else
worker_local wl; worker_local wl;
#endif #endif
@ -564,7 +564,7 @@ typedef struct various_codes {
#endif /* YAPOR || TABLING */ #endif /* YAPOR || TABLING */
#ifdef THREADS #ifdef THREADS
lockvar thread_handles_lock; /* protect ThreadManipulation */ lockvar thread_handles_lock; /* protect ThreadManipulation */
struct thandle thread_handle[MAX_WORKERS]; struct thandle thread_handle[MAX_THREADS];
#endif #endif
UInt n_of_atoms; UInt n_of_atoms;
UInt atom_hash_table_size; UInt atom_hash_table_size;

10
H/Yap.h
View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h,v 1.31 2008-03-27 00:41:32 vsc Exp $ * * version: $Id: Yap.h,v 1.32 2008-04-02 15:41:50 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -388,6 +388,12 @@ typedef pthread_rwlock_t rwlock_t;
#ifdef __alpha #ifdef __alpha
#include <alpha_locks_funcs.h> #include <alpha_locks_funcs.h>
#endif #endif
#ifdef YAPOR
#define MAX_AGENTS MAX_WORKERS
#endif
#ifdef THREADS
#define MAX_AGENTS MAX_THREADS
#endif
#endif #endif
/************ variables concerned with Error Handling *************/ /************ variables concerned with Error Handling *************/
@ -730,7 +736,7 @@ typedef struct thread_globs
} tglobs; } tglobs;
extern struct thread_globs Yap_thread_gl[MAX_WORKERS]; extern struct thread_globs Yap_thread_gl[MAX_THREADS];
#define Yap_LocalBase Yap_thread_gl[worker_id].local_base #define Yap_LocalBase Yap_thread_gl[worker_id].local_base

View File

@ -301,3 +301,7 @@
#undef MAX_WORKERS #undef MAX_WORKERS
#undef MAX_THREADS

4251
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -240,7 +240,7 @@ AC_ARG_WITH(trail-space,
[yap_cv_trail_space=0]) [yap_cv_trail_space=0])
AC_ARG_WITH(max-workers, AC_ARG_WITH(max-workers,
[ --with-max-workers[=integer] maximum number of threads or parallel processes], [ --with-max-workers[=integer] maximum number of or-parallel processes],
if test "$withval" = yes; then if test "$withval" = yes; then
yap_cv_max_workers="(8*SIZEOF_INT_P)" yap_cv_max_workers="(8*SIZEOF_INT_P)"
elif test "$withval" = no; then elif test "$withval" = no; then
@ -250,6 +250,17 @@ AC_ARG_WITH(max-workers,
fi, fi,
[yap_cv_max_workers="(8*SIZEOF_INT_P)"]) [yap_cv_max_workers="(8*SIZEOF_INT_P)"])
AC_ARG_WITH(max-threads,
[ --with-max-threads[=integer] maximum number of or-parallel processes],
if test "$withval" = yes; then
yap_cv_max_threads="1024"
elif test "$withval" = no; then
yap_cv_max_threads="1"
else
yap_cv_max_threads=$withval
fi,
[yap_cv_max_threads="1024"])
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
then then
@ -270,13 +281,20 @@ AC_CANONICAL_SYSTEM
AC_DEFINE_UNQUOTED(HOST_ALIAS,"${target}") AC_DEFINE_UNQUOTED(HOST_ALIAS,"${target}")
if test "$or-parallelism" = no -a "$threads" = no if test "$or-parallelism" = no
then then
AC_DEFINE(MAX_WORKERS,1) AC_DEFINE(MAX_WORKERS,1)
else else
eval "AC_DEFINE(MAX_WORKERS,$yap_cv_max_workers)" eval "AC_DEFINE(MAX_WORKERS,$yap_cv_max_workers)"
fi fi
if test "$threads" = no
then
AC_DEFINE(MAX_THREADS,1)
else
eval "AC_DEFINE(MAX_THREADS,$yap_cv_max_threads)"
fi
dnl condor does not like dynamic linking on Linux, DEC, and HP-UX platforms. dnl condor does not like dynamic linking on Linux, DEC, and HP-UX platforms.
if test "$yap_cv_matlab" = no if test "$yap_cv_matlab" = no

View File

@ -428,41 +428,41 @@ yap_flag(min_tagged_integer,X) :-
/* ISO Core Revision DTR: new float flags /* ISO Core Revision DTR: new float flags
yap_flag(oat_mantissa_digits,X) :- yap_flag(float_mantissa_digits,X) :-
var(X), !, var(X), !,
????? ?????
yap_flag(oat_mantissa_digits,X) :- yap_flag(float_mantissa_digits,X) :-
integer(X), X > 0, !, integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_mantissa_digits),yap_flag(float_mantissa_digits,X)). '$do_error'(permission_error(modify,flag,float_mantissa_digits),yap_flag(float_mantissa_digits,X)).
yap_flag(oat_mantissa_digits,X) :- yap_flag(float_mantissa_digits,X) :-
'$do_error'(domain_error(flag_value,float_mantissa_digits+X),yap_flag(float_mantissa_digits,X)). '$do_error'(domain_error(flag_value,float_mantissa_digits+X),yap_flag(float_mantissa_digits,X)).
yap_flag(oat_epsilon,X) :- yap_flag(float_epsilon,X) :-
var(X), !, var(X), !,
????? ?????
yap_flag(oat_epsilon,X) :- yap_flag(float_epsilon,X) :-
float(X), X > 0, !, float(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_epsilon),yap_flag(float_epsilon,X)). '$do_error'(permission_error(modify,flag,float_epsilon),yap_flag(float_epsilon,X)).
yap_flag(oat_epsilon,X) :- yap_flag(float_epsilon,X) :-
'$do_error'(domain_error(flag_value,float_epsilon+X),yap_flag(float_epsilon,X)). '$do_error'(domain_error(flag_value,float_epsilon+X),yap_flag(float_epsilon,X)).
yap_flag(oat_min_exponent,X) :- yap_flag(float_min_exponent,X) :-
var(X), !, var(X), !,
????? ?????
yap_flag(oat_min_exponent,X) :- yap_flag(float_min_exponent,X) :-
integer(X), X > 0, !, integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,oat_min_exponent),yap_flag(float_min_exponent,X)). '$do_error'(permission_error(modify,flag,float_min_exponent),yap_flag(float_min_exponent,X)).
yap_flag(oat_epsilon,X) :- yap_flag(float_epsilon,X) :-
'$do_error'(domain_error(flag_value,oat_min_exponent+X),yap_flag(float_min_exponent,X)). '$do_error'(domain_error(flag_value,float_min_exponent+X),yap_flag(float_min_exponent,X)).
yap_flag(float_max_exponent,X) :- yap_flag(float_max_exponent,X) :-
var(X), !, var(X), !,
????? ?????
yap_flag(float_max_exponent,X) :- yap_flag(float_max_exponent,X) :-
integer(X), X > 0, !, integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,oat_max_exponent),yap_flag(float_max_exponent,X)). '$do_error'(permission_error(modify,flag,float_max_exponent),yap_flag(float_max_exponent,X)).
yap_flag(float_max_exponent,X) :- yap_flag(float_max_exponent,X) :-
'$do_error'(domain_error(flag_value,oat_max_exponent+X),yap_flag(float_max_exponent,X)). '$do_error'(domain_error(flag_value,float_max_exponent+X),yap_flag(float_max_exponent,X)).
*/ */
yap_flag(char_conversion,X) :- yap_flag(char_conversion,X) :-