📄 testvmx.c
字号:
else printf("Function vec_cmpgt [type integer] ===> OK\n"); err = 0; BIaux1.v = vec_cmpgt( UIcons1, UIcons2 ); UIaux2.v = UIcons1; UIaux3.v = UIcons2; for( i=0; i< 4; i++ ) { if (UIaux2.e[i] > UIaux3.e[i]) BIaux=0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmpgt [type unsigned int] ===> Error\n"); else printf("Function vec_cmpgt [type unsigned int] ===> OK\n");#if defined TEST_FLOATS err = 0; BIaux1.v = vec_cmpgt( Fcons1, Fcons2 ); Faux2.v = Fcons1; Faux3.v = Fcons2; for( i=0; i< 4; i++ ) { if (Faux2.e[i] > Faux3.e[i]) BIaux = 0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmpgt [type float] ===> Error\n"); else printf("Function vec_cmpgt [type float] ===> OK\n");#endif#if defined TEST_FLOATS/* Function vec_cmple */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; BIaux1.v = vec_cmple( Fcons1, Fcons2 ); Faux2.v = Fcons1; Faux3.v = Fcons2; for( i=0; i< 4; i++ ) { if (Faux2.e[i] <= Faux3.e[i]) BIaux = 0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmple [type float] ===> Error\n"); else printf("Function vec_cmple [type float] ===> OK\n");#endif/* Function vec_cmplt */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; BCaux1.v = vec_cmplt( Ccons1, Ccons2 ); Caux2.v = Ccons1; Caux3.v = Ccons2; for( i=0; i< 16; i++ ) { if (Caux2.e[i] < Caux3.e[i]) BCaux = 0xFF; else BCaux = 0; if (BCaux1.e[i] != BCaux) err++; } if (err) printf("Function vec_cmplt [type char] ===> Error\n"); else printf("Function vec_cmplt [type char] ===> OK\n"); err = 0; BCaux1.v = vec_cmplt( UCcons1, UCcons2 ); UCaux2.v = UCcons1; UCaux3.v = UCcons2; for( i=0; i< 16; i++ ) { if (UCaux2.e[i] < UCaux3.e[i]) BCaux = 0xFF; else BCaux = 0; if (BCaux1.e[i] != BCaux) err++; } if (err) printf("Function vec_cmplt [type unsigned char] ===> Error\n"); else printf("Function vec_cmplt [type unsigned char] ===> OK\n"); err = 0; BSaux1.v = vec_cmplt( Scons1, Scons2 ); Saux2.v = Scons1; Saux3.v = Scons2; for( i=0; i< 8; i++ ) { if (Saux2.e[i] < Saux3.e[i]) BSaux = 0xFFFF; else BSaux = 0; if (BSaux1.e[i] != BSaux) err++; } if (err) printf("Function vec_cmplt [type short] ===> Error\n"); else printf("Function vec_cmplt [type short] ===> OK\n"); err = 0; BSaux1.v = vec_cmplt( UScons1, UScons2 ); USaux2.v = UScons1; USaux3.v = UScons2; for( i=0; i< 8; i++ ) { if (USaux2.e[i] < USaux3.e[i]) BSaux = 0xFFFF; else BSaux = 0; if (BSaux1.e[i] != BSaux) err++; } if (err) printf("Function vec_cmplt [type unsigned short] ===> Error\n"); else printf("Function vec_cmplt [type unsigned short] ===> OK\n"); err = 0; BIaux1.v = vec_cmplt( Icons1, Icons2 ); Iaux2.v = Icons1; Iaux3.v = Icons2; for( i=0; i< 4; i++ ) { if (Iaux2.e[i] < Iaux3.e[i]) BIaux = 0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmplt [type integer] ===> Error\n"); else printf("Function vec_cmplt [type integer] ===> OK\n"); err = 0; BIaux1.v = vec_cmplt( UIcons1, UIcons2 ); UIaux2.v = UIcons1; UIaux3.v = UIcons2; for( i=0; i< 4; i++ ) { if (UIaux2.e[i] < UIaux3.e[i]) BIaux=0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmplt [type unsigned int] ===> Error\n"); else printf("Function vec_cmplt [type unsigned int] ===> OK\n");#if defined TEST_FLOATS err = 0; BIaux1.v = vec_cmplt( Fcons1, Fcons2 ); Faux2.v = Fcons1; Faux3.v = Fcons2; for( i=0; i< 4; i++ ) { if (Faux2.e[i] < Faux3.e[i]) BIaux = 0xFFFFFFFF; else BIaux = 0; if (BIaux1.e[i] != BIaux) err++; } if (err) printf("Function vec_cmplt [type float] ===> Error\n"); else printf("Function vec_cmplt [type float] ===> OK\n");#endif#if defined TEST_FLOATS/* Function vec_ctf */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; b = 2; Faux1.v = vec_ctf( Icons1, 2 ); Iaux1.v = Icons1; for( i=0; i< 4; i++ ) if (Faux1.e[i] != (((float)Iaux1.e[i])/(1<<b))) err++; if (err) printf("Function vec_ctf [type integer] ===> Error\n"); else printf("Function vec_ctf [type integer] ===> OK\n"); err = 0; b = 2; Faux1.v = vec_ctf( UIcons1, 2 ); UIaux1.v = UIcons1; for( i=0; i< 4; i++ ) if (Faux1.e[i] != (((float)UIaux1.e[i])/(1<<b))) err++; if (err) printf("Function vec_ctf [type unsigned int] ===> Error\n"); else printf("Function vec_ctf [type unsigned int] ===> OK\n");#endif#if defined TEST_FLOATS/* Function vec_cts */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; b = 2; Iaux1.v = vec_cts( Fcons3, 2 ); Faux1.v = Fcons3; for( i=0; i< 4; i++ ) if (Iaux1.e[i] != (int)(Faux1.e[i]*(1<<b))) err++; if (err) printf("Function vec_cts [type float] ===> Error\n"); else printf("Function vec_cts [type float] ===> OK\n");#endif#if defined TEST_FLOATS/* Function vec_ctu */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; b = 2; UIaux1.v = vec_ctu( Fcons3, 2 ); Faux1.v = Fcons3; for( i=0; i< 4; i++ ) { double d = Faux1.e[i]*(1<<b); if (d > 0xffffffff) d = 0xffffffff; if (d < 0) d = 0; if (UIaux1.e[i] != (unsigned int)(d)) err++; } if (err) printf("Function vec_ctu [type float] ===> Error\n"); else printf("Function vec_ctu [type float] ===> OK\n");#endif part1(); part2(); part3(); part4(); part5(); return 0;}int part1(){ TvecChar Caux1;//, Caux2, Caux3, Caux4; TvecUChar UCaux1;//, UCaux2, UCaux3, UCaux4; TvecShort Saux1;//, Saux2, Saux3, Saux4; TvecUShort USaux1;//, USaux2, USaux3, USaux4; TvecInt Iaux1;//, Iaux2, Iaux3, Iaux4; TvecUInt UIaux1;//, UIaux2, UIaux3, UIaux4;#if defined TEST_FLOATS TvecFloat Faux1, Faux2;//, Faux3, Faux4;#endif int i, err, j;//, b, bAux;// signed int Ivec1, Ivec2, Ivec3;// signed short *Svec1;// unsigned int *UIvec1;// unsigned short *USvec1;// unsigned char *UCvec1;#if defined TEST_FLOATS// float *Fvec1;#endif /* For saturated rutines */// long long int LLaux;#if defined TEST_FLOATS float Faux;#endif signed int Iaux;//, I1, I2;// unsigned int UIaux, UI1, UI2;// signed short Saux;// unsigned short USaux;// signed char Caux;// unsigned char UCaux;/* union { float f; signed int si; unsigned int ui; signed short ss[2]; unsigned short us[2]; signed char sc[4]; unsigned char uc[4]; } INTunion1, INTunion2; union { signed short ss; unsigned short us; signed char sc[2]; unsigned char uc[2]; } SHOunion1, SHOunion2;*/#if defined (GCC_COMPILER) vector signed char Ccons1 = (vector signed char){-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7};// vector signed char Ccons2 = (vector signed char){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};// vector signed char Ccons3 = (vector signed char){-128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127}; vector unsigned char UCcons1 = (vector unsigned char){248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7};// vector unsigned char UCcons2 = (vector unsigned char){2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};// vector unsigned char UCcons3 = (vector unsigned char){1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8}; vector signed short Scons1 = (vector signed short){-4, -3, -2, -1, 0, 1, 2, 3};// vector signed short Scons2 = (vector signed short){-32768, 10000, 1, 1, 1, 1, -10000, -10000};// vector signed short Scons3 = (vector signed short){-32768, 32767, -32768, 32767, -32768, 32767, -32768, 32767};// vector unsigned short UScons1 = (vector unsigned short){65532, 65533, 65534, 65535, 0, 1, 2, 3};// vector unsigned short UScons2 = (vector unsigned short){1, 1, 1, 1, 1, 1, 1, 1}; vector unsigned short UScons3 = (vector unsigned short){1, 2, 3, 4, 1, 2, 3, 4}; vector signed int Icons1 = (vector signed int){-4, -1, 1, 4};// vector signed int Icons2 = (vector signed int){1, 1, 1, 1};// vector signed int Icons3 = (vector signed int){0x80000000, 0x7FFFFFFF, 0x80000000, 0x7FFFFFFF}; vector unsigned int UIcons1 = (vector unsigned int){0xFFFFFFFE, 0xFFFFFFFF, 0, 1};// vector unsigned int UIcons2 = (vector unsigned int){1, 1, 1, 1};// vector unsigned int UIcons3 = (vector unsigned int){1, 2, 1, 2};#if defined TEST_FLOATS vector float Fcons1 = (vector float){-1.5, 1.0, 0.5, -3.999};// vector float Fcons2 = (vector float){1.0, 1.0, 1.0, 1.0}; vector float Fcons3 = (vector float){100000000000.0, 1.0, -1.0, -1234567890.0};#endif#elif defined (MAC_COMPILER) || defined (XLC_COMPILER) vector signed char Ccons1 = (vector signed char)(-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7); vector signed char Ccons2 = (vector signed char)(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); vector signed char Ccons3 = (vector signed char)(-128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 127); vector unsigned char UCcons1 = (vector unsigned char)(248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7); vector unsigned char UCcons2 = (vector unsigned char)(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); vector unsigned char UCcons3 = (vector unsigned char)(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8); vector signed short Scons1 = (vector signed short)(-4, -3, -2, -1, 0, 1, 2, 3); vector signed short Scons2 = (vector signed short)(-32768, 10000, 1, 1, 1, 1, -10000, -10000); vector signed short Scons3 = (vector signed short)(-32768, 32767, -32768, 32767, -32768, 32767, -32768, 32767); vector unsigned short UScons1 = (vector unsigned short)(65532, 65533, 65534, 65535, 0, 1, 2, 3); vector unsigned short UScons2 = (vector unsigned short)(1, 1, 1, 1, 1, 1, 1, 1); vector unsigned short UScons3 = (vector unsigned short)(1, 2, 3, 4, 1, 2, 3, 4); vector signed int Icons1 = (vector signed int)(-4, -1, 1, 4); vector signed int Icons2 = (vector signed int)(1, 1, 1, 1); vector signed int Icons3 = (vector signed int)(0x80000000, 0x7FFFFFFF, 0x80000000, 0x7FFFFFFF); vector unsigned int UIcons1 = (vector unsigned int)(0xFFFFFFFE, 0xFFFFFFFF, 0, 1); vector unsigned int UIcons2 = (vector unsigned int)(1, 1, 1, 1); vector unsigned int UIcons3 = (vector unsigned int)(1, 2, 1, 2);#if defined TEST_FLOATS vector float Fcons1 = (vector float)(-1.5, 1.0, 0.5, -3.999); vector float Fcons2 = (vector float)(1.0, 1.0, 1.0, 1.0); vector float Fcons3 = (vector float)(100000000000.0, 1.0, -1.0, -1234567890.0);#endif#endif/* Variables to be allocated with calloc_vec (16 bytes aligned) */ unsigned char *UCmem = (unsigned char*)calloc_vec( 1, sizeof(vector unsigned char) ); signed char *Cmem = (signed char*)calloc_vec( 1, sizeof(vector signed char) ); unsigned short *USmem = (unsigned short*)calloc_vec( 1, sizeof(vector unsigned short) ); signed short *Smem = (signed short*)calloc_vec( 1, sizeof(vector signed short) ); unsigned int *UImem = (unsigned int*)calloc_vec( 1, sizeof(vector unsigned int) ); signed int *Imem = (signed int*)calloc_vec( 1, sizeof(vector signed int) );#if defined TEST_FLOATS float *Fmem = (float*)calloc_vec( 1, sizeof(vector float) );#endif/* Function vec_dss */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dss [Vector data Stream Stop] not checked\n");/* Function vec_dssall */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dssall [Vector Stream Stop all] not checked\n");/* Function vec_dst */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dst [Vector Data Stream Touch] not checked\n");/* Function vec_dstst */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dstst [Vector Data Stream Touch for Store] not checked\n"); /* Function vec_dststt */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dststt [Vector Data Stream Touch for Store Transient] not checked\n");/* Function vec_dstt */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); printf("Function vec_dstt [Vector Data Stream Touch Transient] not checked\n");#if defined TEST_FLOATS/* Function vec_expte */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; Faux1.v = vec_expte( Fcons1 ); Faux2.v = Fcons1; for( i=0; i< 4; i++ ) { Faux = pow(2,Faux2.e[i]);/* Ivec1 = (signed int*)(&Faux1.e[i]); Ivec2 = (signed int*)(&Faux); *Ivec1 = (*Ivec1) & 0xFFF00000; *Ivec2 = (*Ivec2) & 0xFFF00000; if (Faux1.e[i] != Faux) err++;*/ Faux = (Faux - Faux1.e[i])/Faux; if (Faux>0.1) err++; } if (err) printf("Function vec_expte [type float] ===> Error\n"); else printf("Function vec_expte [type float] ===> OK\n");#endif#if defined TEST_FLOATS/* Function vec_floor */ printf("\n:::::::::::::::::::::::::::::::::::::::\n"); err = 0; Faux1.v = vec_floor( Fcons1 ); Faux2.v = Fcons1; for( i=0; i< 4; i++ ) if (Faux1.e[i] != floor(Faux2.e[i])) err++; if (err) printf("Function vec_floor [type float] ===> Error\n"); else printf("Function vec_floor [type float] ===> OK\n");#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -