diff --git a/C/threads.c b/C/threads.c index ae14e7ec5..94ed2f506 100644 --- a/C/threads.c +++ b/C/threads.c @@ -645,6 +645,12 @@ p_nof_threads(void) return Yap_unify(ARG1,MkIntegerTerm(i)); } +static Int +p_max_workers(void) +{ /* '$max_workers'(+P) */ + return Yap_unify(ARG1,MkIntegerTerm(MAX_WORKERS)); +} + static Int p_max_threads(void) { /* '$max_threads'(+P) */ @@ -666,6 +672,7 @@ p_thread_runtime(void) void Yap_InitThreadPreds(void) { Yap_InitCPred("$no_threads", 0, p_no_threads, HiddenPredFlag); + Yap_InitCPred("$max_workers", 1, p_max_workers, HiddenPredFlag); Yap_InitCPred("$max_threads", 1, p_max_threads, HiddenPredFlag); Yap_InitCPred("$thread_new_tid", 1, p_thread_new_tid, HiddenPredFlag); Yap_InitCPred("$create_thread", 6, p_create_thread, HiddenPredFlag); diff --git a/docs/yap.tex b/docs/yap.tex index 3835d2708..701549c1f 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -537,7 +537,8 @@ or-parallelism supported by one of these three forms. This option is still highly experimental. @item @code{--with-max-workers} allows definition of the maximum -number of parallel processes. +number of parallel processes (its value can be consulted at runtime +using the flag @code{max_workers}). @item @code{--with-gmp[=DIR]} give a path to where one can find the @code{GMP} library if not installed in the default path. @@ -7775,6 +7776,11 @@ integers that are writable character codes using the list notation. It is @code{on} if enables or @code{off} if disabled. The default value for this flag is @code{off}. +@item max_workers +@findex max_workers (yap_flag/2 option) +@* Read-only flag telling the maximum number of Prolog workers when using +or-parallelism. + @item max_threads @findex max_threads (yap_flag/2 option) @* Read-only flag telling the maximum number of Prolog threads that can diff --git a/pl/directives.yap b/pl/directives.yap index 3b9edcf78..afafc4eef 100644 --- a/pl/directives.yap +++ b/pl/directives.yap @@ -817,6 +817,15 @@ yap_flag(float_format,X) :- yap_flag(float_format,X) :- '$do_error'(type_error(atom,X),yap_flag(float_format,X)). +yap_flag(max_workers,X) :- + var(X), !, + '$max_workers'(X). +yap_flag(max_workers,X) :- + integer(X), X > 0, !, + '$do_error'(permission_error(modify,flag,max_workers),yap_flag(max_workers,X)). +yap_flag(max_workers,X) :- + '$do_error'(domain_error(flag_value,max_workers+X),yap_flag(max_workers,X)). + yap_flag(max_threads,X) :- var(X), !, '$max_threads'(X). @@ -865,6 +874,7 @@ yap_flag(dialect,yap). V = max_arity ; V = max_integer ; V = max_tagged_integer ; + V = max_workers ; V = max_threads ; V = min_integer ; V = min_tagged_integer ;