[m-rev.] diff: A bug fix and some other corrections for the deep profiler tools.
Paul Bone
pbone at csse.unimelb.edu.au
Thu Jan 13 15:43:29 AEDT 2011
A bug fix and some other corrections for the deep profiler tools.
deep_profiler/analysis_utils.m:
Handle calculating the recursive call costs at the base case by returning
an empty dictionary since there are none. Previously a dictionary
containing incorrect values was returned.
Remove a 'is det' from a pred declaration that has sepearte mode
declarations.
deep_profiler/coverage.m:
Adjust layout slightly.
Fixed trailing whitespace.
deep_profiler/recursion_patterns.m:
Fix an incorrect comment.
deep_profiler/measurements.m:
Add recursion_depth_is_base_case/1.
Check for negative depths in recursion_depth_descend/2.
Index: deep_profiler/analysis_utils.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/analysis_utils.m,v
retrieving revision 1.6
diff -u -p -b -r1.6 analysis_utils.m
--- deep_profiler/analysis_utils.m 13 Jan 2011 00:36:55 -0000 1.6
+++ deep_profiler/analysis_utils.m 13 Jan 2011 04:32:17 -0000
@@ -79,7 +79,7 @@
%
:- pred build_recursive_call_site_cost_map(deep, clique_ptr,
proc_dynamic_ptr, recursion_type, maybe(recursion_depth),
- maybe_error(map(reverse_goal_path, cs_cost_csq))) is det.
+ maybe_error(map(reverse_goal_path, cs_cost_csq))).
:- mode build_recursive_call_site_cost_map(in, in, in,
in(recursion_type_known_costs), in(maybe_yes(ground)),
out(maybe_error_ok(ground))) is det.
@@ -219,31 +219,39 @@ build_recursive_call_site_cost_map(Deep,
;
RecursionType = rt_single(_, _, _AvgMaxDepth, _AvgRecCost, CostFn),
(
- MaybeDepth = yes(Depth),
- DepthI = recursion_depth_to_int(Depth)
+ MaybeDepth = yes(Depth0),
+ ( recursion_depth_is_base_case(Depth0) ->
+ MaybeRecursiveCallSiteCostMap = ok(map.init)
;
- MaybeDepth = no,
- unexpected($module,
- "Expected valid depth for known recursion type")
- ),
-
+ % Descend once to move to the depth of the recursive callees.
+ recursion_depth_descend(Depth0, Depth),
+ DepthI = recursion_depth_to_int(Depth),
get_recursive_calls_and_counts(Deep, CliquePtr, PDPtr,
CallCountsMap),
RecursiveCallSiteCostMap = map_values_only(
(func(Count) =
- build_cs_cost_csq_percall(float(Count), CostFn(DepthI))),
+ build_cs_cost_csq_percall(float(Count),
+ CostFn(DepthI))),
CallCountsMap),
MaybeRecursiveCallSiteCostMap = ok(RecursiveCallSiteCostMap),
- trace [compile_time(flag("debug_recursive_call_costs")), io(!IO)] (
+ trace [compile_time(flag("debug_recursive_call_costs")),
+ io(!IO)] (
format_recursive_call_site_cost_map(
RecursiveCallSiteCostMap, PrettyCostMapCord),
PrettyCostMap = append_list(cord.list(PrettyCostMapCord)),
io.format(
- "D: In clique %s recursive call site cost map is:\n%s\n",
+ "D: In clique %s recursive call site cost map is:" ++
+ "\n%s\n",
[s(string(CliquePtr)), s(PrettyCostMap)], !IO),
io.flush_output(!IO)
)
+ )
+ ;
+ MaybeDepth = no,
+ unexpected($module,
+ "Expected valid depth for known recursion type")
+ )
;
( RecursionType = rt_divide_and_conquer(_, _)
; RecursionType = rt_mutual_recursion(_)
Index: deep_profiler/coverage.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/coverage.m,v
retrieving revision 1.12
diff -u -p -b -r1.12 coverage.m
--- deep_profiler/coverage.m 13 Jan 2011 00:36:55 -0000 1.12
+++ deep_profiler/coverage.m 13 Jan 2011 04:32:17 -0000
@@ -110,6 +110,8 @@
:- import_module string.
:- import_module unit.
+%-----------------------------------------------------------------------------%
+
get_coverage_before(coverage_known(Before, _), Before).
get_coverage_before(coverage_known_zero, 0).
get_coverage_before(coverage_known_same(Before), Before).
Index: deep_profiler/measurements.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/measurements.m,v
retrieving revision 1.25
diff -u -p -b -r1.25 measurements.m
--- deep_profiler/measurements.m 15 Dec 2010 06:30:34 -0000 1.25
+++ deep_profiler/measurements.m 13 Jan 2011 04:28:59 -0000
@@ -199,6 +199,8 @@
:- pred recursion_depth_descend(recursion_depth, recursion_depth).
:- mode recursion_depth_descend(in, out) is det.
+:- pred recursion_depth_is_base_case(recursion_depth::in) is semidet.
+
%-----------------------------------------------------------------------------%
:- type static_coverage_info.
@@ -889,7 +891,17 @@ recursion_depth_to_float(recursion_depth
recursion_depth_to_int(D) =
round_to_int(recursion_depth_to_float(D)).
-recursion_depth_descend(recursion_depth(D), recursion_depth(D - 1.0)).
+recursion_depth_descend(recursion_depth(D), recursion_depth(D - 1.0)) :-
+ ( D >= 0.5 ->
+ true
+ ;
+ unexpected($module, $pred,
+ format("Recursion depth will be less than zero: %f", [f(D - 1.0)]))
+ ).
+
+recursion_depth_is_base_case(recursion_depth(D)) :-
+ D < 0.5,
+ D >= -0.5.
%----------------------------------------------------------------------------%
Index: deep_profiler/recursion_patterns.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/recursion_patterns.m,v
retrieving revision 1.11
diff -u -p -b -r1.11 recursion_patterns.m
--- deep_profiler/recursion_patterns.m 13 Jan 2011 00:36:55 -0000 1.11
+++ deep_profiler/recursion_patterns.m 13 Jan 2011 04:32:17 -0000
@@ -6,7 +6,7 @@
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
-% File: query.m.
+% File: recursion_patterns.m.
% Authors: pbone.
%
% This module contains code that analysis the recursive structures of cliques.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20110113/103cb6f9/attachment.sig>
More information about the reviews
mailing list