// stencil_test.c // code to test the Stenciler and stencil_worker classes #include #include #include #include "./matrix_defs.h" #include "./convolve.h" main(int argc,char *argv[]) { stencil *testStencil, *testSt2; DATA_TYPE *array; convolve St; int i,j; string *src, *dest; char csrc[80], cdest[80]; int pre,post; int stenNum, pieces, rpieces; if (argc != 6) { printf ("Usage = conv_test <#pieces> <#rows> <#stencils> \n"); fflush (stdout); exit (-1); } printf ("Num pieces = %s\n", argv[1]); printf ("Num rows = %s\n", argv[2]); printf ("Stencils = %s\n", argv[3]); printf ("Input file = %s\n", argv[4]); printf ("Output file = %s\n", argv[5]); fflush (stdout); sscanf (argv[1], "%d", &pieces); sscanf (argv[2], "%d", &rpieces); sscanf (argv[3], "%d", &stenNum); printf ("Num pieces = %d num rows = %d num stencils = %d\n", pieces, rpieces, stenNum); fflush (stdout); strcpy (csrc, argv[4]); strcpy (cdest, argv[5]); src = (string*) csrc; dest = (string*) cdest; #ifndef SERIAL St.create(); #endif St.init(); pre = St.setSource(src); post = pre; pre = St.setDest(dest); post = pre; for (i = 0; iget_r_ptr(0); for (j = 0; j < 81; j++) array[j] = 1; array [40] = 2; array [31] = 2; array [49] = 2; array [39] = 2; array [41] = 2; pre = St.addStencil(testSt2); post = pre; } pre = St.setPieces(pieces); post = pre; pre = St.setRowPieces(rpieces); post = pre; printf ("Starting doStencil\n"); fflush (stdout); pre = St.doStencil(); post = pre; // pre = St.cleanup(); // post = pre; #ifndef SERIAL St.destroy(); #endif }