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.14 2004-04-12 15:49:56 edgomez 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 |
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 |
//, { "IA64 ", XVID_CPU_IA64 } |
//, { "IA64 ", XVID_CPU_IA64 } |
126 |
//, { "TSC ", XVID_CPU_TSC } |
//, { "TSC ", XVID_CPU_TSC } |
127 |
, { 0, 0 } }; |
, { 0, 0 } }; |
780 |
} |
} |
781 |
|
|
782 |
/********************************************************************* |
/********************************************************************* |
783 |
|
* test distortion operators |
784 |
|
*********************************************************************/ |
785 |
|
|
786 |
|
static void ieee_reseed(long s); |
787 |
|
static long ieee_rand(int Min, int Max); |
788 |
|
|
789 |
|
#define TEST_SSE(FUNCTION, SRC1, SRC2, STRIDE) \ |
790 |
|
do { \ |
791 |
|
t = gettime_usec(); \ |
792 |
|
tst = nb_tests; \ |
793 |
|
while((tst--)>0) sse = (FUNCTION)((SRC1), (SRC2), (STRIDE)); \ |
794 |
|
emms(); \ |
795 |
|
t = (gettime_usec() - t)/(double)nb_tests; \ |
796 |
|
} while(0) |
797 |
|
|
798 |
|
|
799 |
|
void test_sse() |
800 |
|
{ |
801 |
|
const int nb_tests = 100000*speed_ref; |
802 |
|
int i; |
803 |
|
CPU *cpu; |
804 |
|
DECLARE_ALIGNED_MATRIX(Src1, 8, 8, int16_t, 16); |
805 |
|
DECLARE_ALIGNED_MATRIX(Src2, 8, 8, int16_t, 16); |
806 |
|
DECLARE_ALIGNED_MATRIX(Src3, 8, 8, int16_t, 16); |
807 |
|
DECLARE_ALIGNED_MATRIX(Src4, 8, 8, int16_t, 16); |
808 |
|
|
809 |
|
printf( "\n ===== test sse =====\n" ); |
810 |
|
|
811 |
|
ieee_reseed(1); |
812 |
|
for(i=0; i<64; ++i) { |
813 |
|
Src1[i] = ieee_rand(-2048, 2047); |
814 |
|
Src2[i] = ieee_rand(-2048, 2047); |
815 |
|
Src3[i] = ieee_rand(-2048, 2047); |
816 |
|
Src4[i] = ieee_rand(-2048, 2047); |
817 |
|
} |
818 |
|
|
819 |
|
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
820 |
|
{ |
821 |
|
double t; |
822 |
|
int tst, sse; |
823 |
|
|
824 |
|
if (!init_cpu(cpu)) |
825 |
|
continue; |
826 |
|
|
827 |
|
/* 16 bit element blocks */ |
828 |
|
TEST_SSE(sse8_16bit, Src1, Src2, 16); |
829 |
|
printf("%s - sse8_16bit#1 %.3f usec sse=%d %s\n", |
830 |
|
cpu->name, t, sse, (sse!=182013834)?"| ERROR": ""); |
831 |
|
TEST_SSE(sse8_16bit, Src1, Src3, 16); |
832 |
|
printf("%s - sse8_16bit#2 %.3f usec sse=%d %s\n", |
833 |
|
cpu->name, t, sse, (sse!=142545203)?"| ERROR": ""); |
834 |
|
TEST_SSE(sse8_16bit, Src1, Src4, 16); |
835 |
|
printf("%s - sse8_16bit#3 %.3f usec sse=%d %s\n", |
836 |
|
cpu->name, t, sse, (sse!=146340935)?"| ERROR": ""); |
837 |
|
TEST_SSE(sse8_16bit, Src2, Src3, 16); |
838 |
|
printf("%s - sse8_16bit#4 %.3f usec sse=%d %s\n", |
839 |
|
cpu->name, t, sse, (sse!=130136661)?"| ERROR": ""); |
840 |
|
TEST_SSE(sse8_16bit, Src2, Src4, 16); |
841 |
|
printf("%s - sse8_16bit#5 %.3f usec sse=%d %s\n", |
842 |
|
cpu->name, t, sse, (sse!=136870353)?"| ERROR": ""); |
843 |
|
TEST_SSE(sse8_16bit, Src3, Src4, 16); |
844 |
|
printf("%s - sse8_16bit#6 %.3f usec sse=%d %s\n", |
845 |
|
cpu->name, t, sse, (sse!=164107772)?"| ERROR": ""); |
846 |
|
|
847 |
|
/* 8 bit element blocks */ |
848 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src2, 8); |
849 |
|
printf("%s - sse8_8bit#1 %.3f usec sse=%d %s\n", |
850 |
|
cpu->name, t, sse, (sse!=1356423)?"| ERROR": ""); |
851 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src3, 8); |
852 |
|
printf("%s - sse8_8bit#2 %.3f usec sse=%d %s\n", |
853 |
|
cpu->name, t, sse, (sse!=1173074)?"| ERROR": ""); |
854 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src1, (int8_t*)Src4, 8); |
855 |
|
printf("%s - sse8_8bit#3 %.3f usec sse=%d %s\n", |
856 |
|
cpu->name, t, sse, (sse!=1092357)?"| ERROR": ""); |
857 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src3, 8); |
858 |
|
printf("%s - sse8_8bit#4 %.3f usec sse=%d %s\n", |
859 |
|
cpu->name, t, sse, (sse!=1360239)?"| ERROR": ""); |
860 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src2, (int8_t*)Src4, 8); |
861 |
|
printf("%s - sse8_8bit#5 %.3f usec sse=%d %s\n", |
862 |
|
cpu->name, t, sse, (sse!=1208414)?"| ERROR": ""); |
863 |
|
TEST_SSE(sse8_8bit, (int8_t*)Src3, (int8_t*)Src4, 8); |
864 |
|
printf("%s - sse8_8bit#6 %.3f usec sse=%d %s\n", |
865 |
|
cpu->name, t, sse, (sse!=1099285)?"| ERROR": ""); |
866 |
|
|
867 |
|
printf(" ---\n"); |
868 |
|
} |
869 |
|
} |
870 |
|
|
871 |
|
/********************************************************************* |
872 |
* test non-zero AC counting |
* test non-zero AC counting |
873 |
*********************************************************************/ |
*********************************************************************/ |
874 |
|
|
909 |
continue; |
continue; |
910 |
|
|
911 |
TEST_CBP(calc_cbp, Src1); |
TEST_CBP(calc_cbp, Src1); |
912 |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n", |
913 |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
914 |
TEST_CBP(calc_cbp, Src2); |
TEST_CBP(calc_cbp, Src2); |
915 |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x %s\n", |
916 |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
917 |
TEST_CBP(calc_cbp, Src3); |
TEST_CBP(calc_cbp, Src3); |
918 |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x %s\n", |
919 |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
920 |
TEST_CBP(calc_cbp, Src4); |
TEST_CBP(calc_cbp, Src4); |
921 |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x\n", |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
922 |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
923 |
printf( " --- \n" ); |
printf( " --- \n" ); |
924 |
} |
} |
1588 |
if (what==0 || what==4) test_transfer(); |
if (what==0 || what==4) test_transfer(); |
1589 |
if (what==0 || what==5) test_quant(); |
if (what==0 || what==5) test_quant(); |
1590 |
if (what==0 || what==6) test_cbp(); |
if (what==0 || what==6) test_cbp(); |
1591 |
|
if (what==0 || what==10) test_sse(); |
1592 |
|
|
1593 |
if (what==7) { |
if (what==7) { |
1594 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |
1618 |
if (what==-2) |
if (what==-2) |
1619 |
test_quant_bug(); |
test_quant_bug(); |
1620 |
|
|
1621 |
if (what >= 0 && what <= 6) { |
if ((what >= 0 && what <= 6) || what == 10) { |
1622 |
printf("\n\n" |
printf("\n\n" |
1623 |
"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" |
1624 |
" 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" |