How could I pass my code to AVX2 code and get the same result as before?
Is it possible to use __m256i
in the LongNumInit,LongNumPrint functions instead of uint8_t *L
, or some similar type of variable?
My knowledge of AVX is quite limited; I investigated quite a bit however I do not understand very well how to transform my code any suggestion and explanation is welcome.
I'm really interested in this code in AVX2.
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