// pde_test.c // code to test the Stenciler and stencil_worker classes #include #include #include #include "pde.h" main(int argc, char* argv[]) { int pieces, rpieces; float convGoal; stencil* testStencil; DATA_TYPE* array; pde St; string *src, *dest; char csrc[80], cdest[80]; int rows,cols; int pre,post; if (argc != 6) { printf ("Proper format = pde_test <#Pieces> <#Rows> \n"); fflush (stdout); exit (-1); } sscanf (argv[1], "%d", &pieces); sscanf (argv[2], "%d", &rpieces); sscanf (argv[3], "%f", &convGoal); strcpy (csrc, argv[4]); strcpy (cdest, argv[5]); printf ("Num pieces = %d Num rows = %d\n", pieces,rpieces); printf ("Run until convergence < %f:\n", convGoal); fflush (stdout); testStencil = new (3,3) MATRIX_TYPE (3,3); array = testStencil->get_r_ptr(0); array[0] = 0.0; array[1] = 1.0; array[2] = 0.0; array[3] = 1.0; array[4] = 0.0; array[5] = 1.0; array[6] = 0.0; array[7] = 1.0; array[8] = 0.0; 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; rows = St.getNumRows(); cols = St.getNumCols(); pre = St.addStencil(testStencil); post = pre; pre = St.setPieces(pieces); post = pre; pre = St.setRowPieces(rpieces); post = pre; pre = St.setWindow(1,1,rows-2,cols-2); post = pre; pre = St.setGoal(convGoal); post = pre; pre = St.doStencil(); post = pre; #ifndef SERIAL St.destroy(); #endif }