Debian Codegraph @

manual/gf-complete.html

raw
1 <html>
2
3 <head>
4
5 <link rel="stylesheet" type="text/css" href="style.css">
6
7 </head>
8
9 <body>
10
11 <div id="box">
12
13 <h1>
14 GF-Complete: A Comprehensive Open Source Library for Galois </br>
15 Field Arithmetic
16 </h1>
17
18 <h1> Version 1.02 </h1>
19
20 <h4>James S. Plank* &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Ethan L. Miller
21 Kevin M. Greenan &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Benjamin A. Arnold<br>
22 John A. Burnum &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Adam W. Disney &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
23 Allen C. McBride
24
25 </h4> <br>
26
27
28
29 <a href="">
30
31 https://bitbucket.org/jimplank/gf-complete
32
33 </a><br><br>
34 <a href="">
35 http://web.eecs.utk.edu/~plank/plank/papers/GF-Complete-Manual-1.02.pdf
36
37
38 </a> <br> <br>
39
40
41
42
43
44
45
46 </div>
47
48
49 <div id="pages_paragraphs_2">
50
51 This is a user's manual for GF-Complete, version 1.02. This release supersedes version 0.1 and represents the first
52 major release of GF-Complete. To our knowledge, this library implements every Galois Field multiplication technique
53 applicable to erasure coding for storage, which is why we named it GF-Complete. The primary goal of this library is
54 to allow storage system researchers and implementors to utilize very fast Galois Field arithmetic for Reed-Solomon
55 coding and the like in their storage installations. The secondary goal is to allow those who want to explore different
56 ways to perform Galois Field arithmetic to be able to do so effectively.
57
58
59 <p>
60 If you wish to cite GF-Complete, please cite technical report UT-CS-13-716: [PMG<sup>+</sup>13].
61
62 </p>
63
64
65 <h2>If You Use This Library or Document </h2>
66
67
68
69 Please send me an email to let me know how it goes. Or send me an email just to let me know you are using the
70 library. One of the ways in which we are evaluated both internally and externally is by the impact of our work, and if
71 you have found this library and/or this document useful, we would like to be able to document it. Please send mail to
72 <em>[email protected].</em> Please send bug reports to that address as well.
73
74
75
76 <p>
77 The library itself is protected by the New BSD License. It is free to use and modify within the bounds of this
78 license. To the authors' knowledge, none of the techniques implemented in this library have been patented, and the
79 authors are not pursing patents. </p> <br>
80
81 </div>
82 <div id="footer">
83
84 <span id="footer_bar">&nbsp&nbsp&nbsp&nbsp.*[email protected] (University of Tennessee), el </span> <em>[email protected] </em>(UC Santa Cruz), <em>[email protected] </em> (Box). This material
85 is based upon work supported by the National Science Foundation under grants CNS-0917396, IIP-0934401 and CSR-1016636, plus REU supplements
86 CNS-1034216, CSR-1128847 and CSR-1246277. Thanks to Jens Gregor for helping us wade through compilation issues, and for Will
87 Houston for his initial work on this library.
88
89 </div>
90
91 <b>Finding the Code </b>
92 <br><br>
93 This code is actively maintained on bitbucket:<a href=""> https://bitbucket.org/jimplank/gf-complete. </a> There are
94 previous versions on my UTK site as a technical report; however, that it too hard to maintain, so the main version is
95 on bitbucket.<br><br>
96
97
98 <b>Two Related Papers </b> <br><br>
99
100 This software acccompanies a large paper that describes these implementation techniques in detail [PGM13a]. We
101 will refer to this as <em> "The Paper." </em> You do not have to read The Paper to use the software. However, if you want to
102 start exploring the various implementations, then The Paper is where you'll want to go to learn about the techniques
103 in detail.
104
105
106
107 <p>This library implements the techniques described in the paper "Screaming Fast Galois Field Arithmetic Using Intel
108 SIMD Instructions," [PGM13b]. The Paper describes all of those techniques as well.
109 </p><br><br>
110
111 <b>If You Would Like HelpWith the Software </b><br><br>
112
113 Please contact the first author of this manual.<br><br>
114
115 <b>Changes from Revision 1.01</b>
116 <br><br>
117 The major change is that we are using autoconf to aid with compilation, thus obviating the need for the old <b>flag_tester</b>
118 code. Additionally, we have added a quick timing tool, and we have modified <b>gf_methods</b> so that it may be used to
119 run the timing tool and the unit tester.
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 <br/>
139 CONTENT <span class="aligning_page_number"> 3 </span>
140 <h2>Contents </h2>
141 <div class="index">
142 1 <span class="aligning_numbers">Introduction </span> <span class="aligning_page_number"> 5 </span>
143 <br><br>
144 2 <span class="aligning_numbers">Files in the Library </span> <span class="aligning_page_number"> 6 </span> <br> </div>
145
146 <div class="sub_indices">
147 2.1 Header files in the directory <b>"include"</b> . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 6 </span> <br>
148 2.2 Source files in the <b>"src"</b> directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<span class="aligning_page_number"> 7 </span> <br>
149 2.3 Library tools files in the <b>"tools"</b> directory . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 7 </span> <br>
150 2.4 The unit tester in the <b>"test"</b> directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 8 </span> <br>
151 2.5 Example programs in the <b>"examples"</b> directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<span class="aligning_page_number"> 8 </span>
152
153 </div>
154 <br>
155 <div class="index">
156
157 3 <span class="aligning_numbers">Compilation </span><span class="aligning_page_number"> 8 </span> <br> <br>
158 4 <span class="aligning_numbers">Some Tools and Examples to Get You Started </span><span class="aligning_page_number"> 8 </span> <br><br> </div>
159
160
161
162 <div class="sub_indices">
163 4.1 Three Simple Command Line Tools: gf_mult, gf_div and gf_add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 8</span> <br>
164 4.2 Quick Starting Example #1: Simple multiplication and division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 9 </span> <br>
165 4.3 Quick Starting Example #2: Multiplying a region by a constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 10 </span> <br>
166 4.4 Quick Starting Example #3: Using w = 64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 11 </span> <br>
167 4.5 Quick Starting Example #4: Using w = 128. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 11 </span>
168 </div>
169 <br>
170
171
172 <div class="index">
173 5 <span class="aligning_numbers"> Important Information on Alignment when Multiplying Regions </span><span class="aligning_page_number"> 12</span> <br><br>
174
175 6 <span class="aligning_numbers"> The Defaults</span><span class="aligning_page_number"> 13 </span> <br>
176
177 </div>
178
179 <div class="sub_indices">
180 6.1 Changing the Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<span class="aligning_page_number"> 14 </span> <br>
181
182
183 <ul style="list-style-type:none;">
184 <li>6.1.1 Changing the Components of a Galois Field with <b> create_gf_from_argv() </b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 15 </span> <br>
185 </li>
186 <li>
187 6.1.2 Changing the Polynomial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 16 </span> <br>
188 </li>
189 <li>
190 6.1.3 Changing the Multiplication Technique. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<span class="aligning_page_number"> 17 </span>
191 </li>
192
193
194 <li>
195 6.1.4 Changing the Division Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 19 </span>
196 </li>
197
198
199 <li>
200 6.1.5 Changing the Region Technique. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..<span class="aligning_page_number"> 19 </span>
201 </li>
202 </ul>
203 6.2 Determining Supported Techniques with <b>gf_methods</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 20</span> <br>
204
205 6.3 Testing with <b>gf_unit, gf_time,</b> and <b>time_tool.sh </b>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 21</span>
206
207 <ul style="list-style-type:none;">
208 <li>
209 6.3.1 <b>time_tool.sh</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . <span class="aligning_page_number"> 22 </span>
210 </li>
211
212 <li>
213 6.3.2 An example of <b>gf_methods</b> and <b>time_tool.sh</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .. . .<span class="aligning_page_number"> 23 </span>
214 </li>
215
216 </ul>
217
218 6.4 Calling <b>gf_init_hard()</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . . . . <span class="aligning_page_number"> 24</span> <br>
219
220 6.5 <b>gf_size()</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . <span class="aligning_page_number"> 26</span> <br><br>
221 </div>
222
223
224 <div class="index">
225 8 <span class="aligning_numbers"> Further Information on Options and Algorithms </span><span class="aligning_page_number"> 26 </span> </div> <br><br> </div>
226 <div class="sub_indices">
227 7.1 Inlining Single Multiplication and Division for Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 26 </span> <br>
228 7.2 Using different techniques for single and region multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 27 </span> <br>
229 7.3 General <em>w</em> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 28 </span><br>
230
231 7.4 Arguments to <b>"SPLIT"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 28</span> <br>
232 7.5 Arguments to <b>"GROUP"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number">29 </span> <br>
233 7.6 Considerations with <b>"COMPOSITE"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number">30 </span> <br>
234 7.7 <b>"CARRY_FREE"</b> and the Primitive Polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number">31 </span> <br>
235 7.8 More on Primitive Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . <span class="aligning_page_number">31 </span> <br>
236
237
238 <ul style="list-style-type:none;">
239 <li>
240 7.8.1 Primitive Polynomials that are not Primitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 31</span> <br>
241
242 </li>
243 <li>7.8.2 Default Polynomials for Composite Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 32</span> <br>
244
245 </li>
246 </ul>
247
248 </div>
249
250
251
252
253
254
255
256
257
258
259
260 <br/>
261 CONTENT <span class="aligning_page_number"> 4 </span>
262
263 <div class="sub_indices">
264 <ul style="list-style-type:none">
265 <li> 7.8.3 The Program <b>gf_poly</b> for Verifying Irreducibility of Polynomials </span><span class="aligning_page_number"> 33 </span>
266 </li>
267 </ul>
268
269
270 7.9<span class="aligning_numbers"><b>"ALTMAP"</b> considerations and <b>extract_word()</b> </span><span class="aligning_page_number"> 34 </span>
271 <ul style="list-style-type:none">
272 <li>
273
274 7.9.1 Alternate mappings with <b>"SPLIT"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .<span class="aligning_page_number"> 34</span> <br>
275 </li>
276 <li>
277 7.9.2 Alternate mappings with <b>"COMPOSITE"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 36 </span> <br>
278 </li>
279 <li>
280 7.9.3 The mapping of <b>"CAUCHY"</b> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . .. <span class="aligning_page_number"> 37 </span> <br>
281 </li>
282 </ul>
283 </div>
284
285
286 8 <span class="aligning_numbers"><b>Thread Safety </b></span><span class="aligning_page_number"> 37 </span> <br><br> </div>
287
288 9 <span class="aligning_numbers"><b>Listing of Procedures</b> </span><span class="aligning_page_number"> 37 </span> <br><br> </div>
289
290 10 <span class="aligning_numbers"><b>Troubleshooting</b> </span><span class="aligning_page_number"> 38 </span> <br><br> </div>
291 11 <span class="aligning_numbers"><b>Timings</b> </span><span class="aligning_page_number"> 41 </span> <br><br> </div>
292
293 <div class="sub_indices">
294 11.1 Multiply() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . . . . . . . . . .. . . . <span class="aligning_page_number"> 42</span> <br>
295 11.2 Divide() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . . . . .. . . . . <span class="aligning_page_number"> 42 </span> <br>
296 11.3 Multiply Region() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . .. . . . . . . . . . . . . . . . . . <span class="aligning_page_number"> 43 </span> <br>
297 </div>
298
299
300
301
302
303
304 <br/>
305 INTRODUCTION <span class="aligning_page_number"> 5 </span>
306
307
308 <h3>1 Introduction </h3>
309
310 Galois Field arithmetic forms the backbone of erasure-coded storage systems, most famously the Reed-Solomon
311 erasure code. A Galois Field is defined over w-bit words and is termed <em>GF(2<sup>w</sup>).</em> As such, the elements of a Galois
312 Field are the integers 0, 1, . . ., 2<sup>w</sup> - 1. Galois Field arithmetic defines addition and multiplication over these closed
313 sets of integers in such a way that they work as you would hope they would work. Specifically, every number has a
314 unique multiplicative inverse. Moreover, there is a value, typically the value 2, which has the property that you can
315 enumerate all of the non-zero elements of the field by taking that value to successively higher powers.
316
317
318 <p>Addition in a Galois Field is equal to the bitwise exclusive-or operation. That's nice and convenient. Multiplication
319 is a little more complex, and there are many, many ways to implement it. The Paper describes them all, and the
320 following references providemore supporting material: [Anv09, GMS08, LHy08, LD00, LBOX12, Pla97]. The intent
321 of this library is to implement all of the techniques. That way, their performancemay be compared, and their tradeoffs
322 may be analyzed. <p>
323
324
325
326
327 <ol>
328
329 When used for erasure codes, there are typically five important operations:<br>
330 <li> <b>Adding two numbers in </b> GF(2<sup>w</sup>). That's bitwise exclusive-or. </li>
331 <li> <b>Multiplying two numbers in</b> GF(2<sup>w</sup>). Erasure codes are usually based on matrices in GF(2<sup>w</sup>), and constructing
332 these matrices requires both addition and multiplication.</li>
333 <li> <b>Dividing two numbers in </b>GF(2<sup>w</sup>). Sometimes you need to divide to construct matrices (for example, Cauchy
334 Reed-Solomon codes [BKK<sup>+</sup>95, Rab89]). More often, though, you use division to invert matrices for decoding.
335 Sometimes it is easier to find a number's inverse than it is to divide. In that case, you can divide by multiplying
336 by an inverse. </li>
337
338 <li><b>adding two regions of numbers in</b> GF(2<sup>w</sup>), which will be explained along with... </li>
339 <li> <b>Mutiplying a region of numbers in </b>GF(2<sup>w</sup>) by a constant in GF(2<sup>w</sup>). Erasure coding typically boils down
340 to performing dot products in GF(2<sup>w</sup>). For example, you may define a coding disk using the equation: </li><br>
341
342
343
344
345 <center>c<em><sub>0</sub></em>= d<em><sub>0</sub></em> + 2d<em><sub>1</sub></em> + 4d<em><sub>2</sub></em> + 8d<em><sub>3</sub></em>.</sup> </center><br>
346
347 That looks like three multiplications and three additions However, the way ' implemented in a disk system
348 looks as in Figure 1. Large regions of disks are partitioned into w-bit words in GF(2<sup>w</sup>). In the example, let us
349 suppose that <em>w</em> = 8, and therefore that words are bytes. Then the regions pictured are 1 KB from each disk.
350 The bytes on disk Di are labeled d<sub>i,0,</sub> d<sub>i,1, . . . ,</sub> d<sub>i,1023,</sub> and the equation above is replicated 1024 times. For
351 0 &#8804 j < 1024:
352 <br><br>
353 <center>c<em><sub>0,j</sub></em> = d<em><sub>0,j</sub></em> + 2d<em><sub>1,j</sub></em> + 4d<em><sub>2,j</sub></em> + 8d<em><sub>3,j</sub></em> . </center>
354 <br>
355
356
357 While it's possible to implement each of these 1024 equations independently, using the single multiplication
358 and addition operations above, it is often much more efficient to aggregate. For example, most computer architectures
359 support bitwise exclusive-or of 64 and 128 bit words. Thus, it makes much more sense to add regions
360 of numbers in 64 or 128 bit chunks rather than as words in GF(2<sup>w</sup>). Multiplying a region by a constant can
361 leverage similar optimizations. </ol>
362
363
364 <p>GF-Complete supports multiplication and division of single values for all values of <em>w</em> &#8804 32, plus <em>w</em> = 64 and <em>w</em> =
365 128. It also supports adding two regions of memory (for any value of <em>w</em>, since addition equals XOR), and multiplying
366 a region by a constant in <em>GF(2<sup>4</sup>), GF(2<sup>8</sup>), GF(2<sup>16</sup>), GF(2<sup>32</sup>), GF(2<sup>64</sup>) and GF(2<sup>128</sup>).</em> These values are chosen
367 because words in GF(2<sup>w</sup>) fit into machine words with these values of <em>w.</em> Other values of w don't lend themselves
368 to efficient multiplication of regions by constants (although see the <b>"CAUCHY"</b> option in section 6.1.5 for a way to
369 multiply regions for other values of <em>w</em>).</p>
370
371
372
373
374
375
376 <br/>
377
378 2 &nbsp &nbsp <em> FILES IN THE LIBRARY </em> <span id="index_number">6 </span> <br><br><br>
379
380
381
382 <div class="image-cell_1"> </div> <br><br><br>
383
384 Figure 1: An example of adding two regions of numbers, and multiplying a region of numbers by a constant
385 in <em>GF(2<sup>w</sup>) </em>. In this example, <em>w</em> = 8, and each disk is holding a 1KB region. The same coding equation -
386 c<sub>0,j</sub></b> = d<sub>0,j</sub> + ad<sub>1,j</sub> + a<sup>2</sup>d<sub>2,j</sub> + a<sup>3</sup>d<sub>3,j</sub> is applied 1024 times. However, rather than executing this equation 1024
387 times, it is more efficient to implement this with three region-constant multiplications and three region-region additions.
388
389 <h3>2 &nbsp&nbsp&nbsp Files in the Library </h3>
390 This section provides an overview of the files that compose GF-Complete. They are partitioned among multiple
391 directories.
392
393 <h4> <b>2.1 &nbsp&nbsp&nbsp Header files in the directory "include"</b> </h4>
394
395 The following header files are part of GF-Complete.
396 <ul>
397 <li><b>gf_complete.h:</b> This is the header file that applications should include. It defines the gf_t type, which holds
398 all of the data that you need to perform the various operations in GF(2<sup>w</sup>). It also defines all of the arithmetic
399 operations. For an application to use this library, you should include gf_complete.h and then compile with the
400 library src/libgf_complete.la. </li><br>
401
402 <li><b>gf_method.h:</b> If you are wanting to modify the implementation techniques from the defaults, this file provides
403 a "helper" function so that you can do it from the Unix command line.
404 </li><br>
405
406 <li><b>gf_general.h:</b> This file has helper routines for doing basic Galois Field operations with any legal value of <em>w.</em>
407 The problem is that <em>w </em> &#8804 32, <em>w </em> = 64 and <em> w </em> = 128 all have different data types, which is a pain. The procedures
408 in this file try to alleviate that pain. They are used in <b>gf_mult, gf_unit</b> and <b>gf_time.</b> I'm guessing that most
409 applications won't use them, as most applications use <em>w</em> &#8804 32. </li><br>
410
411 <li><b>gf_rand.h:</b> I've learned that <b>srand48()</b> and its kin are not supported in all C installations. Therefore, this file
412 defines some randomnumber generators to help test the programs. The randomnumber generator is the "Mother
413 </li>
414
415 </ul>
416
417
418
419
420
421
422
423 <br/>
424
425 2 &nbsp &nbsp <em> FILES IN THE LIBRARY </em> <span id="index_number">7 </span> <br><br><br>
426 <ul>
427
428 of All" random number generator [Mar94] which we've selected because it has no patent issues. <b>gf_unit</b> and
429 <b>gf_time</b> use these random number generators.<br><br>
430 <li><b>gf_int.h:</b> This is an internal header file that the various source files use. This is <em>not</em> intended for applications to
431 include.</li><br>
432 <li><b>config.xx</b> and <b>stamp-h1</b> are created by autoconf, and should be ignored by applications. </li>
433 </ul>
434
435 <h3>2.2 &nbsp &nbsp <b> Source files in the "src" directory" </b> </h3>
436 <ul>
437 The following C files compose <b>gf_complete.a,</b> and they are in the direcoty src. You shouldn't have to mess with these
438 files, but we include them in case you have to:<br><br>
439 <li><b> gf_.c:</b> This implements all of the procedures in both <b>gf_complete.h</b> and <b>gf_int.h.</b> </li><br>
440 <li><b> gf_w4.c:</b> Procedures specific to <em>w </em> = 4. </li><br>
441 <li> <b>gf_w8.c:</b> Procedures specific to <em>w </em> = 8</li><br>
442 <li> <b>gf_w16.c:</b> Procedures specific to <em>w </em> = 16</li><br>
443 <li> <b>gf_w32.c:</b> Procedures specific to <em>w </em> = 32</li><br>
444 <li><b>gf_w64.c:</b> Procedures specific to <em>w </em> = 64</li><br>
445 <li> <b>gf_w128.c:</b> Procedures specific to <em>w </em> = 128</li><br>
446 <li> <b>gf_wgen.c:</b> Procedures specific to other values of <em>w </em> between 1 and 31</li><br>
447 <li> <b>gf_general.c:</b> Procedures that let you manipulate general values, regardless of whether <em>w </em> &#8804 32, <em>w </em> = 64
448 or <em>w </em> = 128. (I.e. the procedures defined in <b>gf_ general.h</b>)</li><br>
449 <li> <b>gf_method.c:</b> Procedures to help you switch between the various implementation techniques. (I.e. the procedures
450 defined in <b>gf_method.h</b>)</li><br>
451 <li> <b>gf_ rand.c:</b>"The Mother of all" random number generator. (I.e. the procedures defined in <b>gf_rand.h</b>)</li><br> </ul>
452
453 <h3>2.3 &nbsp &nbsp Library tools files in the "tools" directory </h3>
454
455 <ul>
456 The following are tools to help you with Galois Field arithmetic, and with the library. They are explained in greater
457 detail elsewhere in this manual.<br><br>
458 <li> <b>gf_mult.c, gf_ div.c</b> and <b>gf_ add:</b> Command line tools to do multiplication, division and addition by single numbers</li><br>
459 <li> <b>gf_time.c:</b> A program that times the procedures for given values of <em>w </em> and implementation options</li><br>
460 <li> <b>time_tool.sh:</b> A shell script that helps perform rough timings of the various multiplication, division and region
461 operations in GF-Complete</li><br>
462 <li> <b>gf_methods.c:</b> A program that enumerates most of the implementation methods supported by GF-Complete</li><br>
463 <li> <b> gf_poly.c:</b> A program to identify irreducible polynomials in regular and composite Galois Fields</li><br>
464
465 </ul>
466
467
468
469
470
471
472
473
474 <br/>
475
476 3 &nbsp &nbsp <em> COMPILATION </em> <span id="index_number">8 </span> <br><br><br>
477
478
479 <h3>2.4 &nbsp &nbsp The unit tester in the "test" directory </h3>
480
481 The test directory contains the proram <b>gf_unit.c,</b> which performs a battery of unit tests on GF-Complete. This is
482 explained in more detail in section 6.3.
483
484
485 <h3>2.5&nbsp &nbsp Example programs in the "examples" directory </h3>
486
487 There are seven example programs to help you understand various facets of GF-Complete. They are in the files
488 <b>gf_example x.c </b> in the <b>examples</b> directory. They are explained in sections 4.2 through 4.5, and section 7.9.<br><br>
489
490 <h2>3 &nbsp &nbsp Compilation </h2>
491
492 <em>From revision 1.02 forward, we are using autoconf. The old "flag tester" directory is now gone, as it is no longer in
493 use. </em><br><br>
494 To compile and install, you should do the standard operations that you do with most open source Unix code:<br><br>
495
496 UNIX> ./configure <br>
497 ... <br>
498 UNIX> make <br>
499 ... <br>
500 UNIX> sudo make install <br><br>
501
502
503 <p>If you perform the <b>install,</b> then the header, source, tool, and library files will be moved to system locations. In
504 particular, you may then compile the library by linking with the flag <b>-lgf_complete,</b> and you may use the tools from a
505 global executable directory (like <b>/usr/local/bin</b>). </p>
506
507 <p>
508 If you don't perform the install, then the header and tool files will be in their respective directories, and the library
509 will be in <b>src/libgf_complete.la.</b> </p>
510 <p>
511 If your system supports the various Intel SIMD instructions, the compiler will find them, and GF-Complete will
512 use them by default. </p>
513
514
515
516 <h2>4 &nbsp &nbsp Some Tools and Examples to Get You Started </h2>
517 <h3>4.1 Three Simple Command Line Tools: gf_mult, gf_div and gf_add </h3>
518
519
520 Before delving into the library, it may be helpful to explore Galois Field arithmetic with the command line tools:
521 <b>gf_mult, gf_div </b> and <b>gf_add.</b> These perform multiplication, division and addition on elements in <em>GF(2<sup>w</sup>).</em> If these are
522 not installed on your system, then you may find them in the tools directory. Their syntax is:
523 <ul>
524 <li><b>gf_mult a b</b> <em>w </em> - Multiplies a and b in <em> GF(2<sup>w</sup>)</em>. </li><br>
525 <li> <b>gf_div a b </b><em>w </em> - Divides a by b in GF(2<em><sup>w </sup></em>). </li><br>
526 <li><b>gf_add a b </b> <em>w </em> - Adds a and b in GF(2<em><sup>w </sup> </em>). </li><br>
527
528 You may use any value of <em>w </em> from 1 to 32, plus 64 and 128. By default, the values are read and printed in decimal;
529 however, if you append an 'h' to <em>w </em>, then <em>a, b </em> and the result will be printed in hexadecimal. For <em>w </em> = 128, the 'h' is
530 mandatory, and all values will be printed in hexadecimal.
531
532
533
534
535
536
537
538 <br/>
539
540 4 &nbsp &nbsp <em> SOME TOOLS AND EXAMPLES TO GET YOU STARTED 9 </em> <span id="index_number">9 </span> <br><br><br>
541
542
543 <p>Try them out on some examples like the ones below. You of course don't need to know that, for example, 5 * 4 = 7
544 in <em>GF(2<sup>4 </sup>) </em>; however, once you know that, you know that 7/
545 5 = 4 and 7/4 = 5. You should be able to verify the <b>gf_add</b>
546 statements below in your head. As for the other <b>gf_mult's</b>, you can simply verify that division and multiplication work
547 with each other as you hope they would. </p>
548 <br><br>
549 <div id="number_spacing">
550
551 UNIX> gf_mult 5 4 4 <br>
552 7 <br>
553 UNIX> gf_div 7 5 4 <br>
554 4 <br>
555 UNIX> gf_div 7 4 4 <br>
556 5 <br>
557 UNIX> gf_mult 8000 2 16h <br>
558 100b <br>
559 UNIX> gf_add f0f0f0f0f0f0f0f0 1313131313131313 64h <br>
560 e3e3e3e3e3e3e3e3 <br>
561 UNIX> gf_mult f0f0f0f0f0f0f0f0 1313131313131313 64h <br>
562 8da08da08da08da0 <br>
563 UNIX> gf_div 8da08da08da08da0 1313131313131313 64h <br>
564 f0f0f0f0f0f0f0f0 <br>
565 UNIX> gf_add f0f0f0f0f0f0f0f01313131313131313 1313131313131313f0f0f0f0f0f0f0f0 128h <br>
566 e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3 <br>
567 UNIX> gf_mult f0f0f0f0f0f0f0f01313131313131313 1313131313131313f0f0f0f0f0f0f0f0 128h <br>
568 786278627862784982d782d782d7816e <br>
569 UNIX> gf_div 786278627862784982d782d782d7816e f0f0f0f0f0f0f0f01313131313131313 128h <br>
570 1313131313131313f0f0f0f0f0f0f0f0 <br>
571 UNIX> <br><br>
572
573 </div>
574
575
576 Don't bother trying to read the source code of these programs yet. Start with some simpler examples like the ones
577 below. <br><br>
578
579 <h3>4.2 Quick Starting Example #1: Simple multiplication and division </h3>
580
581 The source files for these examples are in the examples directory.
582 <p>These two examples are intended for those who just want to use the library without getting too complex. The
583 first example is <b>gf_example 1,</b> and it takes one command line argument - w, which must be between 1 and 32. It
584 generates two random non-zero numbers in <em>GF(2<sup>w </sup>) </em> and multiplies them. After doing that, it divides the product by
585 each number. </p>
586 <p>
587 To perform multiplication and division in <em>GF(2<sup>w </sup>) </em>, you must declare an instance of the gf_t type, and then initialize
588 it for <em>GF(2<sup>w </sup>) </em> by calling <b>gf_init_easy().</b> This is done in <b>gf_example 1.c</b> with the following lines: </p><br><br>
589
590 gf_t gf; <br><br>r
591 ... <br><br>
592 if (!gf_init_easy(&gf, w)) { <br>
593 fprintf(stderr, "Couldn't initialize GF structure.\n"); <br>
594 exit(0); <br>
595 } <br>
596
597
598
599
600
601
602 <br/>
603
604 4 &nbsp &nbsp <em> SOME TOOLS AND EXAMPLES TO GET YOU STARTED </em> <span id="index_number">10 </span> <br><br><br>
605
606 <p>Once <b>gf</b> is initialized, you may use it for multiplication and division with the function pointers <b>multiply.w32</b> and
607 <b>divide.w32.</b> These work for any element of <em>GF(2<sup>w</sup>)</em> so long as w &#8804 32. </p> <br><br>
608
609 <div id="number_spacing">
610 <div style="padding-left:54px">
611 c = gf.multiply.w32(&gf, a, b);<br>
612 printf("%u * %u = %u\n", a, b, c);<br><br>
613 printf("%u / %u = %u\n", c, a, gf.divide.w32(&gf, c, a));<br>
614 printf("%u / %u = %u\n", c, b, gf.divide.w32(&gf, c, b));<br>
615
616
617 </div> </div>
618 <br><br>
619 Go ahead and test this program out. You can use <b>gf_mult</b> and <b>gf_div</b> to verify the results:<br><br>
620
621 <div id="number_spacing">
622 UNIX> gf_example_1 4 <br>
623 12 * 4 = 5 <br>
624 5 / 12 = 4 <br>
625 5 / 4 = 12 <br>
626 UNIX> gf_mult 12 4 4 <br>
627 5 <br>
628 UNIX> gf_example_1 16 <br>
629 14411 * 60911 = 44568 <br>
630 44568 / 14411 = 60911 <br>
631 44568 / 60911 = 14411 <br>
632 UNIX> gf_mult 14411 60911 16 <br>
633 44568 <br>
634 UNIX> <br><br>
635 </div>
636
637 <b>gf_init_easy()</b> (and <b>later_gf_init_hard()</b>) do call <b>malloc()</b> to implement internal structures. To release memory, call
638 <b>gf_free().</b> Please see section 6.4 to see how to call <b>gf_init_hard()</b> in such a way that it doesn't call <b>malloc().</b> <br><br>
639
640
641
642 <h3>4.3 &nbsp &nbsp &nbspQuick Starting Example #2: Multiplying a region by a constant </h3>
643
644
645 The program <b>gf_example</b> 2 expands on <b>gf_example</b> 1. If <em>w</em> is equal to 4, 8, 16 or 32, it performs a region multiply
646 operation. It allocates two sixteen byte regions, <b>r1</b> and <b>r2,</b> and then multiples <b>r1</b> by a and puts the result in <b>r2</b> using
647 the <b>multiply_region.w32</b> function pointer: <br><br>
648
649 <div style="padding-left:52px">
650 gf.multiply_region.w32 (&gf, r1, r2, a, 16, 0); <br><br>
651 </div>
652
653 That last argument specifies whether to simply place the product into r2 or to XOR it with the contents that are already
654 in r2. Zero means to place the product there. When we run it, it prints the results of the <b>multiply_region.w32</b> in
655 hexadecimal. Again, you can verify it using <b>gf_mult</b>:<br><br>
656 <div id="number_spacing">
657 UNIX> gf_example_2 4 <br>
658 12 * 2 = 11 <br>
659 11 / 12 = 2 <br>
660 11 / 2 = 12 <br><br>
661 multiply_region by 0xc (12) <br><br>
662 R1 (the source): 0 2 d 9 d 6 8 a 8 d b 3 5 c 1 8 8 e b 0 6 1 5 a 2 c 4 b 3 9 3 6 <br>
663 R2 (the product): 0 b 3 6 3 e a 1 a 3 d 7 9 f c a a 4 d 0 e c 9 1 b f 5 d 7 6 7 e <br>
664
665 </div>
666
667
668
669
670
671
672
673
674
675
676 <br/>
677
678 4 &nbsp &nbsp <em> SOME TOOLS AND EXAMPLES TO GET YOU STARTED </em> <span id="index_number">11 </span> <br><br><br>
679
680 <div id="number_spacing">
681 <table cellpadding="6">
682 <tr><td>UNIX></td> <td colspan="4"> gf_example_2 16 </td> </tr>
683
684 <tr>
685
686 <td>49598</td> <td> * </td> <td> 35999</td> <td> = </td> <td>19867 </td> </tr>
687
688 <tr><td>19867 </td><td>/ </td> <td> 49598 </td> <td> = </td> <td>35999 </td> </tr>
689 <tr><td>19867</td><td> /</td> <td> 35999 </td> <td> = </td> <td> 49598 </td> </tr> </table><br>
690
691
692 &nbsp multiply_region by 0xc1be (49598) <br><br>
693
694
695 <table cellpadding="6" >
696 <tr>
697 <td>R1 (the source):</td> <td> 8c9f </td> <td> b30e </td> <td> 5bf3 </td> <td> 7cbb </td> <td>16a9 </td> <td> 105d </td> <td> 9368 </td> <td> 4bbe </td> </tr>
698 <td>R2 (the product):</td> <td> 4d9b</td> <td> 992d </td> <td> 02f2 </td> <td> c95c </td> <td> 228e </td> <td> ec82 </td> <td> 324e </td> <td> 35e4 </td></tr>
699 </table>
700 </div>
701 <div id="number_spacing">
702 <div style="padding-left:9px">
703 UNIX> gf_mult c1be 8c9f 16h<br>
704 4d9b <br>
705 UNIX> gf_mult c1be b30e 16h <br>
706 992d <br>
707 UNIX> <br><br>
708 </div>
709 </div>
710
711 <h3>4.4 &nbsp &nbsp &nbsp Quick Starting Example #3: Using <em>w </em>= 64 </h3>
712 The program in <b>gf_example 3.c </b> is identical to the previous program, except it uses <em> GF(2<sup>64 </sup>). </em> Now <em>a, b</em> and <em> c </em> are
713 <b>uint64 t'</b>s, and you have to use the function pointers that have <b>w64</b> extensions so that the larger types may be employed.
714 <br><br>
715 <div id="number_spacing">
716
717 UNIX> gf_example_31
718 <table cellpadding="6">
719 <tr>
720
721 <td>a9af3adef0d23242 </td> <td> * </td> <td> 61fd8433b25fe7cd</td> <td> = </td> <td>bf5acdde4c41ee0c </td> </tr>
722
723 <td>bf5acdde4c41ee0c </td> <td> / </td> <td> a9af3adef0d23242 </td> <td> = </td> <td>61fd8433b25fe7cd </td> </tr>
724 <td>bf5acdde4c41ee0c </td> <td> / </td> <td> 61fd8433b25fe7cd </td> <td>= </td> <td>a9af3adef0d23242 </td> </tr>
725 </table><br><br>
726
727 &nbsp multiply_region by a9af3adef0d23242<br><br>
728 <table cellpadding="6" >
729 <tr>
730 <td>R1 (the source): </td> <td> 61fd8433b25fe7cd </td> <td>272d5d4b19ca44b7 </td> <td> 3870bf7e63c3451a </td> <td> 08992149b3e2f8b7 </td> </tr>
731 <tr><td>R2 (the product): </td> <td> bf5acdde4c41ee0c </td> <td> ad2d786c6e4d66b7 </td> <td> 43a7d857503fd261 </td> <td> d3d29c7be46b1f7c </td> </tr>
732 </table>
733
734 <div style="padding-left:9px">
735
736 UNIX> gf_mult a9af3adef0d23242 61fd8433b25fe7cd 64h <br>
737 bf5acdde4c41ee0c<br>
738 UNIX><br><br>
739 </div>
740 </div>
741 <h3>4.5 &nbsp &nbsp &nbsp Quick Starting Example #4: Using <em>w </em>= 128 </h3>
742 Finally, the program in <b>gf_example_4.c</b> uses <em>GF(2<sup>128</sup>).</em> Since there is not universal support for uint128 t, the library
743 represents 128-bit numbers as arrays of two uint64 t's. The function pointers for multiplication, division and region
744 multiplication now accept the return values as arguments:<br><br>
745
746 gf.multiply.w128(&gf, a, b, c); <br><br>
747
748 Again, we can use <b>gf_mult </b> and <b>gf_div </b>to verify the results:<br><br>
749 <div id="number_spacing">
750 <div style="padding-left:9px">
751 UNIX> gf_example_4 </div>
752 <table cellpadding="6" >
753 <tr>
754
755 <td>e252d9c145c0bf29b85b21a1ae2921fa </td> <td> * </td> <td> b23044e7f45daf4d70695fb7bf249432 </td> <td> = </td> </tr>
756 <tr><td>7883669ef3001d7fabf83784d52eb414 </td> </tr>
757
758 </table>
759
760 </div>
761
762
763
764
765
766
767
768
769 <br/>
770
771 4 &nbsp &nbsp <em> IMPORTANT INFORMATION ON ALIGNMENT WHEN MULTIPLYING REGIONS </em> <span id="index_number">12 </span> <br><br><br>
772
773 <div id="number_spacing">
774 multiply_region by e252d9c145c0bf29b85b21a1ae2921fa <br>
775 R1 (the source): f4f56f08fa92494c5faa57ddcd874149 b4c06a61adbbec2f4b0ffc68e43008cb <br>
776 R2 (the product): b1e34d34b031660676965b868b892043 382f12719ffe3978385f5d97540a13a1 <br>
777 UNIX> gf_mult e252d9c145c0bf29b85b21a1ae2921fa f4f56f08fa92494c5faa57ddcd874149 128h <br>
778 b1e34d34b031660676965b868b892043 <br>
779 UNIX> gf_div 382f12719ffe3978385f5d97540a13a1 b4c06a61adbbec2f4b0ffc68e43008cb 128h<br>
780 e252d9c145c0bf29b85b21a1ae2921fa<br>
781 UNIX><br><br>
782
783 </div>
784
785
786 <h2>5 &nbsp &nbsp &nbspImportant Information on Alignment when Multiplying Regions </h2>
787
788
789
790 In order to make multiplication of regions fast, we often employ 64 and 128 bit instructions. This has ramifications
791 for pointer alignment, because we want to avoid bus errors, and because on many machines, loading and manipulating
792 aligned quantities is much faster than unalinged quantities.<br><br>
793
794
795 When you perform multiply_region.wxx(<em>gf, source, dest, value, size, add </em>), there are three requirements:
796 <ol>
797 <li>
798 The pointers <em>source</em> and <em>dest </em> must be aligned for <em>w</em>-bit words. For <em>w </em> = 4 and <em>w </em> = 8, there is no restriction;
799 however for <em>w </em> = 16, the pointers must be multiples of 2, for <em>w </em> = 32, they must be multiples of 4, and for
800 <em>w </em> &#1013; {64, 128}, they must be multiples of 8. </li><br>
801
802 <li> The <em>size</em> must be a multiple of &#91; <em>w /
803 </em>
804 8 .&#93;
805 With <em>w </em> = 4 and <em>w </em> = 8, <em>w/ </em>
806 8 = 1 and there is no restriction. The other
807 sizes must be multiples of <em>w </em>/
808 8 because you have to be multiplying whole elements of <em> GF(2<sup>w </sup>) </em>. </li><br>
809
810 <li> The <b>source</b> and <b>dest</b> pointers must be aligned identically with respect to each other for the implementation
811 chosen. This is subtle, and we explain it in detail in the next few paragraphs. However, if you'd rather not figure
812 it out, the following recommendation will <em>always </em> work in GF-Complete: </li>
813
814 </ol>
815
816
817
818 <div style="padding-left:100px">
819 <b>If you want to be safe, make sure that source and dest are both multiples of 16. That is not a
820 strict requirement, but it will always work! </b> <br><br>
821 </div>
822
823
824 If you want to relax the above recommendation, please read further.
825 <p>When performing <b>multiply_region.wxx() </b>, the implementation is typically optimized for a region of bytes whose
826 size must be a multiple of a variable <em>s </em> ,, and which must be aligned to a multiple of another variable <em>t </em>. For example,
827 when doing <b>multiply_region.w32() </b> in <em> GF(2<sup>16 </sup>) </em> with SSE enabled, the implementation is optimized for regions of
828 32 bytes, which must be aligned on a 16-byte quantity. Thus, <em>s </em> = 32 and <em>t</em> = 16. However, we don't want <b>multiply_
829 region.w32() </b> to be too restrictive, so instead of requiring <em>source</em> and <em> dest </em> to be aligned to 16-byte regions, we
830 require that (<em>source </em> mod 16) equal (<em>dest</em> mod 16). Or, in general, that (<em>source</em> mod t) equal (<em>dest</em> mod <em>t</em>). </p>
831
832
833 <p>
834 Then, <b>multiply_region.wxx()</b> proceeds in three phases. In the first phase,<b> multiply.wxx()</b> is called on successive
835 words until (<em>source</em> mod <em>t</em>) equals zero. The second phase then performs the optimized region multiplication on
836 chunks of <em> s </em>bytes, until the remaining part of the region is less than s bytes. At that point, the third phase calls
837 <em>multiply.wxx() </em> on the last part of the region. </p>
838
839 A detailed example helps to illustrate. Suppose we make the following call in <em>GF(2<sup>16</sup>) </em> with SSE enabled:<br><br>
840 <center><b>multiply region.w32(gf, 0x10006, 0x20006, a, 274, 0)</b> </center>
841
842
843
844
845
846
847
848 <br/>
849
850 2 &nbsp &nbsp <em> FILES IN THE LIBRARY </em> <span id="index_number">13 </span> <br><br><br>
851
852
853
854 <div class="image-cell_2"> </div> <br><br><br>
855
856 Figure 2: Example of multiplying a region of 274 bytes in GF(216) when (source mod 16) = (dest mod 16) = 6. The
857 alignment parameters are s = 32 and t = 16. The multiplication is in three phases, which correspond to the initial
858 unaligned region (10 bytes), the aligned region of s-byte chunks (256 bytes), and the final leftover region (8 bytes).
859
860
861 <p>First, note that <em>source</em> and <em>dest</em> are aligned on two-byte quantities, which they must be in <em>GF(2<sup>16</sup>).</em> Second, note
862 that size is a multiple of &#91; 16/
863 8 &#93 = 2. And last, note that (<em>source</em> mod 16) equals (<em>dest</em> mod 16). We illustrate the three
864 phases of region multiplication in Figure 2. Because (<em>source</em> mod 16) = 6, there are 10 bytes of unaligned words that
865 are multiplied with five calls to <b>multiply.w32()</b> in the first phase. The second phase multiplies 256 bytes (eight chunks
866 of <em>s</em> = 32 bytes) using the SSE instructions. That leaves 8 bytes remaining for the third phase.
867 </p>
868
869 <p>
870 When we describe the defaults and the various implementation options, we specify s and t as "alignment parameters."
871 </p>
872 <p>
873 One of the advanced region options is using an alternate mapping of words to memory ("ALTMAP"). These interact
874 in a more subtle manner with alignment. Please see Section 7.9 for details.
875 </p>
876
877 <h3> 6 &nbsp &nbspThe Defaults </h3>
878
879
880 GF-Complete implements a wide variety of techniques for multiplication, division and region multiplication. We have
881 set the defaults with three considerations in mind:
882 <ol>
883 <li>
884 <b>Speed:</b> Obviously, we want the implementations to be fast. Therefore, we choose the fastest implementations
885 that don’t violate the other considerations. The compilation environment is considered. For example, if SSE is
886 enabled, region multiplication in <em> GF(2<sup>4 </sup>) </em> employs a single multiplication table. If SSE is not enabled, then a
887 "double" table is employed that performs table lookup two bytes at a time. </li><br>
888 <li>
889 <b>Memory Consumption:</b> We try to keep the memory footprint of GF-Complete low. For example, the fastest
890 way to perform <b>multiply.w32()</b> in <em>GF(2<sup>32</sup>) </em> is to employ 1.75 MB of multiplication tables (see Section 7.4
891 below). We do not include this as a default, however, because we want to keep the default memory consumption
892 of GF-Complete low.
893 </li>
894
895 </ul>
896
897
898
899
900
901
902 <br/>
903
904 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">14 </span> <br><br><br>
905
906 <ul>
907
908 3. &nbsp <b>Compatibility with "standard" implementations:</b> While there is no <em>de facto</em> standard of Galois Field arithmetic,
909 most libraries implement the same fields. For that reason, we have not selected composite fields, alternate
910 polynomials or memory layouts for the defaults, even though these would be faster. Again, see section 7.7 for
911 more information.
912
913 </ul>
914
915 <p>Table 1 shows the default methods used for each power-of-two word size, their alignment parameters <em>s</em> and <em> t,</em> their
916 memory consumption and their rough performance. The performance tests are on an Intel Core i7-3770 running at
917 3.40 GHz, and are included solely to give a flavor of performance on a standard microprocessor. Some processors
918 will be faster with some techniques and others will be slower, so we only put numbers in so that you can ballpark it.
919 For other values of <em>w</em> between 1 and 31, we use table lookup when w &#8804 8, discrete logarithms when w &#8804 16 and
920 "Bytwo<sub>p</sub>" for w &#8804 32. </p>
921 <br><br>
922 <center> With SSE
923 <div id="data1">
924 <table cellpadding="6" cellspacing="0">
925 <tr>
926 <th>w </th><th class="double_border" >Memory <br> Usage </br> </th><th>multiply() <br> Implementation</th><th>Performance <br>(Mega Ops / s) </th><th>multiply region() <br> Implementation </th>
927 <th>s </th> <th>t </th> <th> Performance <br>(MB/s)</th>
928 </tr>
929 <tr>
930 <td>4 </td><td class="double_border"><1K </td><td>Table</td><td>501</td><td>Table</td>
931 <td>16 </td><td>16 </td> <td>11,659</td> </tr>
932
933 <tr>
934 <td>8 </td><td class="double_border">136K </td><td>Table</td><td>501</td><td>Split Table (8,4)</td>
935 <td>16 </td><td>16 </td> <td>11,824</td> </tr>
936
937 <tr>
938 <td>16 </td><td class="double_border">896K </td><td>Log</td><td>260</td><td>Split Table (16,4)</td>
939 <td>32 </td><td>16 </td> <td>7,749</td> </tr>
940
941 <tr>
942 <td>32 </td><td class="double_border"><1K </td><td>Carry-Free</td><td>48</td><td>Split Table (32,4)</td>
943 <td>64 </td><td>16 </td> <td>5,011</td> </tr>
944
945 <tr>
946 <td>64 </td><td class="double_border">2K </td><td>Carry-Free</td><td>84</td><td>Split Table (64,4)</td>
947 <td>128 </td><td>16 </td> <td>2,402</td> </tr>
948
949 <tr>
950 <td>128 </td><td class="double_border">64K </td><td>Carry-Free</td><td>48</td><td>Split Table (128,4)</td>
951 <td>16 </td><td>16 </td> <td>833</td> </tr>
952 </table></div>
953
954
955 <div id="data1">
956 <center>Without SE </center>
957 <table cellpadding="6" cellspacing="0">
958 <tr>
959 <th>w </th><th>Memory <br> Usage </br> </th><th>multiply() <br> Implementation</th><th>Performance <br>(Mega Ops / s) </th><th>multiply region() <br> Implementation </th>
960 <th>s </th> <th>t </th> <th> Performance <br>(MB/s)</th>
961 </tr>
962 <tr>
963 <td>4 </td><td>4K </td><td>Table</td><td>501</td><td>Double Table</td>
964 <td>16 </td><td>16 </td> <td>11,659</td> </tr>
965
966 <tr>
967 <td>8 </td><td>128K </td><td>Table</td><td>501</td><td>Table</td>
968 <td>1 </td><td>1 </td> <td>1,397</td> </tr>
969
970 <tr>
971 <td>16 </td><td>896K </td><td>Log</td><td>266</td><td>Split Table (16,8)</td>
972 <td>32 </td><td>16 </td> <td>2,135</td> </tr>
973
974 <tr>
975 <td>32 </td><td>4K </td><td>Bytwo<sub>p</sub></td><td>19</td><td>Split Table (32,4)</td>
976 <td>4 </td><td>4 </td> <td>1,149</td> </tr>
977
978 <tr>
979 <td>64 </td><td>16K </td><td>Bytwo<sub>p</sub></td><td>9</td><td>Split Table (64,4)</td>
980 <td>8 </td><td>8 </td> <td>987</td> </tr>
981
982 <tr>
983 <td>128 </td><td>64K </td><td>Bytwo<sub>p</sub></td><td>1.4</td><td>Split Table (128,4)</td>
984 <td>16 </td><td>8 </td> <td>833</td> </tr>
985 </table>
986 </div>
987 </center>
988 <br><br>
989 Table 1: The default implementations, memory consumption and rough performance when w is a power of two. The
990 variables s and t are alignment variables described in Section 5.
991 <p>
992 A few comments on Table 1 are in order. First, with SSE, the performance of <b>multiply()</b> is faster when <em> w </em> = 64
993 than when<em> w </em> = 32. That is because the primitive polynomial for <em> w </em>= 32, that has historically been used in Galois
994 Field implementations, is sub-ideal for using carry-free multiplication (PCLMUL). You can change this polynomial
995 (see section 7.7) so that the performance matches <em>w </em> = 64. </p>
996 <p>
997 The region operations for <em> w </em>= 4 and <em>w </em>= 8 without SSE have been selected to have a low memory footprint. There
998 are better options that consume more memory, or that only work on large memory regions (see section 6.1.5).
999 </p>
1000
1001 There are times that you may want to stray from the defaults. For example:
1002 <ul>
1003 <li>
1004 You may want better performance.
1005 </li>
1006
1007 </ul>
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018 <br/>
1019
1020 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">15 </span> <br><br><br>
1021
1022 <ul>
1023 <li>You may want a lower memory footprint.</li>
1024 <li>You may want to use a different Galois Field or even a ring.</li>
1025 <li>You only care about multiplying a region by the value two.</li>
1026
1027 </ul>
1028
1029
1030 <p>
1031 Our command line tools allow you to deviate from the defaults, and we have two C functions <b>-gf_init_hard()</b>
1032 and <b>create_gf_from_argv()</b> that can be called from application code to override the default methods. There are six
1033 command-line tools that can be used to explore the many techniques implemented in GF-Complete: </p>
1034
1035 <ul><br>
1036
1037 <li> <b>gf_methods</b> is a tool that enumerates most of the possible command-line arguments that can be sent to the other
1038 tools</li><br>
1039 <li> <b>gf_mult</b> and <b>gf_div</b> are explained above. You may change the multiplication and division technique in these
1040 tools if you desire</li><br>
1041 <li> <b>gf_unit</b> performs unit tests on a set of techniques to verify correctness</li><br>
1042 <li> <b> gf_time measures </b> the performance of a particular set of techniques</li><br>
1043 <li> <b>time_tool.sh </b> makes some quick calls to <b>gf_time</b> so that you may gauge rough performance.</li><br>
1044 <li> <b>gf_poly</b> tests the irreducibility of polynomials in a Galois Field</li><br>
1045 </ul>
1046
1047
1048 <p>To change the default behavior in application code, you need to call <b>gf_init_hard()</b> rather than <b>gf_init_easy().</b>
1049 Alternatively, you can use <b>create_g_from_argv(),</b> included from <b>gf_method.h,</b> which uses an <b>argv</b>-style array of
1050 strings to specify the options that you want. The procedure in <b>gf_method.c</b> parses the array and makes the proper
1051 <b>gf_init_hard()</b> procedure call. This is the technique used to parse the command line in <b> gf_mult, gf_div, gf_unit </b><em>et al.</em> </p>
1052
1053
1054 <h2>6.1.1 Changing the Components of a Galois Field with create <b>gf_from_argv()</b> </h2>
1055 There are five main components to every Galois Field instance:
1056 <ul>
1057 <li> <em>w </em> </li>
1058 <li> Multiplication technique </li>
1059 <li> Division technique </li>
1060 <li> Region technique(s) </li>
1061 <li> Polynomial </li>
1062 </ul>
1063
1064 <p>The procedures <b>gf_init_hard()</b> and <b> create_gf_from_argv()</b> allow you to specify these parameters when you create
1065 your Galois Field instance. We focus first on <b>create_gf_from_argv(),</b> because that is how the tools allow you to specify
1066 the components. The prototype of <b>create_gf_from_argv()</b> is as follows: </p><br>
1067
1068 <div id="number_spacing">
1069 int create_gf_from_argv(gf_t *gf, int w, int argc, char **argv, int starting);<br><br> </div>
1070
1071 You pass it a pointer to a gf_t, which it will initialize. You specify the word size with the parameter <em><b>w,</b></em> and then you
1072 pass it an <b>argc/argv</b> pair as in any C or C++ program. You also specify a <b>starting</b> argument, which is where in <b>argv</b>
1073 the specifications begin. If it successfully parses <b>argc</b> and <b>argv,</b> then it creates the <b>gf_t</b> using <b>gf_init_hard()</b> (described
1074 below in section 6.4). It returns one past the last index of <b>argv</b> that it considered when creating the <b>gf_t.</b> If it fails, then
1075 it returns zero, and the <b>gf_t</b> is unmodified.
1076
1077
1078
1079 <p>For example, <b>gf_mult.c</b> calls create gf_from_argv() by simply passing <b>argc</b> and <b>argv</b> from its <b>main()</b> declaration,
1080 and setting starting to 4.</p>
1081
1082
1083
1084
1085
1086
1087
1088
1089 <br/>
1090
1091 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">16 </span> <br><br><br>
1092
1093 <p>
1094 To choose defaults, <b>argv[starting]</b> should equal "-". Otherwise, you specify the component that you are changing
1095 with "-m" for multiplication technique, "-d" for division technique, "-r" for region technique, and "-p" for the
1096 polynomial. You may change multiple components. You end your specification with a single dash. For example, the
1097 following call multiplies 6 and 5 in <em>GF(2<sup>4</sup>)</em> with polynomial 0x19 using the "SHIFT" technique for multiplication
1098 (we'll explain these parameters later):
1099 </p><br><br>
1100
1101 <div id="number_spacing">
1102 UNIX> ./gf_mult 6 5 4 -p 0x19 -m SHIFT -<br>
1103 7 <br>
1104 UNIX> <br><br>
1105 </div>
1106
1107 <p>If <b>create_gf_from_argv()</b> fails, then you can call the procedure <b>gf_error(),</b> which prints out the reason why <b>create_
1108 gf_from_argv()</b> failed. </p>
1109
1110
1111 <h2>6.1.2 Changing the Polynomial </h2>
1112
1113 Galois Fields are typically implemented by representing numbers as polynomials with binary coefficients, and then
1114 using the properties of polynomials to define addition and multiplication. You do not need to understand any of that to
1115 use this library. However, if you want to learn more about polynomial representations and how they construct fields,
1116 please refer to The Paper.
1117
1118 <p>Multiplication is based on a special polynomial that we will refer to here as the "defining polynomial." This
1119 polynomial has binary coefficients and is of degree <em> w.</em> You may change the polynomial with "-p" and then a number
1120 in hexadecimal (the leading "0x" is optional). It is assumed that the <em>w</em>-th bit of the polynomial is set - you may include
1121 it or omit it. For example, if you wish to set the polynomial for GF(2<sup>16</sup>) to x<sup>16</sup> + x<sup>5</sup> + x<sup>3</sup> + x<sup>2</sup> + 1, rather than its
1122 default of x<sup>16</sup> + x<sup>12</sup> + x<sup>3</sup> + x + 1, you may say "-p 0x1002d," "-p 1002d," "-p 0x2d" or "-p 2d."
1123 We discuss changing the polynomial for three reasons in other sections: </p>
1124 <ul>
1125 <li>Leveraging carry-free multiplication (section 7.7). </li>
1126 <li>Defining composite fields (section 7.6). </li>
1127 <li>Implementing rings (section 7.8.1). </li>
1128
1129 </ul>
1130
1131 <p>
1132 Some words about nomenclature with respect to the polynomial. A Galois Field requires the polynomial to be
1133 <em>irreducible </em>.. That means that it cannot be factored. For example, when the coefficients are binary, the polynomial x<sup>5</sup>+
1134 x<sup>4</sup>+x+1 may be factored as (x<sup>4</sup>+1)(x+1). Therefore it is not irreducible and cannot be used to define a Galois Field.
1135 It may, however, be used to define a ring. Please see section 7.8.1 for a discussion of ring support in GF-Complete. </p>
1136 <p>
1137 There is a subset of irreducible polynomials called primitive. These have an important property that one may enumerate
1138 all of the elements of the field by raising 2 to successive posers. All of the default polynomials in GF-Complete
1139 are primitive. However, so long as a polynomial is irreducible, it defines a Galois Field. Please see section 7.7 for a
1140 further discussion of the polynomial. </p>
1141
1142 <p>
1143 One thing that we want to stress here is that changing the polynomial changes the field, so fields with different
1144 polynomialsmay not be used interchangeably. So long as the polynomial is irreducible, it generates a Galois Field that
1145 is isomorphic to all other Galois Fields; however the multiplication and division of elements will differ. For example,
1146 the polynomials 0x13 (the default) and 0x19 in <em>GF(2<sup>4</sup>) </em> are both irreducible, so both generate valid Galois Fields.
1147 However, their multiplication differs: </p><br>
1148
1149 <div id="number_spacing">
1150 UNIX> gf_mult 8 2 4 -p 0x13 - <br>
1151 3 <br>
1152 UNIX> gf_mult 8 2 4 -p 0x19 - <br>
1153 9 <br>
1154 </div>
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164 <br/>
1165
1166 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">17 </span> <br><br><br>
1167
1168 <div id="number_spacing">
1169 UNIX> gf_div 3 8 4 -p 0x13 -<br>
1170 2 <br>
1171 UNIX> gf_div 9 8 4 -p 0x19 - <br>
1172 2 <br>
1173 UNIX> <br>
1174
1175 </div>
1176
1177
1178 <h3>6.1.3 &nbsp &nbsp Changing the Multiplication Technique </h3>
1179 The following list describes the multiplication techinques that may be changed with "-m". We keep the description
1180 here brief. Please refer to The Paper for detailed descriptions of these techniques.<br><br>
1181
1182
1183 <li><b> "TABLE:" </b> Multiplication and division are implemented with tables. The tables consume quite a bit of memory
1184 (2<sup>w</sup> &#215 2 <sup>w</sup> &#215 <sup>w</sup>/
1185 8 bytes), so they are most useful when <em>w</em> is small. Please see <b>"SSE," "LAZY," "DOUBLE"</b> and
1186
1187 <b>"QUAD"</b> under region techniques below for further modifications to <b>"TABLE"</b> to perform <b>multiply_region()</b></li><br>
1188
1189
1190 <li> <b>"LOG:"</b> This employs discrete (or "Zeph") logarithm <b>tables</b> to implement multiplication and division. The
1191 memory usage is roughly (3 &#215 2<sup>w</sup> &#215 w /
1192 8 bytes), so they are most useful when w is small, but they tolerate
1193 larger <em>w</em> than <b>"TABLE."</b> If the polynomial is not primitive (see section 6.1.2), then you cannot use <b>"LOG"</b> as
1194 an implementation. In that case,<b> gf_init_hard()</b> or <b>create_gf_from_argv()</b> will fail</li><br>
1195
1196
1197 <li><b> "LOG_ZERO:"</b> Discrete logarithm tables which include extra room for zero entries. This more than doubles
1198 the memory consumption to remove an <b>if</b> statement (please see [GMS08] or The Paper for more description). It
1199 doesn’t really make a huge deal of difference in performance</li><br>
1200
1201 <li> <b>"LOG_ZERO_EXT:"</b> This expends even more memory to remove another <b>if</b> statement. Again, please see The
1202 Paper for an explanation. As with <b>"LOG_ZERO,"</b> the performance difference is negligible</li><br>
1203
1204 <li> <b>"SHIFT:"</b> Implementation straight from the definition of Galois Field multiplication, by shifting and XOR-ing,
1205 then reducing the product using the polynomial. This is <em>slooooooooow,</em> so we don’t recommend you use it</li><br>
1206
1207
1208 <li> <b>"CARRY_FREE:"</b> This is identical to <b>"SHIFT,"</b> however it leverages the SSE instruction PCLMUL to perform
1209 carry-freemultiplications in single instructions. As such, it is the fastest way to perform multiplication for large
1210 values of <em>w</em> when that instruction is available. Its performance depends on the polynomial used. See The Paper
1211 for details, and see section 7.7 below for the speedups available when <em>w </em>= 16 and <em>w</em> = 32 if you use a different
1212 polynomial than the default one</li><br>
1213
1214
1215 <li> <b>"BYTWO_p:"</b> This implements multiplication by successively multiplying the product by two and selectively
1216 XOR-ing the multiplicand. See The Paper for more detail. It can leverage Anvin’s optimization that multiplies
1217 64 and 128 bits of numbers in <em>GF(2<sup>w</sup>) </em> by two with just a few instructions. The SSE version requires SSE2</li><br>
1218
1219
1220 <li> <b>"BYTWO_b:"</b> This implements multiplication by successively multiplying the multiplicand by two and selectively
1221 XOR-ing it into the product. It can also leverage Anvin's optimization, and it has the feature that when
1222 you're multiplying a region by a very small constant (like 2), it can terminate the multiplication early. As such,
1223 if you are multiplying regions of bytes by two (as in the Linux RAID-6 Reed-Solomon code [Anv09]), this is
1224 the fastest of the techniques, regardless of the value of <em>w.</em> The SSE version requires SSE2</li><br>
1225
1226
1227 <li> <b>"SPLIT:"</b> Split multiplication tables (like the LR tables in [GMS08], or the SIMD tables for w &#8804 8 in [LHy08,
1228 Anv09, PGM13b]). This argument must be followed by two more arguments, w<sub>a</sub> and w<sub>b</sub>, which are the index
1229 sizes of the sub-tables. This implementation reduces the size of the table from <b>"TABLE,"</b> but requires multiple
1230 </li><br>
1231
1232
1233
1234
1235
1236
1237 <br/>
1238
1239 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">18 </span> <br><br><br>
1240 <ul>
1241 table lookups. For example, the following multiplies 100 and 200 in <em>GF(2<sup>8</sup>) </em> using two 4K tables, as opposed
1242 to one 64K table when you use <b>"TABLE:"</b><br><br>
1243 <div id="number_spacing">
1244 UNIX> ./gf_mult 100 200 8 -m SPLIT 8 4 - <br>
1245 79<br>
1246 UNIX><br><br>
1247 </div>
1248
1249 See section 7.4 for additional information on the arguments to <b>"SPLIT."</b> The SSE version typically requires
1250 SSSE3.<br><br>
1251
1252
1253 <li> <b>"GROUP:"</b> This implements the "left-to-right comb" technique [LBOX12]. I'm afraid we don't like that name,
1254 so we call it <b>"GROUP,"</b> because it performs table lookup on groups of bits for shifting (left) and reducing (right).
1255 It takes two additional arguments - g<sub>s,</sub> which is the number of bits you use while shifting (left) and g<sub>r</sub>, which
1256 is the number of bits you use while reducing (right). Increasing these arguments can you higher computational
1257 speed, but requires more memory. SSE version exists only for <em> w </em> = 128 and it requires SSE4. For more
1258 description on the arguments g<sub>s</sub> and g<sub>r</sub>, see section 7.5. For a full description of <b>"GROUP"</b> algorithm, please
1259 see The Paper.
1260 </li><br>
1261
1262 <li> <b>"COMPOSITE:"</b> This allows you to perform operations on a composite Galois Field, <em> GF((2<sup>l</sup>)<sup>k</sup>)</em> as described
1263 in [GMS08], [LBOX12] and The Paper. The field size <em>w </em> is equal to <em>lk.</em> It takes one argument, which is <em>k,</em> and
1264 then a specification of the base field. Currently, the only value of <em>k</em> that is supported is two. However, that may
1265 change in a future revision of the library. </li><br>
1266
1267
1268 In order to specify the base field, put appropriate flags after specifying <em>k.</em> The single dash ends the base field,
1269 and after that, you may continue making specifications for the composite field. This process can be continued
1270 for multiple layers of <b>"COMPOSITE."</b> As an example, the following multiplies 1000000 and 2000000
1271 in <em>GF((2<sup>16</sup>)<sup>2</sup>),</em> where the base field uses <b>BYTWO_p</b> for multiplication: <br><br>
1272 <center>./gf_mult 1000000 2000000 32 -m COMPOSITE 2 <span style="color:red">-m BYTWO_p - -</span> </center><br>
1273
1274 In the above example, the red text applies to the base field, and the black text applies to the composite field.
1275 Composite fields have two defining polynomials - one for the composite field, and one for the base field. Thus, if
1276 you want to change polynomials, you should change both. The polynomial for the composite field must be of the
1277 form x<sup>2</sup>+sx+1, where s is an element of <em>GF(2<sup>k</sup>).</em> To change it, you specify s (in hexadecimal)with "-p." In the
1278 example below, we multiply 20000 and 30000 in <em>GF((2<sup>8</sup>)<sup>2</sup>) </em>, setting s to three, and using x<sup>8</sup>+x<sup>4</sup>+x<sup>3</sup>+x<sup>2</sup>+1
1279 as the polynomial for the base field: <br><br>
1280
1281 <center>./gf_mult 20000 30000 16 -m COMPOSITE 2 <span style="color:red">-p 0x11d </span> - -p 0x3 - </center> <br><br>
1282
1283 If you use composite fields, you should consider using <b>"ALTMAP"</b> as well. The reason is that the region
1284 operations will go much faster. Please see section 7.6.<br><br>
1285 As with changing the polynomial, when you use a composite field, <em> GF((2<sup>l</sup>)<sup>k</sup>)</em>, you are using a different field
1286 than the "standard" field for <em> GF((2<sup>l</sup>)<sup>k</sup>)</em>. All Galois Fields are isomorphic to each other, so they all have the
1287 desired properties; however, the fields themselves change when you use composite fields.<br><br>
1288 </ul>
1289 <p>
1290 With the exception of <b>"COMPOSITE"</b>, only one multiplication technique can be provided for a given Galois
1291 Field instance. Composite fields may use composite fields as their base fields, in which case the specification will be
1292 recursive. </p>
1293
1294
1295
1296
1297
1298
1299
1300
1301 <br/>
1302
1303 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">19 </span> <br><br><br>
1304
1305 <h3>6.1.4 &nbsp &nbsp &nbsp Changing the Division Technique </h3>
1306
1307 There are two techniques for division that may be set with "-d". If "-d" is not specified, then appropriate defaults
1308 are employed. For example, when the multiplication technique is <b>"TABLE,"</b> a table is created for division as well as
1309 multiplication. When <b>"LOG"</b> is specified, the logarithm tables are used for division. With <b>"COMPOSITE,"</b> a special
1310 variant of Euclid's algorithm is employed that performs division using multiplication and division in the base field.
1311 Otherwise, Euclid's algorithm is used. Please see The Paper for a description of Euclid's algorithm applied to Galois
1312 Fields.
1313
1314 <p>If you use "-d", you must also specify the multiplication technique with "-m." </p>
1315 <p>To force Euclid's algorithm instead of the defaults, you may specify it with "-d EUCLID." If instead, you would
1316 rather convert elements of a Galois Field to a binary matrix and find an element's inverse by inverting the matrix,
1317 then specify "-d MATRIX." In all of our tests, <b>"MATRIX"</b> is slower than <b>"EUCLID." "MATRIX" </b> is also not defined
1318 for <em>w </em> > 32.
1319 </p>
1320
1321
1322 <h3>6.1.5 &nbsp&nbsp&nbsp Changing the Region Technique </h3>
1323 The following are the region multiplication options ("-r"):
1324 <ul>
1325 <li>
1326 <b>"SSE:"</b> Use SSE instructions. Initialization will fail if the instructions aren't supported. Table 2 details the
1327 multiplication techniques which can leverage SSE instructions and which versions of SSE are required. </li><br>
1328
1329 <center>
1330 <div id="data1">
1331 <table cellpadding="6" cellspacing="0" style="text-align:center;font-size:19px">
1332 <tr>
1333 <th>Multiplication <br> Technique</th><th>multiply() </th><th>multiply_region() </th><th>SSE Version </th><th>Comments</th>
1334
1335 </tr>
1336 <tr>
1337 <td><b>"TABLE"</b></td><td >- </td><td>Yes</td><td>SSSE3</td><td>Only for <em>GF(2<sup>4</sup>). </em></td>
1338
1339 <tr>
1340 <td><b>"SPLIT"</b></td><td>-</td><td>Yes</td><td>SSSE3</td><td>Only when the second argument equals 4.</td>
1341
1342 <tr>
1343 <td><b>"SPLIT"</b></td><td>- </td><td>Yes</td><td>SSE4</td><td>When <em>w </em> = 64 and not using <b>"ALTMAP".</b></td>
1344
1345 <tr>
1346 <td><b>"BYTWO_p"</b></td><td>- </td><td>Yes</td><td>SSE2</td><td></td>
1347
1348 <tr>
1349 <td><b>"BYTWO_p"</b></td><td>- </td><td>Yes</td><td>SSE2</td><td></td>
1350
1351 </table></div> <br><br>
1352 Table 2: Multiplication techniques which can leverage SSE instructions when they are available.
1353 </center> <br><br>
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366 <li> <b>"NOSSE:"</b> Force non-SSE version </li><br>
1367
1368 <li> <b> "DOUBLE:"</b> Use a table that is indexed on two words rather than one. This applies only to <em>w </em> = 4, where
1369 the table is indexed on bytes rather than 4-bit quantities, and to <em>w </em> = 8, where the table is indexed on shorts
1370 rather than bytes. In each case, the table lookup performs two multiplications at a time, which makes region
1371 multiplication faster. It doubles the size of the lookup table. </li><br>
1372
1373 <li> <b>"QUAD:"</b> Use a table that is indexed on four words rather than two or one. This only applies to <em>w </em> = 4, where
1374 the table is indexed on shorts. The "Quad" table may be lazily created or created ahead of time (the default). If
1375 the latter, then it consumes 2<sup>4</sup> &#215 2<sup>16</sup> &#215 2 = 2 MB of memory. </li><br>
1376
1377 <li> <b> "LAZY:"</b> Typically it's clear whether tables are constructed upon initialization or lazily when a region operation
1378 is performed. There are two times where it is ambiguous: <b>"QUAD"</b> when <em>w </em> = 4 and <b>"DOUBLE"</b> when <em>w </em> = 8.
1379 If you don't specify anything, these tables are created upon initialization, consuming a lot of memory. If you
1380 specify <b>"LAZY,"</b> then the necessary row of the table is created lazily when you call <b>"multiply_region().</b>
1381 </li>
1382
1383 </ul>
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395 <br/>
1396
1397 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">20 </span> <br><br><br>
1398 <ul>
1399
1400 <li> <b>"ALTMAP:"</b> Use an alternate mapping, where words are split across different subregions of memory. There
1401 are two places where this matters. The first is when implementing "<b>SPLIT</b> <em>w </em> 4" using SSE when <em>w </em> > 8. In
1402 these cases, each byte of the word is stored in a different 128-bit vector, which allows the implementation to
1403 better leverage 16-byte table lookups. See section 7.4 for examples, and The Paper or [PGM13b] for detailed
1404 explanations.<br><br> </li>
1405
1406 The second place where it matters is when using <b>"COMPOSITE."</b> In this case, it is advantageous to split each
1407 memory region into two chunks, and to store half of each word in a different chunk. This allows us to call
1408 <b>region_multiply() </b> recursively on the base field, which is <em>much </em> faster than the alternative. See Section 7.6 for
1409 examples, and The Paper for an explanation.<br><br>
1410
1411 It is important to note that with <b>"ALTMAP,"</b> the words are not "converted" from a standard mapping to an
1412 alternate mapping and back again. They are assumed to always be in the alternate mapping. This typically
1413 doesn't matter, so long as you always use the same <b>"ALTMAP"</b> calls. Please see section 7.9 for further details
1414 on <b>"ALTMAP,"</b> especially with respect to alignment.<br><br>
1415
1416 <li> <b>"CAUCHY:"</b> Break memory into <em>w </em> subregions and perform only XOR's as in Cauchy Reed-Solomon coding
1417 [BKK<sup>+</sup>95] (also described in The Paper). This works for <em>any</em> value of <em>w </em> &#8804 32, even those that are not
1418 powers of two. If SSE2 is available, then XOR's work 128 bits at a time. For <b>"CAUCHY"</b> to work correctly,
1419 <em>size</em> must be a multiple of <em>w </em>.</li> </ul>
1420
1421
1422
1423 <p>It is possible to combine region multiplication options. This is fully supported as long as <b>gf_methods</b> has the combination
1424 listed. If multiple region options are required, they should be specified independently (as flags for <b>gf_init_hard()</b>
1425 and independent options for command-line tools and <b>create_gf_from_argv()).</b> </p>
1426
1427
1428 <h3>6.2 &nbsp&nbsp&nbspDetermining Supported Techniques with gf_methods </h3>
1429
1430
1431 The program <b>gf_methods</b> prints a list of supported methods on standard output. It is called as follows:<br><br>
1432 <div id="number_spacing">
1433 <center>./gf_methods <em>w </em> -BADC -LUMDRB <br><br> </center> </div>
1434
1435 The first argument is <em>w </em>, which may be any legal value of <em>w </em>. The second argument has the following flags: <br><br>
1436 <ul>
1437
1438 <li> <b>"B:"</b> This only prints out "basic" methods that are useful for the given value of <em>w </em>. It omits <b>"SHIFT"</b> and other
1439 methods that are never really going to be useful.</li><br>
1440
1441 <li> <b> "A:"</b> In constrast, this specifies to print "all" methods. </li><br>
1442
1443 <li> <b>"D:"</b> This includes the <b>"EUCLID"</b> and <b>"MATRIX"</b> methods for division. By default, they are not included. </li><br>
1444
1445 <li> <b>"C:"</b> This includes the <b>"CAUCHY"</b> methods for region multiplication. By default, it is not included.</li> <br>
1446 </ul>
1447 <p>
1448 You may specify multiple of these as the second argument. If you include both <b>"B"</b> and <b>"A,"</b> then it uses the last
1449 one specified. </p>
1450 <p>
1451 The last argument determines the output format of <b>gf_methods.</b> If it is <b>"L,"</b> then it simply lists methods. If it
1452 is <b>"U,"</b> then the output contains <b>gf_unit</b> commands for each of the methods. For the others, the output contains
1453 <b>gf_time_tool.sh</b> commands for <b>M </b>ultiplication,<b>D</b>ivision,<b>R</b>egion multiplications with multiple buffer sizes, and the
1454 <b>B</b>est region multiplication. </p>
1455 <p>
1456 <b>gf_methods</b> enumerates combinations of flags, and calls <b>create_gf_from_argv()</b> to see if the combinations are
1457 supported. Although it enumerates a large number of combinations, it doesn't enumerate all possible parameters for
1458 <b>"SPLIT," "GROUP"</b> or <b>"COMPOSITE."</b> </p>
1459
1460 <p>Some examples of calling <b>gf_methods</b> are shown below in section 6.3.2. </p>
1461
1462
1463
1464
1465
1466
1467
1468 <br/>
1469
1470 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">21 </span> <br><br><br>
1471
1472
1473 <h3>6.3 Testing with <b>gf_unit </b>, <b>gf_time </b>, and time_tool.sh </h3>
1474
1475
1476
1477 <b>gf_unit </b> and <b>gf_time </b> may be used to verify that a combination of arguments works correctly and efficiently on your
1478 platform. If you plan to stray from the defaults, it is probably best to run both tools to ensure there are no issues with
1479 your environment. <b>gf_unit </b> will run a set of unit tests based on the arguments provided to the tool, and <b>gf_time </b> will
1480 time Galois Field methods based on the provided arguments.<br>
1481 The usage of gf_ unit is:<br><br>
1482 <div id="number_spacing">
1483 <b>gf_unit </b> w tests seed method<br><br> </div>
1484 The usage of gf_ time is:<br><br>
1485 <div id="number_spacing">
1486 <b>gf_time </b> w tests seed buffer-size iterations method<br><br>
1487 </div>
1488
1489
1490
1491 The seed is an integer- negative one uses the current time. The tests are specified by a listing of characters. The
1492 following tests are supported (All are supported by <b>gf_time.</b> Only ', 'S' and 'R' are supported by <b>gf_unit</b>):<br><br>
1493
1494 <ul>
1495 <li> <b>'M':</b> Single multiplications</li><br>
1496 <li> <b> 'D':</b> Single divisions</li><br>
1497 <li> <b> 'I':</b> Single inverses</li><br>
1498 <li> <b>'G': </b> Region multiplication of a buffer by a random constant</li><br>
1499 <li> <b>'0': </b> Region multiplication of a buffer by zero (does nothing and<b>bzero()</b>)</li><br>
1500 <li> <b>'1': </b> Region multiplication of a buffer by one (does <b>memcpy()</b> and <b>XOR</b>)</li><br>
1501 <li> <b>'2': </b> Region multiplication of a buffer by two – sometimes this is faster than general multiplication</li><br>
1502 <li> <b>'S':</b> All three single tests</li><br>
1503 <li> <b>'R':</b> All four region tests</li><br>
1504 <li> <b>'A':</b> All seven tests</li><br>
1505 </ul>
1506
1507
1508
1509
1510
1511 <p>Here are some examples of calling <b>gf_unit</b> and <b>gf_time</b> to verify that <b>"-m SPLIT 32 4 -r ALTMAP -"</b> works
1512 in <em>GF(2<sup>32</sup>),</em> and to get a feel for its performance. First, we go to the test directory and call <b>gf_unit:</b> </p><br><br>
1513
1514
1515 <div id="number_spacing">
1516 UNIX> cd test <br>
1517 UNIX> ./gf_unit 32 A -1 -m SPLIT 32 4 -r ALTMAP - <br>
1518 Args: 32 A -1 -m SPLIT 32 4 -r ALTMAP - / size (bytes): 684 <br>
1519 UNIX> <br><br>
1520 </div>
1521
1522 <b>gf_unit</b> reports on the arguments and how may bytes the <b>gf_t</b> consumes. If it discovers any problems or inconsistencies
1523 with multiplication, division or region multiplication, it will report them. Here, there are no problems.
1524 Next, we move to the <b>tools</b> directory and run performance tests on a 10K buffer, with 10,000 iterations of each test:<br><br>
1525
1526
1527 UNIX> cd ../tools <br>
1528 UNIX> ./gf_time 32 A -1 10240 10000 -m SPLIT 32 4 -r ALTMAP -<br>
1529 Seed: 1388435794 <br>
1530 <div id="number_spacing">
1531 <table cellpadding="0" cellspacing="25" style="font-size:19px,font-family: 'Roboto Condensed', sans-serif;
1532 ">
1533
1534 <tr>
1535
1536 <td>Multiply:</td> <td>4.090548 s</td> <td> Mops: </td> <td> 24.414 </td> <td>5.968 Mega-ops/s </td> </tr>
1537 <tr><td>Divide:</td> <td> 37.794962 s </td> <td>Mops: </td> <td> 24.414 </td> <td>0.646 Mega-ops/s </td> </tr>
1538 <tr><td>Inverse:</td> <td> 33.709875 s </td> <td> Mops: </td> <td> 24.414 </td> <td> 0.724 Mega-ops/s </td> </tr>
1539 <tr><td>Region-Random: XOR: 0 </td> <td> 0.035210 s </td> <td> MB:</td> <td> 97.656 </td> <td> 2773.527 MB/s </td></tr>
1540 <tr><td>Region-Random: XOR: 1 </td> <td> 0.036081 s</td> <td> MB:</td> <td> 97.656 </td> <td>2706.578 MB/s </td></tr>
1541 <tr><td>Region-By-Zero:XOR: 0 </td> <td> 0.003199 s </tD> <td> MB: </td> <td>97.656 </td> <td> 30523.884 MB/s </td> </tr>
1542 <tr><td>Region-By-Zero: XOR: 1 </td> <td> 0.000626 s </td> <td>MB: </td> <td> 97.656 </td> <td> 156038.095 MB/s </td></tr>
1543
1544 </table>
1545 </div>
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556 <br/>
1557
1558 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">22 </span> <br><br><br>
1559
1560 <div id="number_spacing">
1561 <table cellpadding="0" cellspacing="10" style="font-family: 'Roboto Condensed', sans-serif;
1562 ">
1563
1564 <tr>
1565 <td>Region-By-One: XOR: 0</td> <td> 0.003810 s</td> <td> MB:</td> <td> 97.656 </td> <td> 25628.832 MB/s </td>
1566 <tr><td>Region-By-One: XOR: 1 </td> <td> 0.008363 s </td> <td> MB:</td> <td> 97.656 </tD> <td>11677.500 MB/s </td></tr>
1567
1568 <tr><td>Region-By-Two: XOR: 0 </td> <td>0.032942 s </td> <td>MB: </td> <td> 97.656 </td> <td> 2964.486 MB/s </td> </tr>
1569 <tr><td>Region-By-Two: XOR: 1 </td> <td> 0.033488 s </td> <td> MB: </td> <td> 97.656 </td> <td> 2916.153 MB/s </td> </tr> </table>
1570 </div>
1571 UNIX><br><br>
1572
1573 <p>The first column of output displays the name of the test performed. Region tests will test with and without the XOR
1574 flag being set (see Section 4.3 for an example). The second column displays the total time the test took to complete
1575 measured in seconds (s). The third column displays the size of the test measured in millions of operations (Mops) for
1576 single tests and in Megabytes (MB) for the region tests. The final column displays the speed of the tests calculated
1577 from the second and third columns, and is where you should look to get an idea of a method's performance.</p>
1578 <p>
1579 If the output of <b>gf_unit</b> and <b>gf_time</b> are to your satisfaction, you can incorporate the method into application code
1580 using create <b>gf_from_argv()</b> or <b>gf_init hard().</b></p>
1581 <p>
1582 The performance of "Region-By-Zero" and "Region-By-One" will not change from test to test, as all methods make
1583 the same calls for these. "Region-By-Zero" with "XOR: 1" does nothing except set up the tests. Therefore, you may
1584 use it as a control.</p>
1585
1586 <h3>6.3.1 &nbsp &nbsp &nbsp time_tool.sh </h3>
1587
1588 Finally, the shell script <b>time_tool.sh</b> makes a bunch of calls to <b>gf_time</b> to give a rough estimate of performance. It is
1589 called as follows:<br><br>
1590 usage sh time_tool.sh M|D|R|B w method<br><br>
1591
1592
1593 <p>The values for the first argument are <b>MDRB,</b> for <b>M</b>ultiplication, <b>D</b>ivision,<b>R</b>egion multiplications with multiple
1594 buffer sizes, and the <b>B</b>est region multiplication. For the example above, let's call <b>time_tool.sh</b> to get a rough idea of
1595 performance: </p><br><br>
1596
1597 <div id="number_spacing">
1598 UNIX> sh time_tool.sh M 32 -m SPLIT 32 4 -r ALTMAP - <br>
1599 M speed (MB/s): 6.03 W-Method: 32 -m SPLIT 32 4 -r ALTMAP - <br>
1600 UNIX> sh time_tool.sh D 32 -m SPLIT 32 4 -r ALTMAP - <br>
1601 D speed (MB/s): 0.65 W-Method: 32 -m SPLIT 32 4 -r ALTMAP - <br>
1602 UNIX> sh time_tool.sh R 32 -m SPLIT 32 4 -r ALTMAP - <br>
1603
1604 <table cellpadding="0" cellspacing="10" style="font-family: 'Roboto Condensed', sans-serif;
1605 ">
1606
1607 <tr>
1608 <td>Region Buffer-Size:</td> <td> 16K (MB/s):</td> <td>3082.91</td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1609 <tr><td>Region Buffer-Size:</td> <td>32K (MB/s): </td> <td>3529.07 </td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1610 <tr><td>Region Buffer-Size:</td> <td>64K (MB/s): </td> <td> 3749.94</td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1611 <tr><td>Region Buffer-Size:</td> <td>128K (MB/s):</td> <td>3861.27 </td> <td>W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1612 <tr><td>Region Buffer-Size:</td> <td>512K (MB/s):</td> <td>3820.82 </td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1613 <tr><td>Region Buffer-Size:</td> <td>1M (MB/s):</td> <td>3737.41 </td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1614 <tr><td>Region Buffer-Size:</td> <td>2M (MB/s):</td> <td>3002.90 </td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1615 <tr><td>Region Buffer-Size:</td> <td>4M (MB/s): </td><td>2760.77</td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1616 <tr><td>Region Best (MB/s):</td><td> 3861.27</td><td> W-Method: 32 </td> <td>-m SPLIT 32 4 </td> <td>-r ALTMAP -</td> </tr>
1617 </table>
1618
1619 UNIX> sh time_tool.sh B 32 -m SPLIT 32 4 -r ALTMAP - <br>
1620 Region Best (MB/s): 3929.09 W-Method: 32 -m SPLIT 32 4 -r ALTMAP -</br>
1621 UNIX><br><br>
1622 </div>
1623 <p>
1624 We say that <b>time_tool.sh </b>is "rough" because it tries to limit each test to 5 ms or less. Thus, the time granularity
1625 is fine, which means that the numbers may not be as precise as they could be were the time granularity to be course.
1626 When in doubt, you should make your own calls to <b>gf_time</b> with a lot of iterations, so that startup costs and roundoff
1627 error may be minimized. </p>
1628
1629
1630
1631
1632
1633
1634
1635
1636 <br/>
1637
1638 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">23 </span> <br><br><br>
1639
1640 <h3>6.3.2 &nbsp &nbsp &nbsp An example of gf_methods and time_tool.sh </h3><br><br>
1641 Let's give an example of how some of these components fit together. Suppose we want to explore the basic techniques
1642 in <em>GF(2<sup>32</sup>).</em> First, let's take a look at what <b>gf_methods</b> suggests as "basic" methods: <br><br>
1643 <div id="number_spacing">
1644 UNIX> gf_methods 32 -B -L <br>
1645 w=32: - <br>
1646 w=32: -m GROUP 4 8 - <br>
1647 w=32: -m SPLIT 32 4 - <br>
1648 w=32: -m SPLIT 32 4 -r ALTMAP - <br>
1649 w=32: -m SPLIT 32 8 - <br>
1650 w=32: -m SPLIT 8 8 - <br>
1651 w=32: -m COMPOSITE 2 - - <br>
1652 w=32: -m COMPOSITE 2 - -r ALTMAP - <br>
1653 UNIX> <br><br>
1654 </div>
1655
1656
1657 <p>
1658
1659 You'll note, this is on my old Macbook Pro, which doesn't support (PCLMUL), so <b>"CARRY_FREE"</b> is not included
1660 as an option. Now, let's run the unit tester on these to make sure they work, and to see their memory consumption: </p><br><br>
1661
1662 <div id="number_spacing">
1663 UNIX> gf_methods 32 -B -U <br>
1664 ../test/gf_unit 32 A -1 - <br>
1665 ../test/gf_unit 32 A -1 -m GROUP 4 8 - <br>
1666 ../test/gf_unit 32 A -1 -m SPLIT 32 4 - <br>
1667 ../test/gf_unit 32 A -1 -m SPLIT 32 4 -r ALTMAP - <br>
1668 ../test/gf_unit 32 A -1 -m SPLIT 32 8 - <br>
1669 ../test/gf_unit 32 A -1 -m SPLIT 8 8 - <br>
1670 ../test/gf_unit 32 A -1 -m COMPOSITE 2 - - <br>
1671 ../test/gf_unit 32 A -1 -m COMPOSITE 2 - -r ALTMAP - <br>
1672 UNIX> gf_methods 32 -B -U | sh <br>
1673 Args: 32 A -1 - / size (bytes): 684 <br>
1674 Args: 32 A -1 -m GROUP 4 8 - / size (bytes): 1296 <br>
1675 Args: 32 A -1 -m SPLIT 32 4 - / size (bytes): 684 <br>
1676 Args: 32 A -1 -m SPLIT 32 4 -r ALTMAP - / size (bytes): 684 <br>
1677 Args: 32 A -1 -m SPLIT 32 8 - / size (bytes): 4268 <br>
1678 Args: 32 A -1 -m SPLIT 8 8 - / size (bytes): 1839276 <br>
1679 Args: 32 A -1 -m COMPOSITE 2 - - / size (bytes): 524648 <br>
1680 Args: 32 A -1 -m COMPOSITE 2 - -r ALTMAP - / size (bytes): 524648 <br>
1681 UNIX> <br> <br>
1682 </div>
1683 <p>
1684 As anticipated, <b>"SPLIT 8 8"</b> consumes quite a bit of memory! Now, let's see how well they perform with both
1685 single multiplications and region multiplications: </p> <br><br>
1686 <div id="number_spacing">
1687 UNIX> gf_methods 32 -B -M <br>
1688 sh time_tool.sh M 32 - <br>
1689 sh time_tool.sh M 32 -m GROUP 4 8 - <br>
1690 sh time_tool.sh M 32 -m SPLIT 32 4 - <br>
1691 sh time_tool.sh M 32 -m SPLIT 32 4 -r ALTMAP -<br>
1692 sh time_tool.sh M 32 -m SPLIT 32 8 - <br>
1693 sh time_tool.sh M 32 -m SPLIT 8 8 - <br>
1694
1695 </div>
1696
1697
1698
1699
1700
1701
1702
1703
1704 <br/>
1705
1706 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">24 </span> <br><br><br>
1707
1708 <div id="number_spacing">
1709 sh time_tool.sh M 32 -m COMPOSITE 2 - <br>
1710 sh time_tool.sh M 32 -m COMPOSITE 2 - -r ALTMAP <br>
1711 UNIX> gf_methods 32 -B -M | sh
1712 M speed (MB/s): 5.90 W-Method: 32 <br>
1713 M speed (MB/s): 14.09 W-Method: 32 -m GROUP 4 8 <br>
1714 M speed (MB/s): 5.60 W-Method: 32 -m SPLIT 32 4 <br>
1715 M speed (MB/s): 5.19 W-Method: 32 -m SPLIT 32 4 -r ALTMAP <br>
1716 M speed (MB/s): 5.98 W-Method: 32 -m SPLIT 32 8 <br>
1717 M speed (MB/s): 22.10 W-Method: 32 -m SPLIT 8 8 <br>
1718 M speed (MB/s): 34.98 W-Method: 32 -m COMPOSITE 2 - <br>
1719 M speed (MB/s): 34.16 W-Method: 32 -m COMPOSITE 2 - -r ALTMAP <br>
1720 UNIX> gf_methods 32 -B -B | sh
1721 Region Best (MB/s): 2746.76 W-Method: 32 <br>
1722 Region Best (MB/s): 177.06 W-Method: 32 -m GROUP 4 8 <br>
1723 Region Best (MB/s): 2818.75 W-Method: 32 -m SPLIT 32 4 <br>
1724 Region Best (MB/s): 3818.21 W-Method: 32 -m SPLIT 32 4 -r ALTMAP <br>
1725 Region Best (MB/s): 728.68 W-Method: 32 -m SPLIT 32 8 <br>
1726 Region Best (MB/s): 730.97 W-Method: 32 -m SPLIT 8 8 <br>
1727 Region Best (MB/s): 190.20 W-Method: 32 -m COMPOSITE 2 - <br>
1728 Region Best (MB/s): 1837.99 W-Method: 32 -m COMPOSITE 2 - -r ALTMAP <br>
1729 UNIX>
1730 </div>
1731 <p>
1732 The default is quite a bit slower than the best performing methods for both single and region multiplication. So
1733 why are the defaults the way that they are? As detailed at the beginning of this chapter, we strive for lower memory
1734 consumption, so we don't use <b>"SPLIT 8 8,"</b> which consumes 1.75MB.We don't implement alternate fields by default,
1735 which is why we don't use <b>"COMPOSITE."</b> Finally, we don't implement alternate mappings of memory by default,
1736 which is why we don't use "<b>-m SPLIT 32 4 -r ALTMAP -.</b>"</p>
1737
1738 <p>Of course, you may change these defaults if you please.</p>
1739 <p>
1740 <b>Test question:</b> Given the numbers above, it would appear that <b>"COMPOSITE"</b> yields the fastest performance of
1741 single multiplication, while "SPLIT 32 4" yields the fastest performance of region multiplication. Should I use two
1742 gf_t's in my application – one for single multiplication that uses <b>"COMPOSITE,"</b> and one for region multiplication
1743 that uses <b>"SPLIT 32 4?"</b></p>
1744 <p>
1745 The answer to this is "no." Why? Because composite fields are different from the "standard" fields, and if you mix
1746 these two <b>gf_t</b>'s, then you are using different fields for single multiplication and region multiplication. Please read
1747 section 7.2 for a little more information on this.</p>
1748
1749 <h3>6.4 &nbsp &nbsp &nbspCalling gf_init_hard()</h3>
1750
1751 We recommend that you use <b>create_gf_from_argv()</b> instead of <b>gf_init_hard().</b> However, there are extra things that
1752 you can do with <b>gf_init_hard().</b> Here's the prototype:<br><br>
1753 <div id="number_spacing">
1754 int gf_init_hard(gf_t *gf<br>
1755 <div style="padding-left:100px">
1756 int w<br>
1757 int mult_type<br>
1758 int region_type<br>
1759 int divide_type<br>
1760 uint64_t prim_poly<br>
1761 int arg1<br>
1762 int arg2<br>
1763 </div>
1764 </div>
1765
1766
1767
1768
1769
1770
1771
1772
1773 <br/>
1774
1775 6 &nbsp &nbsp <em> THE DEFAULTS </em> <span id="index_number">25 </span> <br><br><br>
1776 <div id="number_spacing">
1777 <div style="padding-left:100px">
1778 GFP base_gf, <br>
1779 void *scratch_memory); </div><br><br>
1780
1781
1782 The arguments mult type, region type and divide type allow for the same specifications as above, except the
1783 types are integer constants defined in gf_complete.h: <br><br>
1784 typedef enum {GF_MULT_DEFAULT,<br>
1785 <div style="padding-left:124px">
1786 GF_MULT_SHIFT<br>
1787 GF_MULT_CARRY_FREE<br>
1788 GF_MULT_GROUP<br>
1789 GF_MULT_BYTWO_p<br>
1790 GF_MULT_BYTWO_b<br>
1791 GF_MULT_TABLE<br>
1792 GF_MULT_LOG_TABLE<br>
1793 GF_MULT_LOG_ZERO<br>
1794 GF_MULT_LOG_ZERO_EXT<br>
1795 GF_MULT_SPLIT_TABLE<br>
1796 GF_MULT_COMPOSITE } gf_mult_type_t;<br><br>
1797
1798 </div>
1799
1800 #define GF_REGION_DEFAULT (0x0)<br>
1801 #define GF_REGION_DOUBLE_TABLE (0x1) <br>
1802 #define GF_REGION_QUAD_TABLE (0x2) <br>
1803 #define GF_REGION_LAZY (0x4) <br>
1804 #define GF_REGION_SSE (0x8) <br>
1805 #define GF_REGION_NOSSE (0x10) <br>
1806 #define GF_REGION_ALTMAP (0x20) <br>
1807 #define GF_REGION_CAUCHY (0x40) <br><br>
1808 typedef enum { GF_DIVIDE_DEFAULT<br>
1809 <div style="padding-left:130px">GF_DIVIDE_MATRIX<br>
1810 GF_DIVIDE_EUCLID } gf_division_type_t;<br><br>
1811 </div>
1812 </div>
1813 <p>
1814 You can mix the region types with bitwise or. The arguments to <b>GF_MULT_GROUP,GF_MULT_SPLIT_TABLE</b>
1815 and <b>GF_MULT_COMPOSITE</b> are specified in arg1 and arg2. <b>GF_MULT_COMPOSITE</b> also takes a base field
1816 in <b>base_gf.</b> The base field is itself a <b>gf_t,</b> which should have been created previously with <b>create_gf_fro_argv(),</b>
1817 <b>gf_init_easy()</b> or <b>gf_init_hard().</b> Note that this <b>base_gf</b> has its own <b>base_gf</b> member and can be a composite field
1818 itself.</p>
1819 <p>
1820 You can specify an alternate polynomial in <b>prim_poly.</b> For <em>w </em>&#8804 32, the leftmost one (the one in bit position <em>w</em>) is
1821 optional. If you omit it, it will be added for you. For <em>w </em> = 64, there's no room for that one, so you have to leave it off.
1822 For <em>w </em>= 128, your polynomial can only use the bottom-most 64 bits. Fortunately, the standard polynomial only uses
1823 those bits. If you set <b>prim_poly</b> to zero, the library selects the "standard" polynomial.
1824 </p>
1825 <p>
1826 Finally, <b>scratch_memory</b> is there in case you don't want <b>gf_init_hard()</b> to call <b>malloc()</b>. Youmay call <b>gf_scratch_size()</b>
1827 to find out how much extra memory each technique uses, and then you may pass it a pointer for it to use in <b>scratc_memory.</b>
1828 If you set scratch memory to NULL, then the extra memory is allocated for you with <b>malloc().</b> If you use <b>gf_init_easy()</b>
1829 or <b>create_gf_from_argv(),</b> or you use <b>gf_init_hard()</b> and set <b>scratch_memory</b> to <b>NULL,</b> then you should call <b>gf_free()</b>
1830 to free memory. If you use <b>gf_init_hard()</b> and use your own <b>scratch_memory</b> you can still call <b>gf_free(),</b> and it will
1831 not do anything.</p>
1832 <p>
1833 Both <b>gf_init_hard()</b> and <b>gf_scratch_size()</b> return zero if the arguments don't specify a valid <b>gf_t.</b> When that happens,
1834 you can call <b>gf_error()</b> to print why the call failed.</p>
1835
1836
1837
1838
1839
1840
1841
1842
1843 <br/>
1844
1845
1846 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">26 </span> <br><br><br>
1847
1848
1849 <p>We'll give you one example of calling <b>gf_ init_hard().</b> Suppose you want to make a <b>gf_ init_hard()</b> call to be
1850 equivalent to "-m SPLIT 16 4 -r SSE -r ALTMAP -" and you want to allocate the scratch space yourself. Then you'd
1851 do the following:</p><br><br>
1852
1853 <div id="number_spacing">
1854 gf_t gf; <br>
1855 void *scratch; <br>
1856 int size; <br>
1857 size = gf_scratch_size(16, GF_MULT_SPLIT_TABLE,<br>
1858 GF_REGION_SSE | GF_REGION_ALTMAP,<br>
1859 GF_DIVIDE_DEFAULT,<br>
1860 16, 4); <br>
1861 if (size == 0) { gf_error(); exit(1); } /* It failed. That shouldn’t happen */<br>
1862 scratch = (void *) malloc(size); <br>
1863 if (scratch == NULL) { perror("malloc"); exit(1); } <br>
1864 if (!gf_init_hard(&gf, 16, GF_MULT_SPLIT_TABLE, <br>
1865 GF_REGION_SSE | GF_REGION_ALTMAP, <br>
1866 GF_DIVIDE_DEFAULT,<br>
1867 0, 16, 4, NULL, scratch)) { <br>
1868 gf_error(); <br>
1869 exit(1); <br>
1870 } <br>
1871
1872 </div>
1873
1874
1875 <h3>6.5 &nbsp &nbsp gf_size() </h3>
1876
1877 You can call <b>gf_size(gf_t *gf)</b> to learn the memory consumption of the <b>gf_t.</b> It returns all memory consumed by the
1878 <b>gf_t,</b> including the <b>gf_t</b> itself, any scratch memory required by the gf_ t, and the memory consumed by the sub-field
1879 if the field is <b>"COMPOSITE."</b> If you provided your own memory to <b>gf_init_hard(),</b> it does not report the size of
1880 this memory, but what the size should be, as determined by <b>gf_scratch size(). gf_ unit() </b> prints out the return value of
1881 <b>gf_size()</b> on the given field.
1882
1883
1884 <h2>7 &nbsp Further Information on Options and Algorithms </h2>
1885 <h3>
1886 7.1 &nbsp Inlining Single Multiplication and Division for Speed </h3>
1887
1888 Obviously, procedure calls are more expensive than single instructions, and the mechanics of multiplication in <b>"TABLE"</b>
1889 and <b>"LOG"</b> are pretty simple. For that reason, we support inlining for <b>"TABLE"</b> when <em>w </em> = 4 and <em>w </em> = 8, and
1890 for <b>"LOG"</b> when <em>w </em> = 16. We elaborate below.
1891 <p>
1892 When <em>w </em> = 4, you may inline multiplication and division as follows. The following procedures return pointers to
1893 the multiplication and division tables respectively: </p> <br><br>
1894
1895 <div id="number_spacing">
1896 uint8_t *gf_w4_get_mult_table(gf_t * gf);<br>
1897 uint8_t *gf_w4_get_div_table(gf_t * gf);<br><br>
1898 </div>
1899 <p>The macro <b>Gf_W4_INLINE_MULTDIV </b>(<em>table, a, b</em>) then multiplies or divides <em>a </em> by <em>b</em> using the given table. This
1900 of course only works if the multiplication technique is <b>"TABLE,"</b> which is the default for <em>w </em> = 4. If the multiplication
1901 technique is not <b>"TABLE,"</b> then <b>gf_w4_get_mult_table()</b> will return <b>NULL.</b></p>
1902
1903
1904
1905
1906
1907
1908
1909
1910 <br/>
1911
1912
1913 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">27 </span> <br><br><br>
1914
1915
1916
1917
1918 <p>When <em>w </em> = 8, the procedures <b>gf_w8_et_mult_table()</b> and <b>gf_ w8_get_div_table(),</b> and the macro </p>
1919
1920 <b>GF_W8_INLINE_MULTDIV </b>(<em>table, a, b</em>) work identically to the <em>w </em> = 4 case.
1921
1922 <p>When <em>w </em> = 16, the following procedures return pointers to the logarithm table, and the two inverse logarithm tables
1923 respectively: </p><br>
1924
1925 <div id="number_spacing">
1926 uint16_t *gf_w16_get_log_table(gf_t * gf); <br>
1927 uint16_t *gf_w16_get_mult_alog_table(gf_t * gf);<br>
1928 uint16_t *gf_w16_get_div_alog_table(gf_t * gf);<br>
1929
1930 </div>
1931 <br>
1932 <p>
1933 The first inverse logarithm table works for multiplication, and the second works for division. They actually point
1934 to the same table, but to different places in the table. You may then use the macro <b>GF_W16_INLINE_MULT</b>(<em>log,
1935 alog, a, b </em>) to multiply <em>a</em> and <em>b</em>, and the macro <b>GF_W16_INLINE_DIV </b>(<em>log, alog, a, b </em>) to divide a and b. Make
1936 sure you use the <em>alog</em> table returned by <b>gf_w16_get_mult_alog_table()</b> for multiplication and the one returned by
1937 <b>gf_w16_get_div_alog_table()</b> for division. Here are some timings: </p> <br><br>
1938
1939
1940 UNIX> gf_time 4 M 0 10240 10240 - <br>
1941 Seed: 0 <br>
1942 Multiply: 0.228860 s Mops: 100.000 436.949 Mega-ops/s <br>
1943 UNIX> gf_inline_time 4 0 10240 10240 <br>
1944 Seed: 0 <br>
1945 Inline mult: 0.096859 s Mops: 100.000 1032.424 Mega-ops/s <br>
1946 UNIX> gf_time 8 M 0 10240 10240 - <br>
1947 Seed: 0 <br>
1948 Multiply: 0.228931 s Mops: 100.000 436.812 Mega-ops/s <br>
1949 UNIX> gf_inline_time 8 0 10240 10240 <br>
1950 Seed: 0 <br>
1951 Inline mult: 0.114300 s Mops: 100.000 874.889 Mega-ops/s <br>
1952 UNIX> gf_time 16 M 0 10240 10240 - <br>
1953 Seed: 0 <br>
1954 Multiply: 0.193626 s Mops: 50.000 258.229 Mega-ops/s <br>
1955 UNIX> gf_inline_time 16 0 10240 10240 <br>
1956 Seed: 0 <br>
1957 Inline mult: 0.310229 s Mops: 100.000 322.342 Mega-ops/s <br>
1958 UNIX> <br> <br>
1959
1960 <h3>
1961 7.2 &nbsp &nbsp Using different techniques for single and region multiplication </h3>
1962
1963
1964 You may want to "mix and match" the techniques. For example, suppose you'd like to use "-m SPLIT 8 8" for
1965 <b>multiply()</b> in <em>GF(2<sup>32</sup>),</em> because it's fast, and you don't mind consuming all of that space for tables. However, for
1966 <b>multiply_region(),</b> you'd like to use "-m SPLIT 32 4 -r ALTMAP," because that's the fastest way to implement
1967 <b>multiply_region().</b> Unfortunately, There is no way to create a <b>gf_t</b> that does this combination. In this case, you should
1968 simply create two <b>gf_t's,</b> and use one for <b>multiply()</b> and the other for <b>multiply_region().</b> All of the implementations
1969 may be used interchangably with the following exceptions:
1970
1971 <ul>
1972 <li>
1973 <b>"COMPOSITE"</b> implements a different Galois Field. </li><br>
1974
1975 <li>If you change a field's polynomial, then the resulting Galois Field will be different. </li>
1976
1977 </ul>
1978
1979
1980
1981
1982
1983
1984
1985
1986 <br/>
1987
1988
1989 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">28 </span> <br><br><br>
1990
1991 <ul>
1992 <li>
1993
1994 If you are using <b>"ALTMAP"</b> to multiply regions, then the contents of the resulting regions of memory will
1995 depend on the multiplication technique, the size of the region and its alignment. Please see section 7.9 for a
1996 detailed explanation of this. </li>
1997
1998 <li>If you are using <b>"CAUCHY"</b> to multiply regions, then like <b>"ALTMAP,"</b> the contents of the result regions of
1999 memory the multiplication technique and the size of the region. You don't have to worry about alignment. </li>
2000
2001 <h3>7.3 &nbsp &nbsp General <em>w </em> </h3>
2002 The library supports Galois Field arithmetic with 2 < <em>w </em> &#8804 32. Values of <em>w </em> which are not whole number powers of
2003 2 are handled by the functions in <b>gf_wgen.c</b> . For these values of <em>w </em>, the available multiplication types are <b>"SHIFT,"
2004 "BYT<em>w </em>O p," "BYT<em>w </em>O b," "GROUP," "TABLE"</b> and <b>"LOG." "LOG" </b> is only valid for <em>w </em> < 28 and <b>"TABLE"</b>
2005
2006 is only valid for <em>w </em> < 15. The defaults for these values of <em>w </em> are <b>"TABLE"</b> for <em>w </em> < 8, <b>"LOG"</b> for <em>w </em> < 16, and
2007 <b>"BYT<em>w </em>O p"</b> for <em>w </em> < 32.<br><br>
2008
2009 <h3>7.4 Arguments to "SPLIT" </h3>
2010
2011 The "SPLIT" technique is based on the distributive property of multiplication and addition: <br><br>
2012 <center>
2013 a * (b + c) = (a * b) + (a * c). </center>
2014 <br>
2015 This property allo<em>w </em>s us to, for example, split an eight bit <em>w </em>ord into t<em>w </em>o four-bit components and calculate the product
2016 by performing t<em>w </em>o table lookups in 16-element tables on each of the compoents, and adding the result. There is much
2017 more information on <b>"SPLIT"</b> in The Paper. Here <em>w </em>e describe the version of <b>"SPLIT"</b> implemented in GF-Complete.
2018
2019 <p>
2020 <b>"SPLIT"</b> takes t<em>w </em>o arguments, <em>w </em>hich are the number of bits in each component of a, <em>w </em>hich <em>w </em>e call <em>w </em><sub>a</sub>, and the
2021 number of bits in each component of b, <em>w </em>hich <em>w </em>e call <em>w </em><sub>b.</sub> If the t<em>w </em>o differ, it does not matter <em>w </em>hich is bigger - the
2022 library recognizes this and performs the correct implementation. The legal values of <em>w </em><sub>a</sub> and <em>w </em><sub>b</sub> fall into five categories:
2023 </p><br>
2024
2025
2026 <ol>
2027 <li>
2028 <em>w </em><sub>a</sub> is equal to <em>w </em> and <em>w </em><sub>b</sub> is equal to four. In this case, b is broken up into <em>w </em>/4
2029 four-bit <em>w </em>ords <em>w </em>hich are used
2030 in 16-element lookup tables. The tables are created on demand in <b>multiply_region()</b> and the SSSE3 instruction
2031
2032 <b>mm_shuffle_epi8()</b> is leveraged to perform 16 lookups in parallel. Thus, these are very fast implementations.
2033 <em>w </em>hen <em>w </em> &#8805 16, you should combine this <em>w </em>ith <b>"ALTMAP"</b> to get the best performance (see The Paper
2034 or [PGM13b] for explanation). If you do this please see section 7.9 for information about <b>"ALTMAP"</b> and
2035 alignment.<br><br>
2036
2037
2038 If you don't use <b>"ALTMAP,"</b> the implementations for <em>w </em> &#8712 {16, 32, 64} convert the standard representation into
2039 <b>"ALTMAP,"</b> perform the multiplication <em>w </em>ith <b>"ALTMAP"</b> and then convert back to the standard representation.
2040 The performance difference using <b>"ALTMAP"</b> can be significant: <br><br><br>
2041
2042 <div id="number_spacing">
2043 <center>
2044 <div id="table_page28">
2045 <table cellpadding="6" cellspacing="0" style="text-align:center;font-size:19px">
2046 <tr>
2047 <td> gf_time 16 G 0 1048576 100 -m SPLIT 16 4 -</td> <td>Speed = 8,389 MB/s </td>
2048 </tr>
2049 <tr>
2050 <td>gf_time 16 G 0 1048576 100 -m SPLIT 16 4 -r ALTMAP - </td> <td>Speed = 8,389 MB/s </td>
2051 </tr>
2052
2053 <tr>
2054 <td>gf_time 32 G 0 1048576 100 -m SPLIT 32 4 -</td> <td> Speed = 5,304 MB/s</td>
2055 </tr>
2056 <tr>
2057 <td>gf_time 32 G 0 1048576 100 -m SPLIT 32 4 -r ALTMAP -</td> <td> Speed = 7,146 MB/s</td>
2058 </tr>
2059
2060
2061 <tr>
2062 <td>gf_time 64 G 0 1048576 100 -m SPLIT 64 4 - </td> <td>Speed = 2,595 MB/s </td>
2063 </tr>
2064
2065 <tr>
2066 <td>gf_time 64 G 0 1048576 100 -m SPLIT 64 4 -r ALTMAP - </td> <td>Speed = 3,436 MB/s </td>
2067 </tr>
2068 </div>
2069
2070
2071
2072 </table>
2073 </div>
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083 <br/>
2084
2085
2086 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">29 </span> <br><br><br>
2087
2088 <ol style="list-style-type:none">
2089
2090
2091 <li>2. &nbsp w<sub>a</sub> is equal to <em>w </em> and w<sub>b</sub> is equal to eight. Now, b is broken into bytes, each of these is used in its own 256-element
2092 lookup table. This is typically the best w<sub>a</sub>y to perform <b>multiply_region()</b> without SSE.</li>
2093 Because this is a region optimization, when you specify these options, you get a default <b>multiply()</b> see
2094 Table 1 for a listing of the defaults. See section 7.2 for using a different <b>multiply()</b> than the defaults.<br><br>
2095
2096
2097 <li>
2098 3. &nbsp w<sub>a</sub> is equal to <em>w </em> and <em>w </em><sub>b</sub> is equal to 16. This is only valid for <em>w </em> = 32 and <em>w </em> = 64. No<em>w </em>, b is broken into shorts,
2099 each of these is used in its own 64K-element lookup table. This is typically slower than when <em>w </em><sub>b</suB> equals 8, and
2100 requires more amortization (larger buffer sizes) to be effective. </li><br>
2101
2102
2103 <li>4. &nbsp <em>w </em><sub>a</sub> and <em>w </em><sub>b</sub> are both equal to eight. Now both <em>a</em> and <em>b</em> are broken into bytes,
2104 and the products of the various bytes
2105 are looked up in multiple 256 &#215 256 tables. In <em>GF(2<sup>16</sup>),</em> there are three of these tables. In <em>GF(232),</em> there are
2106 seven, and in <em>GF(2<sup>64</sup>)</em> there are fifteen. Thus, this implementation can be a space hog. How ever, for <em>w </em> = 32,
2107 this is the fastest way to perform <b>multiply()</b> on some machines.
2108 when this option is employed, <b>multiply_region()</b> is implemented in an identical fashion to when <em>w </em><sub>a</sub> = <em>w </em>
2109 and <em>w </em><sub>b</sub> = 8. </li><br>
2110
2111 <li>5.&nbsp w<sub>a</sub> = 32 and w<sub>b</sub> = 2. (<em>w</em> = 32 only). I was playing with a different way to use <b>mm_shuffle_epi8().</b> It works,
2112 but it's slower than when w<sub>b</sub> = 4.
2113 </li>
2114
2115 </ul>
2116
2117
2118
2119 <h2>7.5 &nbsp&nbsp Arguments to "GROUP" </h3>
2120
2121 The <b>"GROUP"</b> multiplication option takes t<em>w </em>o arguments, g<sub>s</sub> and g<sub>r</sub>. It implements multiplication in the same manner
2122 as <b>"SHIFT,"</b> except it uses a table of size 2<sup>gs</sup> to perform g<sup>s</sup> shifts at a time, and a table of size 2<sup>gr</sup> to perform g<sup>r</sup>
2123 reductions at at time. The program <b>gf_methods</b> only prints the options 4 4 and 4 8 as arguments for <b>"GROUP."</b>
2124 However, other values of g<sub>s</sub> and g<sub>r</sub> are legal and sometimes desirable: <br><br>
2125
2126 <ol>
2127 <li>
2128 For <em>w </em> &#8804 32 and <em>w </em> = 64, any values of g<sub>s</sub> and g<sub>r</sub> may be used, so long as they are less than or equal to <em>w </em> and so
2129 long as the tables fit into memory. There are four exceptions to this, listed belo<em>w </em>. </li><br>
2130 <li> For <em>w </em> = 4, <b>"GROUP"</b> is not supported. </li><br>
2131 <li> For <em>w </em> = 8, <b>"GROUP"</b> is not supported. </li><br>
2132 <li> For <em>w </em> = 16, <b>"GROUP"</b> is only supported for gs = gr = 4. </li><br>
2133 <li> For <em>w </em> = 128 <b>"GROUP"</b> only supports <em>g<sub>s</sub></em> = 4 and <em> g<sub>r</b> </em> &#8712 {4, 8, 16}.</li><br>
2134 </ol>
2135 <p>
2136 The way that gs and gr impact performance is as follows. The <b>"SHIFT"</b> implementation works by performing a
2137 carry-free multiplication in <em>w </em> steps, and then performing reduction in <em>w </em> steps. In "GROUP," the carry-free multiplication
2138 is reduced to <em>w /</em>g<sub>s</sub>steps, and the reduction is reduced to <em>w /</em>g<sub>r</sub>
2139
2140 . Both require tables. The table for the carry-free
2141 multiplication must be created at the beginning of each <b>multiply()</b> or <b>multiply_region(),</b> while the table for reduction
2142 is created when the <b>gf_t</b> is initialized. For that reason, it makes sense for g<sub>r</sub> to be bigger than g<sub>s.</sub></p>
2143
2144 <p>
2145 To give a flavor for the impact of these arguments, Figure 3 show </em>s the performance of varying g<sub>s</sub> and g<sub>r</sub> for
2146 single multiplication and region multiplication respectively, in <em> GF(2<sup>32</sup>)</em> and <em>GF(2<sup>64</sup>).</em> As the graphs demonstrate,
2147 <b>multiply()</b> performs better <em>w </em>ith smaller values of gs, <em>w </em>hile multiply region() amortizes the creation of the shifting
2148 table, and can tolerate larger values of g<sub>s.</sub> <em>w </em>hen g<sub>s</sub> equals g<sub>r,</sub> there are some optimizations that we hand-encode.
2149 These can be seen clearly in the <b>multiply_region()</b> graphs.
2150 </p>
2151
2152
2153
2154
2155
2156
2157
2158
2159 <br/>
2160 7 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">30 </span>
2161
2162
2163 <div id="box_1">
2164
2165 <div class="image-cell_3"> </div>
2166
2167 <div class="image-cell_4"> </div>
2168 </div>
2169 Figure 3: The performance of <b>multiply()</b> and <b>multiply_region()</b> using <b>"GROUP,"</b> and varying the arguments <br> g<sub>s</sub>
2170 and g<sub>r.</sub> All graphs are heat maps with black equaling zero. The region size is 100KB.
2171
2172 <h3>7.6 &nbspConsiderations with "COMPOSITE" </h3>
2173
2174
2175 As mentioned above, using <b>"ALTMAP"</b> with <b>"COMPOSITE"</b> allows <b>multiply_region()</b> to recursively call <b>multiply_
2176 region(),</b> rather than simply calling <b>multiply()</b> on every word in the region. The difference can be pronounced:<br><br>
2177
2178 <div id="table_page28"><center>
2179
2180 <table cellpadding="6" cellspacing="0" style="text-align:center;font-size:19px"><tr>
2181 <td>
2182 gf_time 32 G 0 10240 10240 -m COMPOSITE 2 - -
2183 Speed = 322 MB/s </td> </tr>
2184 <tr>
2185 <td>gf_time 32 G 0 10240 10240 -m COMPOSITE 2 - -r ALTMAP -
2186 Speed = 3,368 MB/s </td> </tr>
2187
2188 <tr>
2189 <td>
2190 gf_time 32 G 0 10240 10240 -m COMPOSITE 2 -m SPLIT 16 4 -r ALTMAP - -r ALTMAP -
2191 Speed = 3,925 MB/s </td> </tr>
2192 </center>
2193 </table>
2194 </div>
2195
2196
2197 <br><br>
2198 <p>
2199 There is support for performing <b>multiply()</b> inline for the <b>"TABLE"</b> implementations for w &#8712 {4, 8} and for the
2200 "LOG" implementation for <em>w</em> = 16 (see section 7.1). These are leveraged by <b>multiply()</b> in <b>"COMPOSITE,"</b> and
2201 by <b>multiply_region()</b> if you are not using <b>"ALTMAP."</b> To demonstrate this, in the table below, you can see that the
2202 performance of <b>multiply()</b> with <b>"SPLIT 8 4"</b> is 88 percent as fast than the default in <em>w</em> = 8 (which is <b>"TABLE"</b>).
2203 When you use each as a base field for <b>"COMPOSITE"</b> with <em>w</em> = 16, the one with <b>"SPLIT 8 4"</b> is now just 37 percent
2204 as fast. The difference is the inlining of multiplication in the base field when <b>"TABLE"</b> is employed:</p><br><br>
2205
2206 <div id="table_page28" border="0"><center>
2207
2208 <table cellpadding="6" cellspacing="0" style="text-align:center;font-size:19px">
2209
2210 <tr><td>gf_time 8 M 0 1048576 100 - Speed = 501 Mega-ops/s</td> </tr>
2211 <tr><td>gf_time 8 M 0 1048576 100 -m SPLIT 8 4 - Speed = 439 Mega-ops/s </td> </tr>
2212 <tr><td>gf_time 8 M 0 1048576 100 -m COMPOSITE 2 - - Speed = 207 Mega-ops/s </td> </tr>
2213 <tr><td>gf_time 8 M 0 1048576 100 -m COMPOSITE 2 -m SPLIT 8 4 - - Speed = 77 Mega-ops/s </td> </tr>
2214
2215 </table>
2216 </center>
2217 <br><br>
2218 </div>
2219
2220 You can keep making recursive definitions of composites field if you want. For example, this one's not too slow for
2221 region operations (641 MB/s):
2222
2223
2224
2225
2226
2227
2228
2229
2230 <br/>
2231 <br/>
2232
2233
2234 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">31 </span> <br><br><br>
2235
2236 <div id="number_spacing">
2237 <center>
2238 gf_time 128 G 0 1048576 100 -m COMPOSITE 2 <span style="color:red">-m COMPOSITE 2 </span> <span style="color:blue">-m COMPOSITE 2 </span> <br>
2239 <span style="color:rgb(250, 149, 167)">-m SPLIT 16 4 -r ALTMAP -</span> <span style="color:blue">-r ALTMAP -</span> <span style="color:red"> -r ALTMAP -</span> -r ALTMAP -
2240 </center>
2241 </div><br>
2242
2243 <p>Please see section 7.8.1 for a discussion of polynomials in composite fields.</p>
2244
2245 <h2>7.7 &nbsp &nbsp &nbsp "CARRY_FREE" and the Primitive Polynomial </h2>
2246
2247
2248 If your machine supports the PCLMUL instruction, then we leverage that in <b>"CARRY_FREE."</b> This implementation
2249 first performs a carry free multiplication of two <em>w</em>-bit numbers, which yields a 2<em>w</em>-bit number. It does this with
2250 one PCLMUL instruction. To reduce the 2<em>w</em>-bit number back to a <em>w</em>-bit number requires some manipulation of the
2251 polynomial. As it turns out, if the polynomial has a lot of contiguous zeroes following its leftmost one, the number of
2252 reduction steps may be minimized. For example, with <em>w </em> = 32, we employ the polynomial 0x100400007, because that
2253 is what other libraries employ. This only has 9 contiguous zeros following the one, which means that the reduction
2254 takes four steps. If we instead use 0x1000000c5, which has 24 contiguous zeros, the reduction takes just two steps.
2255 You can see the difference in performance:
2256 <br><br>
2257 <center>
2258 <div id="table_page28">
2259
2260 <table cellpadding="6" cellspacing="0" style="text-align:center;font-size:19px">
2261 <tr>
2262
2263 <td>gf_time 32 M 0 1048576 100 -m CARRY_FREE - </td> <td> Speed = 48 Mega-ops/s</td> </tr>
2264
2265 <tr><td>gf_time 32 M 0 1048576 100 -m CARRY_FREE -p 0xc5 -</td> <td> Speed = 81 Mega-ops/s </td> </tr>
2266
2267 </table></center>
2268 </div>
2269 <br><br>
2270
2271 <p>
2272 This is relevant for <em>w </em> = 16 and <em>w </em> = 32, where the "standard" polynomials are sub-optimal with respect to
2273 <b>"CARRY_FREE."</b> For <em>w </em> = 16, the polynomial 0x1002d has the desired property. It’s less important, of course,
2274 with <em>w </em> = 16, because <b>"LOG"</b> is so much faster than <b>CARRY_FREE.</b> </p>
2275
2276 <h2>7.8 &nbsp More on Primitive Polynomials </h3>
2277
2278 <h3>7.8.1 &nbsp Primitive Polynomials that are not Primitive </h4>
2279
2280 The library is willing to work with most polynomials, even if they are not primitive or irreducible. For example, the
2281 polynomial x<sup>4</sup> + x<sup>3</sup> +x<sup>2</sup> +x+1 is irreducible, and therefore generates a valid Galois Field for <em>GF(2<sup>4</sup>).</em> However, it
2282 is not primitive, because 2<sup>5</sup> = 1. For that reason, if you use this polynomial, you cannot use the <b>"LOG"</b> method. The
2283 other methods will work fine: <br><br>
2284
2285 <div id="number_spacing">
2286
2287 UNIX> gf_mult 2 2 4 -p 0xf - <br>
2288 4 <br>
2289 UNIX> gf_mult 4 2 4 -p 0xf - <br>
2290 8 <br>
2291 UNIX> gf_mult 8 2 4 -p 0xf - <br>
2292 15 <br>
2293 UNIX> gf_mult 15 2 4 -p 0xf - <br>
2294 1 <br>
2295 UNIX> gf_div 1 15 4 -p 0xf - <br>
2296 2 <br>
2297 UNIX> gf_div 1 15 4 -p 0xf -m LOG - <br>
2298 usage: gf_div a b w [method] - does division of a and b in GF(2&#710;w) <br>
2299 Bad Method Specification: Cannot use Log tables because the polynomial is not primitive. <br>
2300 UNIX> <br>
2301 </div>
2302 <p>
2303 If a polynomial is reducible, then it does not define a Galois Field, but instead a ring. GF-Complete attempts to
2304 work here where it can; however certain parts of the library will not work:
2305 </p>
2306
2307
2308
2309
2310
2311
2312 <br/>
2313
2314
2315 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">32 </span> <br><br><br>
2316 <ol>
2317 <li>
2318 Division is a best effort service. The problemis that often quotients are not unique. If <b>divide()</b> returns a non-zero
2319 number, then that number will be a valid quotient, but it may be one of many. If the multiplication technique is
2320 <b>"TABLE,"</b> then if a quotient exists, one is returned. Otherwise, zero is returned. Here are some examples - the
2321 polynomial x<sup>4</sup> + 1 is reducible, and therefore produces a ring. Below, we see that with this polynomal, 1*6 = 6
2322 and 14*6 = 6. Therefore, 6/6 has two valid quotients: 1 and 14. GF-Complete returns 14 as the quotient:</li><br>
2323
2324 <div id="number_spacing">
2325 UNIX> gf_mult 1 6 4 -p 0x1 -<br>
2326 6 <br>
2327 UNIX> gf_mult 14 6 4 -p 0x1 - <br>
2328 6 <br>
2329 UNIX> gf_div 6 6 4 -p 0x1 - <br>
2330 14 <br>
2331 UNIX> <br><br>
2332 </div>
2333
2334
2335 <li>When <b>"EUCLID"</b> is employed for division, it uses the extended Euclidean algorithm for GCD to find a number's
2336 inverse, and then it multiplies by the inverse. The problem is that not all numbers in a ring have inverses. For
2337 example, in the above ring, there is no number <em>a</em> such that 6a = 1. Thus, 6 has no inverse. This means that even
2338 though 6/6 has quotients in this ring, <b>"EUCLID"</b> will fail on it because it is unable to find the inverse of 6. It will
2339 return 0:
2340 </li><br>
2341 <div id="number_spacing">
2342 UNIX> gf_div 6 6 4 -p 0x1 -m TABLE -d EUCLID -<br>
2343 0<br>
2344 UNIX><br>
2345 </div><br>
2346
2347 <li> Inverses only work if a number has an inverse. Inverses may not be unique. </li><br>
2348
2349 <li> <b>"LOG"</b> will not work. In cases where the default would be <b>"LOG,"</b> <b>"SHIFT"</b> is used instead. </li>
2350 </ol>
2351
2352 <p>
2353 Due to problems with division, <b>gf_unit</b> may fail on a reducible polynomial. If you are determined to use such a
2354 polynomial, don't let this error discourage you.
2355 </p>
2356
2357 <h3>7.8.2 Default Polynomials for Composite Fields </h3>
2358
2359 GF-Complete will successfully select a default polynomial in the following composite fields:
2360 <ul>
2361 <li> <em>w </em> = 8 and the default polynomial (0x13) is employed for <em>GF(2<sup>4</sup>)</em></li><br>
2362 <li> w = 16 and the default polynomial (0x11d) is employed for <em>GF(2<sup>8</sup>)</em></li><br>
2363 <li> <em>w </em> = 32 and the default polynomial (0x1100b) is employed for <em>GF(2<sup>16</sup>) </em></li><br>
2364 <li> <em>w </em> = 32 and 0x1002d is employed for <em>GF(2<sup>16</sup>) </em></li><br>
2365 <li> <em>w </em> = 32 and the base field for <em>GF(w<em>16</em>) </em> is a composite field that uses a default polynomial</li><br>
2366 <li> <em>w </em> = 64 and the default polynomial (0x100400007) is employed for <em>GF(2<sup>32</sup>)</em></li><br>
2367 <li> <em>w </em> = 64 and 0x1000000c5 is employed for <em>GF(2<sup>32</sup>) </em></li><br>
2368 <li> <em>w </em> = 64 and the base field for <em>GF(w<sup>32</sup>) </em> is a composite field that uses a default polynomial</li><br>
2369 <li> <em>w </em> = 128 and the default polynomial (0x1b) is employed for <em>GF(2<sup>64</sup>) </em></li><br>
2370 <li> <em>w </em> = 128 and the base field for <em> GF(w<sup>64 </sup>) </em> is a composite field that uses a default polynomial</li><br>
2371 </ul>
2372
2373
2374
2375
2376
2377
2378
2379
2380 <br/>
2381
2382
2383 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">33 </span> <br><br><br>
2384
2385
2386 <h3>7.8.3 The Program gf_poly for Verifying Irreducibility of Polynomials </h3>
2387
2388 The program <b>gf_poly</b> uses the Ben-Or algorithm[GP97] to determine whether a polynomial with coefficients in <em> GF(2<sup>w </sup>) </em>
2389 is reducible. Its syntax is:<br><br>
2390 <div id="number_spacing">
2391 gf_poly w method power:coef power:coef ...
2392 </div>
2393
2394 <br>
2395 <p>You can use it to test for irreducible polynomials with binary coefficients by specifying w = 1. For example, from
2396 the discussion above, we know that x<sup>4</sup> +x+1 and x<sup>4</sup> +x<sup>3</sup> +x<sup>2</sup> +x+1 are both irreducible, but x<sup>4</sup> +1 is reducible.
2397 <b>gf_poly</b> confirms:<p><br>
2398
2399 <div id="number_spacing">
2400 UNIX> gf_poly 1 - 4:1 1:1 0:1 <br>
2401 Poly: x&#710;4 + x + 1 <br>
2402 Irreducible. <br>
2403 UNIX> gf_poly 1 - 4:1 3:1 2:1 1:1 0:1 <rb>
2404 Poly: x&#710;4 + x&#710;3 + x&#710;2 + x + 1 <br>
2405 Irreducible. <br>
2406 UNIX> gf_poly 1 - 4:1 0:1 r<br>
2407 Poly: x&#710;4 + 1 <br>
2408 Reducible. <br>
2409 UNIX> <br>
2410
2411 </div>
2412
2413
2414 <p>
2415 For composite fields <em>GF((2<sup>l</sup>)<sup>2</sup>),</em> we are looking for a value s such that x<sup>2</sup> + sx + 1 is irreducible. That value
2416 depends on the base field. For example, for the default field <em>GF(2<sup>32</sup>),</em> a value of <em>s</em> = 2 makes the polynomial
2417 irreducible. However, if the polynomial 0xc5 is used (so that PCLMUL is fast - see section 7.7), then <em>s</em> = 2 yields a
2418 reducible polynomial, but <em>s</em> = 3 yields an irreducible one. You can use <b>gf_poly</b> to help verify these things, and to help
2419 define s if you need to stray from the defaults:</p> <br>
2420
2421 <div id="number_spacing">
2422 UNIX> gf_poly 32 - 2:1 1:2 0:1<br>
2423 Poly: x&#710;2 + (0x2)x + 1 <br>
2424 Irreducible. <br>
2425 UNIX> gf_poly 32 -p 0xc5 - 2:1 1:2 0:1 <br>
2426 Poly: x&#710;2 + (0x2)x + 1 <br>
2427 Reducible. <br>
2428 UNIX> gf_poly 32 -p 0xc5 - 2:1 1:3 0:1 <br>
2429 Poly: x&#710;2 + (0x3)x + 1 <br>
2430 Irreducible. <br>
2431 UNIX> <br>
2432 </div>
2433
2434 <p>
2435 <b>gf_unit</b> does random sampling to test for problems. In particular, it chooses a random a and a random b, multiplies
2436 them, and then tests the result by dividing it by a and b. When w is large, this sampling does not come close to
2437 providing complete coverage to check for problems. In particular, if the polynomial is reducible, there is a good
2438 chance that <b>gf_unit</b> won't discover any problems. For example, the following <b>gf_unit</b> call does not flag any problems,
2439 even though the polynomial is reducible.</p>
2440 <br>
2441 <div id="number_spacing">
2442 UNIX> gf_unit 64 A 0 -m COMPOSITE 2 -p 0xc5 - -p 2 -<br>
2443 UNIX>
2444 </div>
2445
2446 <p>
2447 How can we demonstrate that this particular field has a problem? Well, when the polynomial is 0xc5, we can factor
2448 x<sup>2</sup> + 2x + 1 as (x + 0x7f6f95f9)(x + 0x7f6f95fb). Thus, in the composite field, when we multiply 0x17f6f95f9 by
2449 0x17f6f95fb, we get zero. That's the problem:
2450 </p>
2451
2452
2453
2454
2455
2456
2457
2458
2459 <br/>
2460
2461
2462 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">34 </span> <br><br><br>
2463
2464 <div id="number_spacing">
2465
2466 UNIX> gf_mult 7f6f95f9 7f6f95fb 32h -p 0xc5 - <br>
2467 1 <br>
2468 UNIX> gf_mult 17f6f95f9 17f6f95fb 64h -m COMPOSITE 2 -p 0xc5 - -p 2 - <br>
2469 0 <br>
2470 UNIX> <br>
2471
2472 </div>
2473
2474 <h2>7.9 "ALTMAP" considerations and extract_word() </h2>
2475
2476 There are two times when you may employ alternate memory mappings:
2477 <ol>
2478 <li> When using <b>"SPLIT"</b> and w<sub>b</sub> = 4. </li>
2479 <li> When using <b>"COMPOSITE."</b> </li>
2480 </ol>
2481
2482 Additionally, by default, the <b>"CAUCHY"</b> region option also employs an alternate memory mapping.
2483
2484 <p>When you use alternate memory mappings, the exact mapping of words in <em> GF(2<sup>w </sup>) </em> to memory depends on the
2485 situation, the size of the region, and the alignment of the pointers. To help you figure things out, we have included the
2486 procedures <b>extract_word.wxx()</b> as part of the <b>gf_t</b> struct. This procedure takes four parameters: </p>
2487 <ul>
2488 <li>A pointer to the <b>gf_t.</b> </li>
2489 <li> The beginning of the memory region. </li>
2490 <li>The number of bytes in the memory region. </li>
2491 <li>The desired word number: <em>n.</em> </li>
2492 </ul>
2493
2494 <p>
2495 It then returns the <em>n</em>-th word in memory. When the standard mapping is employed, this simply returns the <em>n</em>-
2496 th contiguous word in memory. With alternate mappings, each word may be split over several memory regions, so
2497 <b>extract_word()</b> grabs the relevant parts of each memory region to extract the word. Below, we go over each of the
2498 above situations in detail. Please refer to Figure 2 in Section 5 for reference. </p>
2499
2500
2501 <h3>7.9.1 Alternate mappings with "SPLIT" </h3>
2502
2503 The alternate mapping with <b>"SPLIT"</b> is employed so that we can best leverage <b>mm_shuffle_epi8().</b> Please read [PGM13b]
2504 for details as to why. Consider an example when <em>w</em> = 16. In the main region of memory (the middle region in Figure
2505 2), multiplication proceeds in units of 32 bytes, which are each broken into two 16-byte regions. The first region
2506 holds the high bytes of each word in <em>GF(2<sup>16</sup>),</em> and the second region holds the low bytes.
2507 Let's look at a very detailed example, from <b>gf_example_5.c.</b> This program makes the following call, where <b>gf</b> has
2508
2509 been initialized for <em>w</em> = 16, using <b>"SPLIT"</b> and <b>"ALTMAP:"</b><br><br>
2510 <div id="number_spacing">
2511 gf.multiply_region.w32(&gf, a, b, 0x1234, 30*2, 0);
2512 </div><br>
2513
2514
2515 <p>In other words, it is multiplying a region a of 60 bytes (30 words) by the constant 0x1234 in <em> GF(2<sup>16</sup>),</em> and placing
2516 the result into <em>b.</em> The pointers <em>a</em> and <em>b</em> have been set up so that they are not multiples of 16. The first line of output
2517 prints <em>a</em> and <em>b:</em></p><br>
2518
2519 a: 0x10010008c b: 0x10010015c <br><br>
2520
2521 As described in Section 5, the regions of memory are split into three parts:
2522
2523
2524
2525
2526
2527
2528
2529
2530 <br/>
2531
2532
2533 6 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">35 </span> <br><br><br>
2534
2535
2536 <ol>
2537 <li> 4 bytes starting at 0x1001008c / 0x10010015c. </li>
2538 <li> 32 bytes starting at 0x10010090 / 0x100100160. </li>
2539 <li> 24 bytes starting at 0x100100b0 / 0x100100180. </li>
2540
2541 </ol>
2542
2543
2544 <p>In the first and third parts, the bytes are laid out according to the standard mapping. However, the second part is
2545 split into two 16-byte regions- one that holds the high bytes of each word and one that holds the low bytes. To help
2546 illustrate, the remainder of the output prints the 30 words of <em>a</em> and <em>b</em> as they appear in memory, and then the 30 return
2547 values of <b>extract_word.w32():</b> </p><br>
2548
2549 <div id="number_spacing">
2550 <table cellspacing="6" style="text-align:right">
2551
2552 <tr>
2553 <td></td> <td> 1</td> <td> 2 </td> <td> 3 </td> <td> 4</td> <td> 5 </td> <td> 6 </td> <td> 7</td> <td> 8 </td> <td> 9</td> </tr>
2554 <tr>
2555 <td>a:</td><td> 640b</td> <td> 07e5</td> <td> 2fba </td> <td> ce5d </td> <td> f1f9</td> <td> 3ab8</td> <td> c518 </td> <td> 1d97</td> <td> 45a7</td>
2556 <td> 0160</td> </tr>
2557
2558 <tr><td>b:</td> <td>1ba3</td><td> 644e</td> <td> 84f8</td> <td> be3c</td> <td> 4318</td> <td> 4905</td> <td> b2fb </td> <td> 46eb </td> <td> ef01 </td>
2559 <td>a503</td>
2560 </tr>
2561 </table>
2562 <br><br>
2563 <table cellspacing="6" style="text-align:right">
2564
2565 <tr>
2566 <td> 10</td> <td> 11 </td> <td> 12</td> <td> 13</td> <td> 14 </td> <td> 15 </td> <td> 16</td> <td> 17</td> <td>18</td> <td> 19 </td></tr>
2567 <tr>
2568 <td>a:</td><td> 3759</td> <td> b107</td> <td> 9660 </td> <td> 3fde </td> <td> b3ea</td> <td> 8a53</td> <td> 75ff </td> <td> 46dc</td> <td> c504</td>
2569 <td> 72c2</td> </tr>
2570
2571 <tr><td>b:</td> <td>da27</td><td> e166</td> <td> a0d2</td> <td> b3a2</td> <td> 1699</td> <td> 3a3e</td> <td> 47fb </td> <td> 39af </td> <td> 1314 </td>
2572 <td>8e76</td>
2573 </tr>
2574 </table>
2575
2576 <table cellspacing="6" style="text-align:right">
2577 <br><br>
2578 <tr>
2579 <td> 20</td> <td> 21 </td> <td> 22</td> <td> 23</td> <td> 24 </td> <td> 25 </td> <td> 26</td> <td> 27</td> <td>28</td> <td> 29 </td></tr>
2580 <tr>
2581 <td>a:</td><td> b469</td> <td> 1b97</td> <td> e91d </td> <td> 1dbc </td> <td> 131e</td> <td> 47e0</td> <td> c11a </td> <td> 7f07</td> <td> 76e0</td>
2582 <td> fe86</td> </tr>
2583
2584 <tr><td>b:</td> <td>937c</td><td> a5db</td> <td> 01b7</td> <td> 7f5f</td> <td> 8974</td> <td> 05e1</td> <td> cff3 </td> <td> a09c </td> <td> de3c </td>
2585 <td>4ac0</td>
2586 </tr>
2587 </table>
2588 <br><br>
2589 <table cellspacing="6">
2590
2591
2592 <tr><td>Word</td><td> 0:</td> <td>0x640b </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x1ba3 Word 15:</td> <td>0x4575 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xef47</td></tr>
2593 <tr><td>Word</td> <td> 1:</td> <td>0x07e5 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x644e Word 16:</td> <td>0x60dc </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x03af</td></tr>
2594 <tr><td>Word</td> <td> 2:</td> <td>0xba59 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xf827 Word 17:</td> <td>0x0146 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xa539 </td> </tr>
2595 <tr><td>Word</td> <td>3:</td> <td>0x2f37 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x84da Word 18:</td> <td>0xc504 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x1314 </td> </tr>
2596 <tr><td>Word</td> <td>4:</td> <td>0x5d07 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x3c66 Word 19:</td> <td>0x72c2 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x8e76 </td> </tr>
2597 <tr><td>Word</td> <td>5:</td> <td>0xceb1 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xbee1 Word 20:</td> <td>0xb469 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x937c </td> </tr>
2598 <tr><td>Word</td> <td>6:</td> <td>0xf960 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x18d2 Word 21:</td> <td>0x1b97 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xa5db </td> </tr>
2599 <tr><td>Word</td> <td>7:</td> <td>0xf196 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x43a0 Word 22:</td> <td>0xe91d </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x01b7 </td> </tr>
2600 <tr><td>Word</td> <td>8:</td> <td>0xb8de </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x05a2 Word 23:</td> <td>0x1dbc </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x7f5f </td> </tr>
2601 <tr><td>Word</td> <td>9:</td> <td>0x3a3f </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x49b3 Word 24:</td> <td>0x131e </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x8974 </td> </tr>
2602 <tr><td>Word</td> <td>10:</td> <td>0x18ea </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xfb99 Word 25:</td> <td>0x47e0 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x05e1 </td> </tr>
2603 <tr><td>Word</td> <td>11:</td> <td>0xc5b3 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xb216 Word 26:</td> <td>0xc11a </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xcff3 </td> </tr>
2604 <tr><td>Word</td> <td>12:</td> <td>0x9753 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xeb3e Word 27:</td> <td>0x7f07 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xa09c </td> </tr>
2605 <tr><td>Word</td> <td>13:</td> <td>0x1d8a </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x463a Word 28:</td> <td>0x76e0 </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0xde3c </td> </tr>
2606 <tr><td>Word</td> <td>14:</td> <td>0xa7ff </td><td>*</td> <td>0x1234</td> <td>=</td> <td>0x01fb Word 29:</td> <td>0xfe86 <td>*</td> <td>0x1234</td> <td>=</td> <td>0x4ac0 </td> </tr>
2607
2608 </table>
2609 </div>
2610 <br>
2611 In the first region are words 0 and 1, which are identical to how they appear in memory: 0x640b and 0x07e5. In
2612 the second region are words 2 through 17. These words are split among the two sixteen-byte regions. For example,
2613 word 2, which <b>extract_word()</b> reports is 0xba59, is constructed from the low byte in word 2 (0xba) and the low byte
2614 in word 10 (0x59). Since 0xba59 * 0x1234 = 0xf827, we see that the low byte in word 2 of <em> b </em> is 0xf8, and the low byte
2615 in word 10 is 0x27.
2616 <p>When we reach word 22, we are in the third region of memory, and words are once again identical to how they
2617 appear in memory.</p>
2618
2619 <p>While this is confusing, we stress that that so long as you call <b>multiply_region()</b> with pointers of the same alignment
2620 and regions of the same size, your results with <b>ALTMAP</b> will be consistent. If you call it with pointers of </p>
2621
2622
2623
2624
2625
2626
2627 <br/>
2628
2629
2630 7 &nbsp &nbsp <em> FURTHER INFORMATION ON OPTIONS AND ALGORITHMS </em> <span id="index_number">36 </span> <br><br><br>
2631
2632 different alignments, or with different region sizes, then the results will not be consistent. To reiterate, if you don't use
2633 <b>ALTMAP,</b> you don't have to worry about any of this - words will always be laid out contiguously in memory.
2634 <p>
2635 When <em>w</em> = 32, the middle region is a multiple of 64, and each word in the middle region is broken into bytes, each
2636 of which is in a different 16-byte region. When <em>w</em> = 64, the middle region is a multiple of 128, and each word is
2637 stored in eight 16-byte regions. And finally, when<em>w</em> = 128, the middle region is a multiple of 128, and each word is
2638 stored in 16 16-byte regions.</p><br>
2639
2640 <h3>7.9.2 &nbsp Alternate mappings with "COMPOSITE" </h3>
2641
2642 With <b>"COMPOSITE,"</b> the alternate mapping divides the middle region in half. The lower half of each word is stored
2643 in the first half of the middle region, and the higher half is stored in the second half. To illustrate, gf_example_6
2644 performs the same example as gf_example_5, except it is using <b>"COMPOSITE"</b> in GF((2<sup>16</sup>)<sup>2</sup>), and it is multiplying
2645 a region of 120 bytes rather than 60. As before, the pointers are not aligned on 16-bit quantities, so the region is broken
2646 into three regions of 4 bytes, 96 bytes, and 20 bytes. In the first and third region, each consecutive four byte word is a
2647 word in <em>GF(2<sup>32</sup>).</em> For example, word 0 is 0x562c640b, and word 25 is 0x46bc47e0. In the middle region, the low two
2648 bytes of each word come from the first half, and the high two bytes come from the second half. For example, word 1
2649 as reported by <b>extract_word()</b> is composed of the lower two bytes of word 1 of memory (0x07e5), and the lower two
2650 bytes of word 13 (0x3fde). The product of 0x3fde07e5 and 0x12345678 is 0x211c880d, which is stored in the lower
2651 two bytes of words 1 and 13 of <em>b.</em><br><br>
2652
2653 a: 0x10010011c b: 0x1001001ec
2654
2655 <br><br>
2656
2657 <div id="number_spacing">
2658 <table cellspacing="6" style="text-align:right">
2659
2660 <tr>
2661 <td></td> <td> 1</td> <td> 2 </td> <td> 3 </td> <td> 4</td> <td> 5 </td> <td> 6 </td> <td> 7</td> <td> 8 </td> <td> 9</td> </tr>
2662 <tr>
2663 <td>a:</td><td> 562c640b</td> <td> 959407e5</td> <td> 56592fba </td> <td> cbadce5d </td> <td> 1d1cf1f9</td> <td> 35d73ab8</td> <td> 6493c518 </td> <td> b37c1d97</td>
2664 <td> 8e4545a7</td>
2665 <td> c0d80160</td> </tr>
2666
2667 <tr><td>b:</td> <td>f589f36c</td><td> f146880d</td> <td> 74f7b349</td> <td> 7ea7c5c6</td> <td> 34827c1a</td> <td> 93cc3746</td> <td> bfd9288b </td>
2668 <td> 763941d1 </td>
2669 <td> bcd33a5d </td>
2670 <td>da695e64</td>
2671 </tr>
2672 </table>
2673
2674
2675 <br><br>
2676 <table cellspacing="6" style="text-align:right">
2677
2678 <tr>
2679 <td> 10</td> <td> 11 </td> <td> 12</td> <td> 13</td> <td> 14 </td> <td> 15 </td> <td> 16</td> <td> 17</td> <td>18</td> <td> 19 </td></tr>
2680 <tr>
2681 <td>a:</td><td> 965b3759</td> <td> cb3eb107</td> <td> 1b129660 </td> <td> 95a33fde </td> <td> 95a7b3ea</td> <td> d16c8a53</td> <td> 153375ff </td>
2682 <td> f74646dc</td> <td> 35aac504</td>
2683 <td> 98f972c2</td> </tr>
2684
2685 <tr><td>b:</td> <td>fd70f125</td><td> 3274fa8f</td> <td> d9dd34ee</td> <td> c01a211c</td> <td> d4402403</td> <td> 8b55c08b</td> <td> da45f0ad </td>
2686 <td> 90992e18 </td> <td> b65e0902 </td>
2687 <td>d91069b5</td>
2688 </tr>
2689 </table>
2690
2691
2692 <table cellspacing="6" style="text-align:right">
2693 <br><br>
2694 <tr>
2695 <td> 20</td> <td> 21 </td> <td> 22</td> <td> 23</td> <td> 24 </td> <td> 25 </td> <td> 26</td> <td> 27</td> <td>28</td> <td> 29 </td></tr>
2696 <tr>
2697 <td>a:</td><td> 5509b469</td> <td> 7f8a1b97</td> <td> 3472e91d </td> <td> 9ee71dbc </td> <td> de4e131e</td> <td> 46bc47e0</td> <td> 5bc9c11a </td>
2698 <td> 931d7f07</td> <td> c85cfe86</td>
2699 <td> fe86</td> </tr>
2700
2701 <tr><td>b:</td> <td>fc92b8f5</td><td> edd59668</td> <td> b4bc0d90</td> <td> a679e4ce</td> <td> 1a98f7d0</td> <td> 6038765f</td> <td> b2ff333f </td> <td> e7937e49 </td>
2702 <td> fa5a5867 </td>
2703 <td>79c00ea2</td>
2704 </tr>
2705 </table>
2706 <br><br>
2707
2708
2709 <table cellspacing="6" style="text-align:right">
2710
2711
2712 <tr><td>Word</td><td> 0:</td> <td>0x562c640b </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xf589f36c Word 15:</td> <td>0xb46945a7 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xb8f53a5d</td></tr>
2713 <tr><td>Word</td> <td> 1:</td> <td>0x3fde07e5 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x211c880d Word 16:</td> <td>0x55098e45 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xfc92bcd3</td></tr>
2714 <tr><td>Word</td> <td> 2:</td> <td>0x95a39594 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xc01af146 Word 17:</td> <td>0x1b970160 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x96685e64 </td> </tr>
2715 <tr><td>Word</td> <td>3:</td> <td>0xb3ea2fba </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x2403b349 Word 18:</td> <td>0x7f8ac0d8 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xedd5da69 </td> </tr>
2716 <tr><td>Word</td> <td>4:</td> <td>0x95a75659 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xd44074f7 Word 19:</td> <td>0xe91d3759 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x0d90f125 </td> </tr>
2717 <tr><td>Word</td> <td>5:</td> <td>0x8a53ce5d </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xc08bc5c6 Word 20:</td> <td>0x3472965b </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xb4bcfd70 </td> </tr>
2718 <tr><td>Word</td> <td>6:</td> <td>0xd16ccbad </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x8b557ea7 Word 21:</td> <td>0x1dbcb107 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xe4cefa8f </td> </tr>
2719 <tr><td>Word</td> <td>7:</td> <td>0x75fff1f9 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xf0ad7c1a Word 22:</td> <td>0x9ee7cb3e </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xa6793274 </td> </tr>
2720 <tr><td>Word</td> <td>8:</td> <td>0x15331d1c </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xda453482 Word 23:</td> <td>0x131e9660 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xf7d034ee </td> </tr>
2721 <tr><td>Word</td> <td>9:</td> <td>0x46dc3ab8 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x2e183746 Word 24:</td> <td>0xde4e1b12 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x1a98d9dd </td> </tr>
2722 <tr><td>Word</td> <td>10:</td> <td>0xf74635d7 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x909993cc Word 25:</td> <td>0x46bc47e0 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x6038765f </td> </tr>
2723 <tr><td>Word</td> <td>11:</td> <td>0xc504c518 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0x0902288b Word 26:</td> <td>0x5bc9c11a </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xb2ff333f </td> </tr>
2724 <tr><td>Word</td> <td>12:</td> <td>0x35aa6493 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xb65ebfd9 Word 27:</td> <td>0x931d7f07 </td><td>*</td> <td>0x12345678</td> <td>=</td> <td>0xe7937e49 </td> </tr>
2725
2726 </table>
2727 </div>
2728
2729
2730
2731
2732
2733
2734
2735
2736 <br/>
2737
2738
2739 8 &nbsp &nbsp <em> THREAD SAFETY </em> <span id="index_number">37 </span> <br><br><br>
2740 <div id="number_spacing">
2741 <table cellpadding="6" cellspacing="0">
2742 <tr>
2743 <td>Word 13:</td> <td> 0x72c21d97</td> <td> *</td> <td> 0x12345678</td> <td> =</td> <td> 0x69b541d1</td> <td> Word 28:</tD>
2744
2745 <td> 0xd40676e0 </td> <td> * </td> <td> 0x12345678 </td> <td> = </td> <td> 0xfa5a5867 </td> </tr>
2746
2747 <tr><td>Word 14:</td> <td> 0x98f9b37c</td> <td> * </td> <td> 0x12345678 </td> <td> = </td> <td> 0xd9107639</td> <td> Word 29:</td>
2748 <td> 0xc85cfe86</td> <td>*</td> <td> 0x12345678</td> <td> =</td> <td> 0x79c00ea2</td></tr>
2749
2750 </table>
2751 </div><br>
2752
2753
2754 <p>
2755 As with <b>"SPLIT,"</b> using <b>multiply_region()</b> with <b>"COMPOSITE"</b> and <b>"ALTMAP"</b> will be consistent only if the
2756 alignment of pointers and region sizes are identical. </p>
2757
2758
2759 <h3>7.9.3 The mapping of "CAUCHY" </h3>
2760
2761 With <b>"CAUCHY,"</b> the region is partitioned into <em>w</em> subregions, and each word in the region is broken into <em>w</em> bits,
2762 each of which is stored in a different subregion. To illustrate, <b>gf_example_7</b> multiplies a region of three bytes by 5
2763 in <em>GF(2<sup>3</sup>)</em> using <b>"CAUCHY:"</b><br><br>
2764
2765 <div id="number_spacing">
2766
2767 UNIX> gf_example_7 <br>
2768 a: 0x100100190 b: 0x1001001a0 <br><br>
2769 a: 0x0b 0xe5 0xba <br>
2770 b: 0xee 0xba 0x0b <br><br>
2771 a bits: 00001011 11100101 10111010 <br>
2772 b bits: 11101110 10111010 00001011<br><br>
2773 Word 0: 3 * 5 = 4 <br>
2774 Word 1: 5 * 5 = 7 <br>
2775 Word 2: 2 * 5 = 1 <br>
2776 Word 3: 5 * 5 = 7 <br>
2777 Word 4: 4 * 5 = 2 <br>
2778 Word 5: 6 * 5 = 3 <br>
2779 Word 6: 2 * 5 = 1 <br>
2780 Word 7: 6 * 5 = 3 <br>
2781 UNIX><br><br> </div>
2782 <p>
2783
2784 The program prints the three bytes of a and b in hexadecimal and in binary. To see how words are broken up,
2785 consider word 0, which is the lowest bit of each of the three bytes of a (and b). These are the bits 1, 1 and 0 in a, and
2786 0, 0, and 1 in b. Accordingly, the word is 3 in a, and 3*5 = 4 in b. Similarly, word 7 is the high bit in each byte: 0, 1, 1
2787 (6) in a, and 1, 1, 0 (3) in b.</p>
2788 <p>With <b>"CAUCHY," multiply_region()</b>may be implemented exclusively with XOR operations. Please see [BKK<sup>+</sup>95]
2789 for more information on the motivation behind <b>"CAUCHY."</b> </p>
2790
2791 <h2>8 &nbsp Thread Safety </h2>
2792
2793 Once you initialize a <b>gf_t,</b> you may use it wontonly in multiple threads for all operations except for the ones below.
2794 With the implementations listed below, the scratch space in the <b>gf_t</b> is used for temporary tables, and therefore you
2795 cannot call <b>region_multiply,</b> and in some cases <b>multiply</b> from multiple threads because they will overwrite each
2796 others' tables. In these cases, if you want to call the procedures from multiple threads, you should allocate a separate
2797 gf_t for each thread:
2798 <ul>
2799 <li>
2800 All "GROUP" implementations are not thread safe for either <b>region_multiply()</b> or <b> multiply().</b> Other than
2801 <b>"GROUP," multiply() </b> is always thread-safe.
2802
2803 </li>
2804 </ul>
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814 <br/>
2815
2816
2817 9 &nbsp &nbsp <em> LISTING OF PROCEDURES </em> <span id="index_number">38 </span> <br><br><br>
2818 <ul>
2819 <li>
2820
2821 For <em>w </em> = 4, <b>region_multiply.w32()</b> is unsafe in in "-m TABLE -r QUAD -r LAZY." </li><br>
2822 <li> For <em>w </em> = 8, <b> region_multiply.w32()</b> is unsafe in in "-m TABLE -r DOUBLE -r LAZY."</li><br>
2823 <li> For <em>w </em> = 16, <b>region_multiply.w32() </b> is unsafe in in "-m TABLE."</li><br>
2824 <li> For <em>w </em> &#8712 {32, 64, 128}, all <b>"SPLIT"</b> implementations are unsafe for <b>region_multiply().</b> This means that if the
2825 default uses <b>"SPLIT"</b> (see Table 1 for when that occurs), then <b>region_multiply()</b> is not thread safe.</li><br>
2826 <li> The <b>"COMPOSITE"</b> operations are only safe if the implementations of the underlying fields are safe.</li>
2827 </ul>
2828
2829 <h2>9 &nbspListing of Procedures </h2>
2830
2831 The following is an alphabetical listing of the procedures, data types and global variables for users to employ in
2832 GF-complete.<br>
2833
2834 <ul>
2835 <li> <b>GF_W16_INLINE_DIV()</b> in <b>gf_complete.h:</b> This is a macro for inline division when <em>w </em> = 16. See section 7.1.</li><br>
2836 <li> <b>GF_W16_INLINE_MULT()</b> in <b>gf_complete.h:</b> This is a macro for inline multiplication when <em>w </em> = 16. See
2837 section 7.1.</li><br>
2838 <li> <b>GF_W4_INLINE_MULTDIV()</b> in <b>gf_complete.h:</b> This is a macro for inline multiplication/division when <em>w </em> =
2839 4. See section 7.1.</li><br>
2840
2841 <li> <b>GF_W8_INLINE_MULTDIV()</b> in <b>gf_complete.h:</b> This is a macro for inline multiplication/division when <em>w </em> =
2842 8. See section 7.1.</li><br>
2843 <li> <b>MOA_Fill_Random_Region()</b> in <b>gf_rand.h:</b> Fills a region with random numbers.</li><br>
2844 <li> <b>MOA_Random_128()</b> in <b>gf_rand.h:</b> Creates a random 128-bit number.</li><br>
2845 <li> <b>MOA_Random_32()</b> in <b>gf_rand.h:</b> Creates a random 32-bit number. </li><br>
2846 <li> <b>MOA_Random_64()</b> in <b>gf_rand.h:</b> Creates a random 64-bit number. </li><br>
2847 <li> <b>MOA_Random_W()</b> in <b>gf_rand.h:</b> Creates a random w-bit number, where <em>w </em> &#8804 32. </li><br>
2848 <li> <b>MOA_Seed()</b> in <b>gf_rand.h:</b> Sets the seed for the random number generator. </li><br>
2849 <li> <b>gf_errno</b> in <b>gf_complete.h:</b> This is to help figure out why an initialization call failed. See section 6.1.</li><br>
2850 <li> <b>gf_create_gf_from_argv()</b> in <b>gf_method.h:</b> Creates a gf_t using C style argc/argv. See section 6.1.1. </li><br>
2851 <li> <b>gf_division_type_t</b> in <b>gf_complete.h:</b> the different ways to specify division when using <b>gf_init_hard().</b> See
2852 section 6.4. </li><br>
2853 <li> <b>gf_error()</b> in <b>gf_complete.h:</b> This prints out why an initialization call failed. See section 6.1. </li><br>
2854
2855 <li> <b>gf_extract</b> in <b>gf_complete.h:</b> This is the data type of <b>extract_word()</b> in a gf_t. See section 7.9 for an example
2856 of how to use extract word().</li>
2857 </ul>
2858
2859
2860
2861
2862
2863 <br/>
2864
2865
2866 9 &nbsp &nbsp <em> LISTING OF PROCEDURES </em> <span id="index_number">39 </span> <br><br><br>
2867 <ul>
2868 <li>
2869 <b>gf_free()</b> in <b>gf_complete.h:</b> If <b>gf_init easy(), gf_init hard()</b> or <b>create_gf_from_argv()</b> allocated memory, this
2870 frees it. See section 6.4. </li>
2871
2872 <li> <b>gf_func_a_b</b> in <b>gf_complete.h:</b> This is the data type of <b>multiply()</b> and <b>divide()</b> in a gf_t. See section 4.2 for
2873 examples of how to use <b>multiply()</b> and <b>divide()</b></li><br>
2874
2875 <li> <b>gf_func_a_b</b> in <b>gf_complete.h:</b> This is the data type of <b>multiply()</b> and <b>divide()</b> in a <b>gf_t.</b> See section 4.2 for
2876 examples of how to use <b>multiply()</b> and <b>divide()</b></li><br>
2877
2878 <li> <b>gf_func_a</b> in <b>gf_complete.h:</b> This is the data type of <b>inverse()</b> in a <b>gf_t</b></li><br>
2879
2880 <li> <b>gf_general_add()</b> in <b>gf_general.h:</b> This adds two <b>gf_general_t's </b></li><br>
2881
2882 <li> <b>gf_general_divide()</b> in <b>gf_general.h:</b> This divides two <b>gf_general t's </b></li><br>
2883
2884 <li> <b>gf_general_do_region_check() </b> in <b>gf_general.h:</b> This checks a region multiply of <b>gf_general_t's </b></li><br>
2885
2886 <li> <b>gf_general_do_region_multiply() </b> in <b>gf_general.h:</b> This does a region multiply of <b>gf_general_t's </b></li><br>
2887
2888 <li> <b>gf_general_do_single_timing_test()</b> in <b>gf_general.h:</b> Used in <b>gf_time.c </b></li><br>
2889
2890 <li> <b>gf_general_inverse() </b> in <b>gf_general.h:</b> This takes the inverse of a <b>gf_general_t </b></li><br>
2891
2892 <li> <b>gf_general_is_one() </b> in <b>gf_general.h:</b> This tests whether a <b>gf_general_t </b> is one</li><br>
2893
2894 <li> <b>gf_general_is_two() </b> in <b>gf_general.h:</b> This tests whether a <b>gf_general_t </b>is two</li><br>
2895
2896 <li> <b>gf_general_is_zero() </b> in <b>gf_general.h:</b> This tests whether a <b>gf_general_t </b> is zero</li><br>
2897
2898 <li> <b>gf_general_multiply() </b> in <b>gf_general.h:</b> This multiplies two <b>gf_general_t's.</b> See the implementation of gf_mult.c
2899
2900 for an example</li><br>
2901 <li> <b>gf_general_s_to_val() </b> in <b>gf_general.h:</b> This converts a string to a <b>gf_general t.</b> See the implementation of
2902 gf_mult.c for an example</li><br>
2903 <li> <b>gf_general_set_one() </b> in <b>gf_general.h:</b> This sets a <b>gf_general_t</b> to one</li><br>
2904 <li> <b>gf_general_set_random()</b> in <b>gf_general.h:</b> This sets a <b>gf_general_t </b> to a random number</li><br>
2905 <li> <b>gf_general_set_two() in </b><b>gf_general.h:</b> This sets a <b>gf_general_t </b> to two</li><br>
2906 <li> <b>gf_general_set_up_single_timing_test() </b> in <b>gf_general.h:</b> Used in <b>gf_time.c</b></li><br>
2907 <li> <b>gf_general_set_zero() in </b><b>gf_general.h:</b> This sets a <b>gf_general_t_to_zero</b></li><br>
2908 <li> <b>gf_general_t_in .</b><b>gf_general.h:</b> This is a general data type for all values of w. See the implementation of gf_mult.c
2909 for examples of using these</li><br>
2910 <li> <b>gf_general_val_to_s()</b> in<b>gf_general.h:</b> This converts a <b>gf_general_t </b> to a string. See the implementation of
2911 <b>gf_mult.c</b> for an example</li><br>
2912
2913 <li> <b>gf_init_easy()</b> in <b>gf_complete.h:</b> This is how you initialize a default <b>gf_t.</b> See 4.2 through 4.5 for examples of
2914 calling <b>gf_init_easy()</b></li><br>
2915 </ul>
2916
2917
2918
2919
2920
2921
2922
2923 <br/>
2924
2925
2926 9 &nbsp &nbsp <em> LISTING OF PROCEDURES </em> <span id="index_number">40 </span> <br><br><br>
2927
2928 <ul>
2929
2930 <li><b>gf_init hard()</b> in <b>gf_complete.h: </b> This allows you to initialize a <b>gf_t</b> without using the defaults. See 6.4. We
2931 recommend calling create <b>gf_from argv()</b> when you can, instead of <b>gf_ init_hard()</b></li><br>
2932
2933 <li> <b>gf_ mult_type_t </b> in <b>gf_complete.h: </b> the different ways to specify multiplication when using <b>gf_init hard()</b>. See
2934 section 6.4</li><br>
2935
2936 <li> <b>gf_region_type_t</b> in <b>gf_complete.h: </b> the different ways to specify region multiplication when using <b>gf_init_hard()</b>.
2937 See section 6.4</li><br>
2938
2939 <li> <b>gf_region_in</b> <b>gf_complete.h: </b> This is the data type of <b>multiply_region()</b> in a <b>gf_t.</b> See section 4.3 for an example
2940 of how to use <b>multiply_region()</b></li><br>
2941
2942 <li> <b>gf_scratch_size()</b> in <b>gf_complete.h: </b> This is how you calculate how much memory a <b>gf_t</b> needs. See section 6.4.</li><br>
2943
2944 <li> <b>gf_size()</b> in <b>gf_complete.h: </b> Returns the memory consumption of a <b>gf_t.</b> See section 6.5.</li><br>
2945
2946 <li> <b>gf_ val_128_t</b> in <b>gf_complete.h: </b> This is how you store a value where <em>w </em> &#8804 128. It is a pointer to two 64-bit
2947 unsigned integers. See section 4.4</li><br>
2948
2949
2950 <li> <b>gf_val_32_t</b> in <b>gf_ complete.h: </b> This is how you store a value where <em>w </em> &#8804 32. It is equivalent to a 32-bit unsigned
2951 integer. See section 4.2</li><br>
2952
2953 <li> <b>gf_ val_64_t</b> in <b>gf_complete.h: </b> This is how you store a value where <em>w </em> &#8804 64. It is equivalent to a 64-bit unsigned
2954 integer. See section 4.5</li><br>
2955
2956 <li> <b>gf_w16_get_div_alog_table()</b> in <b>gf_ complete.h: </b> This returns a pointer to an inverse logarithm table that can be
2957 used for inlining division when <em>w </em> = 16. See section 7.1</li><br>
2958
2959
2960 <li> <b>gf_w16_get_log_table()</b> in <b>gf_complete.h: </b> This returns a pointer to a logarithm table that can be used for inlining
2961 when <em>w </em> = 16. See section 7.1</li><br>
2962
2963
2964 <li> <b>gf_w16_get_mult_alog_table()</b> in <b>gf_complete.h: </b> This returns a pointer to an inverse logarithm table that can be
2965 used for inlining multiplication when <em>w </em> = 16. See section 7.1</li><br>
2966
2967
2968 <li> <b>gf_ w4 get div table()</b> in <b>gf_complete.h: </b> This returns a pointer to a division table that can be used for inlining
2969 when <em>w </em> = 4. See section 7.1</li><br>
2970
2971
2972 <li> <b>gf_w4_get_mult_table()</b> in <b>gf_complete.h: </b> This returns a pointer to a multiplication table that can be used for
2973 inlining when <em>w </em> = 4. See section 7.1</li><br>
2974
2975 <li> <b>gf_w8_get_div_table()</b> in <b>gf_complete.h: </b> This returns a pointer to a division table that can be used for inlining
2976 when <em>w </em> = 8. See section 7.1</li><br>
2977
2978 <li> <b>gf_w8_get_mult_table()</b> in <b>gf_complete.h: </b> This returns a pointer to a multiplication table that can be used for
2979 inlining when <em>w </em> = 8. See section 7.1</li><br>
2980
2981 </ul>
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991 <br/>
2992 10 &nbsp &nbsp <em>TROUBLESHOOTING </em> <span id="index_number">41 </span> <br><br><br>
2993
2994 <ul>
2995 <li><b> SSE support.</b> Leveraging SSE instructions requires processor support as well as compiler support. For example,
2996 the Mac OS 10.8.4 (and possibly earlier versions) default compile environment fails to properly compile
2997 PCLMUL instructions. This issue can be fixed by installing an alternative compiler; see Section 3 for details</li><br>
2998
2999 <li> <b>Initialization segfaults.</b> You have to already have allocated your <b>gf_t</b> before you pass a pointer to it in
3000 <b>bgf_init_easy()</b>, <b>create_gf_ from_argv()</b>, or <b>bgf_ini_hard()</b></li><br>
3001
3002
3003 <li> <b>GF-Complete is slower than it should be.</b> Perhaps your machine has SSE, but you haven't specified the SSE
3004 compilation flags. See section 3 for how to compile using the proper flags</li><br>
3005
3006
3007 <li> <b>Bad alignment.</b> If you get alignment errors, see Section 5</li><br>
3008
3009 <li> <b>Mutually exclusive region types.</b> Some combinations of region types are invalid. All valid and implemented
3010 combinations are printed by <b>bgf_methods.c </b></li><br>
3011
3012 <li><b>Incompatible division types.</b> Some choices of multiplication type constrain choice of divide type. For example,
3013 <b>"COMPOSITE"</b> methods only allow the default division type, which divides by finding inverses (i.e.,
3014 neither <b>"EUCLID"</b> nor <b>"MATRIX"</b> are allowed). For each multiplication method printed by <b>gf_methods.c,</b> the
3015 corresponding valid division types are also printed</li><br>
3016
3017
3018 <li><b> Arbitrary "GROUP" arguments.</b> The legal arguments to <b>"GROUP"</b> are specified in section 7.5</li><br>
3019
3020 <li> <b> Arbitrary "SPLIt" arguments.</b> The legal arguments to <b>"SPLIt"</b> are specified in section 7.4</li><br>
3021
3022 <li> <b>Threading problems.</b> For threading questions, see Section 8</li><br>
3023
3024 <li> <b>No default polynomial.</b> If you change the polynomial in a base field using <b>"COMPOSITE,"</b> then unless it is
3025 a special case for which GF-Complete finds a default polynomial, you'll need to specify the polynomial of the
3026 composite field too. See 7.8.2 for the fields where GF-Complete will support default polynomials</li><br>
3027 <li> Encoding/decoding with different fields. Certain fields are not compatible. Please see section 7.2 for an
3028 explanation</li><br>
3029
3030
3031 <li> <b>"ALTMAP" is confusing.</b> We agree. Please see section 7.9 for more explanation.</li><br>
3032
3033 <li> <b>I used "ALTMAP" and it doesn't appear to be functioning correctly.</b> With 7.9, the size of the region and
3034 its alignment both matter in terms of how <b>"ALTMAP"</b> performs <b>multiply_region()</b>. Please see section 7.9 for
3035 detailed explanation</li><br>
3036
3037 <li><b>Where are the erasure codes?.</b> This library only implements Galois Field arithmetic, which is an underlying
3038 component for erasure coding. Jerasure will eventually be ported to this library, so that you can have fast erasure
3039 coding</li><br>
3040 </ul>
3041 <h2>11 &nbsp &nbsp Timings </h2>
3042
3043 We don't want to get too detailed with timing, because it is quite machine specific. However, here are the timings on
3044 an Intel Core i7-3770 CPU running at 3.40 GHz, with 4 &#215 256 KB L2 caches and an 8MB L3 cache. All timings are
3045 obtained with <b>gf_time</b> or <b>gf_inline_time,</b> in user mode with the machine dedicated solely to running these jobs.
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055 <br/>
3056 10 &nbsp &nbsp <em>TROUBLESHOOTING </em> <span id="index_number">41 </span> <br><br><br>
3057
3058 <div class="image-cell_5"> </div>
3059 <center>Figure 4: Speed of doing single multiplications for w &#8712 {4, 8, 16}. </center>
3060 <h2>11.1 &nbsp Multiply() </h2>
3061
3062 The performance of <b>multiply()</b> is displayed in Figures 4 for w &#8712 {4, 8, 16} and 5 for w &#8712 {32, 64, 128}. These
3063 numbers were obtained by calling <b>gf_time</b> with the size and iterations both set to 10240. We plot the speed in megaops
3064 per second.
3065
3066 <p>As would be anticipated, the inlined operations (see section 7.1) outperform the others. Additionally, in all
3067 cases with the exception of <em>w</em> = 32, the defaults are the fastest performing implementations. With w = 32,
3068 "CARRY_FREE" is the fastest with an alternate polynomial (see section 7.7). Because we require the defaults to
3069 use a "standard" polynomial, we cannot use this implementation as the default. </p>
3070
3071 <h2>11.2 &nbsp Divide() </h2>
3072
3073 For the <b>"TABLE"</b> and <b>"LOG"</b> implementations, the performance of division is the same as multiplication. This means
3074 that for w &#8712 {4, 8, 16}, it is very fast indeed. For the other implementations, division is implemented with Euclid's
3075 method, and is several factors slower than multiplication.
3076 In Figure 6, we plot the speed of a few implementations of the larger word sizes. Compared to the <b>"TABLE"</b> and
3077 <b>"LOG"</b> implemenations for the smaller word sizes, where the speeds are in the hundreds of mega-ops per second,
3078 these are very slow. Of note is the <b>"COMPOSITE"</b> implementation for <em>w</em> = 32, which is much faster than the others
3079
3080
3081
3082
3083
3084
3085
3086
3087 <br/>
3088 10 &nbsp &nbsp <em>TROUBLESHOOTING </em> <span id="index_number">43 </span> <br><br><br>
3089
3090 <div class="image-cell_6"> </div>
3091
3092 <center>Figure 5: Speed of doing single multiplications for w &#8712 {32, 64, 128}. </center><br>
3093
3094 because it uses a special application of Euclid's method, which relies on division in <em>GF(2<sup>16</sup>),</em> which is very fast.<br><br>
3095
3096 <h3>11.3 &nbsp Multiply_Region() </h2>
3097
3098 Tables 3 through 8 show the performance of the various region operations. It should be noted that for <em>GF(2<sup>16 </sup>) </em>
3099 through <em>GF(2<sup>128</sup>),</em> the default is not the fastest implementation of <b>multiply_region().</b> The reasons for this are outlined
3100 in section 6
3101 <p>
3102 For these tables, we performed 1GB worth of <b>multiply_region()</b> calls for all regions of size 2i bytes for 10 &#8804 i &#8804
3103 30. In the table, we plot the fastest speed obtained.</p>
3104 <p>We note that the performance of <b>"CAUCHY"</b> can be improved with techniques from [LSXP13] and [PSR12].</p>
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114 <br/>
3115 <em>REFERENCES </em> <span id="index_number">44 </span> <br><br><br>
3116
3117 <div class="image-cell_7"> </div>
3118
3119 <center>Figure 6: Speed of doing single divisions for w &#8712 {32, 64, 128}. </center><br>
3120
3121 <center>
3122 <div id="data2">
3123 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3124
3125 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3126
3127 <tr><td>-m TABLE (Default) -</td> <td>11879.909</td> </tr>
3128 <tr><td>-m TABLE -r CAUCHY -</td> <td>9079.712</td> </tr>
3129 <tr><td>-m BYTWO_b -</td> <td>5242.400</td> </tr>
3130 <tr><td>-m BYTWO_p -</td> <td>4078.431</td> </tr>
3131 <tr><td>-m BYTWO_b -r NOSSE -</td> <td>3799.699</td> </tr>
3132 <tr><td>-m TABLE -r QUAD -</td> <td>3014.315</td> </tr>
3133
3134 <tr><td>-m TABLE -r DOUBLE -</td> <td>2253.627</td> </tr>
3135 <tr><td>-m TABLE -r NOSSE -</td> <td>2021.237</td> </tr>
3136 <tr><td>-m TABLE -r NOSSE -</td> <td>1061.497</td> </tr>
3137 <tr><td>-m LOG -</td> <td>503.310</td> </tr>
3138
3139
3140 <tr><td>m SHIFT -</td> <td>157.749</td> </tr>
3141 <tr><td>-m CARRY_FREE -</td> <td>86.202</td> </tr>
3142 </div>
3143 </table> <br><br>
3144 </div> </center>
3145 <center>Table 3: Speed of various calls to <b>multiply_region()</b> for <em>w</em> = 4. </center>
3146
3147 <h3>References </h3>
3148
3149 [Anv09] H. P. Anvin. The mathematics of RAID-6.<a href=""> http://kernel.org/pub/linux/kernel/people/hpa/
3150 raid6.pdf,</a> 2009.<br><br>
3151
3152 [BKK<sup>+</sup>95] J. Blomer, M. Kalfane, M. Karpinski, R. Karp, M. Luby, and D. Zuckerman. An XOR-based erasureresilient
3153 coding scheme. Technical Report TR-95-048, International Computer Science Institute, August
3154 1995. <br><br>
3155
3156 [GMS08] K. Greenan, E. Miller, and T. J. Schwartz. Optimizing Galois Field arithmetic for diverse processor
3157 architectures and applications. In MASCOTS 2008: <em>16th IEEE Symposium on Modeling, Analysis and
3158 Simulation of Computer and Telecommunication Systems,</em> Baltimore, MD, September 2008.<br><br>
3159
3160
3161 [GP97] S. Gao and D. Panario. Tests and constructions of irreducible polynomials over finite fields. In <em> Foundations
3162 of Computational Mathematics,</em> pages 346–361. Springer Verlag, 1997.
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179 <br/>
3180 <em>REFERENCES </em> <span id="index_number">45 </span> <br><br><br>
3181
3182
3183 <center>
3184 <div id="data2">
3185 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3186
3187 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3188 <tr><td>-m SPLIT 8 4 (Default)</td> <td>13279.146</td> </tr>
3189 <tr><td>-m COMPOSITE 2 - -r ALTMAP -</td> <td>5516.588</td> </tr>
3190 <tr><td>-m TABLE -r CAUCHY -</td> <td>4968.721</td> </tr>
3191 <tr><td>-m BYTWO_b -</td> <td>2656.463</td> </tr>
3192 <tr><td>-m TABLE -r DOUBLE -</td> <td>2561.225</td> </tr>
3193 <tr><td>-m TABLE -</td> <td>1408.577</td> </tr>
3194
3195 <tr><td>-m BYTWO_b -r NOSSE -</td> <td>1382.409</td> </tr>
3196 <tr><td>-m BYTWO_p -</td> <td>1376.661</td> </tr>
3197 <tr><td>-m LOG_ZERO_EXT -</td> <td>1175.739</td> </tr>
3198 <tr><td>-m LOG_ZERO -</td> <td>1174.694</td> </tr>
3199
3200
3201 <tr><td>-m LOG -</td> <td>997.838</td> </tr>
3202 <tr><td>-m SPLIT 8 4 -r NOSSE -</td> <td>885.897</td> </tr>
3203
3204
3205 <tr><td>-m BYTWO_p -r NOSSE -</td> <td>589.520</td> </tr>
3206 <tr><td>-m COMPOSITE 2 - -</td> <td>327.039</td> </tr>
3207
3208
3209 <tr><td>-m SHIFT -</td> <td>106.115</td> </tr>
3210
3211 <tr><td>-m CARRY_FREE -</td> <td>104.299</td> </tr>
3212
3213
3214 </div>
3215 </table> <br><br>
3216 </div> </center>
3217 <center>Table 4: Speed of various calls to multiply region() for <em>w</em> = 4. </center><br><br>
3218
3219 [LBOX12] J. Luo, K. D. Bowers, A. Oprea, and L. Xu. Efficient software implementations of large finite fields
3220 <em>GF(2<sup>n</sup>) </em> for secure storage applications.<em> ACM Transactions on Storage, 8(2),</em> February 2012.<br><br>
3221
3222 [LD00] J. Lopez and R. Dahab. High-speed software multiplication in f<sub>2<sup>m</sup></sub>. In <em>Annual International Conference
3223 on Cryptology in India,</em> 2000.<br><br>
3224
3225 [LHy08] H. Li and Q. Huan-yan. Parallelized network coding with SIMD instruction sets. In <em>International Symposium
3226 on Computer Science and Computational Technology,</em> pages 364-369. IEEE, December 2008.<br><br>
3227
3228 [LSXP13] J. Luo, M. Shrestha, L. Xu, and J. S. Plank. Efficient encoding schedules for XOR-based erasure codes.
3229 <em>IEEE Transactions on Computing,</em>May 2013.<br><br>
3230
3231 [Mar94] G. Marsaglia. The mother of all random generators.<a href=""> ftp://ftp.taygeta.com/pub/c/mother.
3232 c,</a> October 1994.<br>
3233
3234 [PGM13a] J. S. Plank, K. M. Greenan, and E. L. Miller. A complete treatment of software implementations of
3235 finite field arithmetic for erasure coding applications. Technical Report UT-CS-13-717, University of
3236 Tennessee, September 2013.<br><br>
3237
3238 [PGM13b] J. S. Plank, K. M. Greenan, and E. L. Miller. Screaming fast Galois Field arithmetic using Intel SIMD
3239 instructions. In FAST-2013: <em>11th Usenix Conference on File and Storage Technologies,</em> San Jose, February
3240 2013.<br><br>
3241
3242 [Pla97] J. S. Plank. A tutorial on Reed-Solomon coding for fault-tolerance in RAID-like systems.<em> Software -
3243 Practice & Experience,</em> 27(9):995-1012, September 1997.
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256 <br/>
3257 <em>REFERENCES </em> <span id="index_number">46 </span> <br><br><br>
3258
3259
3260 <center>
3261 <div id="data2">
3262 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3263
3264 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3265 <tr><td>-m SPLIT 16 4 -r ALTMAP -</td> <td>10460.834</td> </tr>
3266 <tr><td>-m SPLIT 16 4 -r SSE (Default) - </td> <td>8473.793</td> </tr>
3267 <tr><td>-m COMPOSITE 2 - -r ALTMAP -</td> <td>5215.073</td> </tr>
3268 <tr><td>-m LOG -r CAUCHY -</td> <td>2428.824</td> </tr>
3269 <tr><td>-m TABLE -</td> <td>2319.129</td> </tr>
3270 <tr><td>-m SPLIT 16 8 -</td> <td>2164.111</td> </tr>
3271
3272 <tr><td>-m SPLIT 8 8 -</td> <td>2163.993</td> </tr>
3273 <tr><td>-m SPLIT 16 4 -r NOSSE -</td> <td>1148.810</td> </tr>
3274 <tr><td>-m LOG -</td> <td>1019.896</td> </tr>
3275 <tr><td>-m LOG_ZERO -</td> <td>1016.814</td> </tr>
3276 <tr><td>-m BYTWO_b -</td> <td>738.879</td> </tr>
3277 <tr><td>-m COMPOSITE 2 - -</td> <td>596.819</td> </tr>
3278 <tr><td>-m BYTWO_p -</td> <td>560.972</td> </tr>
3279 <tr><td>-m GROUP 4 4 -</td> <td>450.815</td> </tr>
3280 <tr><td>-m BYTWO_b -r NOSSE -</td> <td>332.967</td> </tr>
3281 <tr><td>-m BYTWO_p -r NOSSE -</td> <td>249.849</td> </tr>
3282 <tr><td>-m CARRY_FREE -</td> <td>111.582</td> </tr>
3283 <tr><td>-m SHIFT -</td> <td>95.813</td> </tr>
3284
3285
3286 </div>
3287 </table> <br><br>
3288 </div> </center>
3289 <center>Table 5: Speed of various calls to multiply region() for <em>w</em> = 4. </center><br><br>
3290
3291 [PMG<sup>+</sup>13] J. S. Plank, E. L. Miller, K. M. Greenan, B. A. Arnold, J. A. Burnum, A. W. Disney, and A. C. McBride.
3292 GF-Complete: A comprehensive open source library for Galois Field arithmetic. version 1.0. Technical
3293 Report UT-CS-13-716, University of Tennessee, September 2013.<br><br>
3294
3295 [PSR12] J. S. Plank, C. D. Schuman, and B. D. Robison. Heuristics for optimizing matrix-based erasure codes for
3296 fault-tolerant storage systems. In DSN-2012:<em> The International Conference on Dependable Systems and
3297 Networks,</em> Boston, MA, June 2012. IEEE.<br><br>
3298
3299 [Rab89] M. O. Rabin. Efficient dispersal of information for security, load balancing, and fault tolerance. <em>Journal
3300 of the Association for Computing Machinery,</em> 36(2):335-348, April 1989.
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310 <br/>
3311 <em>REFERENCES </em> <span id="index_number">47 </span> <br><br><br>
3312 <center>
3313 <div id="data2">
3314 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3315 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3316 <tr>
3317
3318 <td>
3319
3320 -m SPLIT 32 4 -r SSE -r ALTMAP - <br>
3321 -m SPLIT 32 4 (Default) <br>
3322 -m COMPOSITE 2 -m SPLIT 16 4 -r ALTMAP - -r ALTMAP - <br>
3323 -m COMPOSITE 2 - -r ALTMAP - <br>
3324 -m SPLIT 8 8 - <br>
3325 -m SPLIT 32 8 - <br>
3326 -m SPLIT 32 16 - <br>
3327 -m SPLIT 8 8 -r CAUCHY <br>
3328 -m SPLIT 32 4 -r NOSSE <br>
3329 -m CARRY_FREE -p 0xc5 <br>
3330 -m COMPOSITE 2 - <br>
3331 -m BYTWO_b - <br>
3332 -m BYTWO_p - <br>
3333 -m GROUP 4 8 - <br>
3334 -m GROUP 4 4 - <br>
3335 -m CARRY_FREE - <br>
3336 -m BYTWO_b -r NOSSE - <br>
3337 -m BYTWO_p -r NOSSE - <br>
3338 -m SHIFT - <br>
3339
3340 </td>
3341
3342 <td>
3343 7185.440 <br>
3344 5063.966 <br>
3345 4176.440 <br>
3346 3360.860 <br>
3347 1345.678 <br>
3348 1340.656 <br>
3349 1262.676 <br>
3350 1143.263 <br>
3351 480.859 <br>
3352 393.185 <br>
3353 332.964 <br>
3354 309.971 <br>
3355 258.623 <br>
3356 242.076 <br>
3357 227.399 <br>
3358 226.785 <br>
3359 143.403 <br>
3360 111.956 <br>
3361 52.295 <br>
3362 </td>
3363
3364
3365 </tr>
3366
3367 </div>
3368 </table> <br><br>
3369 </div> </center>
3370 <center>Table 6: Speed of various calls to multiply region() <em>w</em> = 4. </center><br><br>
3371
3372 <center>
3373 <div id="data2">
3374 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3375 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3376 <tr>
3377
3378 <td>
3379 -m SPLIT 64 4 -r ALTMAP - <br>
3380 -m SPLIT 64 4 -r SSE (Default) - <br>
3381 -m COMPOSITE 2 -m SPLIT 32 4 -r ALTMAP - -r ALTMAP - <br>
3382 -m COMPOSITE 2 - -r ALTMAP - <br>
3383 -m SPLIT 64 16 - <br>
3384 -m SPLIT 64 8 - <br>
3385 -m CARRY_FREE - <br>
3386 -m SPLIT 64 4 -r NOSSE - <br>
3387 -m GROUP 4 4 - <br>
3388 -m GROUP 4 8 - <br>
3389 -m BYTWO_b - <br>
3390 -m BYTWO_p - <br>
3391 -m SPLIT 8 8 - <br>
3392 -m BYTWO_p -r NOSSE - <br>
3393 -m COMPOSITE 2 - - <br>
3394 -m BYTWO_b -r NOSSE - <br>
3395 -m SHIFT - <br>
3396
3397 </td>
3398
3399 <td>3522.798 <br>
3400 2647.862 <br>
3401 2461.572 <br>
3402 1860.921 <br>
3403 1066.490 <br>
3404 998.461 <br>
3405 975.290 <br>
3406 545.479 <br>
3407 230.137 <br>
3408 153.947 <br>
3409 144.052 <br>
3410 124.538 <br>
3411 98.892 <br>
3412 77.912 <br>
3413 77.522 <br>
3414 36.391 <br>
3415 25.282 <br>
3416 </td>
3417
3418
3419 </tr>
3420
3421 </div>
3422 </table> <br><br>
3423 </div> </center>
3424 <center>Table 7: Speed of various calls to multiply region() for <em>w</em> = 4. </center><br><br>
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438 <br/>
3439 <em>REFERENCES </em> <span id="index_number">48 </span> <br><br><br>
3440
3441 <center>
3442 <div id="data2">
3443 <table cellpadding="2" cellspacing="0" style="text-align:center;font-size:19px">
3444 <tr><th>Method</td> <th>Speed (MB/s)</td> </tr>
3445 <tr>
3446
3447 <td>
3448
3449 -m SPLIT 128 4 -r ALTMAP - <br>
3450 -m COMPOSITE 2 -m SPLIT 64 4 -r ALTMAP - -r ALTMAP - <br>
3451 -m COMPOSITE 2 - -r ALTMAP - <br>
3452 -m SPLIT 128 8 (Default) - <br>
3453 -m CARRY_FREE -<br>
3454 -m SPLIT 128 4 -<br>
3455 -m COMPOSITE 2 - <br>
3456 -m GROUP 4 8 -<br>
3457 -m GROUP 4 4 -<br>
3458 -m BYTWO_p -<br>
3459 -m BYTWO_b -<br>
3460 -m SHIFT -<br>
3461 </td>
3462
3463 <td>
3464 1727.683 <br>
3465 1385.693 <br>
3466 1041.456 <br>
3467 872.619 <br>
3468 814.030 <br>
3469 500.133 <br>
3470 289.207 <br>
3471 133.583 <br>
3472 116.187 <br>
3473 25.162 <br>
3474 25.157 <br>
3475 14.183 <br>
3476 </td>
3477
3478
3479 </tr>
3480
3481 </div>
3482 </table> <br><br>
3483 </div> </center>
3484 <center>Table 8: Speed of various calls to multiply region() for <em>w</em> = 4. </center><br><br>