19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: xvid_bench.c,v 1.12 2004-04-02 21:29:21 edgomez Exp $ |
* $Id: xvid_bench.c,v 1.16 2005-04-18 08:31:42 Skal Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
26 |
/***************************************************************************** |
/***************************************************************************** |
27 |
* |
* |
28 |
* 'Reference' output is at the end of file. |
* 'Reference' output is at the end of file. |
|
* Don't take the checksums and crc too seriouly, they aren't |
|
|
* bullet-proof (should plug some .md5 here)... |
|
29 |
* |
* |
30 |
* compiles with something like: |
* compiles with something like: |
31 |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
* gcc -o xvid_bench xvid_bench.c -I../src/ -lxvidcore -lm |
81 |
#else |
#else |
82 |
clock_t clk; |
clock_t clk; |
83 |
clk = clock(); |
clk = clock(); |
84 |
return clk * 1000000 / CLOCKS_PER_SEC; |
return clk * 1000. / CLOCKS_PER_SEC; /* clock() returns time in Milliseconds */ |
85 |
#endif |
#endif |
86 |
} |
} |
87 |
|
|
119 |
, { "3DNOW ", XVID_CPU_3DNOW } |
, { "3DNOW ", XVID_CPU_3DNOW } |
120 |
, { "3DNOWE", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT } |
, { "3DNOWE", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT } |
121 |
#endif |
#endif |
122 |
|
#ifdef ARCH_IS_PPC |
123 |
|
, { "ALTIVEC", XVID_CPU_ALTIVEC } |
124 |
|
#endif |
125 |
|
#ifdef ARCH_IS_X86_64 |
126 |
|
, { "X86_64", XVID_CPU_ASM} |
127 |
|
#endif |
128 |
//, { "IA64 ", XVID_CPU_IA64 } |
//, { "IA64 ", XVID_CPU_IA64 } |
129 |
//, { "TSC ", XVID_CPU_TSC } |
//, { "TSC ", XVID_CPU_TSC } |
130 |
, { 0, 0 } }; |
, { 0, 0 } }; |
783 |
} |
} |
784 |
|
|
785 |
/********************************************************************* |
/********************************************************************* |
786 |
|
* test distortion operators |
787 |
|
*********************************************************************/ |
788 |
|
|
789 |
|
static void ieee_reseed(long s); |
790 |
|
static long ieee_rand(int Min, int Max); |
791 |
|
|
792 |
|
#define TEST_SSE(FUNCTION, SRC1, SRC2, STRIDE) \ |
793 |
|
do { \ |
794 |
|
t = gettime_usec(); \ |
795 |
|
tst = nb_tests; \ |
796 |
|
while((tst--)>0) sse = (FUNCTION)((SRC1), (SRC2), (STRIDE)); \ |
797 |
|
emms(); \ |
798 |
|
t = (gettime_usec() - t)/(double)nb_tests; \ |
799 |
|
} while(0) |
800 |
|
|
801 |
|
|
802 |
|
void test_sse() |
803 |
|
{ |
804 |
|
const int nb_tests = 100000*speed_ref; |
805 |
|
int i; |
806 |
|
CPU *cpu; |
807 |
|
DECLARE_ALIGNED_MATRIX(Src1, 8, 8, int16_t, 16); |
808 |
|
DECLARE_ALIGNED_MATRIX(Src2, 8, 8, int16_t, 16); |
809 |
|
DECLARE_ALIGNED_MATRIX(Src3, 8, 8, int16_t, 16); |
810 |
|
DECLARE_ALIGNED_MATRIX(Src4, 8, 8, int16_t, 16); |
811 |
|
|
812 |
|
printf( "\n ===== test sse =====\n" ); |
813 |
|
|
814 |
|
ieee_reseed(1); |
815 |
|
for(i=0; i<64; ++i) { |
816 |
|
Src1[i] = ieee_rand(-2048, 2047); |
817 |
|
Src2[i] = ieee_rand(-2048, 2047); |
818 |
|
Src3[i] = ieee_rand(-2048, 2047); |
819 |
|
Src4[i] = ieee_rand(-2048, 2047); |
820 |
|
} |
821 |
|
|
822 |
|
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
823 |
|
{ |
824 |
|
double t; |
825 |
|
int tst, sse; |
826 |
|
|
827 |
|
if (!init_cpu(cpu)) |
828 |
|
continue; |
829 |
|
|
830 |
|
/* 16 bit element blocks */ |
831 |
|
TEST_SSE(sse8_16bit, Src1, Src2, 16); |
832 |
|
printf("%s - sse8_16bit#1 %.3f usec sse=%d %s\n", |
833 |
|
cpu->name, t, sse, (sse!=182013834)?"| ERROR": ""); |
834 |
|
TEST_SSE(sse8_16bit, Src1, Src3, 16); |
835 |
|
printf("%s - sse8_16bit#2 %.3f usec sse=%d %s\n", |
836 |
|
cpu->name, t, sse, (sse!=142545203)?"| ERROR": ""); |
837 |
|
TEST_SSE(sse8_16bit, Src1, Src4, 16); |
838 |
|
printf("%s - sse8_16bit#3 %.3f usec sse=%d %s\n", |
839 |
|
cpu->name, t, sse, (sse!=146340935)?"| ERROR": ""); |
840 |
|
TEST_SSE(sse8_16bit, Src2, Src3, 16); |
841 |
|
printf("%s - sse8_16bit#4 %.3f usec sse=%d %s\n", |
842 |
|
cpu->name, t, sse, (sse!=130136661)?"| ERROR": ""); |
843 |
|
TEST_SSE(sse8_16bit, Src2, Src4, 16); |
844 |
|
printf("%s - sse8_16bit#5 %.3f usec sse=%d %s\n", |
845 |
|
cpu->name, t, sse, (sse!=136870353)?"| ERROR": ""); |
846 |
|
TEST_SSE(sse8_16bit, Src3, Src4, 16); |
847 |
|
printf("%s - sse8_16bit#6 %.3f usec sse=%d %s\n", |
848 |
|
cpu->name, t, sse, (sse!=164107772)?"| ERROR": ""); |
849 |
|
|
850 |
|
/* 8 bit element blocks */ |
851 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src2, 8); |
852 |
|
printf("%s - sse8_8bit#1 %.3f usec sse=%d %s\n", |
853 |
|
cpu->name, t, sse, (sse!=1356423)?"| ERROR": ""); |
854 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src3, 8); |
855 |
|
printf("%s - sse8_8bit#2 %.3f usec sse=%d %s\n", |
856 |
|
cpu->name, t, sse, (sse!=1173074)?"| ERROR": ""); |
857 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src4, 8); |
858 |
|
printf("%s - sse8_8bit#3 %.3f usec sse=%d %s\n", |
859 |
|
cpu->name, t, sse, (sse!=1092357)?"| ERROR": ""); |
860 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src3, 8); |
861 |
|
printf("%s - sse8_8bit#4 %.3f usec sse=%d %s\n", |
862 |
|
cpu->name, t, sse, (sse!=1360239)?"| ERROR": ""); |
863 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src4, 8); |
864 |
|
printf("%s - sse8_8bit#5 %.3f usec sse=%d %s\n", |
865 |
|
cpu->name, t, sse, (sse!=1208414)?"| ERROR": ""); |
866 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src3, (int8_t*)Src4, 8); |
867 |
|
printf("%s - sse8_8bit#6 %.3f usec sse=%d %s\n", |
868 |
|
cpu->name, t, sse, (sse!=1099285)?"| ERROR": ""); |
869 |
|
|
870 |
|
printf(" ---\n"); |
871 |
|
} |
872 |
|
} |
873 |
|
|
874 |
|
/********************************************************************* |
875 |
* test non-zero AC counting |
* test non-zero AC counting |
876 |
*********************************************************************/ |
*********************************************************************/ |
877 |
|
|
912 |
continue; |
continue; |
913 |
|
|
914 |
TEST_CBP(calc_cbp, Src1); |
TEST_CBP(calc_cbp, Src1); |
915 |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n", |
916 |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
917 |
TEST_CBP(calc_cbp, Src2); |
TEST_CBP(calc_cbp, Src2); |
918 |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x %s\n", |
919 |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
920 |
TEST_CBP(calc_cbp, Src3); |
TEST_CBP(calc_cbp, Src3); |
921 |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x %s\n", |
922 |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
923 |
TEST_CBP(calc_cbp, Src4); |
TEST_CBP(calc_cbp, Src4); |
924 |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
925 |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
926 |
printf( " --- \n" ); |
printf( " --- \n" ); |
927 |
} |
} |
1591 |
if (what==0 || what==4) test_transfer(); |
if (what==0 || what==4) test_transfer(); |
1592 |
if (what==0 || what==5) test_quant(); |
if (what==0 || what==5) test_quant(); |
1593 |
if (what==0 || what==6) test_cbp(); |
if (what==0 || what==6) test_cbp(); |
1594 |
|
if (what==0 || what==10) test_sse(); |
1595 |
|
|
1596 |
if (what==7) { |
if (what==7) { |
1597 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |
1621 |
if (what==-2) |
if (what==-2) |
1622 |
test_quant_bug(); |
test_quant_bug(); |
1623 |
|
|
1624 |
if (what >= 0 && what <= 6) { |
if ((what >= 0 && what <= 6) || what == 10) { |
1625 |
printf("\n\n" |
printf("\n\n" |
1626 |
"NB: If a function isn't optimised for a specific set of intructions,\n" |
"NB: If a function isn't optimised for a specific set of intructions,\n" |
1627 |
" a C function is used instead. So don't panic if some functions\n" |
" a C function is used instead. So don't panic if some functions\n" |