[m-rev.] for review: disallow impure parallel conjuncts

Peter Wang wangp at students.csse.unimelb.edu.au
Mon Sep 11 14:49:55 AEST 2006


On 2006-09-08, Peter Schachte <schachte at csse.unimelb.edu.au> wrote:
> Hi Peter,
> 
> Just a minor point, but...
> 
> On Tue, Aug 15, 2006 at 10:23:47AM +1000, Peter Wang wrote:
> > Disallow impure parallel conjuncts as they can introduce concurrency issues.
> > e.g. in the following X could be bound to `foo' or `bar' in different runs.
> > 
> >     impure set_mutvar(foo),
> >     (
> > 	semipure get_mutvar(X)
> >     &
> > 	impure set_mutvar(bar)
> >     )
> 
> That's true, but if both conjuncts are semidet, they still can run in
> parallel, since they are both sensitive to the environment, but
> neither can effect the environment.

You're right, thanks.  Here's a followup patch.

Peter


Estimated hours taken: 0.5
Branches: main

compiler/purity.m:
	Allow semipure parallel conjunctions as, by themselves, they can't
	introduce concurrency issues.  Only impure parallel conjunctions
	are disallowed now.

tests/invalid/purity/impure_par_conj.err_exp:
	Update test case.


Index: compiler/purity.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/purity.m,v
retrieving revision 1.102
diff -u -r1.102 purity.m
--- compiler/purity.m	5 Sep 2006 06:21:30 -0000	1.102
+++ compiler/purity.m	11 Sep 2006 04:05:35 -0000
@@ -112,8 +112,7 @@
 %   inline (since ordering is not an issue for them).
 %
 % To do:
-%   Reconsider whether impure or semipure parallel conjuncts should be
-%   allowed.  Currently both are disallowed.
+%   Reconsider whether impure parallel conjuncts should be allowed.
 %
 %-----------------------------------------------------------------------------%
 
@@ -933,11 +932,11 @@
         !ContainsTrace, !Info) :-
     compute_goal_purity(Goal0, Goal, GoalPurity, GoalContainsTrace, !Info),
     (
-        GoalPurity = purity_pure
+        ( GoalPurity = purity_pure
+        ; GoalPurity = purity_semipure
+        )
     ;
-        ( GoalPurity = purity_semipure
-        ; GoalPurity = purity_impure
-        ),
+        GoalPurity = purity_impure,
         Goal0 = _ - GoalInfo0,
         goal_info_get_context(GoalInfo0, Context),
         purity_info_add_message(error(impure_parallel_conjunct_error(Context,
@@ -1229,7 +1228,7 @@
     purity_name(Purity, PurityName),
     Pieces = [words("Purity error: parallel conjunct is"),
         fixed(PurityName ++ ","),
-        words("but parallel conjuncts must be pure.")],
+        words("but parallel conjuncts must be semipure or pure.")],
     write_error_pieces(Context, 0, Pieces, !IO).
 
 %-----------------------------------------------------------------------------%
Index: tests/invalid/purity/impure_par_conj.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/purity/impure_par_conj.err_exp,v
retrieving revision 1.1
diff -u -r1.1 impure_par_conj.err_exp
--- tests/invalid/purity/impure_par_conj.err_exp	31 Aug 2006 07:18:05 -0000	1.1
+++ tests/invalid/purity/impure_par_conj.err_exp	11 Sep 2006 04:43:21 -0000
@@ -1,8 +1,4 @@
-impure_par_conj.m:014: Purity error: parallel conjunct is semipure, but
-impure_par_conj.m:014:   parallel conjuncts must be pure.
 impure_par_conj.m:018: Purity error: parallel conjunct is impure, but parallel
-impure_par_conj.m:018:   conjuncts must be pure.
+impure_par_conj.m:018:   conjuncts must be semipure or pure.
 impure_par_conj.m:022: Purity error: parallel conjunct is impure, but parallel
-impure_par_conj.m:022:   conjuncts must be pure.
-impure_par_conj.m:024: Purity error: parallel conjunct is semipure, but
-impure_par_conj.m:024:   parallel conjuncts must be pure.
+impure_par_conj.m:022:   conjuncts must be semipure or pure.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list