[m-rev.] diff: fix unwanted parallel dependencies
Zoltan Somogyi
zs at csse.unimelb.edu.au
Mon Nov 2 16:53:30 AEDT 2009
compiler/polymprphism.m:
Fix a problem identified by Paul that introduced unwanted
dependencies (and thus synchronization) into parallel conjunctions.
Zoltan.
cvs diff: Diffing .
Index: md4.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/md4.m,v
retrieving revision 1.1
diff -u -b -r1.1 md4.m
--- md4.m 16 Apr 2009 01:45:08 -0000 1.1
+++ md4.m 31 Oct 2009 12:15:49 -0000
@@ -267,4 +267,3 @@
sorry($file, $pred).
%-----------------------------------------------------------------------------%
-% vim: ft=mercury ts=8 sts=4 sw=4 et
Index: polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.348
diff -u -b -r1.348 polymorphism.m
--- polymorphism.m 22 Sep 2009 07:34:16 -0000 1.348
+++ polymorphism.m 2 Nov 2009 05:49:38 -0000
@@ -1098,7 +1098,17 @@
% The rest of the cases just process goals recursively.
(
GoalExpr0 = conj(ConjType, Goals0),
- polymorphism_process_conj(Goals0, Goals, !Info),
+ (
+ ConjType = plain_conj,
+ polymorphism_process_plain_conj(Goals0, Goals, !Info)
+ ;
+ ConjType = parallel_conj,
+ get_maps_snapshot(!.Info, InitialSnapshot),
+ polymorphism_process_par_conj(Goals0, Goals, InitialSnapshot,
+ !Info)
+ % Unlike with disjunctions, we do not have to reset to
+ % InitialSnapshot.
+ ),
GoalExpr = conj(ConjType, Goals)
;
GoalExpr0 = disj(Goals0),
@@ -1941,13 +1951,30 @@
varset.lookup_name(TypeVarSet, TVar, TVarName0),
TVarName = "_" ++ TVarName0.
-:- pred polymorphism_process_conj(list(hlds_goal)::in,
+:- pred polymorphism_process_plain_conj(list(hlds_goal)::in,
list(hlds_goal)::out, poly_info::in, poly_info::out) is det.
-polymorphism_process_conj([], [], !Info).
-polymorphism_process_conj([Goal0 | Goals0], [Goal | Goals], !Info) :-
+polymorphism_process_plain_conj([], [], !Info).
+polymorphism_process_plain_conj([Goal0 | Goals0], [Goal | Goals], !Info) :-
+ polymorphism_process_goal(Goal0, Goal, !Info),
+ polymorphism_process_plain_conj(Goals0, Goals, !Info).
+
+:- pred polymorphism_process_par_conj(list(hlds_goal)::in,
+ list(hlds_goal)::out, maps_snapshot::in, poly_info::in, poly_info::out)
+ is det.
+
+polymorphism_process_par_conj([], [], _, !Info).
+polymorphism_process_par_conj([Goal0 | Goals0], [Goal | Goals],
+ InitialSnapshot, !Info) :-
+ % Any variable that a later parallel conjunct reuses from an earlier
+ % parallel conjunct (a) will definitely require synchronization, whose
+ % cost will be greater than the cost of building a typeinfo from scratch,
+ % and (b) may drastically reduce the available parallelism, if the earlier
+ % conjunct produces the variable late but the later conjunct requires it
+ % early.
+ set_maps_snapshot(InitialSnapshot, !Info),
polymorphism_process_goal(Goal0, Goal, !Info),
- polymorphism_process_conj(Goals0, Goals, !Info).
+ polymorphism_process_par_conj(Goals0, Goals, InitialSnapshot, !Info).
:- pred polymorphism_process_disj(list(hlds_goal)::in, list(hlds_goal)::out,
maps_snapshot::in, poly_info::in, poly_info::out) is det.
cvs diff: Diffing notes
--------------------------------------------------------------------------
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