[m-rev.] diff: fix bitrot in benchmarks

Ian MacLarty maclarty at cs.mu.OZ.AU
Thu Oct 6 19:10:14 AEST 2005


Estimated hours taken: 1

benchmarks/progs/compress/bitbuf2.m:
benchmarks/progs/compress/compress5.m:
benchmarks/progs/icfp2000/space_partition.m:
benchmarks/progs/nuc/nuc5.m:
benchmarks/progs/ray/debug.m:
benchmarks/progs/ray/proj.m:
benchmarks/progs/ray/ray.m:
benchmarks/progs/tree234/tree234x.m:
	Bring benchmarks up to date with current Mercury syntax and library
	API.

Index: progs/compress/bitbuf2.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/compress/bitbuf2.m,v
retrieving revision 1.1
diff -u -r1.1 bitbuf2.m
--- progs/compress/bitbuf2.m	10 Jul 2002 08:32:57 -0000	1.1
+++ progs/compress/bitbuf2.m	5 Oct 2005 13:44:01 -0000
@@ -14,24 +14,24 @@

 :- type bitbuf(S).

-:- some [S] pred new_bitbuf(bitbuf(S), store(S)).
+:- some [S] pred new_bitbuf(bitbuf(S), S) => store(S).
 :-          mode new_bitbuf(out, uo) is det.

-:- pred read_byte(io__result(int), bitbuf(S), store(S), store(S),
-            io__state, io__state).
+:- pred read_byte(io__result(int), bitbuf(S), S, S,
+            io__state, io__state) <= store(S).
 :- mode read_byte(out, in, di, uo, di, uo) is det.

-:- pred write_code(int, int, bitbuf(S), store(S), store(S),
-            io__state, io__state).
+:- pred write_code(int, int, bitbuf(S), S, S,
+            io__state, io__state) <= store(S).
 :- mode write_code(in, in, in, di, uo, di, uo) is det.

-:- pred compression_ratio_fallen(bitbuf(S), bool, store(S), store(S)).
+:- pred compression_ratio_fallen(bitbuf(S), bool, S, S) <= store(S).
 :- mode compression_ratio_fallen(in, out, di, uo) is det.

-:- pred reset_compression_ratio(bitbuf(S), store(S), store(S)).
+:- pred reset_compression_ratio(bitbuf(S), S, S) <= store(S).
 :- mode reset_compression_ratio(in, di, uo) is det.

-:- pred flush_buffer(bitbuf(S), store(S), store(S), io__state, io__state).
+:- pred flush_buffer(bitbuf(S), S, S, io__state, io__state) <= store(S).
 :- mode flush_buffer(in, di, uo, di, uo) is det.

 % ---------------------------------------------------------------------------- %
@@ -45,11 +45,11 @@

 :- type bitbuf(S)
     --->    bitbuf(
-            bits_in     :: mutvar(int, S), % Number of bits read in.
-            bits_out    :: mutvar(int, S), % Number of bits written out.
-            ratio       :: mutvar(int, S), % Compression ratio guide.
-            data        :: mutvar(int, S), % Buffer contents.
-            size        :: mutvar(int, S)  % Number of bits in buffer.
+            bits_in     :: generic_mutvar(int, S), % Number of bits read in.
+            bits_out    :: generic_mutvar(int, S), % Number of bits written out.
+            ratio       :: generic_mutvar(int, S), % Compression ratio guide.
+            data        :: generic_mutvar(int, S), % Buffer contents.
+            size        :: generic_mutvar(int, S)  % Number of bits in buffer.
         ).

 % ---------------------------------------------------------------------------- %
Index: progs/compress/compress5.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/compress/compress5.m,v
retrieving revision 1.1
diff -u -r1.1 compress5.m
--- progs/compress/compress5.m	10 Jul 2002 08:32:57 -0000	1.1
+++ progs/compress/compress5.m	5 Oct 2005 13:46:34 -0000
@@ -33,7 +33,7 @@
 % ---------------------------------------------------------------------------- %

 :- pragma inline(start/4).
-:- pred start(bitbuf(T), store(T), io__state, io__state).
+:- pred start(bitbuf(T), T, io__state, io__state) <= store(T).
 :- mode start(in, di, di, uo) is det.

 start(Buf, S) -->
@@ -51,8 +51,8 @@

 % ---------------------------------------------------------------------------- %

-:- pred main_loop(code, code, code_table, int, bitbuf(T), store(T),
-            io__state, io__state).
+:- pred main_loop(code, code, code_table, int, bitbuf(T), T,
+            io__state, io__state) <= store(T).
 :- mode main_loop(in, in, array_di, in, in, di, di, uo) is det.

 main_loop(C, N, T, BPC, Buf, S) -->
