-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
660 lines (545 loc) · 21.4 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/*
* LICENSE available at the bottom
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <immintrin.h>
#ifdef IS_WINDOWS
#include <windows.h>
#endif
#define ITJ_CSV_IMPLEMENTATION_AVX2
#include "itj_csv.h"
#define KB(x) (x * 1024)
#define MB(x) (KB(x) * 1024)
#define SIZE_OF_NULL_TERMINATOR 1
#define SIZE_OF_DIR_SEPERATOR 1
#define NUM_BUFFERED_CYCLES (10 * 1000 * 1000)
#ifdef IS_WINDOWS
#define DIR_SEPERATOR "\\"
#else
#define DIR_SEPERATOR "/"
#endif
#ifdef IS_WINDOWS
double g_freq;
double get_time_ms() {
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return ((double)li.QuadPart)/g_freq;
}
#else
double get_time_ms() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (double)ts.tv_sec * 1000.0 + (double)ts.tv_nsec / 1000000.0;
}
#endif
itj_csv_bool compare_strings(char *base1, itj_csv_umax len1, char *base2, itj_csv_umax len2) {
if (len1 == len2) {
if (memcmp(base1, base2, len1) == 0) {
return ITJ_CSV_TRUE;
}
}
return ITJ_CSV_FALSE;
}
itj_csv_bool g_did_a_test_fail = ITJ_CSV_FALSE;
char *g_sitrep_filepath;
void sitrep(char *fmt, ...) {
char *buf = (char *)calloc(1, KB(512));
if (!buf) {
printf("Unable to allocate memory for sitrep\n");
return;
}
va_list va;
va_start(va, fmt);
itj_csv_umax buf_len = vsnprintf(buf, KB(512), fmt, va);
va_end(va);
printf("%s", buf);
FILE *fh = fopen(g_sitrep_filepath, "ab");
if (fh) {
fwrite(buf, 1, buf_len, fh);
fclose(fh);
}
free(buf);
}
void test_print(char *str) {
sitrep("%s... ", str);
}
void test_print_result(itj_csv_bool result) {
if (result == ITJ_CSV_TRUE) {
sitrep("OK\n");
} else {
sitrep("FAIL\n");
g_did_a_test_fail = ITJ_CSV_TRUE;
}
}
void print_total(itj_csv_umax bytes_read, double time_start, double time_end) {
double time_diff_ms = time_end - time_start;
double time_diff_sec = time_diff_ms / 1000.0;
sitrep("Read %llu total bytes. %.3f MB per second\n", bytes_read, ((double)bytes_read / (1024.0 * 1024.0)) / time_diff_sec);
}
void test_correctness(struct itj_csv_value value, itj_csv_smax num_columns, itj_csv_smax *num_columns_out, itj_csv_u32 num_lines, itj_csv_u32 *num_lines_out) {
itj_csv_umax column;
if (num_columns == -1) {
column = value.idx;
} else {
column = value.idx % num_columns;
}
if (column == 0) {
if (num_lines == 0) {
test_print("Is header[0] == column1");
test_print_result(compare_strings(value.data.base, value.data.len, "column1", 7));
} else if (num_lines == 1) {
test_print("Is the first column of the first row == row1_column1");
test_print_result(compare_strings(value.data.base, value.data.len, "row1_column1", 12));
} else if (num_lines == 2) {
test_print("Is the first column of the second row == row2_column1");
test_print_result(compare_strings(value.data.base, value.data.len, "row2_column1", 12));
}
} else if (column == 1) {
if (num_lines == 0) {
test_print("Is header[1] == column2");
test_print_result(compare_strings(value.data.base, value.data.len, "column2", 7));
} else if (num_lines == 1) {
test_print("Is the second column of the first row == row1_column2");
test_print_result(compare_strings(value.data.base, value.data.len, "row1_column2", 12));
} else if (num_lines == 2) {
test_print("Is the second column of the second row == row2_column2");
test_print_result(compare_strings(value.data.base, value.data.len, "row2_column2", 12));
}
} else if (column == 2) {
if (num_lines == 0) {
test_print("Is header[2] == column\\r\\n3");
test_print_result(compare_strings(value.data.base, value.data.len, "column\r\n3", 9));
} else if (num_lines == 1) {
test_print("Is the third column of the first row == row1_column\\r\\n3");
test_print_result(compare_strings(value.data.base, value.data.len, "row1_column\r\n3", 14));
} else if (num_lines == 2) {
test_print("Is the third column of the second row == row2_column\\r\\n3");
test_print_result(compare_strings(value.data.base, value.data.len, "row2_column\r\n3", 14));
}
} else if (column == 3) {
if (num_lines == 0) {
test_print("Is header[3] == column\"4");
test_print_result(compare_strings(value.data.base, value.data.len, "column\"4", 8));
} else if (num_lines == 1) {
test_print("Is the fourth column of the first row == row1_column\"4");
test_print_result(compare_strings(value.data.base, value.data.len, "row1_column\"4", 13));
} else if (num_lines == 2) {
test_print("Is the fourth column of the second row == row2_column\"4");
test_print_result(compare_strings(value.data.base, value.data.len, "row2_column\"4", 13));
}
} else if (column == 4) {
if (num_lines == 0) {
test_print("Is header[4] == columnð");
test_print_result(compare_strings(value.data.base, value.data.len, "columnð", 8));
} else if (num_lines == 1) {
test_print("Is the fifth column of the first row == row1_columnð");
test_print_result(compare_strings(value.data.base, value.data.len, "row1_columnð", 13));
} else if (num_lines == 2) {
test_print("Is the fifth column of the second row == row2_columnð");
test_print_result(compare_strings(value.data.base, value.data.len, "row2_columnð", 13));
}
}
if (value.is_end_of_line) {
if (num_columns == -1) {
*num_columns_out = value.idx + 1;
}
*num_lines_out = num_lines + 1;
}
}
int main(int argc, char *argv[]) {
printf("Press any key to start\n");
getc(stdin);
#ifdef IS_WINDOWS
{
LARGE_INTEGER large_integer;
QueryPerformanceFrequency(&large_integer);
g_freq = ((double)large_integer.QuadPart) / 1000.0;
}
#endif
g_sitrep_filepath = (char *)calloc(1, KB(10));
if (!g_sitrep_filepath) {
printf("Unable to allocate memory for sitrep filepath\n");
return EXIT_FAILURE;
}
snprintf(g_sitrep_filepath, KB(10), "itj_csv_test_%lld.log", time(NULL));
itj_csv_smax *buffered_cycles = (itj_csv_smax *)calloc(1, NUM_BUFFERED_CYCLES * sizeof(*buffered_cycles));
if (!buffered_cycles) {
printf("Unable to allocate memory for buffered cycles. It might work to lower NUM_BUFFERED_CYCLES\n");
return EXIT_FAILURE;
}
const char *exe_path = argv[0];
if (!exe_path) {
printf("Unable to run because argv[0] does not point to the path to the executable\n");
return EXIT_FAILURE;
}
itj_csv_umax exe_dir_len = strlen(exe_path);
if (exe_dir_len == 0) {
printf("Unable to run because argv[0] points to a zero length string\n");
return EXIT_FAILURE;
}
{
itj_csv_smax i;
for (i = exe_dir_len - 1; i >= 0; i--) {
if (exe_path[i] == '\\' || exe_path[i] == '/') {
break;
}
}
if (i <= 0) {
exe_dir_len = 0;
} else {
exe_dir_len = i;
}
}
char *exe_dir = NULL;
if (exe_dir_len > 0) {
exe_dir = (char *)calloc(1, exe_dir_len + SIZE_OF_NULL_TERMINATOR);
if (!exe_dir) {
printf("Unable to allocate memory for the executable directory path. The executable string is '%s'\n", exe_path);
return EXIT_FAILURE;
}
memcpy(exe_dir, exe_path, exe_dir_len);
exe_dir[exe_dir_len] = '\0';
}
const char *correctness_with_header_csv_path = "correctness_with_header.csv";
itj_csv_umax correctness_with_header_csv_path_len = strlen(correctness_with_header_csv_path);
if (exe_dir_len > 0) {
char *path = (char *)calloc(1, exe_dir_len + correctness_with_header_csv_path_len + SIZE_OF_NULL_TERMINATOR);
if (!path) {
printf("Unable to allocate memory for the example csv path, '%s'\n", correctness_with_header_csv_path);
return EXIT_FAILURE;
}
correctness_with_header_csv_path_len = snprintf(path, exe_dir_len + SIZE_OF_DIR_SEPERATOR + correctness_with_header_csv_path_len + SIZE_OF_NULL_TERMINATOR, "%s" DIR_SEPERATOR "%s", exe_dir, correctness_with_header_csv_path);
correctness_with_header_csv_path = path;
}
const char *generated_csv_path = "generated.csv";
itj_csv_umax generated_csv_path_len = strlen(generated_csv_path);
if (exe_dir_len > 0) {
char *path = (char *)calloc(1, exe_dir_len + generated_csv_path_len + SIZE_OF_NULL_TERMINATOR);
if (!path) {
printf("Unable to allocate memory for the generated csv path, '%s'\n", generated_csv_path);
return EXIT_FAILURE;
}
generated_csv_path_len = snprintf(path, exe_dir_len + SIZE_OF_DIR_SEPERATOR + generated_csv_path_len + SIZE_OF_NULL_TERMINATOR, "%s" DIR_SEPERATOR "%s", exe_dir, generated_csv_path);
generated_csv_path = path;
}
printf("Running itj_csv correctness tests\n");
printf("Running standard correctness tests\n");
g_did_a_test_fail = ITJ_CSV_FALSE;
itj_csv_umax buffer_max = MB(2);
void *buffer = calloc(1, buffer_max);
if (!buffer) {
printf("Unable to allocate memory for parsing buffer\n");
return EXIT_FAILURE;
}
struct itj_csv csv;
if (!itj_csv_open(&csv, correctness_with_header_csv_path, correctness_with_header_csv_path_len, buffer, buffer_max, ITJ_CSV_DELIM_COMMA, NULL)) {
printf("Failed to initalize itj_csv struct to file, '%s'\n", correctness_with_header_csv_path);
return EXIT_FAILURE;
}
itj_csv_umax pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
printf("Unable to read from '%s'\n", correctness_with_header_csv_path);
return EXIT_FAILURE;
}
itj_csv_bool end = ITJ_CSV_FALSE;
itj_csv_u32 num_lines = 0;
itj_csv_smax num_columns = -1;
itj_csv_bool first = ITJ_CSV_TRUE;
for (;;) {
struct itj_csv_value value = itj_csv_get_next_value(&csv);
if (value.need_data) {
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
break;
} else {
continue;
}
}
test_correctness(value, num_columns, &num_columns, num_lines, &num_lines);
if (value.is_end_of_line && first) {
test_print("Expecting 5 columns in header");
test_print_result(value.idx == 4);
first = ITJ_CSV_FALSE;
}
}
itj_csv_close_fh(&csv);
if (g_did_a_test_fail) {
sitrep("NOT ALL CORRECTNESS TESTS COMPLETED SUCCESSFULLY!\n");
} else {
sitrep("ALL CORRECTNESS TESTS COMPLETED SUCCESSFULL\n");
}
printf("Running AVX2 correctness tests\n");
g_did_a_test_fail = ITJ_CSV_FALSE;
if (!itj_csv_open(&csv, correctness_with_header_csv_path, correctness_with_header_csv_path_len, buffer, buffer_max, ITJ_CSV_DELIM_COMMA, NULL)) {
printf("Failed to initalize itj_csv struct to file, '%s'\n", correctness_with_header_csv_path);
return EXIT_FAILURE;
}
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
printf("Unable to read from '%s'\n", correctness_with_header_csv_path);
return EXIT_FAILURE;
}
num_lines = 0;
num_columns = -1;
first = ITJ_CSV_TRUE;
for (;;) {
struct itj_csv_value value = itj_csv_get_next_value_avx2(&csv);
if (value.need_data) {
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
break;
} else {
continue;
}
}
test_correctness(value, num_columns, &num_columns, num_lines, &num_lines);
if (value.is_end_of_line && first) {
test_print("Expecting 5 columns in header");
test_print_result(value.idx == 4);
first = ITJ_CSV_FALSE;
}
}
itj_csv_close_fh(&csv);
if (g_did_a_test_fail) {
sitrep("NOT ALL CORRECTNESS TESTS COMPLETED SUCCESSFULLY!\n");
} else {
sitrep("ALL CORRECTNESS TESTS COMPLETED SUCCESSFULL\n");
}
sitrep("\nRunning itj_csv speed tests\n");
sitrep("Reading generated csv file without any work as reference\n");
FILE *fh = fopen(generated_csv_path, "rb");
if (!fh) {
printf("Unable to open %s for reference reading\n", generated_csv_path);
return EXIT_FAILURE;
}
double time_start_of_reference = get_time_ms();
itj_csv_umax bytes_read = 0;
for (;;) {
itj_csv_smax bytes = fread(buffer, 1, buffer_max, fh);
if (bytes < 0) {
printf("Unable to read all of %s\n", generated_csv_path);
return EXIT_FAILURE;
}
if (bytes == 0) {
break;
}
bytes_read += bytes;
}
double time_end_of_reference = get_time_ms();
fclose(fh);
print_total(bytes_read, time_start_of_reference, time_end_of_reference);
if (!itj_csv_open(&csv, generated_csv_path, generated_csv_path_len, buffer, buffer_max, ITJ_CSV_DELIM_COMMA, NULL)) {
printf("Failed to initalize itj_csv struct to file, '%s'\n", correctness_with_header_csv_path);
printf("Remember to generate a file for profiling first!\n");
return EXIT_FAILURE;
}
bytes_read = 0;
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
printf("Unable to read from '%s'\n", generated_csv_path);
return EXIT_FAILURE;
}
bytes_read += pump_ret;
num_columns = -1;
num_lines = 0;
itj_csv_smax num_values = 0;
double time_start_of_standard = get_time_ms();
for (;;) {
struct itj_csv_value value = itj_csv_get_next_value_avx2(&csv);
#if 0
itj_csv_umax column;
if (num_columns == -1) {
column = value.idx;
} else {
column = value.idx % num_columns;
}
#endif
if (value.need_data) {
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
break;
} else {
bytes_read += pump_ret;
continue;
}
}
if (value.is_end_of_line) {
++num_lines;
if (num_columns == -1) {
num_columns = value.idx + 1;
}
}
++num_values;
}
double time_end_of_standard = get_time_ms();
sitrep("The following numbers are for the non-SIMD version\n");
print_total(bytes_read, time_start_of_standard, time_end_of_standard);
itj_csv_close_fh(&csv);
sitrep("The number of iterations %llu\n", num_values);
sitrep("The number of lines %llu\n", num_lines);
sitrep("The number of columns %llu\n", num_columns);
if (!itj_csv_open(&csv, generated_csv_path, generated_csv_path_len, buffer, buffer_max, ITJ_CSV_DELIM_COMMA, NULL)) {
printf("Failed to initalize itj_csv struct to file, '%s'\n", correctness_with_header_csv_path);
printf("Remember to generate a file for profiling first!\n");
return EXIT_FAILURE;
}
bytes_read = 0;
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
printf("Unable to read from '%s'\n", generated_csv_path);
return EXIT_FAILURE;
}
bytes_read += pump_ret;
num_columns = -1;
num_lines = 0;
num_values = 0;
double time_start_of_avx = get_time_ms();
for (;;) {
struct itj_csv_value value = itj_csv_get_next_value_avx(&csv);
#if 0
itj_csv_umax column;
if (num_columns == -1) {
column = value.idx;
} else {
column = value.idx % num_columns;
}
#endif
if (value.need_data) {
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
break;
} else {
bytes_read += pump_ret;
continue;
}
}
if (value.is_end_of_line) {
++num_lines;
if (num_columns == -1) {
num_columns = value.idx + 1;
}
}
++num_values;
}
double time_end_of_avx = get_time_ms();
sitrep("The following numbers are for the AVX version\n");
print_total(bytes_read, time_start_of_avx, time_end_of_avx);
itj_csv_close_fh(&csv);
if (!itj_csv_open(&csv, generated_csv_path, generated_csv_path_len, buffer, buffer_max, ITJ_CSV_DELIM_COMMA, NULL)) {
printf("Failed to initalize itj_csv struct to file, '%s'\n", correctness_with_header_csv_path);
printf("Remember to generate a file for profiling first!\n");
return EXIT_FAILURE;
}
bytes_read = 0;
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
printf("Unable to read from '%s'\n", generated_csv_path);
return EXIT_FAILURE;
}
bytes_read += pump_ret;
num_columns = -1;
num_lines = 0;
num_values = 0;
double time_start_of_avx2 = get_time_ms();
for (;;) {
struct itj_csv_value value = itj_csv_get_next_value_avx2(&csv);
#if 0
itj_csv_umax column;
if (num_columns == -1) {
column = value.idx;
} else {
column = value.idx % num_columns;
}
#endif
if (value.need_data) {
pump_ret = itj_csv_pump_stdio(&csv);
if (pump_ret == 0) {
break;
} else {
bytes_read += pump_ret;
continue;
}
}
if (value.is_end_of_line) {
++num_lines;
if (num_columns == -1) {
num_columns = value.idx + 1;
}
}
++num_values;
}
double time_end_of_avx2 = get_time_ms();
sitrep("The following numbers are for the AVX2 version\n");
print_total(bytes_read, time_start_of_avx2, time_end_of_avx2);
itj_csv_close_fh(&csv);
fh = fopen(generated_csv_path, "rb");
if (!fh) {
printf("Unable to open %s for the second reference reading\n", generated_csv_path);
return EXIT_FAILURE;
}
double time_start_of_reference2 = get_time_ms();
bytes_read = 0;
for (;;) {
itj_csv_smax bytes = fread(buffer, 1, buffer_max, fh);
if (bytes < 0) {
printf("Unable to read all of %s\n", generated_csv_path);
return EXIT_FAILURE;
}
if (bytes == 0) {
break;
}
bytes_read += bytes;
}
double time_end_of_reference2 = get_time_ms();
sitrep("Reading generated csv file without any work as reference, a final time\n");
print_total(bytes_read, time_start_of_reference2, time_end_of_reference2);
fclose(fh);
printf("Finished. Press any key to quit\n");
getc(stdin);
return EXIT_SUCCESS;
}
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Ian Thomassen Jacobsen
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/