allow the user to configure a maximum number of threads.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1792 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
2ffa06931e
commit
7239e45ec3
14
C/threads.c
14
C/threads.c
@ -568,6 +568,12 @@ p_nof_threads(void)
|
|||||||
return Yap_unify(ARG1,MkIntegerTerm(i));
|
return Yap_unify(ARG1,MkIntegerTerm(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_max_threads(void)
|
||||||
|
{ /* '$max_threads'(+P) */
|
||||||
|
return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS));
|
||||||
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nof_threads_created(void)
|
p_nof_threads_created(void)
|
||||||
{ /* '$nof_threads'(+P) */
|
{ /* '$nof_threads'(+P) */
|
||||||
@ -583,6 +589,7 @@ p_thread_runtime(void)
|
|||||||
void Yap_InitThreadPreds(void)
|
void Yap_InitThreadPreds(void)
|
||||||
{
|
{
|
||||||
Yap_InitCPred("$no_threads", 0, p_no_threads, HiddenPredFlag);
|
Yap_InitCPred("$no_threads", 0, p_no_threads, HiddenPredFlag);
|
||||||
|
Yap_InitCPred("$max_threads", 1, p_max_threads, HiddenPredFlag);
|
||||||
Yap_InitCPred("$thread_new_tid", 1, p_thread_new_tid, HiddenPredFlag);
|
Yap_InitCPred("$thread_new_tid", 1, p_thread_new_tid, HiddenPredFlag);
|
||||||
Yap_InitCPred("$create_thread", 6, p_create_thread, HiddenPredFlag);
|
Yap_InitCPred("$create_thread", 6, p_create_thread, HiddenPredFlag);
|
||||||
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
|
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
|
||||||
@ -625,6 +632,12 @@ p_nof_threads(void)
|
|||||||
return Yap_unify(ARG1,MkIntTerm(1));
|
return Yap_unify(ARG1,MkIntTerm(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_max_threads(void)
|
||||||
|
{ /* '$nof_threads'(+P) */
|
||||||
|
return Yap_unify(ARG1,MkIntTerm(1));
|
||||||
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_nof_threads_created(void)
|
p_nof_threads_created(void)
|
||||||
{ /* '$nof_threads'(+P) */
|
{ /* '$nof_threads'(+P) */
|
||||||
@ -640,6 +653,7 @@ p_thread_runtime(void)
|
|||||||
void Yap_InitThreadPreds(void)
|
void Yap_InitThreadPreds(void)
|
||||||
{
|
{
|
||||||
Yap_InitCPred("$no_threads", 0, p_no_threads, SafePredFlag|HiddenPredFlag);
|
Yap_InitCPred("$no_threads", 0, p_no_threads, SafePredFlag|HiddenPredFlag);
|
||||||
|
Yap_InitCPred("$max_threads", 1, p_max_threads, SafePredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
|
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
|
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
|
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
|
||||||
|
8
H/Yap.h
8
H/Yap.h
@ -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.18 2006-12-13 16:10:25 vsc Exp $ *
|
* version: $Id: Yap.h,v 1.19 2007-01-29 10:18:15 vsc Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -141,12 +141,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
#define MAX_WORKERS (sizeof(unsigned long) * 8)
|
|
||||||
#else
|
|
||||||
#define MAX_WORKERS 1
|
|
||||||
#endif /* YAPOR */
|
|
||||||
|
|
||||||
#if SIZEOF_INT_P==4
|
#if SIZEOF_INT_P==4
|
||||||
|
|
||||||
#if SIZEOF_INT==4
|
#if SIZEOF_INT==4
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<h2>Yap-5.1.2:</h2>
|
<h2>Yap-5.1.2:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> NEW: --with-max-workers tells us how many threads we can have (request from Paulo Moura).</li>
|
||||||
<li> FIXED: wchar_t in the WIN32 is unsigned and 16 bits.</li>
|
<li> FIXED: wchar_t in the WIN32 is unsigned and 16 bits.</li>
|
||||||
<li> FIXED: stack overflow when growing the delay stack.</li>
|
<li> FIXED: stack overflow when growing the delay stack.</li>
|
||||||
<li> FIXED: overflows with MIN_INT (obs from Marius Filip).</li>
|
<li> FIXED: overflows with MIN_INT (obs from Marius Filip).</li>
|
||||||
|
@ -297,3 +297,5 @@
|
|||||||
|
|
||||||
#undef GC_NO_TAGS
|
#undef GC_NO_TAGS
|
||||||
|
|
||||||
|
#undef MAX_WORKERS
|
||||||
|
|
||||||
|
36
configure
vendored
36
configure
vendored
@ -698,6 +698,7 @@ INSTALLCLP
|
|||||||
JAVALIBPATH
|
JAVALIBPATH
|
||||||
JAVAINCPATH
|
JAVAINCPATH
|
||||||
LAMOBJS
|
LAMOBJS
|
||||||
|
MAX_WORKERS
|
||||||
M4GENABSMI
|
M4GENABSMI
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
LTLIBOBJS'
|
LTLIBOBJS'
|
||||||
@ -1319,6 +1320,7 @@ Optional Packages:
|
|||||||
--with-heap-space=space default heap size in Kbytes
|
--with-heap-space=space default heap size in Kbytes
|
||||||
--with-stack-space=space default stack size in Kbytes
|
--with-stack-space=space default stack size in Kbytes
|
||||||
--with-trail-space=space default trail size in Kbytes
|
--with-trail-space=space default trail size in Kbytes
|
||||||
|
--with-max-workers=integer maximum number of threads or parallel processes
|
||||||
|
|
||||||
Some influential environment variables:
|
Some influential environment variables:
|
||||||
CC C compiler command
|
CC C compiler command
|
||||||
@ -3093,6 +3095,22 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --with-max-workers was given.
|
||||||
|
if test "${with_max_workers+set}" = set; then
|
||||||
|
withval=$with_max_workers; if test "$withval" = yes; then
|
||||||
|
yap_cv_max_workers="(8*SIZEOF_INT_P)"
|
||||||
|
elif test "$withval" = no; then
|
||||||
|
yap_cv_max_workers="1"
|
||||||
|
else
|
||||||
|
yap_cv_max_workers=$withval
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
yap_cv_max_workers="(8*SIZEOF_INT_P)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
|
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
|
||||||
then
|
then
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
@ -3298,6 +3316,20 @@ cat >>confdefs.h <<_ACEOF
|
|||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
if test "$or-parallelism" = no -a "$threads" = no
|
||||||
|
then
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define MAX_WORKERS 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
else
|
||||||
|
eval "cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define MAX_WORKERS ($yap_cv_max_workers)
|
||||||
|
_ACEOF
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if test "$use_condor" = yes
|
if test "$use_condor" = yes
|
||||||
then
|
then
|
||||||
use_malloc="yes"
|
use_malloc="yes"
|
||||||
@ -14862,6 +14894,7 @@ EXEC_SUFFIX=""
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ echo "$as_me:$LINENO: checking for gcc threaded code" >&5
|
{ echo "$as_me:$LINENO: checking for gcc threaded code" >&5
|
||||||
@ -18590,12 +18623,13 @@ for ac_last_try in false false false false false :; do
|
|||||||
JAVALIBPATH!$JAVALIBPATH$ac_delim
|
JAVALIBPATH!$JAVALIBPATH$ac_delim
|
||||||
JAVAINCPATH!$JAVAINCPATH$ac_delim
|
JAVAINCPATH!$JAVAINCPATH$ac_delim
|
||||||
LAMOBJS!$LAMOBJS$ac_delim
|
LAMOBJS!$LAMOBJS$ac_delim
|
||||||
|
MAX_WORKERS!$MAX_WORKERS$ac_delim
|
||||||
M4GENABSMI!$M4GENABSMI$ac_delim
|
M4GENABSMI!$M4GENABSMI$ac_delim
|
||||||
LIBOBJS!$LIBOBJS$ac_delim
|
LIBOBJS!$LIBOBJS$ac_delim
|
||||||
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 6; then
|
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 7; then
|
||||||
break
|
break
|
||||||
elif $ac_last_try; then
|
elif $ac_last_try; then
|
||||||
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
||||||
|
21
configure.in
21
configure.in
@ -223,6 +223,18 @@ AC_ARG_WITH(trail-space,
|
|||||||
fi,
|
fi,
|
||||||
[yap_cv_trail_space=0])
|
[yap_cv_trail_space=0])
|
||||||
|
|
||||||
|
AC_ARG_WITH(max-workers,
|
||||||
|
[ --with-max-workers[=integer] maximum number of threads or parallel processes],
|
||||||
|
if test "$withval" = yes; then
|
||||||
|
yap_cv_max_workers="(8*SIZEOF_INT_P)"
|
||||||
|
elif test "$withval" = no; then
|
||||||
|
yap_cv_max_workers="1"
|
||||||
|
else
|
||||||
|
yap_cv_max_workers=$withval
|
||||||
|
fi,
|
||||||
|
[yap_cv_max_workers="(8*SIZEOF_INT_P)"])
|
||||||
|
|
||||||
|
|
||||||
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
|
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
|
||||||
then
|
then
|
||||||
AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P))
|
AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P))
|
||||||
@ -242,6 +254,14 @@ AC_CANONICAL_SYSTEM
|
|||||||
|
|
||||||
AC_DEFINE_UNQUOTED(HOST_ALIAS,"${target}")
|
AC_DEFINE_UNQUOTED(HOST_ALIAS,"${target}")
|
||||||
|
|
||||||
|
if test "$or-parallelism" = no -a "$threads" = no
|
||||||
|
then
|
||||||
|
AC_DEFINE(MAX_WORKERS,1)
|
||||||
|
else
|
||||||
|
eval "AC_DEFINE(MAX_WORKERS,$yap_cv_max_workers)"
|
||||||
|
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 "$use_condor" = yes
|
if test "$use_condor" = yes
|
||||||
then
|
then
|
||||||
@ -1013,6 +1033,7 @@ AC_SUBST(INSTALLCLP)
|
|||||||
AC_SUBST(JAVALIBPATH)
|
AC_SUBST(JAVALIBPATH)
|
||||||
AC_SUBST(JAVAINCPATH)
|
AC_SUBST(JAVAINCPATH)
|
||||||
AC_SUBST(LAMOBJS)
|
AC_SUBST(LAMOBJS)
|
||||||
|
AC_SUBST(MAX_WORKERS)
|
||||||
|
|
||||||
|
|
||||||
dnl check for threaded code
|
dnl check for threaded code
|
||||||
|
Reference in New Issue
Block a user