LCOV - code coverage report
Current view: top level - cmdline - speed.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 473 473 100.0 %
Date: 2017-11-06 22:14:04 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2011 Andrea Mazzoleni
       3             :  *
       4             :  * This program is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 3 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * This program is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "portable.h"
      19             : 
      20             : #include "snapraid.h"
      21             : #include "util.h"
      22             : #include "raid/raid.h"
      23             : #include "raid/cpu.h"
      24             : #include "raid/internal.h"
      25             : #include "raid/memory.h"
      26             : #include "state.h"
      27             : 
      28             : /*
      29             :  * Size of the blocks to test.
      30             :  */
      31             : #define TEST_SIZE (256 * KIBI)
      32             : 
      33             : /*
      34             :  * Number of data blocks to test.
      35             :  */
      36             : #define TEST_COUNT (8)
      37             : 
      38             : /**
      39             :  * Differential us of two timeval.
      40             :  */
      41        2628 : static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop)
      42             : {
      43             :         int64_t d;
      44             : 
      45        2628 :         d = 1000000LL * (stop->tv_sec - start->tv_sec);
      46        2628 :         d += stop->tv_usec - start->tv_usec;
      47             : 
      48        2628 :         return d;
      49             : }
      50             : 
      51             : /**
      52             :  * Start time measurement.
      53             :  */
      54             : #define SPEED_START \
      55             :         count = 0; \
      56             :         gettimeofday(&start, 0); \
      57             :         do { \
      58             :                 for (i = 0; i < delta; ++i)
      59             : 
      60             : /**
      61             :  * Stop time measurement.
      62             :  */
      63             : #define SPEED_STOP \
      64             :                 count += delta; \
      65             :                 gettimeofday(&stop, 0); \
      66             :         } while (diffgettimeofday(&start, &stop) < period * 1000LL) ; \
      67             :         ds = size * (int64_t)count * nd; \
      68             :         dt = diffgettimeofday(&start, &stop);
      69             : 
      70             : /**
      71             :  * Global variable used to propagate side effects.
      72             :  *
      73             :  * This is required to avoid optimizing compilers
      74             :  * to remove code without side effects.
      75             :  */
      76             : static unsigned side_effect;
      77             : 
      78           4 : void speed(int period)
      79             : {
      80             :         struct timeval start;
      81             :         struct timeval stop;
      82             :         int64_t ds;
      83             :         int64_t dt;
      84             :         int i, j;
      85             :         unsigned char digest[HASH_MAX];
      86             :         unsigned char seed[HASH_MAX];
      87             :         int id[RAID_PARITY_MAX];
      88             :         int ip[RAID_PARITY_MAX];
      89             :         int count;
      90           4 :         int delta = period >= 1000 ? 10 : 1;
      91           4 :         int size = TEST_SIZE;
      92           4 :         int nd = TEST_COUNT;
      93             :         int nv;
      94             :         void *v_alloc;
      95             :         void **v;
      96             : 
      97           4 :         nv = nd + RAID_PARITY_MAX + 1;
      98             : 
      99           4 :         v = malloc_nofail_vector_align(nd, nv, size, &v_alloc);
     100             : 
     101             :         /* initialize disks with fixed data */
     102          36 :         for (i = 0; i < nd; ++i)
     103          32 :                 memset(v[i], i, size);
     104             : 
     105             :         /* zero buffer */
     106           4 :         memset(v[nd + RAID_PARITY_MAX], 0, size);
     107           4 :         raid_zero(v[nd + RAID_PARITY_MAX]);
     108             : 
     109             :         /* hash seed */
     110          68 :         for (i = 0; i < HASH_MAX; ++i)
     111          64 :                 seed[i] = i;
     112             : 
     113             :         /* basic disks and parity mapping */
     114          28 :         for (i = 0; i < RAID_PARITY_MAX; ++i) {
     115          24 :                 id[i] = i;
     116          24 :                 ip[i] = i;
     117             :         }
     118             : 
     119           4 :         printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
     120             : 
     121             : #ifdef __GNUC__
     122           4 :         printf("Compiler gcc " __VERSION__ "\n");
     123             : #endif
     124             : 
     125             : #ifdef CONFIG_X86
     126             :         {
     127             :                 char vendor[CPU_VENDOR_MAX];
     128             :                 unsigned family;
     129             :                 unsigned model;
     130             : 
     131           4 :                 raid_cpu_info(vendor, &family, &model);
     132             : 
     133          24 :                 printf("CPU %s, family %u, model %u, flags%s%s%s%s%s%s\n", vendor, family, model,
     134           4 :                         raid_cpu_has_sse2() ? " sse2" : "",
     135           4 :                         raid_cpu_has_ssse3() ? " ssse3" : "",
     136           4 :                         raid_cpu_has_crc32() ? " crc32" : "",
     137           4 :                         raid_cpu_has_avx2() ? " avx2" : "",
     138           4 :                         raid_cpu_has_slowmult() ? " slowmult" : "",
     139           4 :                         raid_cpu_has_slowextendedreg() ? " slowext" : ""
     140             :                 );
     141             :         }
     142             : #else
     143             :         printf("CPU is not a x86/x64\n");
     144             : #endif
     145             : #if WORDS_BIGENDIAN
     146             :         printf("Memory is big-endian %d-bit\n", (int)sizeof(void *) * 8);
     147             : #else
     148           4 :         printf("Memory is little-endian %d-bit\n", (int)sizeof(void *) * 8);
     149             : #endif
     150             : 
     151             : #if HAVE_FUTIMENS
     152           4 :         printf("Support nanosecond timestamps with futimens()\n");
     153             : #elif HAVE_FUTIMES
     154             :         printf("Support nanosecond timestamps with futimes()\n");
     155             : #elif HAVE_FUTIMESAT
     156             :         printf("Support nanosecond timestamps with futimesat()\n");
     157             : #else
     158             :         printf("Does not support nanosecond timestamps\n");
     159             : #endif
     160             : 
     161           4 :         printf("\n");
     162             : 
     163           4 :         printf("Speed test using %u data buffers of %u bytes, for a total of %u KiB.\n", nd, size, nd * size / KIBI);
     164           4 :         printf("Memory blocks have a displacement of %u bytes to improve cache performance.\n", RAID_MALLOC_DISPLACEMENT);
     165           4 :         printf("The reported values are the aggregate bandwidth of all data blocks in MB/s,\n");
     166           4 :         printf("not counting parity blocks.\n");
     167           4 :         printf("\n");
     168             : 
     169           4 :         printf("Memory write speed using the C memset() function:\n");
     170           4 :         printf("%8s", "memset");
     171           4 :         fflush(stdout);
     172             : 
     173         679 :         SPEED_START {
     174        6075 :                 for (j = 0; j < nd; ++j)
     175        5400 :                         memset(v[j], j, size);
     176         675 :         } SPEED_STOP
     177             : 
     178           4 :         printf("%8" PRIu64, ds / dt);
     179           4 :         printf("\n");
     180           4 :         printf("\n");
     181             : 
     182             :         /* crc table */
     183           4 :         printf("CRC used to check the content file integrity:\n");
     184             : 
     185           4 :         printf("%8s", "table");
     186           4 :         fflush(stdout);
     187             : 
     188          48 :         SPEED_START {
     189         396 :                 for (j = 0; j < nd; ++j)
     190         352 :                         side_effect += crc32c_gen(0, v[j], size);
     191          44 :         } SPEED_STOP
     192             : 
     193           4 :         printf("%8" PRIu64, ds / dt);
     194           4 :         printf("\n");
     195             : 
     196           4 :         printf("%8s", "intel");
     197           4 :         fflush(stdout);
     198             : 
     199             : #if HAVE_SSE42
     200           4 :         if (raid_cpu_has_crc32()) {
     201         135 :                 SPEED_START {
     202        1197 :                         for (j = 0; j < nd; ++j)
     203        1064 :                                 side_effect += crc32c_x86(0, v[j], size);
     204         133 :                 } SPEED_STOP
     205             : 
     206           2 :                 printf("%8" PRIu64, ds / dt);
     207             :         }
     208             : #endif
     209           4 :         printf("\n");
     210           4 :         printf("\n");
     211             : 
     212             :         /* hash table */
     213           4 :         printf("Hash used to check the data blocks integrity:\n");
     214             : 
     215           4 :         printf("%8s", "");
     216           4 :         printf("%8s", "best");
     217           4 :         printf("%8s", "murmur3");
     218           4 :         printf("%8s", "spooky2");
     219           4 :         printf("\n");
     220             : 
     221           4 :         printf("%8s", "hash");
     222             : #ifdef CONFIG_X86
     223             :         if (sizeof(void *) == 4 && !raid_cpu_has_slowmult())
     224             :                 printf("%8s", "murmur3");
     225             :         else
     226           4 :                 printf("%8s", "spooky2");
     227             : #else
     228             :         if (sizeof(void *) == 4)
     229             :                 printf("%8s", "murmur3");
     230             :         else
     231             :                 printf("%8s", "spooky2");
     232             : #endif
     233           4 :         fflush(stdout);
     234             : 
     235          16 :         SPEED_START {
     236         108 :                 for (j = 0; j < nd; ++j)
     237          96 :                         memhash(HASH_MURMUR3, seed, digest, v[j], size);
     238          12 :         } SPEED_STOP
     239             : 
     240           4 :         printf("%8" PRIu64, ds / dt);
     241           4 :         fflush(stdout);
     242             : 
     243          40 :         SPEED_START {
     244         324 :                 for (j = 0; j < nd; ++j)
     245         288 :                         memhash(HASH_SPOOKY2, seed, digest, v[j], size);
     246          36 :         } SPEED_STOP
     247             : 
     248           4 :         printf("%8" PRIu64, ds / dt);
     249           4 :         printf("\n");
     250           4 :         printf("\n");
     251             : 
     252             :         /* RAID table */
     253           4 :         printf("RAID functions used for computing the parity with 'sync':\n");
     254           4 :         printf("%8s", "");
     255           4 :         printf("%8s", "best");
     256           4 :         printf("%8s", "int8");
     257           4 :         printf("%8s", "int32");
     258           4 :         printf("%8s", "int64");
     259             : #ifdef CONFIG_X86
     260           4 :         printf("%8s", "sse2");
     261             : #ifdef CONFIG_X86_64
     262           4 :         printf("%8s", "sse2e");
     263             : #endif
     264           4 :         printf("%8s", "ssse3");
     265             : #ifdef CONFIG_X86_64
     266           4 :         printf("%8s", "ssse3e");
     267             : #endif
     268           4 :         printf("%8s", "avx2");
     269             : #ifdef CONFIG_X86_64
     270           4 :         printf("%8s", "avx2e");
     271             : #endif
     272             : #endif
     273           4 :         printf("\n");
     274             : 
     275             :         /* GEN1 */
     276           4 :         printf("%8s", "gen1");
     277           4 :         printf("%8s", raid_gen1_tag());
     278           4 :         fflush(stdout);
     279             : 
     280           4 :         printf("%8s", "");
     281             : 
     282         130 :         SPEED_START {
     283         126 :                 raid_gen1_int32(nd, size, v);
     284         126 :         } SPEED_STOP
     285             : 
     286           4 :         printf("%8" PRIu64, ds / dt);
     287           4 :         fflush(stdout);
     288             : 
     289         246 :         SPEED_START {
     290         242 :                 raid_gen1_int64(nd, size, v);
     291         242 :         } SPEED_STOP
     292             : 
     293           4 :         printf("%8" PRIu64, ds / dt);
     294           4 :         fflush(stdout);
     295             : 
     296             : #ifdef CONFIG_X86
     297             : #ifdef CONFIG_SSE2
     298           4 :         if (raid_cpu_has_sse2()) {
     299         202 :                 SPEED_START {
     300         198 :                         raid_gen1_sse2(nd, size, v);
     301         198 :                 } SPEED_STOP
     302             : 
     303           4 :                 printf("%8" PRIu64, ds / dt);
     304           4 :                 fflush(stdout);
     305             :         }
     306             : #endif
     307             : 
     308             : #ifdef CONFIG_X86_64
     309           4 :         printf("%8s", "");
     310             : #endif
     311           4 :         printf("%8s", "");
     312             : #ifdef CONFIG_X86_64
     313           4 :         printf("%8s", "");
     314             : #endif
     315             : #ifdef CONFIG_AVX2
     316           4 :         if (raid_cpu_has_avx2()) {
     317           2 :                 SPEED_START {
     318           1 :                         raid_gen1_avx2(nd, size, v);
     319           1 :                 } SPEED_STOP
     320             : 
     321           1 :                 printf("%8" PRIu64, ds / dt);
     322           1 :                 fflush(stdout);
     323             :         }
     324             : #endif
     325             : #endif
     326           4 :         printf("\n");
     327             : 
     328             :         /* GEN2 */
     329           4 :         printf("%8s", "gen2");
     330           4 :         printf("%8s", raid_gen2_tag());
     331           4 :         fflush(stdout);
     332             : 
     333           4 :         printf("%8s", "");
     334             : 
     335          52 :         SPEED_START {
     336          48 :                 raid_gen2_int32(nd, size, v);
     337          48 :         } SPEED_STOP
     338             : 
     339           4 :         printf("%8" PRIu64, ds / dt);
     340           4 :         fflush(stdout);
     341             : 
     342          96 :         SPEED_START {
     343          92 :                 raid_gen2_int64(nd, size, v);
     344          92 :         } SPEED_STOP
     345             : 
     346           4 :         printf("%8" PRIu64, ds / dt);
     347           4 :         fflush(stdout);
     348             : 
     349             : #ifdef CONFIG_X86
     350             : #ifdef CONFIG_SSE2
     351           4 :         if (raid_cpu_has_sse2()) {
     352         146 :                 SPEED_START {
     353         142 :                         raid_gen2_sse2(nd, size, v);
     354         142 :                 } SPEED_STOP
     355             : 
     356           4 :                 printf("%8" PRIu64, ds / dt);
     357           4 :                 fflush(stdout);
     358             : 
     359             : #ifdef CONFIG_X86_64
     360         138 :                 SPEED_START {
     361         134 :                         raid_gen2_sse2ext(nd, size, v);
     362         134 :                 } SPEED_STOP
     363             : 
     364           4 :                 printf("%8" PRIu64, ds / dt);
     365           4 :                 fflush(stdout);
     366             : #endif
     367             :         }
     368             : #endif
     369             : 
     370           4 :         printf("%8s", "");
     371             : #ifdef CONFIG_X86_64
     372           4 :         printf("%8s", "");
     373             : #endif
     374             : #ifdef CONFIG_AVX2
     375           4 :         if (raid_cpu_has_avx2()) {
     376           5 :                 SPEED_START {
     377           4 :                         raid_gen2_avx2(nd, size, v);
     378           4 :                 } SPEED_STOP
     379             : 
     380           1 :                 printf("%8" PRIu64, ds / dt);
     381           1 :                 fflush(stdout);
     382             :         }
     383             : #endif
     384             : #endif
     385           4 :         printf("\n");
     386             : 
     387             :         /* GENz */
     388           4 :         printf("%8s", "genz");
     389           4 :         printf("%8s", raid_genz_tag());
     390           4 :         fflush(stdout);
     391             : 
     392           4 :         printf("%8s", "");
     393             : 
     394          34 :         SPEED_START {
     395          30 :                 raid_genz_int32(nd, size, v);
     396          30 :         } SPEED_STOP
     397             : 
     398           4 :         printf("%8" PRIu64, ds / dt);
     399           4 :         fflush(stdout);
     400             : 
     401          62 :         SPEED_START {
     402          58 :                 raid_genz_int64(nd, size, v);
     403          58 :         } SPEED_STOP
     404             : 
     405           4 :         printf("%8" PRIu64, ds / dt);
     406           4 :         fflush(stdout);
     407             : 
     408             : #ifdef CONFIG_X86
     409             : #ifdef CONFIG_SSE2
     410           4 :         if (raid_cpu_has_sse2()) {
     411         107 :                 SPEED_START {
     412         103 :                         raid_genz_sse2(nd, size, v);
     413         103 :                 } SPEED_STOP
     414             : 
     415           4 :                 printf("%8" PRIu64, ds / dt);
     416           4 :                 fflush(stdout);
     417             : 
     418             : #ifdef CONFIG_X86_64
     419          94 :                 SPEED_START {
     420          90 :                         raid_genz_sse2ext(nd, size, v);
     421          90 :                 } SPEED_STOP
     422             : 
     423           4 :                 printf("%8" PRIu64, ds / dt);
     424           4 :                 fflush(stdout);
     425             : #endif
     426             :         }
     427             : #endif
     428             : 
     429           4 :         printf("%8s", "");
     430             : #ifdef CONFIG_X86_64
     431           4 :         printf("%8s", "");
     432             : #endif
     433           4 :         printf("%8s", "");
     434             : 
     435             : #ifdef CONFIG_X86_64
     436             : #ifdef CONFIG_AVX2
     437           4 :         if (raid_cpu_has_avx2()) {
     438           2 :                 SPEED_START {
     439           1 :                         raid_genz_avx2ext(nd, size, v);
     440           1 :                 } SPEED_STOP
     441             : 
     442           1 :                 printf("%8" PRIu64, ds / dt);
     443           1 :                 fflush(stdout);
     444             :         }
     445             : #endif
     446             : #endif
     447             : #endif
     448           4 :         printf("\n");
     449             : 
     450             :         /* GEN3 */
     451           4 :         printf("%8s", "gen3");
     452           4 :         printf("%8s", raid_gen3_tag());
     453           4 :         fflush(stdout);
     454             : 
     455          16 :         SPEED_START {
     456          12 :                 raid_gen3_int8(nd, size, v);
     457          12 :         } SPEED_STOP
     458             : 
     459           4 :         printf("%8" PRIu64, ds / dt);
     460           4 :         fflush(stdout);
     461             : 
     462           4 :         printf("%8s", "");
     463           4 :         printf("%8s", "");
     464             : 
     465             : #ifdef CONFIG_X86
     466           4 :         if (raid_cpu_has_sse2()) {
     467           4 :                 printf("%8s", "");
     468             : 
     469             : #ifdef CONFIG_X86_64
     470           4 :                 printf("%8s", "");
     471             : #endif
     472             :         }
     473             : #endif
     474             : 
     475             : #ifdef CONFIG_X86
     476             : #ifdef CONFIG_SSSE3
     477           4 :         if (raid_cpu_has_ssse3()) {
     478          46 :                 SPEED_START {
     479          43 :                         raid_gen3_ssse3(nd, size, v);
     480          43 :                 } SPEED_STOP
     481             : 
     482           3 :                 printf("%8" PRIu64, ds / dt);
     483           3 :                 fflush(stdout);
     484             : 
     485             : #ifdef CONFIG_X86_64
     486          55 :                 SPEED_START {
     487          52 :                         raid_gen3_ssse3ext(nd, size, v);
     488          52 :                 } SPEED_STOP
     489             : 
     490           3 :                 printf("%8" PRIu64, ds / dt);
     491           3 :                 fflush(stdout);
     492             : #endif
     493             :         }
     494             : #endif
     495             : 
     496           4 :         printf("%8s", "");
     497             : 
     498             : #ifdef CONFIG_X86_64
     499             : #ifdef CONFIG_AVX2
     500           4 :         if (raid_cpu_has_avx2()) {
     501           3 :                 SPEED_START {
     502           2 :                         raid_gen3_avx2ext(nd, size, v);
     503           2 :                 } SPEED_STOP
     504             : 
     505           1 :                 printf("%8" PRIu64, ds / dt);
     506           1 :                 fflush(stdout);
     507             :         }
     508             : #endif
     509             : #endif
     510             : #endif
     511           4 :         printf("\n");
     512             : 
     513             :         /* GEN4 */
     514           4 :         printf("%8s", "gen4");
     515           4 :         printf("%8s", raid_gen4_tag());
     516           4 :         fflush(stdout);
     517             : 
     518          15 :         SPEED_START {
     519          11 :                 raid_gen4_int8(nd, size, v);
     520          11 :         } SPEED_STOP
     521             : 
     522           4 :         printf("%8" PRIu64, ds / dt);
     523           4 :         fflush(stdout);
     524             : 
     525           4 :         printf("%8s", "");
     526           4 :         printf("%8s", "");
     527             : 
     528             : #ifdef CONFIG_X86
     529             : #ifdef CONFIG_SSE2
     530           4 :         if (raid_cpu_has_sse2()) {
     531           4 :                 printf("%8s", "");
     532             : 
     533             : #ifdef CONFIG_X86_64
     534           4 :                 printf("%8s", "");
     535             : #endif
     536             :         }
     537             : #endif
     538             : #endif
     539             : 
     540             : #ifdef CONFIG_X86
     541             : #ifdef CONFIG_SSSE3
     542           4 :         if (raid_cpu_has_ssse3()) {
     543          23 :                 SPEED_START {
     544          20 :                         raid_gen4_ssse3(nd, size, v);
     545          20 :                 } SPEED_STOP
     546             : 
     547           3 :                 printf("%8" PRIu64, ds / dt);
     548           3 :                 fflush(stdout);
     549             : 
     550             : #ifdef CONFIG_X86_64
     551          29 :                 SPEED_START {
     552          26 :                         raid_gen4_ssse3ext(nd, size, v);
     553          26 :                 } SPEED_STOP
     554             : 
     555           3 :                 printf("%8" PRIu64, ds / dt);
     556           3 :                 fflush(stdout);
     557             : #endif
     558             :         }
     559             : #endif
     560             : 
     561           4 :         printf("%8s", "");
     562             : 
     563             : #ifdef CONFIG_X86_64
     564             : #ifdef CONFIG_AVX2
     565           4 :         if (raid_cpu_has_avx2()) {
     566           2 :                 SPEED_START {
     567           1 :                         raid_gen4_avx2ext(nd, size, v);
     568           1 :                 } SPEED_STOP
     569             : 
     570           1 :                 printf("%8" PRIu64, ds / dt);
     571           1 :                 fflush(stdout);
     572             :         }
     573             : #endif
     574             : #endif
     575             : #endif
     576           4 :         printf("\n");
     577             : 
     578             :         /* GEN5 */
     579           4 :         printf("%8s", "gen5");
     580           4 :         printf("%8s", raid_gen5_tag());
     581           4 :         fflush(stdout);
     582             : 
     583          12 :         SPEED_START {
     584           8 :                 raid_gen5_int8(nd, size, v);
     585           8 :         } SPEED_STOP
     586             : 
     587           4 :         printf("%8" PRIu64, ds / dt);
     588           4 :         fflush(stdout);
     589             : 
     590           4 :         printf("%8s", "");
     591           4 :         printf("%8s", "");
     592             : 
     593             : #ifdef CONFIG_X86
     594             : #ifdef CONFIG_SSE2
     595           4 :         if (raid_cpu_has_sse2()) {
     596           4 :                 printf("%8s", "");
     597             : 
     598             : #ifdef CONFIG_X86_64
     599           4 :                 printf("%8s", "");
     600             : #endif
     601             :         }
     602             : #endif
     603             : #endif
     604             : 
     605             : #ifdef CONFIG_X86
     606             : #ifdef CONFIG_SSSE3
     607           4 :         if (raid_cpu_has_ssse3()) {
     608          15 :                 SPEED_START {
     609          12 :                         raid_gen5_ssse3(nd, size, v);
     610          12 :                 } SPEED_STOP
     611             : 
     612           3 :                 printf("%8" PRIu64, ds / dt);
     613           3 :                 fflush(stdout);
     614             : 
     615             : #ifdef CONFIG_X86_64
     616          23 :                 SPEED_START {
     617          20 :                         raid_gen5_ssse3ext(nd, size, v);
     618          20 :                 } SPEED_STOP
     619             : 
     620           3 :                 printf("%8" PRIu64, ds / dt);
     621           3 :                 fflush(stdout);
     622             : #endif
     623             :         }
     624             : #endif
     625             : 
     626           4 :         printf("%8s", "");
     627             : 
     628             : #ifdef CONFIG_X86_64
     629             : #ifdef CONFIG_AVX2
     630           4 :         if (raid_cpu_has_avx2()) {
     631           2 :                 SPEED_START {
     632           1 :                         raid_gen5_avx2ext(nd, size, v);
     633           1 :                 } SPEED_STOP
     634             : 
     635           1 :                 printf("%8" PRIu64, ds / dt);
     636           1 :                 fflush(stdout);
     637             :         }
     638             : #endif
     639             : #endif
     640             : #endif
     641           4 :         printf("\n");
     642             : 
     643             :         /* GEN6 */
     644           4 :         printf("%8s", "gen6");
     645           4 :         printf("%8s", raid_gen6_tag());
     646           4 :         fflush(stdout);
     647             : 
     648          12 :         SPEED_START {
     649           8 :                 raid_gen6_int8(nd, size, v);
     650           8 :         } SPEED_STOP
     651             : 
     652           4 :         printf("%8" PRIu64, ds / dt);
     653           4 :         fflush(stdout);
     654             : 
     655           4 :         printf("%8s", "");
     656           4 :         printf("%8s", "");
     657             : 
     658             : #ifdef CONFIG_X86
     659             : #ifdef CONFIG_SSE2
     660           4 :         if (raid_cpu_has_sse2()) {
     661           4 :                 printf("%8s", "");
     662             : 
     663             : #ifdef CONFIG_X86_64
     664           4 :                 printf("%8s", "");
     665             : #endif
     666             :         }
     667             : #endif
     668             : #endif
     669             : 
     670             : #ifdef CONFIG_X86
     671             : #ifdef CONFIG_SSSE3
     672           4 :         if (raid_cpu_has_ssse3()) {
     673          13 :                 SPEED_START {
     674          10 :                         raid_gen6_ssse3(nd, size, v);
     675          10 :                 } SPEED_STOP
     676             : 
     677           3 :                 printf("%8" PRIu64, ds / dt);
     678           3 :                 fflush(stdout);
     679             : 
     680             : #ifdef CONFIG_X86_64
     681          21 :                 SPEED_START {
     682          18 :                         raid_gen6_ssse3ext(nd, size, v);
     683          18 :                 } SPEED_STOP
     684             : 
     685           3 :                 printf("%8" PRIu64, ds / dt);
     686           3 :                 fflush(stdout);
     687             : #endif
     688             :         }
     689             : #endif
     690             : 
     691           4 :         printf("%8s", "");
     692             : 
     693             : #ifdef CONFIG_X86_64
     694             : #ifdef CONFIG_AVX2
     695           4 :         if (raid_cpu_has_avx2()) {
     696           2 :                 SPEED_START {
     697           1 :                         raid_gen6_avx2ext(nd, size, v);
     698           1 :                 } SPEED_STOP
     699             : 
     700           1 :                 printf("%8" PRIu64, ds / dt);
     701           1 :                 fflush(stdout);
     702             :         }
     703             : #endif
     704             : #endif
     705             : #endif
     706           4 :         printf("\n");
     707           4 :         printf("\n");
     708             : 
     709             :         /* recover table */
     710           4 :         printf("RAID functions used for recovering with 'fix':\n");
     711           4 :         printf("%8s", "");
     712           4 :         printf("%8s", "best");
     713           4 :         printf("%8s", "int8");
     714             : #ifdef CONFIG_X86
     715           4 :         printf("%8s", "ssse3");
     716           4 :         printf("%8s", "avx2");
     717             : #endif
     718           4 :         printf("\n");
     719             : 
     720           4 :         printf("%8s", "rec1");
     721           4 :         printf("%8s", raid_rec1_tag());
     722           4 :         fflush(stdout);
     723             : 
     724          11 :         SPEED_START {
     725          63 :                 for (j = 0; j < nd; ++j)
     726             :                         /* +1 to avoid GEN1 optimized case */
     727          56 :                         raid_rec1_int8(1, id, ip + 1, nd, size, v);
     728           7 :         } SPEED_STOP
     729             : 
     730           4 :         printf("%8" PRIu64, ds / dt);
     731           4 :         fflush(stdout);
     732             : 
     733             : #ifdef CONFIG_X86
     734             : #ifdef CONFIG_SSSE3
     735           4 :         if (raid_cpu_has_ssse3()) {
     736          10 :                 SPEED_START {
     737          63 :                         for (j = 0; j < nd; ++j)
     738             :                                 /* +1 to avoid GEN1 optimized case */
     739          56 :                                 raid_rec1_ssse3(1, id, ip + 1, nd, size, v);
     740           7 :                 } SPEED_STOP
     741             : 
     742           3 :                 printf("%8" PRIu64, ds / dt);
     743             :         }
     744             : #endif
     745             : #ifdef CONFIG_AVX2
     746           4 :         if (raid_cpu_has_avx2()) {
     747           2 :                 SPEED_START {
     748           9 :                         for (j = 0; j < nd; ++j)
     749             :                                 /* +1 to avoid GEN1 optimized case */
     750           8 :                                 raid_rec1_avx2(1, id, ip + 1, nd, size, v);
     751           1 :                 } SPEED_STOP
     752             : 
     753           1 :                 printf("%8" PRIu64, ds / dt);
     754             :         }
     755             : #endif
     756             : #endif
     757           4 :         printf("\n");
     758             : 
     759           4 :         printf("%8s", "rec2");
     760           4 :         printf("%8s", raid_rec2_tag());
     761           4 :         fflush(stdout);
     762             : 
     763           8 :         SPEED_START {
     764          36 :                 for (j = 0; j < nd; ++j)
     765             :                         /* +1 to avoid GEN2 optimized case */
     766          32 :                         raid_rec2_int8(2, id, ip + 1, nd, size, v);
     767           4 :         } SPEED_STOP
     768             : 
     769           4 :         printf("%8" PRIu64, ds / dt);
     770           4 :         fflush(stdout);
     771             : 
     772             : #ifdef CONFIG_X86
     773             : #ifdef CONFIG_SSSE3
     774           4 :         if (raid_cpu_has_ssse3()) {
     775           8 :                 SPEED_START {
     776          45 :                         for (j = 0; j < nd; ++j)
     777             :                                 /* +1 to avoid GEN2 optimized case */
     778          40 :                                 raid_rec2_ssse3(2, id, ip + 1, nd, size, v);
     779           5 :                 } SPEED_STOP
     780             : 
     781           3 :                 printf("%8" PRIu64, ds / dt);
     782             :         }
     783             : #endif
     784             : #ifdef CONFIG_AVX2
     785           4 :         if (raid_cpu_has_avx2()) {
     786           2 :                 SPEED_START {
     787           9 :                         for (j = 0; j < nd; ++j)
     788             :                                 /* +1 to avoid GEN1 optimized case */
     789           8 :                                 raid_rec2_avx2(2, id, ip + 1, nd, size, v);
     790           1 :                 } SPEED_STOP
     791             : 
     792           1 :                 printf("%8" PRIu64, ds / dt);
     793             :         }
     794             : #endif
     795             : #endif
     796           4 :         printf("\n");
     797             : 
     798           4 :         printf("%8s", "rec3");
     799           4 :         printf("%8s", raid_recX_tag());
     800           4 :         fflush(stdout);
     801             : 
     802           8 :         SPEED_START {
     803          36 :                 for (j = 0; j < nd; ++j)
     804          32 :                         raid_recX_int8(3, id, ip, nd, size, v);
     805           4 :         } SPEED_STOP
     806             : 
     807           4 :         printf("%8" PRIu64, ds / dt);
     808           4 :         fflush(stdout);
     809             : 
     810             : #ifdef CONFIG_X86
     811             : #ifdef CONFIG_SSSE3
     812           4 :         if (raid_cpu_has_ssse3()) {
     813           6 :                 SPEED_START {
     814          27 :                         for (j = 0; j < nd; ++j)
     815          24 :                                 raid_recX_ssse3(3, id, ip, nd, size, v);
     816           3 :                 } SPEED_STOP
     817             : 
     818           3 :                 printf("%8" PRIu64, ds / dt);
     819             :         }
     820             : #endif
     821             : #ifdef CONFIG_AVX2
     822           4 :         if (raid_cpu_has_avx2()) {
     823           2 :                 SPEED_START {
     824           9 :                         for (j = 0; j < nd; ++j)
     825           8 :                                 raid_recX_avx2(3, id, ip, nd, size, v);
     826           1 :                 } SPEED_STOP
     827             : 
     828           1 :                 printf("%8" PRIu64, ds / dt);
     829             :         }
     830             : #endif
     831             : #endif
     832           4 :         printf("\n");
     833             : 
     834           4 :         printf("%8s", "rec4");
     835           4 :         printf("%8s", raid_recX_tag());
     836           4 :         fflush(stdout);
     837             : 
     838           8 :         SPEED_START {
     839          36 :                 for (j = 0; j < nd; ++j)
     840          32 :                         raid_recX_int8(4, id, ip, nd, size, v);
     841           4 :         } SPEED_STOP
     842             : 
     843           4 :         printf("%8" PRIu64, ds / dt);
     844           4 :         fflush(stdout);
     845             : 
     846             : #ifdef CONFIG_X86
     847             : #ifdef CONFIG_SSSE3
     848           4 :         if (raid_cpu_has_ssse3()) {
     849           6 :                 SPEED_START {
     850          27 :                         for (j = 0; j < nd; ++j)
     851          24 :                                 raid_recX_ssse3(4, id, ip, nd, size, v);
     852           3 :                 } SPEED_STOP
     853             : 
     854           3 :                 printf("%8" PRIu64, ds / dt);
     855             :         }
     856             : #endif
     857             : #ifdef CONFIG_AVX2
     858           4 :         if (raid_cpu_has_avx2()) {
     859           2 :                 SPEED_START {
     860           9 :                         for (j = 0; j < nd; ++j)
     861           8 :                                 raid_recX_avx2(4, id, ip, nd, size, v);
     862           1 :                 } SPEED_STOP
     863             : 
     864           1 :                 printf("%8" PRIu64, ds / dt);
     865             :         }
     866             : #endif
     867             : #endif
     868           4 :         printf("\n");
     869             : 
     870           4 :         printf("%8s", "rec5");
     871           4 :         printf("%8s", raid_recX_tag());
     872           4 :         fflush(stdout);
     873             : 
     874           8 :         SPEED_START {
     875          36 :                 for (j = 0; j < nd; ++j)
     876          32 :                         raid_recX_int8(5, id, ip, nd, size, v);
     877           4 :         } SPEED_STOP
     878             : 
     879           4 :         printf("%8" PRIu64, ds / dt);
     880           4 :         fflush(stdout);
     881             : 
     882             : #ifdef CONFIG_X86
     883             : #ifdef CONFIG_SSSE3
     884           4 :         if (raid_cpu_has_ssse3()) {
     885           6 :                 SPEED_START {
     886          27 :                         for (j = 0; j < nd; ++j)
     887          24 :                                 raid_recX_ssse3(5, id, ip, nd, size, v);
     888           3 :                 } SPEED_STOP
     889             : 
     890           3 :                 printf("%8" PRIu64, ds / dt);
     891             :         }
     892             : #endif
     893             : #ifdef CONFIG_AVX2
     894           4 :         if (raid_cpu_has_avx2()) {
     895           2 :                 SPEED_START {
     896           9 :                         for (j = 0; j < nd; ++j)
     897           8 :                                 raid_recX_avx2(5, id, ip, nd, size, v);
     898           1 :                 } SPEED_STOP
     899             : 
     900           1 :                 printf("%8" PRIu64, ds / dt);
     901             :         }
     902             : #endif
     903             : #endif
     904           4 :         printf("\n");
     905             : 
     906           4 :         printf("%8s", "rec6");
     907           4 :         printf("%8s", raid_recX_tag());
     908           4 :         fflush(stdout);
     909             : 
     910           8 :         SPEED_START {
     911          36 :                 for (j = 0; j < nd; ++j)
     912          32 :                         raid_recX_int8(6, id, ip, nd, size, v);
     913           4 :         } SPEED_STOP
     914             : 
     915           4 :         printf("%8" PRIu64, ds / dt);
     916           4 :         fflush(stdout);
     917             : 
     918             : #ifdef CONFIG_X86
     919             : #ifdef CONFIG_SSSE3
     920           4 :         if (raid_cpu_has_ssse3()) {
     921           6 :                 SPEED_START {
     922          27 :                         for (j = 0; j < nd; ++j)
     923          24 :                                 raid_recX_ssse3(6, id, ip, nd, size, v);
     924           3 :                 } SPEED_STOP
     925             : 
     926           3 :                 printf("%8" PRIu64, ds / dt);
     927             :         }
     928             : #endif
     929             : #ifdef CONFIG_AVX2
     930           4 :         if (raid_cpu_has_avx2()) {
     931           2 :                 SPEED_START {
     932           9 :                         for (j = 0; j < nd; ++j)
     933           8 :                                 raid_recX_avx2(6, id, ip, nd, size, v);
     934           1 :                 } SPEED_STOP
     935             : 
     936           1 :                 printf("%8" PRIu64, ds / dt);
     937             :         }
     938             : #endif
     939             : #endif
     940           4 :         printf("\n");
     941           4 :         printf("\n");
     942             : 
     943           4 :         printf("If the 'best' expectations are wrong, please report it in the SnapRAID forum\n\n");
     944             : 
     945           4 :         free(v_alloc);
     946           4 :         free(v);
     947           4 : }
     948             : 

Generated by: LCOV version 1.13