Index: progs/icfp2000/space_partition.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/icfp2000/space_partition.m,v
retrieving revision 1.1
diff -u -r1.1 space_partition.m
--- progs/icfp2000/space_partition.m	10 Jul 2002 08:33:04 -0000	1.1
+++ progs/icfp2000/space_partition.m	6 Oct 2005 08:06:48 -0000
@@ -411,7 +411,7 @@
 	double minB[3], maxB[3];	/*box */
 	double origin[3], dir[3];	/*ray */
 	double coord[3];		/* hit point (not used -stayl)*/
-	bool succeeded;
+	MR_bool succeeded;

 	minB[0] = XMin;
 	minB[1] = YMin;
@@ -448,10 +448,10 @@


 :- pragma c_code("
-Bool HitBoundingBox(double minB[3],double maxB[3], double origin[3],
+MR_bool HitBoundingBox(double minB[3],double maxB[3], double origin[3],
 		double dir[3], double coord[3])
 {
-	char inside = TRUE;
+	MR_bool inside = MR_TRUE;
 	char quadrant[NUMDIM];
 	register int i;
 	int whichPlane;
@@ -464,11 +464,11 @@
 		if(origin[i] < minB[i]) {
 			quadrant[i] = LEFT;
 			candidatePlane[i] = minB[i];
-			inside = FALSE;
+			inside = MR_FALSE;
 		}else if (origin[i] > maxB[i]) {
 			quadrant[i] = RIGHT;
 			candidatePlane[i] = maxB[i];
-			inside = FALSE;
+			inside = MR_FALSE;
 		}else	{
 			quadrant[i] = MIDDLE;
 		}
@@ -476,7 +476,7 @@
 	/* Ray origin inside bounding box */
 	if(inside)	{
 		coord = origin;
-		return (TRUE);
+		return (MR_TRUE);
 	}


@@ -495,17 +495,17 @@

 	/* Check final candidate actually inside box */
 	if (maxT[whichPlane] < 0.) {
-		return (FALSE);
+		return (MR_FALSE);
 	}
 	for (i = 0; i < NUMDIM; i++)
 		if (whichPlane != i) {
 			coord[i] = origin[i] + maxT[whichPlane] *dir[i];
 			if (coord[i] < minB[i] || coord[i] > maxB[i])
-				return (FALSE);
+				return (MR_FALSE);
 		} else {
 			coord[i] = candidatePlane[i];
 		}
-	return (TRUE);				/* ray hits box */
+	return (MR_TRUE);				/* ray hits box */
 }").

 :- pred traverse_space_tree_nodes(list(space_tree_node)::in,
Index: progs/nuc/nuc5.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/nuc/nuc5.m,v
retrieving revision 1.1
diff -u -r1.1 nuc5.m
--- progs/nuc/nuc5.m	10 Jul 2002 08:33:09 -0000	1.1
+++ progs/nuc/nuc5.m	5 Oct 2005 12:53:24 -0000
@@ -3067,10 +3067,10 @@
 :- type partial_inst == list(variable).

 :- type constraint == (func(variable, partial_inst) = bool).
-:- inst constraint = (func(in, in) = out is det).
+:- inst constraint == (func(in, in) = out is det).

 :- type closure == (func(partial_inst) = list(variable)).
-:- inst closure = (func(in) = out is det).
+:- inst closure == (func(in) = out is det).

 :- pred search(partial_inst, list(closure), constraint, partial_inst).
 :- mode search(in, in(list_skel(closure)), in(constraint), out) is nondet.
Index: progs/ray/debug.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/ray/debug.m,v
retrieving revision 1.1
diff -u -r1.1 debug.m
--- progs/ray/debug.m	12 Jul 2002 23:38:14 -0000	1.1
+++ progs/ray/debug.m	6 Oct 2005 07:44:25 -0000
@@ -4,17 +4,20 @@

 :- import_module string, list.

-:- pred dump(string, list(string__poly_type)).
+:- impure pred dump(string, list(string__poly_type)).
 :- mode dump(in, in) is det.

 :- implementation.

 dump(Fmt, Args) :-
 	string__format(Fmt, Args, Str),
-	dump_str(Str).
+	impure dump_str(Str).

-:- pred dump_str(string::in) is det.
+:- impure pred dump_str(string::in) is det.

-:- pragma(c_code, dump_str(S::in), "
+:- pragma foreign_proc("C",
+	dump_str(S::in),
+	[will_not_call_mercury, thread_safe],
+"
 	fprintf(stderr, \"%s\", S);
 ").
Index: progs/ray/proj.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/ray/proj.m,v
retrieving revision 1.1
diff -u -r1.1 proj.m
--- progs/ray/proj.m	12 Jul 2002 23:38:15 -0000	1.1
+++ progs/ray/proj.m	6 Oct 2005 07:47:15 -0000
@@ -204,10 +204,10 @@
 gen_dir(Foc, X, MaxX, Y, MaxY, Dir) :-
     (
         DZ = -Foc,
-        int__to_float(X, FX),
-        int__to_float(MaxX, FMaxX),
-        int__to_float(Y, FY),
-        int__to_float(MaxY, FMaxY),
+        FX = float(X),
+        FMaxX = float(MaxX),
+        FY = float(Y),
+        FMaxY = float(MaxY),
         DX = FX - FMaxX / 2.0,
         DY = -(FY - FMaxY / 2.0),
         %dump("gen_dir: direction=(%f, %f, %f)\n", [f(DX), f(DY), f(DZ)]), %%dmo
@@ -216,7 +216,7 @@

 % the following predicates are for debugging.

-:- pred dump_scene(scene).
+:- impure pred dump_scene(scene).
 :- mode dump_scene(in) is det.

 dump_scene(Scene) :-
@@ -224,15 +224,15 @@
         Scene = []
     ;
         Scene = [polytri(Triangles, vec(X, Y, Z), colour(R, G, B)) | Scene1],
-        dump("Polygon colour (%f, %f, %f)\n", [f(R), f(G), f(B)]),
-        dump("        normal (%f, %f, %f)\n", [f(X), f(Y), f(Z)]),
-        dump_triangles(Triangles),
-        dump_scene(Scene1)
+        impure dump("Polygon colour (%f, %f, %f)\n", [f(R), f(G), f(B)]),
+        impure dump("        normal (%f, %f, %f)\n", [f(X), f(Y), f(Z)]),
+        impure dump_triangles(Triangles),
+        impure dump_scene(Scene1)
     ).

 % debugging stuff.
 % print out info about a triangle.
-:- pred dump_triangles(list(triangle)).
+:- impure pred dump_triangles(list(triangle)).
 :- mode dump_triangles(in) is det.

 dump_triangles(Ts) :-
@@ -240,7 +240,7 @@
         Ts = []
     ;
         Ts = [tri(vec(X1, Y1, Z1), vec(X2, Y2, Z2), vec(X3, Y3, Z3), _, _, _) | Ts1],
-        dump("    (%f, %f, %f)\n    (%f, %f, %f)\n    (%f, %f, %f)\n --------\n",
+        impure dump("    (%f, %f, %f)\n    (%f, %f, %f)\n    (%f, %f, %f)\n --------\n",
             [f(X1), f(Y1), f(Z1), f(X2), f(Y2), f(Z2), f(X3), f(Y3), f(Z3)]),
-        dump_triangles(Ts1)
+        impure dump_triangles(Ts1)
     ).
Index: progs/ray/ray.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/ray/ray.m,v
retrieving revision 1.1
diff -u -r1.1 ray.m
--- progs/ray/ray.m	12 Jul 2002 23:38:15 -0000	1.1
+++ progs/ray/ray.m	6 Oct 2005 07:44:10 -0000
@@ -220,19 +220,19 @@


 %debugging %%dmo
-:- pred dump_triangle(triangle, vec3, colour).
+:- impure pred dump_triangle(triangle, vec3, colour).
 :- mode dump_triangle(in, in, in) is det.

 dump_triangle(T, N, C) :-
     (
-        dump("============\n", []),
+        impure dump("============\n", []),
         T = tri(vec(X1, Y1, Z1), vec(X2, Y2, Z2), vec(X3, Y3, Z3), _, _, _),
-        dump("    (%f, %f, %f)\n    (%f, %f, %f)\n    (%f, %f, %f)\n",
+        impure dump("    (%f, %f, %f)\n    (%f, %f, %f)\n    (%f, %f, %f)\n",
             [f(X1), f(Y1), f(Z1), f(X2), f(Y2), f(Z2), f(X3), f(Y3), f(Z3)]),
         N = vec(X, Y, Z),
-        dump("norm(%f, %f, %f)\n", [f(X), f(Y), f(Z)]),
+        impure dump("norm(%f, %f, %f)\n", [f(X), f(Y), f(Z)]),
         C = colour(R, G, B),
-        dump("col (%f, %f, %f)\n", [f(R), f(G), f(B)])
+        impure dump("col (%f, %f, %f)\n", [f(R), f(G), f(B)])
     ).

 % calculate_normal(Point, FaceNormal, Shading, Triangle, PointNormal)
Index: progs/tree234/tree234x.m
===================================================================
RCS file: /home/mercury1/repository/benchmarks/progs/tree234/tree234x.m,v
retrieving revision 1.1
diff -u -r1.1 tree234x.m
--- progs/tree234/tree234x.m	12 Jul 2002 23:38:21 -0000	1.1
+++ progs/tree234/tree234x.m	6 Oct 2005 09:04:04 -0000
@@ -182,7 +182,7 @@

 :- interface.

-:- inst uniq_tree234x(K, V) =
+:- inst uniq_tree234x(K, V) ==
 	unique((
 		empty
 	;	two(K, V, uniq_tree234x(K, V), uniq_tree234x(K, V))
@@ -192,7 +192,7 @@
 			uniq_tree234x(K, V), uniq_tree234x(K, V))
 	)).

-:- inst uniq_tree234x_gg =
+:- inst uniq_tree234x_gg ==
 	unique((
 		empty
 	;	two(ground, ground, uniq_tree234x_gg, uniq_tree234x_gg)
@@ -203,10 +203,10 @@
 			uniq_tree234x_gg, uniq_tree234x_gg)
 	)).

-:- mode di_tree234x(K, V) :: uniq_tree234x(K, V) -> dead.
-:- mode di_tree234x       :: uniq_tree234x(ground, ground) -> dead.
-:- mode uo_tree234x(K, V) :: free -> uniq_tree234x(K, V).
-:- mode uo_tree234x       :: free -> uniq_tree234x(ground, ground).
+:- mode di_tree234x(K, V) == uniq_tree234x(K, V) >> dead.
+:- mode di_tree234x       == uniq_tree234x(ground, ground) >> dead.
+:- mode uo_tree234x(K, V) == free >> uniq_tree234x(K, V).
+:- mode uo_tree234x       == free >> uniq_tree234x(ground, ground).

 :- implementation.

@@ -719,51 +719,51 @@
 %------------------------------------------------------------------------------%
 %------------------------------------------------------------------------------%

-:- inst two(K, V, T) =
+:- inst two(K, V, T) ==
 	bound(
 		two(K, V, T, T)
 	).

-:- inst uniq_two(K, V, T) =
+:- inst uniq_two(K, V, T) ==
 	unique(
 		two(K, V, T, T)
 	).

-:- inst three(K, V, T) =
+:- inst three(K, V, T) ==
 	bound(
 		three(K, V, K, V, T, T, T)
 	).

-:- inst uniq_three(K, V, T) =
+:- inst uniq_three(K, V, T) ==
 	unique(
 		three(K, V, K, V, T, T, T)
 	).

-:- inst four(K, V, T) =
+:- inst four(K, V, T) ==
 	bound(
 		four(K, V, K, V, K, V, T, T, T, T)
 	).

-:- inst uniq_four(K, V, T) =
+:- inst uniq_four(K, V, T) ==
 	unique(
 		four(K, V, K, V, K, V, T, T, T, T)
 	).

-:- mode uo_two :: out(uniq_two(unique, unique, unique)).
-:- mode suo_two :: out(uniq_two(ground, ground, uniq_tree234x_gg)).
-:- mode out_two :: out(two(ground, ground, ground)).
-
-:- mode di_two :: di(uniq_two(unique, unique, unique)).
-:- mode sdi_two :: di(uniq_two(ground, ground, uniq_tree234x_gg)).
-:- mode in_two :: in(two(ground, ground, ground)).
-
-:- mode di_three :: di(uniq_three(unique, unique, unique)).
-:- mode sdi_three :: di(uniq_three(ground, ground, uniq_tree234x_gg)).
-:- mode in_three :: in(three(ground, ground, ground)).
-
-:- mode di_four :: di(uniq_four(unique, unique, unique)).
-:- mode sdi_four :: di(uniq_four(ground, ground, uniq_tree234x_gg)).
-:- mode in_four :: in(four(ground, ground, ground)).
+:- mode uo_two == out(uniq_two(unique, unique, unique)).
+:- mode suo_two == out(uniq_two(ground, ground, uniq_tree234x_gg)).
+:- mode out_two == out(two(ground, ground, ground)).
+
+:- mode di_two == di(uniq_two(unique, unique, unique)).
+:- mode sdi_two == di(uniq_two(ground, ground, uniq_tree234x_gg)).
+:- mode in_two == in(two(ground, ground, ground)).
+
+:- mode di_three == di(uniq_three(unique, unique, unique)).
+:- mode sdi_three == di(uniq_three(ground, ground, uniq_tree234x_gg)).
+:- mode in_three == in(three(ground, ground, ground)).
+
+:- mode di_four == di(uniq_four(unique, unique, unique)).
+:- mode sdi_four == di(uniq_four(ground, ground, uniq_tree234x_gg)).
+:- mode in_four == in(four(ground, ground, ground)).

 %------------------------------------------------------------------------------%


--------------------------------------------------------------------------
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