Line data Source code
1 : // SPDX-License-Identifier: GPL-3.0-or-later
2 : // Copyright (C) 2011 Andrea Mazzoleni
3 :
4 : #include "portable.h"
5 :
6 : #include "snapraid.h"
7 : #include "util.h"
8 : #include "raid/raid.h"
9 : #include "raid/cpu.h"
10 : #include "raid/internal.h"
11 : #include "raid/memory.h"
12 : #include "state.h"
13 :
14 : /**
15 : * Differential us of two timeval.
16 : */
17 2461 : static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop)
18 : {
19 : int64_t d;
20 :
21 2461 : d = 1000000LL * (stop->tv_sec - start->tv_sec);
22 2461 : d += stop->tv_usec - start->tv_usec;
23 :
24 2461 : return d;
25 : }
26 :
27 : /**
28 : * Start time measurement.
29 : */
30 : #define SPEED_START \
31 : count = 0; \
32 : gettimeofday(&start, 0); \
33 : do { \
34 : for (i = 0; i < delta; ++i)
35 :
36 : /**
37 : * Stop time measurement.
38 : */
39 : /* INDENT-OFF */
40 : #define SPEED_STOP \
41 : count += delta; \
42 : gettimeofday(&stop, 0); \
43 : } while (diffgettimeofday(&start, &stop) < period * 1000LL); \
44 : ds = size * (int64_t)count * nd; \
45 : dt = diffgettimeofday(&start, &stop);
46 : /* INDENT-ON */
47 :
48 : /**
49 : * Global variable used to propagate side effects.
50 : *
51 : * This is required to avoid optimizing compilers
52 : * to remove code without side effects.
53 : */
54 : static unsigned side_effect;
55 :
56 5 : void speed(int period, int nd, int size)
57 : {
58 : struct timeval start;
59 : struct timeval stop;
60 : int64_t ds;
61 : int64_t dt;
62 : int i, j;
63 : unsigned char digest[HASH_MAX];
64 : unsigned char seed[HASH_MAX];
65 : int id[RAID_PARITY_MAX];
66 : int ip[RAID_PARITY_MAX];
67 : int count;
68 : int delta;
69 : int nv;
70 : void* v_alloc;
71 : void** v;
72 :
73 5 : if (nd < 0)
74 5 : nd = 8; /* default */
75 5 : if (nd < 6)
76 0 : nd = 6; /* minimum */
77 5 : if (size < 0)
78 5 : size = 256 * KIBI;
79 : else
80 0 : size *= KIBI;
81 5 : if (period < 0)
82 0 : period = 1000;
83 :
84 5 : delta = period >= 1000 ? 10 : 1;
85 :
86 5 : nv = nd + RAID_PARITY_MAX + 1;
87 :
88 5 : v = malloc_nofail_vector_align(nd, nv, size, &v_alloc);
89 :
90 : /* initialize disks with fixed data */
91 45 : for (i = 0; i < nd; ++i)
92 40 : memset(v[i], i, size);
93 :
94 : /* zero buffer */
95 5 : memset(v[nd + RAID_PARITY_MAX], 0, size);
96 5 : raid_zero(v[nd + RAID_PARITY_MAX]);
97 :
98 : /* hash seed */
99 85 : for (i = 0; i < HASH_MAX; ++i)
100 80 : seed[i] = i;
101 :
102 : /* basic disks and parity mapping */
103 35 : for (i = 0; i < RAID_PARITY_MAX; ++i) {
104 30 : id[i] = i;
105 30 : ip[i] = i;
106 : }
107 :
108 5 : printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
109 :
110 : #ifdef __GNUC__
111 5 : printf("Compiler gcc " __VERSION__ "\n");
112 : #endif
113 :
114 : #ifdef CONFIG_X86
115 : {
116 : char vendor[CPU_VENDOR_MAX];
117 : unsigned family;
118 : unsigned model;
119 :
120 5 : raid_cpu_info(vendor, &family, &model);
121 :
122 45 : printf("CPU %s, family %u, model %u, flags%s%s%s%s%s%s%s%s%s\n", vendor, family, model,
123 5 : raid_cpu_has_sse2() ? " sse2" : "",
124 5 : raid_cpu_has_ssse3() ? " ssse3" : "",
125 5 : raid_cpu_has_crc32() ? " crc32" : "",
126 5 : raid_cpu_has_avx2() ? " avx2" : "",
127 5 : raid_cpu_has_avx2gfni() ? " avx2gfni" : "",
128 5 : raid_cpu_has_avx512bw() ? " avx512bw" : "",
129 5 : raid_cpu_has_avx512gfni() ? " avx512gfni" : "",
130 5 : raid_cpu_has_slowmult() ? " slowmult" : "",
131 5 : raid_cpu_has_slowextendedreg() ? " slowext" : ""
132 : );
133 : }
134 : #elif defined(__aarch64__) || defined(_M_ARM64)
135 : printf("CPU 64-bit ARM (AArch64)\n");
136 : #elif defined(__arm__) || defined(_M_ARM)
137 : printf("CPU 32-bit ARM\n");
138 : #elif defined(__powerpc64__)
139 : printf("CPU 64-bit PowerPC\n");
140 : #elif defined(__powerpc__)
141 : printf("CPU 32-bit PowerPC\n");
142 : #elif defined(__riscv)
143 : printf("CPU RISC-V\n");
144 : #elif defined(__s390x__)
145 : printf("CPU 64-bit IBM Z / s390x\n");
146 : #else
147 : printf("CPU of unknown architecture\n");
148 : #endif
149 : #if WORDS_BIGENDIAN
150 : printf("Memory is big-endian %d-bit\n", (int)sizeof(void*) * 8);
151 : #else
152 5 : printf("Memory is little-endian %d-bit\n", (int)sizeof(void*) * 8);
153 : #endif
154 : #if defined(__SIZEOF_INT128__)
155 5 : printf("128-bit integers are supported\n");
156 : #else
157 : printf("128-bit integers are not supported\n");
158 : #endif
159 :
160 : #if HAVE_FUTIMENS
161 5 : printf("Support nanosecond timestamps with futimens()\n");
162 : #elif HAVE_FUTIMES
163 : printf("Support nanosecond timestamps with futimes()\n");
164 : #elif HAVE_FUTIMESAT
165 : printf("Support nanosecond timestamps with futimesat()\n");
166 : #else
167 : printf("Does not support nanosecond timestamps\n");
168 : #endif
169 :
170 5 : printf("\n");
171 :
172 5 : printf("Speed test using %u data buffers of %u bytes, for a total of %u KiB.\n", nd, size, nd * size / KIBI);
173 5 : printf("Memory blocks have a displacement of %u bytes to improve cache performance.\n", RAID_MALLOC_DISPLACEMENT);
174 5 : printf("The reported values are the aggregate bandwidth of all data blocks in MB/s,\n");
175 5 : printf("not counting parity blocks.\n");
176 5 : printf("\n");
177 :
178 5 : printf("Memory write speed using the C memset() function:\n");
179 5 : printf("%8s", "memset");
180 5 : fflush(stdout);
181 :
182 2144 : SPEED_START {
183 9648 : for (j = 0; j < nd; ++j)
184 8576 : memset(v[j], j, size);
185 1072 : } SPEED_STOP
186 :
187 5 : printf("%8" PRIu64, ds / dt);
188 5 : printf("\n");
189 5 : printf("\n");
190 :
191 : /* crc table */
192 5 : printf("CRC used to check the content file integrity:\n");
193 :
194 5 : printf("%8s", "table");
195 5 : fflush(stdout);
196 :
197 86 : SPEED_START {
198 387 : for (j = 0; j < nd; ++j)
199 344 : side_effect += crc32c_gen(0, v[j], size);
200 43 : } SPEED_STOP
201 :
202 5 : printf("%8" PRIu64, ds / dt);
203 5 : printf("\n");
204 :
205 5 : printf("%8s", "intel");
206 5 : fflush(stdout);
207 :
208 : #if HAVE_SSE42
209 5 : if (raid_cpu_has_crc32()) {
210 136 : SPEED_START {
211 612 : for (j = 0; j < nd; ++j)
212 544 : side_effect += crc32c_x86(0, v[j], size);
213 68 : } SPEED_STOP
214 :
215 3 : printf("%8" PRIu64, ds / dt);
216 : }
217 : #endif
218 5 : printf("\n");
219 5 : printf("\n");
220 :
221 : /* hash table */
222 5 : printf("Hash used to check the data blocks integrity:\n");
223 :
224 5 : printf("%8s", "");
225 5 : printf("%8s", "best");
226 5 : printf("%8s", "murmur3");
227 5 : printf("%8s", "spooky2");
228 5 : printf("%8s", "metro");
229 5 : printf("%8s", "museair");
230 5 : printf("\n");
231 :
232 5 : printf("%8s", "hash");
233 5 : printf("%8s", memhashname(membesthash()));
234 5 : fflush(stdout);
235 :
236 20 : SPEED_START {
237 90 : for (j = 0; j < nd; ++j)
238 80 : memhash(HASH_MURMUR3, seed, digest, v[j], size);
239 10 : } SPEED_STOP
240 :
241 5 : printf("%8" PRIu64, ds / dt);
242 5 : fflush(stdout);
243 :
244 58 : SPEED_START {
245 261 : for (j = 0; j < nd; ++j)
246 232 : memhash(HASH_SPOOKY2, seed, digest, v[j], size);
247 29 : } SPEED_STOP
248 :
249 5 : printf("%8" PRIu64, ds / dt);
250 5 : fflush(stdout);
251 :
252 38 : SPEED_START {
253 171 : for (j = 0; j < nd; ++j)
254 152 : memhash(HASH_METRO, seed, digest, v[j], size);
255 19 : } SPEED_STOP
256 :
257 5 : printf("%8" PRIu64, ds / dt);
258 5 : fflush(stdout);
259 :
260 44 : SPEED_START {
261 198 : for (j = 0; j < nd; ++j)
262 176 : memhash(HASH_MUSEAIR, seed, digest, v[j], size);
263 22 : } SPEED_STOP
264 :
265 5 : printf("%8" PRIu64, ds / dt);
266 5 : printf("\n");
267 5 : printf("\n");
268 :
269 : /* RAID table */
270 5 : printf("RAID functions used for computing the parity with 'sync':\n");
271 5 : printf("%8s", "");
272 5 : printf("%8s", "best");
273 5 : printf("%8s", "int8");
274 5 : printf("%8s", "int32");
275 5 : printf("%8s", "int64");
276 : #ifdef CONFIG_X86
277 5 : printf("%8s", "sse2");
278 : #ifdef CONFIG_X86_64
279 5 : printf("%8s", "sse2e");
280 : #endif
281 5 : printf("%8s", "ssse3");
282 : #ifdef CONFIG_X86_64
283 5 : printf("%8s", "ssse3e");
284 : #endif
285 5 : printf("%8s", "avx2");
286 : #ifdef CONFIG_X86_64
287 5 : printf("%8s", "avx2e");
288 5 : printf("%8s", "avx512");
289 : #endif
290 : #endif
291 5 : printf("\n");
292 :
293 : /* GEN1 */
294 5 : printf("%8s", "gen1");
295 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR1));
296 5 : fflush(stdout);
297 :
298 5 : printf("%8s", "");
299 :
300 190 : SPEED_START {
301 95 : raid_gen1_int32(nd, size, v);
302 95 : } SPEED_STOP
303 :
304 5 : printf("%8" PRIu64, ds / dt);
305 5 : fflush(stdout);
306 :
307 354 : SPEED_START {
308 177 : raid_gen1_int64(nd, size, v);
309 177 : } SPEED_STOP
310 :
311 5 : printf("%8" PRIu64, ds / dt);
312 5 : fflush(stdout);
313 :
314 : #ifdef CONFIG_X86
315 : #ifdef CONFIG_SSE2
316 5 : if (raid_cpu_has_sse2()) {
317 172 : SPEED_START {
318 86 : raid_gen1_sse2(nd, size, v);
319 86 : } SPEED_STOP
320 :
321 5 : printf("%8" PRIu64, ds / dt);
322 5 : fflush(stdout);
323 : }
324 : #endif
325 :
326 : #ifdef CONFIG_X86_64
327 5 : printf("%8s", "");
328 : #endif
329 5 : printf("%8s", "");
330 : #ifdef CONFIG_X86_64
331 5 : printf("%8s", "");
332 : #endif
333 : #ifdef CONFIG_AVX2
334 5 : if (raid_cpu_has_avx2()) {
335 46 : SPEED_START {
336 23 : raid_gen1_avx2(nd, size, v);
337 23 : } SPEED_STOP
338 :
339 2 : printf("%8" PRIu64, ds / dt);
340 2 : fflush(stdout);
341 : }
342 : #endif
343 : #ifdef CONFIG_X86_64
344 5 : printf("%8s", "");
345 : #ifdef CONFIG_AVX512BW
346 5 : if (raid_cpu_has_avx512bw()) {
347 40 : SPEED_START {
348 20 : raid_gen1_avx512bw(nd, size, v);
349 20 : } SPEED_STOP
350 :
351 1 : printf("%8" PRIu64, ds / dt);
352 1 : fflush(stdout);
353 : }
354 : #endif
355 : #endif
356 : #endif
357 5 : printf("\n");
358 :
359 : /* GEN2 */
360 5 : printf("%8s", "gen2");
361 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR2));
362 5 : fflush(stdout);
363 :
364 5 : printf("%8s", "");
365 :
366 96 : SPEED_START {
367 48 : raid_gen2_int32(nd, size, v);
368 48 : } SPEED_STOP
369 :
370 5 : printf("%8" PRIu64, ds / dt);
371 5 : fflush(stdout);
372 :
373 178 : SPEED_START {
374 89 : raid_gen2_int64(nd, size, v);
375 89 : } SPEED_STOP
376 :
377 5 : printf("%8" PRIu64, ds / dt);
378 5 : fflush(stdout);
379 :
380 : #ifdef CONFIG_X86
381 : #ifdef CONFIG_SSE2
382 5 : if (raid_cpu_has_sse2()) {
383 52 : SPEED_START {
384 26 : raid_gen2_sse2(nd, size, v);
385 26 : } SPEED_STOP
386 :
387 5 : printf("%8" PRIu64, ds / dt);
388 5 : fflush(stdout);
389 :
390 : #ifdef CONFIG_X86_64
391 54 : SPEED_START {
392 27 : raid_gen2_sse2ext(nd, size, v);
393 27 : } SPEED_STOP
394 :
395 5 : printf("%8" PRIu64, ds / dt);
396 5 : fflush(stdout);
397 : #endif
398 : }
399 : #endif
400 :
401 5 : printf("%8s", "");
402 : #ifdef CONFIG_X86_64
403 5 : printf("%8s", "");
404 : #endif
405 : #ifdef CONFIG_AVX2
406 5 : if (raid_cpu_has_avx2()) {
407 12 : SPEED_START {
408 6 : raid_gen2_avx2(nd, size, v);
409 6 : } SPEED_STOP
410 :
411 2 : printf("%8" PRIu64, ds / dt);
412 2 : fflush(stdout);
413 : }
414 : #endif
415 : #ifdef CONFIG_X86_64
416 5 : printf("%8s", "");
417 : #ifdef CONFIG_AVX512BW
418 5 : if (raid_cpu_has_avx512bw()) {
419 6 : SPEED_START {
420 3 : raid_gen2_avx512bw(nd, size, v);
421 3 : } SPEED_STOP
422 :
423 1 : printf("%8" PRIu64, ds / dt);
424 1 : fflush(stdout);
425 : }
426 : #endif
427 : #endif
428 : #endif
429 5 : printf("\n");
430 :
431 : /* GENz */
432 5 : printf("%8s", "genz");
433 5 : printf("%8s", raid_gen_tag(RAID_ALGO_VANDERMONDE_PAR3));
434 5 : fflush(stdout);
435 :
436 5 : printf("%8s", "");
437 :
438 62 : SPEED_START {
439 31 : raid_genz_int32(nd, size, v);
440 31 : } SPEED_STOP
441 :
442 5 : printf("%8" PRIu64, ds / dt);
443 5 : fflush(stdout);
444 :
445 112 : SPEED_START {
446 56 : raid_genz_int64(nd, size, v);
447 56 : } SPEED_STOP
448 :
449 5 : printf("%8" PRIu64, ds / dt);
450 5 : fflush(stdout);
451 :
452 : #ifdef CONFIG_X86
453 : #ifdef CONFIG_SSE2
454 5 : if (raid_cpu_has_sse2()) {
455 30 : SPEED_START {
456 15 : raid_genz_sse2(nd, size, v);
457 15 : } SPEED_STOP
458 :
459 5 : printf("%8" PRIu64, ds / dt);
460 5 : fflush(stdout);
461 :
462 : #ifdef CONFIG_X86_64
463 30 : SPEED_START {
464 15 : raid_genz_sse2ext(nd, size, v);
465 15 : } SPEED_STOP
466 :
467 5 : printf("%8" PRIu64, ds / dt);
468 5 : fflush(stdout);
469 : #endif
470 : }
471 : #endif
472 :
473 5 : printf("%8s", "");
474 : #ifdef CONFIG_X86_64
475 5 : printf("%8s", "");
476 : #endif
477 5 : printf("%8s", "");
478 :
479 : #ifdef CONFIG_X86_64
480 : #ifdef CONFIG_AVX2
481 5 : if (raid_cpu_has_avx2()) {
482 8 : SPEED_START {
483 4 : raid_genz_avx2ext(nd, size, v);
484 4 : } SPEED_STOP
485 :
486 2 : printf("%8" PRIu64, ds / dt);
487 2 : fflush(stdout);
488 : }
489 : #endif
490 : #endif
491 : #endif
492 5 : printf("\n");
493 :
494 : /* GEN3 */
495 5 : printf("%8s", "gen3");
496 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR3));
497 5 : fflush(stdout);
498 :
499 22 : SPEED_START {
500 11 : raid_gen3_int8(nd, size, v);
501 11 : } SPEED_STOP
502 :
503 5 : printf("%8" PRIu64, ds / dt);
504 5 : fflush(stdout);
505 :
506 5 : printf("%8s", "");
507 5 : printf("%8s", "");
508 :
509 : #ifdef CONFIG_X86
510 5 : if (raid_cpu_has_sse2()) {
511 5 : printf("%8s", "");
512 :
513 : #ifdef CONFIG_X86_64
514 5 : printf("%8s", "");
515 : #endif
516 : }
517 : #endif
518 :
519 : #ifdef CONFIG_X86
520 : #ifdef CONFIG_SSSE3
521 5 : if (raid_cpu_has_ssse3()) {
522 24 : SPEED_START {
523 12 : raid_gen3_ssse3(nd, size, v);
524 12 : } SPEED_STOP
525 :
526 4 : printf("%8" PRIu64, ds / dt);
527 4 : fflush(stdout);
528 :
529 : #ifdef CONFIG_X86_64
530 24 : SPEED_START {
531 12 : raid_gen3_ssse3ext(nd, size, v);
532 12 : } SPEED_STOP
533 :
534 4 : printf("%8" PRIu64, ds / dt);
535 4 : fflush(stdout);
536 : #endif
537 : }
538 : #endif
539 :
540 5 : printf("%8s", "");
541 :
542 : #ifdef CONFIG_X86_64
543 : #ifdef CONFIG_AVX2
544 5 : if (raid_cpu_has_avx2()) {
545 6 : SPEED_START {
546 3 : raid_gen3_avx2ext(nd, size, v);
547 3 : } SPEED_STOP
548 :
549 2 : printf("%8" PRIu64, ds / dt);
550 2 : fflush(stdout);
551 : }
552 : #endif
553 : #ifdef CONFIG_AVX512BW
554 5 : if (raid_cpu_has_avx512bw()) {
555 2 : SPEED_START {
556 1 : raid_gen3_avx512bw(nd, size, v);
557 1 : } SPEED_STOP
558 :
559 1 : printf("%8" PRIu64, ds / dt);
560 1 : fflush(stdout);
561 : }
562 : #endif
563 : #endif
564 : #endif
565 5 : printf("\n");
566 :
567 : /* GEN4 */
568 5 : printf("%8s", "gen4");
569 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR4));
570 5 : fflush(stdout);
571 :
572 20 : SPEED_START {
573 10 : raid_gen4_int8(nd, size, v);
574 10 : } SPEED_STOP
575 :
576 5 : printf("%8" PRIu64, ds / dt);
577 5 : fflush(stdout);
578 :
579 5 : printf("%8s", "");
580 5 : printf("%8s", "");
581 :
582 : #ifdef CONFIG_X86
583 : #ifdef CONFIG_SSE2
584 5 : if (raid_cpu_has_sse2()) {
585 5 : printf("%8s", "");
586 :
587 : #ifdef CONFIG_X86_64
588 5 : printf("%8s", "");
589 : #endif
590 : }
591 : #endif
592 : #endif
593 :
594 : #ifdef CONFIG_X86
595 : #ifdef CONFIG_SSSE3
596 5 : if (raid_cpu_has_ssse3()) {
597 16 : SPEED_START {
598 8 : raid_gen4_ssse3(nd, size, v);
599 8 : } SPEED_STOP
600 :
601 4 : printf("%8" PRIu64, ds / dt);
602 4 : fflush(stdout);
603 :
604 : #ifdef CONFIG_X86_64
605 16 : SPEED_START {
606 8 : raid_gen4_ssse3ext(nd, size, v);
607 8 : } SPEED_STOP
608 :
609 4 : printf("%8" PRIu64, ds / dt);
610 4 : fflush(stdout);
611 : #endif
612 : }
613 : #endif
614 :
615 5 : printf("%8s", "");
616 :
617 : #ifdef CONFIG_X86_64
618 : #ifdef CONFIG_AVX2
619 5 : if (raid_cpu_has_avx2()) {
620 4 : SPEED_START {
621 2 : raid_gen4_avx2ext(nd, size, v);
622 2 : } SPEED_STOP
623 :
624 2 : printf("%8" PRIu64, ds / dt);
625 2 : fflush(stdout);
626 : }
627 : #endif
628 : #ifdef CONFIG_AVX512BW
629 5 : if (raid_cpu_has_avx512bw()) {
630 2 : SPEED_START {
631 1 : raid_gen4_avx512bw(nd, size, v);
632 1 : } SPEED_STOP
633 :
634 1 : printf("%8" PRIu64, ds / dt);
635 1 : fflush(stdout);
636 : }
637 : #endif
638 : #endif
639 : #endif
640 5 : printf("\n");
641 :
642 : /* GEN5 */
643 5 : printf("%8s", "gen5");
644 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR5));
645 5 : fflush(stdout);
646 :
647 20 : SPEED_START {
648 10 : raid_gen5_int8(nd, size, v);
649 10 : } SPEED_STOP
650 :
651 5 : printf("%8" PRIu64, ds / dt);
652 5 : fflush(stdout);
653 :
654 5 : printf("%8s", "");
655 5 : printf("%8s", "");
656 :
657 : #ifdef CONFIG_X86
658 : #ifdef CONFIG_SSE2
659 5 : if (raid_cpu_has_sse2()) {
660 5 : printf("%8s", "");
661 :
662 : #ifdef CONFIG_X86_64
663 5 : printf("%8s", "");
664 : #endif
665 : }
666 : #endif
667 : #endif
668 :
669 : #ifdef CONFIG_X86
670 : #ifdef CONFIG_SSSE3
671 5 : if (raid_cpu_has_ssse3()) {
672 16 : SPEED_START {
673 8 : raid_gen5_ssse3(nd, size, v);
674 8 : } SPEED_STOP
675 :
676 4 : printf("%8" PRIu64, ds / dt);
677 4 : fflush(stdout);
678 :
679 : #ifdef CONFIG_X86_64
680 16 : SPEED_START {
681 8 : raid_gen5_ssse3ext(nd, size, v);
682 8 : } SPEED_STOP
683 :
684 4 : printf("%8" PRIu64, ds / dt);
685 4 : fflush(stdout);
686 : #endif
687 : }
688 : #endif
689 :
690 5 : printf("%8s", "");
691 :
692 : #ifdef CONFIG_X86_64
693 : #ifdef CONFIG_AVX2
694 5 : if (raid_cpu_has_avx2()) {
695 4 : SPEED_START {
696 2 : raid_gen5_avx2ext(nd, size, v);
697 2 : } SPEED_STOP
698 :
699 2 : printf("%8" PRIu64, ds / dt);
700 2 : fflush(stdout);
701 : }
702 : #endif
703 : #ifdef CONFIG_AVX512BW
704 5 : if (raid_cpu_has_avx512bw()) {
705 2 : SPEED_START {
706 1 : raid_gen5_avx512bw(nd, size, v);
707 1 : } SPEED_STOP
708 :
709 1 : printf("%8" PRIu64, ds / dt);
710 1 : fflush(stdout);
711 : }
712 : #endif
713 : #endif
714 : #endif
715 5 : printf("\n");
716 :
717 : /* GEN6 */
718 5 : printf("%8s", "gen6");
719 5 : printf("%8s", raid_gen_tag(RAID_ALGO_CAUCHY_PAR5));
720 5 : fflush(stdout);
721 :
722 20 : SPEED_START {
723 10 : raid_gen6_int8(nd, size, v);
724 10 : } SPEED_STOP
725 :
726 5 : printf("%8" PRIu64, ds / dt);
727 5 : fflush(stdout);
728 :
729 5 : printf("%8s", "");
730 5 : printf("%8s", "");
731 :
732 : #ifdef CONFIG_X86
733 : #ifdef CONFIG_SSE2
734 5 : if (raid_cpu_has_sse2()) {
735 5 : printf("%8s", "");
736 :
737 : #ifdef CONFIG_X86_64
738 5 : printf("%8s", "");
739 : #endif
740 : }
741 : #endif
742 : #endif
743 :
744 : #ifdef CONFIG_X86
745 : #ifdef CONFIG_SSSE3
746 5 : if (raid_cpu_has_ssse3()) {
747 16 : SPEED_START {
748 8 : raid_gen6_ssse3(nd, size, v);
749 8 : } SPEED_STOP
750 :
751 4 : printf("%8" PRIu64, ds / dt);
752 4 : fflush(stdout);
753 :
754 : #ifdef CONFIG_X86_64
755 16 : SPEED_START {
756 8 : raid_gen6_ssse3ext(nd, size, v);
757 8 : } SPEED_STOP
758 :
759 4 : printf("%8" PRIu64, ds / dt);
760 4 : fflush(stdout);
761 : #endif
762 : }
763 : #endif
764 :
765 5 : printf("%8s", "");
766 :
767 : #ifdef CONFIG_X86_64
768 : #ifdef CONFIG_AVX2
769 5 : if (raid_cpu_has_avx2()) {
770 4 : SPEED_START {
771 2 : raid_gen6_avx2ext(nd, size, v);
772 2 : } SPEED_STOP
773 :
774 2 : printf("%8" PRIu64, ds / dt);
775 2 : fflush(stdout);
776 : }
777 : #endif
778 : #ifdef CONFIG_AVX512BW
779 5 : if (raid_cpu_has_avx512bw()) {
780 2 : SPEED_START {
781 1 : raid_gen6_avx512bw(nd, size, v);
782 1 : } SPEED_STOP
783 :
784 1 : printf("%8" PRIu64, ds / dt);
785 1 : fflush(stdout);
786 : }
787 : #endif
788 : #endif
789 : #endif
790 5 : printf("\n");
791 5 : printf("\n");
792 :
793 : /* recover table */
794 5 : printf("RAID functions used for recovering with 'fix':\n");
795 5 : printf("%8s", "");
796 5 : printf("%8s", "best");
797 5 : printf("%8s", "int8");
798 : #ifdef CONFIG_X86
799 5 : printf("%8s", "ssse3");
800 5 : printf("%8s", "avx2");
801 : #ifdef CONFIG_X86_64
802 5 : printf("%8s", "avx512");
803 : #endif
804 : #endif
805 5 : printf("\n");
806 :
807 5 : printf("%8s", "rec1");
808 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR1));
809 5 : fflush(stdout);
810 :
811 38 : SPEED_START {
812 : /* ensure to use same hardware in the delta step */
813 19 : raid_gen_force(1, sizeof(void*) == 8 ? raid_gen1_int64 : raid_gen1_int32);
814 : /* +1 to avoid GEN1 optimized case */
815 19 : raid_rec1_int8(1, id, ip + 1, nd, size, v);
816 19 : } SPEED_STOP
817 :
818 5 : printf("%8" PRIu64, ds / dt);
819 5 : fflush(stdout);
820 :
821 : #ifdef CONFIG_X86
822 : #ifdef CONFIG_SSSE3
823 5 : if (raid_cpu_has_ssse3()) {
824 34 : SPEED_START {
825 : /* ensure to use same hardware in the delta step */
826 17 : raid_gen_force(1, raid_gen1_sse2);
827 : /* +1 to avoid GEN1 optimized case */
828 17 : raid_rec1_ssse3(1, id, ip + 1, nd, size, v);
829 17 : } SPEED_STOP
830 :
831 4 : printf("%8" PRIu64, ds / dt);
832 4 : fflush(stdout);
833 : }
834 : #endif
835 : #ifdef CONFIG_AVX2
836 5 : if (raid_cpu_has_avx2()) {
837 12 : SPEED_START {
838 : /* ensure to use same hardware in the delta step */
839 6 : raid_gen_force(1, raid_gen1_avx2);
840 : /* +1 to avoid GEN1 optimized case */
841 6 : raid_rec1_avx2(1, id, ip + 1, nd, size, v);
842 6 : } SPEED_STOP
843 :
844 2 : printf("%8" PRIu64, ds / dt);
845 2 : fflush(stdout);
846 : }
847 : #endif
848 : #ifdef CONFIG_X86_64
849 : #ifdef CONFIG_AVX512BW
850 5 : if (raid_cpu_has_avx512bw()) {
851 6 : SPEED_START {
852 : /* ensure to use same hardware in the delta step */
853 3 : raid_gen_force(1, raid_gen1_avx512bw);
854 : /* +1 to avoid GEN1 optimized case */
855 3 : raid_rec1_avx512bw(1, id, ip + 1, nd, size, v);
856 3 : } SPEED_STOP
857 :
858 1 : printf("%8" PRIu64, ds / dt);
859 1 : fflush(stdout);
860 : }
861 : #endif
862 : #endif
863 : #endif
864 5 : printf("\n");
865 :
866 5 : printf("%8s", "rec2");
867 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR2));
868 5 : fflush(stdout);
869 :
870 20 : SPEED_START {
871 : /* ensure to use same hardware in the delta step */
872 10 : raid_gen_force(2, sizeof(void*) == 8 ? raid_gen2_int64 : raid_gen2_int32);
873 : /* +1 to avoid GEN2 optimized case */
874 10 : raid_rec2_int8(2, id, ip + 1, nd, size, v);
875 10 : } SPEED_STOP
876 :
877 5 : printf("%8" PRIu64, ds / dt);
878 5 : fflush(stdout);
879 :
880 : #ifdef CONFIG_X86
881 : #ifdef CONFIG_SSSE3
882 5 : if (raid_cpu_has_ssse3()) {
883 16 : SPEED_START {
884 : /* ensure to use same hardware in the delta step */
885 : #ifdef CONFIG_X86_64
886 8 : raid_gen_force(2, raid_gen2_sse2ext);
887 : #else
888 : raid_gen_force(2, raid_gen2_sse2);
889 : #endif
890 : /* +1 to avoid GEN2 optimized case */
891 8 : raid_rec2_ssse3(2, id, ip + 1, nd, size, v);
892 8 : } SPEED_STOP
893 :
894 4 : printf("%8" PRIu64, ds / dt);
895 4 : fflush(stdout);
896 : }
897 : #endif
898 : #ifdef CONFIG_AVX2
899 5 : if (raid_cpu_has_avx2()) {
900 4 : SPEED_START {
901 : /* ensure to use same hardware in the delta step */
902 2 : raid_gen_force(2, raid_gen2_avx2);
903 : /* +1 to avoid GEN2 optimized case */
904 2 : raid_rec2_avx2(2, id, ip + 1, nd, size, v);
905 2 : } SPEED_STOP
906 :
907 2 : printf("%8" PRIu64, ds / dt);
908 2 : fflush(stdout);
909 : }
910 : #endif
911 : #ifdef CONFIG_X86_64
912 : #ifdef CONFIG_AVX512BW
913 5 : if (raid_cpu_has_avx512bw()) {
914 2 : SPEED_START {
915 : /* ensure to use same hardware in the delta step */
916 1 : raid_gen_force(2, raid_gen2_avx512bw);
917 : /* +1 to avoid GEN2 optimized case */
918 1 : raid_rec2_avx512bw(2, id, ip + 1, nd, size, v);
919 1 : } SPEED_STOP
920 :
921 1 : printf("%8" PRIu64, ds / dt);
922 1 : fflush(stdout);
923 : }
924 : #endif
925 : #endif
926 : #endif
927 5 : printf("\n");
928 :
929 5 : printf("%8s", "rec3");
930 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR3));
931 5 : fflush(stdout);
932 :
933 10 : SPEED_START {
934 : /* ensure to use same hardware in the delta step */
935 5 : raid_gen_force(3, raid_gen3_int8);
936 5 : raid_recX_int8(3, id, ip, nd, size, v);
937 5 : } SPEED_STOP
938 :
939 5 : printf("%8" PRIu64, ds / dt);
940 5 : fflush(stdout);
941 :
942 : #ifdef CONFIG_X86
943 : #ifdef CONFIG_SSSE3
944 5 : if (raid_cpu_has_ssse3()) {
945 16 : SPEED_START {
946 : /* ensure to use same hardware in the delta step */
947 : #ifdef CONFIG_X86_64
948 8 : raid_gen_force(3, raid_gen3_ssse3ext);
949 : #else
950 : raid_gen_force(3, raid_gen3_ssse3);
951 : #endif
952 8 : raid_recX_ssse3(3, id, ip, nd, size, v);
953 8 : } SPEED_STOP
954 :
955 4 : printf("%8" PRIu64, ds / dt);
956 4 : fflush(stdout);
957 : }
958 : #endif
959 : #ifdef CONFIG_AVX2
960 5 : if (raid_cpu_has_avx2()) {
961 4 : SPEED_START {
962 : /* ensure to use same hardware in the delta step */
963 : #ifdef CONFIG_X86_64
964 2 : raid_gen_force(3, raid_gen3_avx2ext);
965 : #else
966 : raid_gen_force(3, raid_gen3_ssse3);
967 : #endif
968 2 : raid_recX_avx2(3, id, ip, nd, size, v);
969 2 : } SPEED_STOP
970 :
971 2 : printf("%8" PRIu64, ds / dt);
972 2 : fflush(stdout);
973 : }
974 : #endif
975 : #ifdef CONFIG_X86_64
976 : #ifdef CONFIG_AVX512BW
977 5 : if (raid_cpu_has_avx512bw()) {
978 2 : SPEED_START {
979 : /* ensure to use same hardware in the delta step */
980 1 : raid_gen_force(3, raid_gen3_avx512bw);
981 : /* +1 to avoid GEN1 optimized case */
982 1 : raid_recX_avx512bw(3, id, ip, nd, size, v);
983 1 : } SPEED_STOP
984 :
985 1 : printf("%8" PRIu64, ds / dt);
986 1 : fflush(stdout);
987 : }
988 : #endif
989 : #endif
990 : #endif
991 5 : printf("\n");
992 :
993 5 : printf("%8s", "rec4");
994 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR4));
995 5 : fflush(stdout);
996 :
997 10 : SPEED_START {
998 : /* ensure to use same hardware in the delta step */
999 5 : raid_gen_force(4, raid_gen4_int8);
1000 5 : raid_recX_int8(4, id, ip, nd, size, v);
1001 5 : } SPEED_STOP
1002 :
1003 5 : printf("%8" PRIu64, ds / dt);
1004 5 : fflush(stdout);
1005 :
1006 : #ifdef CONFIG_X86
1007 : #ifdef CONFIG_SSSE3
1008 5 : if (raid_cpu_has_ssse3()) {
1009 10 : SPEED_START {
1010 : /* ensure to use same hardware in the delta step */
1011 : #ifdef CONFIG_X86_64
1012 5 : raid_gen_force(4, raid_gen4_ssse3ext);
1013 : #else
1014 :
1015 : raid_gen_force(4, raid_gen4_ssse3);
1016 : #endif
1017 5 : raid_recX_ssse3(4, id, ip, nd, size, v);
1018 5 : } SPEED_STOP
1019 :
1020 4 : printf("%8" PRIu64, ds / dt);
1021 4 : fflush(stdout);
1022 : }
1023 : #endif
1024 : #ifdef CONFIG_AVX2
1025 5 : if (raid_cpu_has_avx2()) {
1026 4 : SPEED_START {
1027 : /* ensure to use same hardware in the delta step */
1028 : #ifdef CONFIG_X86_64
1029 2 : raid_gen_force(4, raid_gen4_avx2ext);
1030 : #else
1031 : raid_gen_force(4, raid_gen4_ssse3);
1032 : #endif
1033 2 : raid_recX_avx2(4, id, ip, nd, size, v);
1034 2 : } SPEED_STOP
1035 :
1036 2 : printf("%8" PRIu64, ds / dt);
1037 2 : fflush(stdout);
1038 : }
1039 : #endif
1040 : #ifdef CONFIG_X86_64
1041 : #ifdef CONFIG_AVX512BW
1042 5 : if (raid_cpu_has_avx512bw()) {
1043 2 : SPEED_START {
1044 : /* ensure to use same hardware in the delta step */
1045 1 : raid_gen_force(4, raid_gen4_avx512bw);
1046 : /* +1 to avoid GEN1 optimized case */
1047 1 : raid_recX_avx512bw(4, id, ip, nd, size, v);
1048 1 : } SPEED_STOP
1049 :
1050 1 : printf("%8" PRIu64, ds / dt);
1051 1 : fflush(stdout);
1052 : }
1053 : #endif
1054 : #endif
1055 : #endif
1056 5 : printf("\n");
1057 :
1058 5 : printf("%8s", "rec5");
1059 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR5));
1060 5 : fflush(stdout);
1061 :
1062 10 : SPEED_START {
1063 : /* ensure to use same hardware in the delta step */
1064 5 : raid_gen_force(5, raid_gen5_int8);
1065 5 : raid_recX_int8(5, id, ip, nd, size, v);
1066 5 : } SPEED_STOP
1067 :
1068 5 : printf("%8" PRIu64, ds / dt);
1069 5 : fflush(stdout);
1070 :
1071 : #ifdef CONFIG_X86
1072 : #ifdef CONFIG_SSSE3
1073 5 : if (raid_cpu_has_ssse3()) {
1074 8 : SPEED_START {
1075 : /* ensure to use same hardware in the delta step */
1076 : #ifdef CONFIG_X86_64
1077 4 : raid_gen_force(5, raid_gen5_ssse3ext);
1078 : #else
1079 : raid_gen_force(5, raid_gen5_ssse3);
1080 : #endif
1081 4 : raid_recX_ssse3(5, id, ip, nd, size, v);
1082 4 : } SPEED_STOP
1083 :
1084 4 : printf("%8" PRIu64, ds / dt);
1085 4 : fflush(stdout);
1086 : }
1087 : #endif
1088 : #ifdef CONFIG_AVX2
1089 5 : if (raid_cpu_has_avx2()) {
1090 4 : SPEED_START {
1091 : /* ensure to use same hardware in the delta step */
1092 : #ifdef CONFIG_X86_64
1093 2 : raid_gen_force(5, raid_gen5_avx2ext);
1094 : #else
1095 : raid_gen_force(5, raid_gen5_ssse3);
1096 : #endif
1097 2 : raid_recX_avx2(5, id, ip, nd, size, v);
1098 2 : } SPEED_STOP
1099 :
1100 2 : printf("%8" PRIu64, ds / dt);
1101 2 : fflush(stdout);
1102 : }
1103 : #endif
1104 : #ifdef CONFIG_X86_64
1105 : #ifdef CONFIG_AVX512BW
1106 5 : if (raid_cpu_has_avx512bw()) {
1107 2 : SPEED_START {
1108 : /* ensure to use same hardware in the delta step */
1109 1 : raid_gen_force(5, raid_gen5_avx512bw);
1110 : /* +1 to avoid GEN1 optimized case */
1111 1 : raid_recX_avx512bw(5, id, ip, nd, size, v);
1112 1 : } SPEED_STOP
1113 :
1114 1 : printf("%8" PRIu64, ds / dt);
1115 1 : fflush(stdout);
1116 : }
1117 : #endif
1118 : #endif
1119 : #endif
1120 5 : printf("\n");
1121 :
1122 5 : printf("%8s", "rec6");
1123 5 : printf("%8s", raid_rec_tag(RAID_ALGO_CAUCHY_PAR6));
1124 5 : fflush(stdout);
1125 :
1126 10 : SPEED_START {
1127 : /* ensure to use same hardware in the delta step */
1128 5 : raid_gen_force(6, raid_gen6_int8);
1129 5 : raid_recX_int8(6, id, ip, nd, size, v);
1130 5 : } SPEED_STOP
1131 :
1132 5 : printf("%8" PRIu64, ds / dt);
1133 5 : fflush(stdout);
1134 :
1135 : #ifdef CONFIG_X86
1136 : #ifdef CONFIG_SSSE3
1137 5 : if (raid_cpu_has_ssse3()) {
1138 8 : SPEED_START {
1139 : /* ensure to use same hardware in the delta step */
1140 : #ifdef CONFIG_X86_64
1141 4 : raid_gen_force(6, raid_gen6_ssse3ext);
1142 : #else
1143 : raid_gen_force(6, raid_gen6_ssse3);
1144 : #endif
1145 4 : raid_recX_ssse3(6, id, ip, nd, size, v);
1146 4 : } SPEED_STOP
1147 :
1148 4 : printf("%8" PRIu64, ds / dt);
1149 4 : fflush(stdout);
1150 : }
1151 : #endif
1152 : #ifdef CONFIG_AVX2
1153 5 : if (raid_cpu_has_avx2()) {
1154 4 : SPEED_START {
1155 : /* ensure to use same hardware in the delta step */
1156 : #ifdef CONFIG_X86_64
1157 2 : raid_gen_force(6, raid_gen6_avx2ext);
1158 : #else
1159 : raid_gen_force(6, raid_gen6_ssse3);
1160 : #endif
1161 2 : raid_recX_avx2(6, id, ip, nd, size, v);
1162 2 : } SPEED_STOP
1163 :
1164 2 : printf("%8" PRIu64, ds / dt);
1165 2 : fflush(stdout);
1166 : }
1167 : #endif
1168 : #ifdef CONFIG_X86_64
1169 : #ifdef CONFIG_AVX512BW
1170 5 : if (raid_cpu_has_avx512bw()) {
1171 2 : SPEED_START {
1172 : /* ensure to use same hardware in the delta step */
1173 1 : raid_gen_force(6, raid_gen6_avx512bw);
1174 : /* +1 to avoid GEN1 optimized case */
1175 1 : raid_recX_avx512bw(6, id, ip, nd, size, v);
1176 1 : } SPEED_STOP
1177 :
1178 1 : printf("%8" PRIu64, ds / dt);
1179 1 : fflush(stdout);
1180 : }
1181 : #endif
1182 : #endif
1183 : #endif
1184 5 : printf("\n");
1185 5 : printf("\n");
1186 :
1187 5 : printf("If the 'best' expectations are wrong, please report it in the SnapRAID forum\n\n");
1188 :
1189 5 : free(v_alloc);
1190 5 : free(v);
1191 5 : }
1192 :
|