[m-rev.] Updated diff for deep profiling.
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue May 29 18:53:02 AEST 2001
On 22-May-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 22-May-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > You are asking the wrong person. Tom wrote that, not me. However, I believe
> > > he wrote it before Ralph wrote, or at least committed, bitmap.m.
> >
> > If it's just historical reasons, then the code should be changed to use
> > library/bitmap.m.
>
> Maybe it should, but it won't be. I have better things to do than refactor
> software I am not familiar with for such minor gain.
I'm not familiar with the software either, but
the changes required are pretty trivial.
--- cliques.m.old Tue May 29 18:29:28 2001
+++ cliques.m Tue May 29 18:47:21 2001
@@ -33,8 +33,8 @@
:- implementation.
-:- import_module array_util, dense_bitset.
-:- import_module array, int.
+:- import_module array_util.
+:- import_module array, bitmap, int, bool.
:- type graph --->
graph(
@@ -42,7 +42,9 @@
array(set(int))
).
-:- type visit == dense_bitset.
+:- type visit == bitmap.
+:- mode visit_di == bitmap_di.
+:- mode visit_uo == bitmap_uo.
init(graph(1, Array)) :-
% The initial array size doesn't really matter.
@@ -83,16 +85,17 @@
topological_sort(Graph, TSort) :-
dfs_graph(Graph, Dfs),
inverse(Graph, InvGraph),
- Visit = dense_bitset__init,
+ Graph = graph(Size, _),
+ Visit = bitmap__new(Size, no),
tsort(Dfs, InvGraph, Visit, [], TSort0),
reverse(TSort0, TSort).
-:- pred tsort(list(int)::in, graph::in, visit::array_di, list(set(int))::in,
+:- pred tsort(list(int)::in, graph::in, visit::visit_di, list(set(int))::in,
list(set(int))::out) is det.
tsort([], _InvGraph, _Visit, TSort, TSort).
tsort([Node | Nodes], InvGraph, Visit0, TSort0, TSort) :-
- ( dense_bitset__member(Node, Visit0) ->
+ ( bitmap__is_set(Visit0, Node) ->
tsort(Nodes, InvGraph, Visit0, TSort0, TSort)
;
dfs([Node], InvGraph, Visit0, [], Visit, CliqueList),
@@ -109,10 +112,10 @@
dfs_graph(Graph, Dfs) :-
Graph = graph(Size, _Array),
mklist(Size, [], NodeList),
- Visit = dense_bitset__init,
+ Visit = bitmap__new(Size, no),
dfs_graph_2(NodeList, Graph, Visit, [], Dfs).
-:- pred dfs_graph_2(list(int)::in, graph::in, visit::array_di,
+:- pred dfs_graph_2(list(int)::in, graph::in, visit::visit_di,
list(int)::in, list(int)::out) is det.
dfs_graph_2([], _Graph, _Visit, Dfs, Dfs).
@@ -127,15 +130,15 @@
% nodes are descendants of each other. We detect such situations by passing
% along the set of nodes that have been visited already.
-:- pred dfs(list(int)::in, graph::in, visit::array_di, list(int)::in,
- visit::array_uo, list(int)::out) is det.
+:- pred dfs(list(int)::in, graph::in, visit::visit_di, list(int)::in,
+ visit::visit_uo, list(int)::out) is det.
dfs([], _Graph, Visit, Dfs, Visit, Dfs).
dfs([Node | Nodes], Graph, Visit0, Dfs0, Visit, Dfs) :-
- ( dense_bitset__member(Node, Visit0) ->
+ ( bitmap__is_set(Visit0, Node) ->
dfs(Nodes, Graph, Visit0, Dfs0, Visit, Dfs)
;
- Visit1 = dense_bitset__insert(Visit0, Node),
+ Visit1 = bitmap__set(Visit0, Node),
successors(Graph, Node, Succ),
set__to_sorted_list(Succ, SuccList),
dfs(SuccList, Graph, Visit1, Dfs0, Visit2, Dfs1),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list