Attachment 'timing_binary_codes.patch'
Download 1 # HG changeset patch
2 # User Robert L. Miller <[email protected]>
3 # Date 1279197902 -7200
4 # Node ID 258f51eaf502fe5b4d243de4aa33c1574af52f9e
5 # Parent fb13c796966fb0514a9708de9b5431a054b8534a
6 [mq]: timing_binary_codes.patch
7
8 diff -r fb13c796966f -r 258f51eaf502 sage/coding/binary_code.pxd
9 --- a/sage/coding/binary_code.pxd Tue Jul 13 12:52:04 2010 +0200
10 +++ b/sage/coding/binary_code.pxd Thu Jul 15 14:45:02 2010 +0200
11 @@ -5,6 +5,10 @@
12
13 ctypedef unsigned int codeword
14
15 +cdef extern from "time.h":
16 + ctypedef unsigned long clock_t
17 + cdef clock_t clock()
18 +
19 cdef struct WordPermutation:
20 # A word permutation is a permutation of the bits in a codeword.
21 int chunk_num
22 @@ -55,6 +59,10 @@
23 cdef int merge_perm(self, int *, int *)
24
25 cdef class PartitionStack:
26 + cdef clock_t wd_deg_clock_ticks
27 + cdef clock_t cl_deg_clock_ticks
28 + cdef unsigned long wd_deg_calls
29 + cdef unsigned long cl_deg_calls
30 cdef int *wd_ents
31 cdef int *wd_lvls
32 cdef int *col_ents
33 diff -r fb13c796966f -r 258f51eaf502 sage/coding/binary_code.pyx
34 --- a/sage/coding/binary_code.pyx Tue Jul 13 12:52:04 2010 +0200
35 +++ b/sage/coding/binary_code.pyx Thu Jul 15 14:45:02 2010 +0200
36 @@ -2644,6 +2644,8 @@
37 return result
38
39 cdef int refine(self, int k, int *alpha, int alpha_length, BinaryCode CG, int *ham_wts):
40 + cdef clock_t start, end, wd_deg_ticks = <clock_t> 0, cl_deg_ticks = <clock_t> 0
41 + cdef unsigned long wd_deg_calls = 0, cl_deg_calls = 0
42 cdef int q, r, s, t, flag = self.flag, self_ncols = self.ncols
43 cdef int t_w, self_nwords = self.nwords, invariant = 0, i, j, m = 0
44 cdef int *self_wd_degs = self.wd_degs, *self_wd_lvls = self.wd_lvls, *self_wd_ents = self.wd_ents
45 @@ -2664,7 +2666,11 @@
46 while 1:
47 # print 'col_i', self_col_ents[i]
48 # print 'alpha[m]^flag', alpha[m]^flag
49 + start = clock()
50 self_col_degs[i-j] = self.col_degree(CG, self_col_ents[i], alpha[m]^flag, k)
51 + end = clock()
52 + cl_deg_ticks += (end - start)
53 + cl_deg_calls += 1
54 # print 'deg', self_col_degs[i-j]
55 if s == 0 and self_col_degs[i-j] != self_col_degs[0]: s = 1
56 i += 1
57 @@ -2688,7 +2694,11 @@
58 alpha_length += 1
59 r += 1
60 if r >= i: break
61 + start = clock()
62 invariant += self.col_degree(CG, self_col_ents[i-1], alpha[m]^flag, k)
63 + end = clock()
64 + cl_deg_ticks += (end - start)
65 + cl_deg_calls += 1
66 invariant += (i-j)
67 j = i
68 else:
69 @@ -2700,7 +2710,11 @@
70 invariant += 64
71 while 1:
72 # print 'i', i
73 + start = clock()
74 self_wd_degs[i-j] = self.wd_degree(CG, self_wd_ents[i], alpha[m], k, ham_wts)
75 + end = clock()
76 + wd_deg_ticks += (end - start)
77 + wd_deg_calls += 1
78 # print 'deg', self_wd_degs[i-j]
79 if s == 0 and self_wd_degs[i-j] != self_wd_degs[0]: s = 1
80 i += 1
81 @@ -2725,10 +2739,18 @@
82 alpha_length += 1
83 r += 1
84 if r >= i: break
85 + start = clock()
86 invariant += self.wd_degree(CG, self_wd_ents[i-1], alpha[m], k, ham_wts)
87 + end = clock()
88 + wd_deg_ticks += (end - start)
89 + wd_deg_calls += 1
90 invariant += (i-j)
91 j = i
92 m += 1
93 + self.cl_deg_clock_ticks += cl_deg_ticks
94 + self.wd_deg_clock_ticks += wd_deg_ticks
95 + self.cl_deg_calls += cl_deg_calls
96 + self.wd_deg_calls += wd_deg_calls
97 return invariant
98
99 def _clear(self, k):
100 @@ -3214,7 +3236,6 @@
101 return py_aut_gp_gens, py_labeling, aut_gp_size, base
102
103 cdef void aut_gp_and_can_label(self, BinaryCode C, int verbosity):
104 -
105 # declare variables:
106 cdef int i, j, ii, jj, iii, jjj, iiii # local variables
107
108 @@ -3292,12 +3313,15 @@
109 W = self.W
110 e = self.e
111 nu = PartitionStack(nrows, ncols)
112 + nu.cl_deg_clock_ticks = <clock_t> 0
113 + nu.wd_deg_clock_ticks = <clock_t> 0
114 + nu.cl_deg_calls = 0
115 + nu.wd_deg_calls = 0
116 Theta = OrbitPartition(nrows, ncols)
117
118 # trivial case
119 if ncols == 0 or nrows == 0:
120 raise NotImplementedError("Must supply a nontrivial code.")
121 -
122 state = 1
123 while state != -1:
124 if False:
125 @@ -3806,6 +3830,12 @@
126 self.labeling[rho.col_ents[i]] = i
127 for i from 0 <= i < 2*nrows:
128 self.labeling[i+ncols] = rho.basis_locations[i]
129 + print 'wd deg tot clock ticks', nu.wd_deg_clock_ticks
130 + print ' ', nu.wd_deg_calls, 'calls'
131 + print ' ', (<double>nu.wd_deg_clock_ticks) / (<double>nu.wd_deg_calls), 'per call'
132 + print 'cl deg tot clock ticks', nu.cl_deg_clock_ticks
133 + print ' ', nu.cl_deg_calls, 'calls'
134 + print ' ', (<double>nu.cl_deg_clock_ticks) / (<double>nu.cl_deg_calls), 'per call'
135
136 def put_in_canonical_form(self, BinaryCode B):
137 """
138 diff -r fb13c796966f -r 258f51eaf502 sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx
139 --- a/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx Tue Jul 13 12:52:04 2010 +0200
140 +++ b/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx Thu Jul 15 14:45:02 2010 +0200
141 @@ -471,7 +471,6 @@
142 compared_current_and_label_indicators = 0
143 label_ps = PS_copy(current_ps)
144 current_ps.depth -= 1
145 -
146 # Main loop:
147 while current_ps.depth != -1:
148
149 @@ -688,7 +687,7 @@
150 current_ps.depth = j
151 if bitset_check(vertices_have_been_reduced, current_ps.depth):
152 bitset_and(vertices_to_split[current_ps.depth], vertices_to_split[current_ps.depth], minimal_cell_reps_of_generators[index_in_fp_and_mcr])
153 -
154 +
155 # End of main loop.
156
157 mpz_init_set(output.order, subgroup_size)
158 diff -r fb13c796966f -r 258f51eaf502 sage/groups/perm_gps/partn_ref/refinement_binary.pxd
159 --- a/sage/groups/perm_gps/partn_ref/refinement_binary.pxd Tue Jul 13 12:52:04 2010 +0200
160 +++ b/sage/groups/perm_gps/partn_ref/refinement_binary.pxd Thu Jul 15 14:45:02 2010 +0200
161 @@ -14,7 +14,15 @@
162 from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport get_aut_gp_and_can_lab, aut_gp_and_can_lab_return
163 from double_coset cimport double_coset
164
165 +cdef extern from "time.h":
166 + ctypedef unsigned long clock_t
167 + cdef clock_t clock()
168 +
169 cdef class BinaryCodeStruct:
170 + cdef clock_t wd_deg_clock_ticks
171 + cdef clock_t cl_deg_clock_ticks
172 + cdef unsigned long wd_deg_calls
173 + cdef unsigned long cl_deg_calls
174 cdef bitset_s *alpha_is_wd # single bitset of length nwords + degree
175 cdef int degree
176 cdef int nwords
177 diff -r fb13c796966f -r 258f51eaf502 sage/groups/perm_gps/partn_ref/refinement_binary.pyx
178 --- a/sage/groups/perm_gps/partn_ref/refinement_binary.pyx Tue Jul 13 12:52:04 2010 +0200
179 +++ b/sage/groups/perm_gps/partn_ref/refinement_binary.pyx Thu Jul 15 14:45:02 2010 +0200
180 @@ -240,9 +240,17 @@
181 part[i][len(partition[i])] = -1
182 part[len(partition)] = NULL
183 self.first_time = 1
184 -
185 + self.wd_deg_clock_ticks = <clock_t> 0
186 + self.cl_deg_clock_ticks = <clock_t> 0
187 + self.wd_deg_calls = 0
188 + self.cl_deg_calls = 0
189 self.output = get_aut_gp_and_can_lab(self, part, self.degree, &all_children_are_equivalent, &refine_by_bip_degree, &compare_linear_codes, 1, 1, 1)
190 -
191 + print 'wd deg tot clock ticks', self.wd_deg_clock_ticks
192 + print ' ', self.wd_deg_calls, 'calls'
193 + print ' ', (<double>self.wd_deg_clock_ticks) / (<double>self.wd_deg_calls), 'per call'
194 + print 'cl deg tot clock ticks', self.cl_deg_clock_ticks
195 + print ' ', self.cl_deg_calls, 'calls'
196 + print ' ', (<double>self.cl_deg_clock_ticks) / (<double>self.cl_deg_calls), 'per call'
197 for i from 0 <= i < len(partition):
198 sage_free(part[i])
199 sage_free(part)
200 @@ -667,6 +675,8 @@
201 $$ I(G, PS, cells_to_refine_by) = I( \gamma(G), \gamma(PS), \gamma(cells_to_refine_by) ) .$$
202
203 """
204 + cdef clock_t start, end, wd_deg_ticks = <clock_t> 0, cl_deg_ticks = <clock_t> 0
205 + cdef unsigned long wd_deg_calls = 0, cl_deg_calls = 0
206 cdef BinaryCodeStruct BCS = <BinaryCodeStruct> S
207 cdef int current_cell_against = 0
208 cdef int current_cell, i, r, j
209 @@ -702,7 +712,11 @@
210 i = current_cell
211 necessary_to_split_cell = 0
212 while 1:
213 + start = clock()
214 col_degrees[i-current_cell] = col_degree(col_ps, BCS, i, ctrb[current_cell_against], word_ps)
215 + end = clock()
216 + cl_deg_ticks += (end - start)
217 + cl_deg_calls += 1
218 if col_degrees[i-current_cell] != col_degrees[0]:
219 necessary_to_split_cell = 1
220 i += 1
221 @@ -712,7 +726,11 @@
222 if necessary_to_split_cell:
223 invariant += 8
224 first_largest_subcell = sort_by_function(col_ps, current_cell, col_degrees, col_counts, col_output, BCS.nwords+1)
225 + start = clock()
226 invariant += col_degree(col_ps, BCS, i-1, ctrb[current_cell_against], word_ps)
227 + end = clock()
228 + cl_deg_ticks += (end - start)
229 + cl_deg_calls += 1
230 invariant += first_largest_subcell
231 against_index = current_cell_against
232 while against_index < ctrb_len:
233 @@ -737,7 +755,11 @@
234 i = current_cell
235 necessary_to_split_cell = 0
236 while 1:
237 + start = clock()
238 word_degrees[i-current_cell] = word_degree(word_ps, BCS, i, ctrb[current_cell_against], col_ps)
239 + end = clock()
240 + wd_deg_ticks += (end - start)
241 + wd_deg_calls += 1
242 if word_degrees[i-current_cell] != word_degrees[0]:
243 necessary_to_split_cell = 1
244 i += 1
245 @@ -747,7 +769,11 @@
246 if necessary_to_split_cell:
247 invariant += 64
248 first_largest_subcell = sort_by_function(word_ps, current_cell, word_degrees, word_counts, word_output, BCS.degree+1)
249 + start = clock()
250 invariant += word_degree(word_ps, BCS, i-1, ctrb[current_cell_against], col_ps)
251 + end = clock()
252 + wd_deg_ticks += (end - start)
253 + wd_deg_calls += 1
254 invariant += first_largest_subcell
255 against_index = current_cell_against
256 while against_index < ctrb_len:
257 @@ -768,6 +794,10 @@
258 invariant += (i - current_cell)
259 current_cell = i
260 current_cell_against += 1
261 + BCS.cl_deg_clock_ticks += cl_deg_ticks
262 + BCS.wd_deg_clock_ticks += wd_deg_ticks
263 + BCS.cl_deg_calls += cl_deg_calls
264 + BCS.wd_deg_calls += wd_deg_calls
265 return invariant
266
267 cdef int compare_linear_codes(int *gamma_1, int *gamma_2, object S1, object S2):
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.