/* ** produit sans rtcg (version avec appel de fonction) */ #include #include #include #include "size.h" #include "matmult.h" /* boolean type */ #define TRUE (0==0) #define FALSE (0!=0) typedef int bool; int M[MAX_SIZE][MAX_SIZE]; int N[MAX_SIZE][MAX_SIZE]; int O[MAX_SIZE][MAX_SIZE]; int P[MAX_SIZE][MAX_SIZE]; static void fill_mat(int, int [MAX_SIZE][MAX_SIZE], int); static bool compare_mat(int size, int M[MAX_SIZE][MAX_SIZE], int N[MAX_SIZE][MAX_SIZE]); /* * test/bench size sparse naive/rep/sparse/rtcg iterations * tester -t 10 90 naive * tester -b 10 90 naive 1000 */ main(int argc, char **argv) { if ( argc >= 2 ) { char *mode = argv[1]; if ( *mode++ == '-' && ( ((*mode) == 't' && argc == 5) || ((*mode) == 'b' && argc == 6)) ) { int size = atoi(argv[2]); int sparse = atoi(argv[3]); void (*func)(int, int [MAX_SIZE][MAX_SIZE], int [MAX_SIZE][MAX_SIZE], int [MAX_SIZE][MAX_SIZE]) = select_function(argv[4]); if ( func != NULL ) { fill_mat(size, M, sparse); fill_mat(size, N, sparse); if ( *mode == 't' ) { (*select_function("naive"))(size, M, N, O); (*func)(size, M, N, P); printf("test %s\n", compare_mat(size, O, P) ? "ok" : "fail"); } else { int nbiter = atoi(argv[5]); int cpt; for (cpt=0; cpt \n"); printf(" tester -b \n"); printf("\n Test or bench matrix multiplication function \n"); printf(" for x matrix filled with %% of\n"); printf(" zeros. Funcid may be 'naive', 'rep', 'sparse' or 'rtcg'.\n"); } /* ---------------------------------------------------------------------------*/ /* ** fill a matrix with the sparse % of zero */ static void fill_mat(int size, int M[MAX_SIZE][MAX_SIZE], int rate) { int sparse = rate/10; int cpt = 0; int i,j; for (i=0; i