Esempio n. 1
0
int main(int argc, char *argv[])
{
	unsigned char src1[SRC_SIZE], src2[SRC_SIZE], dstm[SRC_SIZE], dstc[SRC_SIZE];
    int size = 2*1024*1024;
    unsigned char *t1 = (unsigned char *)SDL_malloc(size), *t2 = (unsigned char *)SDL_malloc(size), *d = (unsigned char *)SDL_malloc(size);
    int i;

	/* Initialize to make valgrind happy */
	srand((unsigned int)time(NULL));
	for (i = 0; i < size; i++) {
			/* use more random lower-order bits (int->char) */
			t1[i] = rand(); t2[i] = rand(); d[i] = rand();
	}

    SDL_Init(SDL_INIT_TIMER);

	/* SDL_imageFilter Test */

	printf ("TestImageFilter\n\n");
	printf ("Testing an array of 23 bytes - first 16 bytes should be processed\n");
	printf ("by MMX or C code, the last 7 bytes only by C code.\n\n");
	
	print_line();
	
	
#define	TEST_C   0
#define	TEST_MMX 1
        {
#define FUNC(f) { #f, SDL_imageFilter ## f }
		struct func {
			char* name;
			int (*f)(unsigned char*, unsigned char*, unsigned char*, unsigned int);
		};
		struct func funcs[] = {
			FUNC(BitAnd),
			FUNC(BitOr),
			FUNC(Add),
			FUNC(AbsDiff),
			FUNC(Mean),
			FUNC(Sub),
			FUNC(Mult),
			FUNC(MultNor),
			FUNC(MultDivby2),
			FUNC(MultDivby4),
			FUNC(Div),
		};
		
		int k;
		for (k = 0; k < sizeof(funcs)/sizeof(struct func); k++) {
			Uint32 start;
			int i;
			
			setup_src(src1, src2);

			SDL_imageFilterMMXon();
			funcs[k].f(src1, src2, dstm, SRC_SIZE);
			print_result(TEST_MMX, funcs[k].name, src1, src2, dstm);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, t2, d, size);
			}
			printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			SDL_imageFilterMMXoff();
			funcs[k].f(src1, src2, dstc, SRC_SIZE);
			print_result(TEST_C, funcs[k].name, src1, src2, dstc);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, t2, d, size);
			}
			printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			print_compare(dstm,dstc);
			print_line();
		}
        }

	/* setup_src(src1, src2); */
	/* SDL_imageFilterMultNor(src1, src2, dstc, SRC_SIZE); */
        /* start = SDL_GetTicks(); */
        /* for (i = 0; i < 50; i++) { */
        /*     SDL_imageFilterMultNor(t1, t2, d, size); */
        /* } */
        /* printf(" C  %dx%d: %dms\n", i, size, SDL_GetTicks() - start); */
	/* print_result(TEST_C, "MultNor", src1, src2, dstc); */
        /* { */
        /*     unsigned char expected[] = { 0x01, 0x0c, 0x03, 0x06, 0xac, 0x2d, 0x30, 0x31, */
        /*                                  0x30, 0x2d, 0x28, 0x21, 0x18, 0x0d, 0x50, 0xf1, */
        /*                                  0xe0, 0xcd, 0xb8, 0xa1, 0x88, 0x6d, 0x50 }; */
        /*     print_compare(dstc, expected); */
        /* } */
	/* print_line(); */
        /* exit(0); */


        {
		Uint32 start;
		int i;
		char call[1024];
		SDL_snprintf(call, 1024, "BitNegation");
		
		setup_src(src1, src2);
		
		SDL_imageFilterMMXon();
		SDL_imageFilterBitNegation(src1, dstm, SRC_SIZE);
		print_result(TEST_MMX, call, src1, NULL, dstm);
		start = SDL_GetTicks();
		for (i = 0; i < 50; i++) {
			SDL_imageFilterBitNegation(t1, d, size);
		}
		printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
		
		SDL_imageFilterMMXoff();
		SDL_imageFilterBitNegation(src1, dstc, SRC_SIZE);
		print_result(TEST_C, call, src1, NULL, dstc);
		start = SDL_GetTicks();
		for (i = 0; i < 50; i++) {
			SDL_imageFilterBitNegation(t1, d, size);
		}
		printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
		
		print_compare(dstm,dstc);
		print_line();
        }

	
        {
#undef FUNC
#define FUNC(f, c) { #f, SDL_imageFilter ## f, c }
		struct func {
			char* name;
			int (*f)(unsigned char*, unsigned char*, unsigned int, unsigned char);
			unsigned char arg;
		};
		struct func funcs[] = {
			FUNC(AddByte,                3),
			FUNC(AddByteToHalf,          3),
			FUNC(SubByte,                3),
			FUNC(ShiftRight,             1),
			FUNC(ShiftRightUint,         4),
			FUNC(MultByByte,             3),
			FUNC(ShiftLeftByte,          3),
			FUNC(ShiftLeft,              3),
			FUNC(ShiftLeftUint,          4),
			FUNC(BinarizeUsingThreshold, 9),
		};
		
		int k;
		for (k = 0; k < sizeof(funcs)/sizeof(struct func); k++) {
			Uint32 start;
			int i;
			char call[1024];
			SDL_snprintf(call, 1024, "%s(%u)", funcs[k].name, funcs[k].arg);
			
			setup_src(src1, src2);

			SDL_imageFilterMMXon();
			funcs[k].f(src1, dstm, SRC_SIZE, funcs[k].arg);
			print_result(TEST_MMX, call, src1, NULL, dstm);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg);
			}
			printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			SDL_imageFilterMMXoff();
			funcs[k].f(src1, dstc, SRC_SIZE, funcs[k].arg);
			print_result(TEST_C, call, src1, NULL, dstc);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg);
			}
			printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			print_compare(dstm,dstc);
			print_line();
		}
        }

	
        {
#undef FUNC
#define FUNC(f, c1, c2) { #f, SDL_imageFilter ## f, c1, c2 }
		struct func {
			char* name;
			int (*f)(unsigned char*, unsigned char*, unsigned int, unsigned char, unsigned char);
			unsigned char arg1, arg2;
		};
		struct func funcs[] = {
			FUNC(ShiftRightAndMultByByte, 1, 3),
			FUNC(ClipToRange, 3, 8),
		};
		
		int k;
		for (k = 0; k < sizeof(funcs)/sizeof(struct func); k++) {
			Uint32 start;
			int i;
			char call[1024];
			SDL_snprintf(call, 1024, "%s(%u,%u)", funcs[k].name, funcs[k].arg1, funcs[k].arg2);
			
			setup_src(src1, src2);

			SDL_imageFilterMMXon();
			funcs[k].f(src1, dstm, SRC_SIZE, funcs[k].arg1, funcs[k].arg2);
			print_result(TEST_MMX, call, src1, NULL, dstm);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg1, funcs[k].arg2);
			}
			printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			SDL_imageFilterMMXoff();
			funcs[k].f(src1, dstc, SRC_SIZE, funcs[k].arg1, funcs[k].arg2);
			print_result(TEST_C, call, src1, NULL, dstc);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg1, funcs[k].arg2);
			}
			printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			print_compare(dstm,dstc);
			print_line();
		}
        }

        
        {
		Uint32 start;
		int i;
		char call[1024];
		SDL_snprintf(call, 1024, "NormalizeLinear(0,33,0,255)");
		
		setup_src(src1, src2);
		
		SDL_imageFilterMMXon();
		SDL_imageFilterNormalizeLinear(src1, dstm, SRC_SIZE, 0,33, 0,255);
		print_result(TEST_MMX, call, src1, NULL, dstm);
		start = SDL_GetTicks();
		for (i = 0; i < 50; i++) {
			SDL_imageFilterNormalizeLinear(t1, d, size, 0,33, 0,255);
		}
		printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
		
		SDL_imageFilterMMXoff();
		SDL_imageFilterNormalizeLinear(src1, dstc, SRC_SIZE, 0,33, 0,255);
		print_result(TEST_C, call, src1, NULL, dstc);
		start = SDL_GetTicks();
		for (i = 0; i < 50; i++) {
			SDL_imageFilterNormalizeLinear(t1, d, size, 0,33, 0,255);
		}
		printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
		
		print_compare(dstm,dstc);
		print_line();
        }


	/* Uint functions */
	/* Disabled, since broken *//* ??? */
        {
#undef FUNC
#define FUNC(f, c) { #f, SDL_imageFilter ## f, c }
		struct func {
			char* name;
			int (*f)(unsigned char*, unsigned char*, unsigned int, unsigned int);
			unsigned int arg;
		};
		struct func funcs[] = {
			FUNC(AddUint,       0x01020304),
			FUNC(SubUint,       0x01020304),
		};
		
		int k;
		for (k = 0; k < sizeof(funcs)/sizeof(struct func); k++) {
			Uint32 start;
			int i;
			char call[1024];
			SDL_snprintf(call, 1024, "%s(%u)", funcs[k].name, funcs[k].arg);
			
			setup_src(src1, src2);

			SDL_imageFilterMMXon();
			funcs[k].f(src1, dstm, SRC_SIZE, funcs[k].arg);
			print_result(TEST_MMX, call, src1, NULL, dstm);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg);
			}
			printf("MMX %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			SDL_imageFilterMMXoff();
			funcs[k].f(src1, dstc, SRC_SIZE, funcs[k].arg);
			print_result(TEST_C, call, src1, NULL, dstc);
			start = SDL_GetTicks();
			for (i = 0; i < 50; i++) {
				funcs[k].f(t1, d, size, funcs[k].arg);
			}
			printf(" C  %dx%dk: %dms\n", i, size/1024, SDL_GetTicks() - start);
			
			print_compare(dstm,dstc);
			print_line();
		}
        }


	SDL_imageFilterMMXon();
	if (SDL_imageFilterMMXdetect())
	{
		printf("MMX was detected\n\n");
	}
	else
	{
		printf("MMX was NOT detected\n\n");
	}

	printf ("Result: %i of %i passed OK.\n", ok_count, total_count);

	SDL_Quit();
	free(d);
	free(t2);
	free(t1);

	exit(0);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	unsigned char src1[15],src2[15],dstm[15],dstc[15];

	/* SDL_imageFilter Test */

	printf ("TestImageFilter\n\n");
	printf ("Testing an array of 15 bytes - first 8 bytes should be processed\n");
	printf ("by MMX or C code, the last 7 bytes only by C code.\n\n");

	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2); 
	SDL_imageFilterBitAnd ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15); 
	print_result ("MMX BitAnd", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2); 
	SDL_imageFilterBitAnd ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15); 
	print_result (" C  BitAnd", src1, src2, dstc);

	print_compare(dstm,dstc);
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterBitOr ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX BitOr", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterBitOr ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  BitOr", src1, src2, dstc);

	print_compare(dstm,dstc);
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterAdd ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX Add", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterAdd ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  Add", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterAbsDiff ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX AbsDiff", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterAbsDiff ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  AbsDiff", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMean ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX Mean", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMean ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  Mean", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterSub ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX Sub", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterSub ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  Sub", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMult ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX Mult", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMult ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  Mult", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMultNor ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("ASM MultNor", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMultNor ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  MultNor", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMultDivby2 ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX MultDivby2", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMultDivby2 ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  MultDivby2", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMultDivby4 ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("MMX MultDivby4", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMultDivby4 ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  MultDivby4", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterDiv ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstm,15);
	print_result ("ASM Div", src1, src2, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterDiv ((unsigned char *)src1,(unsigned char *)src2,(unsigned char *)dstc,15);
	print_result (" C  Div", src1, src2, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterBitNegation ((unsigned char *)src1,(unsigned char *)dstm,15);
	print_result ("MMX BitNegation", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterBitNegation ((unsigned char *)src1,(unsigned char *)dstc,15);
	print_result (" C  BitNegation", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterAddByte ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX AddByte(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterAddByte ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  AddByte(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterAddByteToHalf ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX AddByteToHalf(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterAddByteToHalf ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  AddByteToHalf(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterSubByte ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX SubByte(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterSubByte ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  SubByte(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftRight ((unsigned char *)src1,(unsigned char *)dstm,15, 1);
	print_result ("MMX ShiftRight(1)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftRight ((unsigned char *)src1,(unsigned char *)dstc,15, 1);
	print_result (" C  ShiftRight(1)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterMultByByte ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX MultByByte(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterMultByByte ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  MultByByte(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftRightAndMultByByte ((unsigned char *)src1,(unsigned char *)dstm,15, 1, 3);
	print_result ("MMX ShiftRightAndMultByByte(1,3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftRightAndMultByByte ((unsigned char *)src1,(unsigned char *)dstc,15, 1, 3);
	print_result (" C  ShuftRightAndMultByByte(1,3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeftByte ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX ShiftLeftByte(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeftByte ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  ShiftLeftByte(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeft ((unsigned char *)src1,(unsigned char *)dstm,15, 3);
	print_result ("MMX ShiftLeft(3)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeft ((unsigned char *)src1,(unsigned char *)dstc,15, 3);
	print_result (" C  ShiftLeft(3)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterBinarizeUsingThreshold ((unsigned char *)src1,(unsigned char *)dstm,15, 2);
	print_result ("MMX BinarizeUsingThreshold(2)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterBinarizeUsingThreshold ((unsigned char *)src1,(unsigned char *)dstc,15, 2);
	print_result (" C  BinarizeUsingThreshold(2)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterClipToRange ((unsigned char *)src1,(unsigned char *)dstm,15, 1,7);
	print_result ("MMX ClipToRange(1,7)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterClipToRange ((unsigned char *)src1,(unsigned char *)dstc,15, 1,7);
	print_result (" C  ClipToRange(1,7)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterNormalizeLinear ((unsigned char *)src1,(unsigned char *)dstm,15, 0,33,0,255);
	print_result ("MMX NormalizeLinear(0,33,0,255)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterNormalizeLinear ((unsigned char *)src1,(unsigned char *)dstc,15, 0,33,0,255);
	print_result (" C  NormalizeLinear(0,33,0,255)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	/* Uint functions */

	/* Disabled, since broken */
	/*

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterAddUint ((unsigned char *)src1,(unsigned char *)dstm,15, 0x01020304);
	print_result ("MMX AddUint(0x01020304)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterAddUint ((unsigned char *)src1,(unsigned char *)dstc,15, 0x01020304);
	print_result (" C  AddUint(0x01020304)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterSubUint ((unsigned char *)src1,(unsigned char *)dstm,15, 0x01020304);
	print_result ("MMX SubUint(0x01020304)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterSubUint ((unsigned char *)src1,(unsigned char *)dstc,15, 0x01020304);
	print_result (" C  SubUint(0x01020304)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftRightUint ((unsigned char *)src1,(unsigned char *)dstm,15, 4);
	print_result ("MMX ShiftRightUint(4)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftRightUint ((unsigned char *)src1,(unsigned char *)dstc,15, 4);
	print_result (" C  ShiftRightUint(4)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	SDL_imageFilterMMXon();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeftUint ((unsigned char *)src1,(unsigned char *)dstm,15, 4);
	print_result ("MMX ShiftLeftUint(4)", src1, NULL, dstm);

	SDL_imageFilterMMXoff();

	setup_src(src1, src2);
	SDL_imageFilterShiftLeftUint ((unsigned char *)src1,(unsigned char *)dstc,15, 4);
	print_result (" C  ShiftLeftUint(4)", src1, NULL, dstc);

	print_compare(dstm,dstc); 
	print_line();

	*/

#ifdef USE_MMX
	SDL_imageFilterMMXon();
	if (SDL_imageFilterMMXdetect())
	{
		printf("MMX was detected\n\n");
	}
	else
	{
		printf("MMX was NOT detected\n\n");
	}
#else
	printf("MMX support disabled in SDL_gfx.\n\n");
#endif

	printf ("Result: %i of %i passed OK.\n", ok_count, total_count);

#ifdef WIN32 
	printf("Press Enter to continue ...");
	pause();
#endif

	exit(0);
}
Esempio n. 3
0
File: setup.c Progetto: GCZhang/SNAP
/*******************************************************************************
 * Control the setup process
 *******************************************************************************/
void setup ( input_data *input_vars, para_data *para_vars, time_data *time_vars,
             geom_data *geom_vars, sn_data *sn_vars, data_data *data_vars,
             solvar_data *solvar_vars, control_data *control_vars,
             mms_data *mms_vars, FILE *fp_out, int *ierr, char **error )
{
/*******************************************************************************
 * Local variables
 *******************************************************************************/
    int flg, mis, mie, mjs, mje, mks, mke, qis, qie, qjs, qje, qks, qke;

    double t1, t2;

 /*******************************************************************************
 *  First put input ny and nz into ny_gl and nz_gl respectively. Use ny
 *  and nz for local sizes. Determine global indices of local bounds.
 *  Establish min of nthreads and ng for threaded MPI calls in sweep.
 *******************************************************************************/
    t1 = wtime();

    NY_GL = NY;
    NZ_GL = NZ;

    NY = NY_GL / NPEY;
    NZ = NZ_GL / NPEZ;

    JLB =  YPROC      * NY + 1;
    JUB = (YPROC + 1) * NY;
    KLB =  ZPROC      * NZ + 1;
    KUB = (ZPROC + 1) * NZ;

    NUM_GRTH = MIN( NTHREADS, NG );

/*******************************************************************************
 *  Allocate needed arrays
 *******************************************************************************/
    setup_alloc( input_vars, para_vars, sn_vars, data_vars, &flg, ierr, error );

    if ( *ierr != 0 )
    {
        print_error ( fp_out, *error, IPROC, ROOT );

        stop_run( flg, 0, 0, para_vars, sn_vars, data_vars, mms_vars,
                   geom_vars, solvar_vars, control_vars );
    }

/*******************************************************************************
 *  Progress through setups. _delta sets cell and step sizes, _vel sets
 *  velocity array, _angle sets the ordinates/weights, _mat sets the
 *  material identifiers, _src sets fixed source, _data sets the
 *  mock cross section arrays, and expcoeff sets up the scattering
 *  expansion basis function array.
 *******************************************************************************/
    setup_delta( input_vars, geom_vars, control_vars );

    setup_vel( input_vars, data_vars );

    setup_angle( input_vars, sn_vars );

    setup_mat( input_vars, geom_vars, data_vars,
               &mis, &mie, &mjs, &mje, &mks, &mke );

    setup_data( input_vars, data_vars );

    expcoeff( input_vars, sn_vars, &NDIMEN );

    setup_src( input_vars, para_vars, geom_vars, sn_vars, data_vars, control_vars,
               mms_vars, &qis, &qie, &qjs, &qje, &qks, &qke, ierr, error );

    if ( *ierr != 0 )
    {
        print_error ( fp_out, *error, IPROC, ROOT );

        stop_run( 2, 0, 0, para_vars, sn_vars, data_vars, mms_vars,
                   geom_vars, solvar_vars, control_vars );
    }

/*******************************************************************************
 *  Echo the data from this module to the output file. If requested via
 *  scatp, print the full scattering matrix to file.
 *******************************************************************************/
    if ( IPROC == ROOT )
    {
        setup_echo ( fp_out, input_vars, para_vars, geom_vars, data_vars, sn_vars,
                     control_vars, mis, mie, mjs, mje, mks, mke,
                     qis, qie, qjs, qje, qks, qke );

        if ( SCATP == 1 ) setup_scatp( input_vars, para_vars, data_vars, ierr, error );
    }

    glmax_i ( ierr, COMM_SNAP );

    if ( *ierr != 0 )
    {
        print_error ( fp_out, *error, IPROC, ROOT );

        FREE ( error );

        stop_run ( 3, 0, 0, para_vars, sn_vars, data_vars, mms_vars,
                   geom_vars, solvar_vars, control_vars );
    }

    t2 = wtime();
    TSET = t2 - t1;
}