Quantcast
Viewing all articles
Browse latest Browse all 22171

How I transform this code to AVX? (gcc 8.2)

How could I pass my code to AVX2 code and get the same result as before?, to be more efficient especially in more complex functions.It is possible to use in The LongNumInit,LongNumPrint functions instead of uint8_t *L __m256i or some similar type of variable? My knowledge at AVX are quite lymitted I investigated quite a bit however I do not understand very well how to transform my code any suggestion and explanation is welcome.This is the code:

void LongNumInit(uint8_t *L, size_t N ){  for(size_t i = 0; i < N; ++i){      L[i] = myRandom()%10;  }}void LongNumPrint( uint8_t *L, size_t N, uint8_t *Name ){  printf("%s:", Name);  for ( size_t i=N; i>0;--i )  {    printf("%d", L[i-1]);  }  printf("\n");}int main (int argc, char **argv){  int i, sum1, sum2, sum3, N=10000, Rep=50;  seed = 12345;  // obtain parameters at run time  if (argc>1) { N    = atoi(argv[1]); }  if (argc>2) { Rep  = atoi(argv[2]); } // Create Long Nums  unsigned char *V1= (unsigned char*) malloc( N);  unsigned char *V2= (unsigned char*) malloc( N);  unsigned char *V3= (unsigned char*) malloc( N);  unsigned char *V4= (unsigned char*) malloc( N);  LongNumInit ( V1, N ); LongNumInit ( V2, N ); LongNumInit ( V3, N );//Print last 32 digits of Long Numbers  LongNumPrint( V1, 32, "V1" ); LongNumPrint( V2, 32, "V2" );  LongNumPrint( V3, 32, "V3" );  LongNumPrint( V4, 32, "V4" );  free(V1); free(V2); free(V3); free(V4);  return 0;}

The result that I obtain in my initial code is this:

V1:59348245908804493219098067811457V2:24890422397351614779297691741341V3:63392771324953818089038280656869V4:00000000000000000000000000000000

Viewing all articles
Browse latest Browse all 22171


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>