/* * $Header: /projects/raw/cvsroot/benchmark/suites/jacobi/src/driver.c,v 1.4 1997/08/09 05:57:38 jbabb Exp $ * * Driver for Jacobi benchmark * * Authors: Jonathan Babb (jbabb@lcs.mit.edu) * * Copyright @ 1997 MIT Laboratory for Computer Science, Cambridge, MA 02129 */ #include #include #include #include #ifdef HARDWARE #include #endif /* This program is the driver program for this benchmark. It is compiled in one of three modes: -DSOFTWARE a software-only version of the benchmark. -DSIMULATION generates simulation vectors to a verilog file. -DHARDWARE runs reconfigurable hardware via a memory-mapped interface. */ /* An additional flag -DHARDWARE_ONLY (currently unused) turns off execution and comparison of the software version whenever the hardware is driven */ /* Drive is written specifically for this benchmark. It calls the following generate_verilog.h routines: vectorRead - generate a verilog read vector for the test shell vectorWrite - generate a verilog write vector for the test shell vectorNop - generate a verilog nop vector for the test shell It calls the following interface.h routines: interfaceOpen - open the memory mapped SBus to VLE interface interfaceClose - close the memory mapped SBus to VLE interface interfaceRead - a macro to read from the interface interfaceWrite - a macro to write to the interface */ driver(int sizex, int sizey, int width, int iter, int scan) { int it,i,j,addr,data,sum,cycles=1,maxpoll,rpts=0; int data1[MAXSIZE],data2[MAXSIZE],data_hw[MAXSIZE]; int idwidth,controlid, scanid=0; u_long* base; float soft_time; tval_t begin_time, end_time; /* width of node identifier */ idwidth = scan ? 1 : int_log(sizex*sizey)+1; /* control node address */ controlid = 1 << (idwidth-1); #ifdef HARDWARE interfaceOpen(&base); #endif #ifdef SOFTWARE get_time(begin_time); do { rpts++; #endif if(sizex*sizey>MAXSIZE) { printf("Matrix to large (MAXSIZE exceeded).\n"); exit(0); } /* Initialize data array */ for(i=0;i> 2; } } } else { for(i=1;i> 2; } } } } #endif #ifdef SOFTWARE } while (get_time(end_time) - begin_time < TIMELIMIT); #endif #ifdef SIMULATION /* write iteration count (also starts iterating) */ addr=controlid; data=iter; vectorWrite(addr,data); /* wait appropriate number of iterations */ vectorNop(iter*cycles); /* now expect a zero at the polling address */ addr=controlid; data=0; vectorRead(addr,data); #endif #ifdef HARDWARE /* write iteration count (also starts iterating) */ addr=controlid; data=iter; interfaceWrite(base+addr,data); /* poll */ maxpoll=0; while(data!=0 && maxpoll < MAXPOLL) { maxpoll++; interfaceRead(base+addr,data); } if(maxpoll==MAXPOLL) { printf("Error: exceeding polling limit %d.\n",MAXPOLL); } #endif /* read back results */ for(i=0;i \n",mode); printf("\n"); printf("sizex is X dimension (power of 2) of Jacobi grid\n"); printf("sizey is Y dimension (power of 2) of Jacobi grid\n"); printf("width is data width of Jacobi elements (4 to 32)\n"); printf("iter is the number of iterations (must be even)\n"); printf("scan is either scan or bus for respective implementations\n"); printf("\n"); exit(-1); }; /* parameters */ sizex=atoi(argv[1]); sizey=atoi(argv[2]); width=atoi(argv[3]); iter =atoi(argv[4]); scan =(strcmp(argv[5],"scan") == 0); /* 0 for bus, 1 for scan */ /* check parameters */ if (width < 4 || width > 32 ) { printf("Width must be between 4 and 32.\n"); exit(-1); } if (iter % 2 ) { printf("Iter must be even.\n"); exit(-1); } /* drive the defined software/simulation/hardware */ driver(sizex,sizey,width,iter,scan); exit(0); }