-
-
Save crazyguitar/f5098dd4f44807a363937931740b6301 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---------------------------------------------------------------------- | |
#include <stdio.h> | |
#include <emmintrin.h> | |
#include <immintrin.h> | |
//---------------------------------------------------------------------- | |
void | |
printm256(__m256d r){ | |
double *a = (double*)(&r); | |
printf("%f %f %f %f\n",a[0],a[1],a[2],a[3]); | |
} | |
//---------------------------------------------------------------------- | |
void | |
print4bit(int i){ | |
while(i>0){ | |
printf("%d",i%1); | |
i = i << 1; | |
} | |
printf("\n"); | |
} | |
//---------------------------------------------------------------------- | |
int | |
main(void){ | |
printf("Pack\n"); | |
__m256d r = _mm256_set_pd(1.0,2.0,3.0,4.0); | |
__m256d r2 = _mm256_set_pd(-1.0,-2.0,-3.0,-4.0); | |
printm256(r2); | |
printf("Broadcast\n"); | |
double a = 1.0; | |
printm256(_mm256_broadcast_sd(&a)); | |
printf("Shuffle\n"); | |
for(int i=0;i<16;i++){ | |
printm256(_mm256_shuffle_pd(r,r2,i)); | |
} | |
} | |
//---------------------------------------------------------------------- | |
/* Result | |
$ icpc m256.cc | |
$ ./a.out | |
Pack | |
-4.000000 -3.000000 -2.000000 -1.000000 | |
Broadcast | |
1.000000 1.000000 1.000000 1.000000 | |
Shuffle | |
4.000000 -4.000000 2.000000 -2.000000 | |
3.000000 -4.000000 2.000000 -2.000000 | |
4.000000 -3.000000 2.000000 -2.000000 | |
3.000000 -3.000000 2.000000 -2.000000 | |
4.000000 -4.000000 1.000000 -2.000000 | |
3.000000 -4.000000 1.000000 -2.000000 | |
4.000000 -3.000000 1.000000 -2.000000 | |
3.000000 -3.000000 1.000000 -2.000000 | |
4.000000 -4.000000 2.000000 -1.000000 | |
3.000000 -4.000000 2.000000 -1.000000 | |
4.000000 -3.000000 2.000000 -1.000000 | |
3.000000 -3.000000 2.000000 -1.000000 | |
4.000000 -4.000000 1.000000 -1.000000 | |
3.000000 -4.000000 1.000000 -1.000000 | |
4.000000 -3.000000 1.000000 -1.000000 | |
3.000000 -3.000000 1.000000 -1.000000 | |
*/ | |
//---------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment