<HTML> <HEAD> <!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 --> <LINK rel="stylesheet" href="ciao.css" type="text/css"> <TITLE>The Ciao Prolog System - Independent and-parallel execution</TITLE> </HEAD> <BODY> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_101.html">previous</A>, <A HREF="ciao_103.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. <P><HR><P> <H1><A NAME="SEC421" HREF="ciao_toc.html#TOC421">Independent and-parallel execution</A></H1> <P> <A NAME="IDX5343"></A> <P> <STRONG>Author(s):</STRONG> Manuel Carro, Manuel Hermenegildo. <P> <STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST) <P> <STRONG>Version of last change:</STRONG> 1.7#160 (2001/11/27, 12:35:53 CET) <P> <STRONG>Note:</STRONG> This is just a partial first shot. The real library still needs to be written. Not difficult, just no time... <P> This library will eventually allow and-parallel execution of goals in (Herbrand-)independent fashion. It resembles the execution rules of &-Prolog [HG90]. Basically, goals are run in and-parallel <EM>provided that their arguments do not share bindings</EM>, i.e., are not bound to terms which contain a common variable. <UL> <LI><A HREF="ciao_102.html#SEC422">Usage and interface (andprolog)</A> <LI><A HREF="ciao_102.html#SEC423">Documentation on internals (andprolog)</A> <LI><A HREF="ciao_102.html#SEC424">Known bugs and planned improvements (andprolog)</A> </UL> <H2><A NAME="SEC422" HREF="ciao_toc.html#TOC422">Usage and interface (<CODE>andprolog</CODE>)</A></H2> <div class="cartouche"> <UL> <LI><STRONG>Library usage:</STRONG> <CODE>:- use_package(andprolog).</CODE> or <CODE>:- module(...,...,[andprolog]).</CODE> <LI><STRONG>New operators defined:</STRONG> <A NAME="IDX5344"></A> <CODE>@&/2</CODE> [950,xfy]. </UL> </div class="cartouche"> <H2><A NAME="SEC423" HREF="ciao_toc.html#TOC423">Documentation on internals (<CODE>andprolog</CODE>)</A></H2> <P> <A NAME="IDX5345"></A> <A NAME="IDX5346"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>@&/2:</B> <DD><A NAME="IDX5347"></A> <P> <CODE>@&(GoalA, GoalB)</CODE> <P> <CODE>GoalA</CODE> and <CODE>GoalB</CODE> are run in independent and-parallel fashion. This is just a first sketch, and valid only for deterministic independent goals. The use is as <PRE> q:- a & b. </PRE> <P> which would start <CODE>a</CODE> and <CODE>b</CODE> in separate threads (possibly in parallalel, if the machine architecture and operating system allows that), and continue when <STRONG>both</STRONG> have finished. This type of execution is safe only when <CODE>a</CODE> and <CODE>b</CODE> are independent in the sense of variable sharing. This condition can be tested with the <A NAME="IDX5348"></A> <CODE>indep/2</CODE> predicate. </DL> <P> <A NAME="IDX5349"></A> <A NAME="IDX5350"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>active_agents/1:</B> <DD><A NAME="IDX5351"></A> <P> <CODE>active_agents(NumberOfAgents)</CODE> <P> Tests/sets the <CODE>NumberOfAgents</CODE> which are active looking for goals to execute. As for now, those agents are resource-consuming, even when they are just looking for work, and not executing any user goals. </DL> <P> <A NAME="IDX5352"></A> <A NAME="IDX5353"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>indep/2:</B> <DD><A NAME="IDX5354"></A> <P> <CODE>indep(X, Y)</CODE> <P> <CODE>X</CODE> and <CODE>Y</CODE> are <A NAME="IDX5355"></A> <A NAME="IDX5356"></A> <EM>independent</EM>, i.e., they are bound to terms which have no variables in common. For example, <CODE>indep(X,Y)</CODE> holds for <CODE>X=f(Z),Y=g(K)</CODE> and also for <CODE>X=f(a),Y=X</CODE> (since both <CODE>X</CODE> and <CODE>Y</CODE> are bound to ground terms). It does not hold for <CODE>X=f(Z),Y=g(Z)</CODE> and for <CODE>X=Y</CODE>. </DL> <P> <A NAME="IDX5357"></A> <A NAME="IDX5358"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>indep/1:</B> <DD><A NAME="IDX5359"></A> <P> <CODE>indep(X)</CODE> <P> <CODE>X</CODE> is a list of lists of length two, i.e., a list of the form <CODE>[[T1, T2], [T3, T4], ...]</CODE>. The variables in each pair of the list <CODE><CODE>X</CODE></CODE> are tested for independence using <A NAME="IDX5360"></A> <CODE>indep/2</CODE>. This list-of-pairs format is the output of several independdnce analyzers for pair sharing. </DL> <H2><A NAME="SEC424" HREF="ciao_toc.html#TOC424">Known bugs and planned improvements (<CODE>andprolog</CODE>)</A></H2> <UL> <LI> <STRONG>Beware:</STRONG> the current code is just a partial first shot. It is provided for the sole purpose of experimentation and development. <LI> The fact that only the first solution is returned for the conjunction is due to performance issues (and lack of time), and we expect to remove it in a near future. <LI> CGEs (i.e., <CODE>=></CODE>) are not supported. <LI> The <A NAME="IDX5361"></A> <CODE>indep/1</CODE>, <A NAME="IDX5362"></A> <CODE>indep/2</CODE>, and <A NAME="IDX5363"></A> <CODE>ground/1</CODE> tests are not very efficient; they will be replaced by native versions (taken from the &-Prolog code) in the future. </UL> <P><HR><P> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_101.html">previous</A>, <A HREF="ciao_103.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. </BODY> </HTML>