Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/control/mlrisc-profiling.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/control/mlrisc-profiling.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (view) (download)

1 : monnier 16 signature MLRISC_PROFILING =
2 :     sig
3 :    
4 :     val profiling : bool ref
5 :     val use_profile_info : bool ref
6 :     val edge_counts : int Array.array Array.array ref
7 :     val edge_table : (int * int) list Array.array ref
8 :     val module_table : (string * int * int) list ref
9 :     val module : string ref
10 :     val cluster_id : int ref
11 :     val new_cluster : int * (int * int) list -> unit
12 :     val get_cluster_id : (unit -> int) ref
13 :    
14 :     end
15 :    
16 :     structure MLRISC_Profiling : MLRISC_PROFILING =
17 :     struct
18 :    
19 :     structure A = Array
20 :    
21 :     val profiling = ref false
22 :     val use_profile_info = ref false
23 :     val edge_counts = ref A.array0 : int A.array A.array ref
24 :     val edge_table = ref A.array0 : (int * int) list A.array ref
25 :     val module_table = ref [] : (string * int * int) list ref
26 :     val module = ref ""
27 :     val cluster_id = ref 0
28 :    
29 :     fun get_id() = let val id = !cluster_id in cluster_id := 1 + id; id end
30 :    
31 :     val get_cluster_id = ref get_id
32 :    
33 :     fun initialize() = Unsafe.setVar(!edge_counts)
34 :    
35 :     fun grow n =
36 :     let val m = A.length(!edge_counts) * 2
37 :     val m = if m < n then n else m
38 :     val m = if m < 10 then 10 else m
39 :     val new_edge_counts = A.array(m,A.array0)
40 :     val new_edge_table = A.array(m,[])
41 :     in A.copy{src= !edge_counts, dst=new_edge_counts,si=0,di=0,len=NONE};
42 :     edge_counts := new_edge_counts;
43 :     A.copy{src= !edge_table, dst=new_edge_table, si=0,di=0,len=NONE};
44 :     edge_table := new_edge_table;
45 :     initialize()
46 :     end
47 :    
48 :     fun new_cluster(cluster_id,edges) =
49 :     let val n = length edges
50 :     in if A.length(!edge_counts) <= cluster_id then grow cluster_id else ();
51 :     A.update(!edge_table,cluster_id,edges);
52 :     A.update(!edge_counts,cluster_id,A.array(n,0))
53 :     end
54 :    
55 :     end
56 :    
57 :     (*
58 : monnier 113 * $Log$
59 : monnier 16 *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0