/* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c s7 generates my chunk of the pseudo-random A stream for Benchmark #7 c single-cpu version does whole stream from 0 to numbufs-1 c c Parameters: c Provided by calling routine: c fd = file descriptor for temp file c myfirst= first bufnum for my PE to generate c mylast = last bufnum for my PE to generate c seed = Seed for randon number generator c A = Array in which to generate the data, a buffer at a time c c If fd >= 0, then total numbufs>1, write the data to disk c If fd < 0, then total numbufs=1, return the data in array A c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ #include "bench7.h" s7 ( int fd, uint64 * A, int myfirst, int mylast, int seed ) { // A[2][BUFSIZE] in main, but S7 just uses the 0th buffer // so ignore the global shape. uint64 PAT1010 = 0XAAAAAAAAAAAAAAAA, PAT0101 = 0X5555555555555555; int64 nwds = BUFSIZE; int64 negseed = -(long)seed; int bufnum; int64 myf=0, myl=0; /* dummy */ int i, i1, i2; // generate a buffer-full at a time and write to disk for ( bufnum = myfirst; bufnum <= mylast; bufnum++ ) { // bufnum+1 to get same data as Fortran get_my_bdata64( bufnum+1, 1, 1, nwds, 1, negseed, A, &myf, &myl ); // Artificially insert several regions that produce // 600-long patterns in the B and C streams and thence // 500-long runs of zeros in E-stream for ( i = -1; i <= 19; i++ ) { A[ i + 68750 ] = PAT1010; A[ i + 78776 ] = PAT0101; A[ i + 137500 ] = 0; A[ i + 157552 ] = -1; } // Create a zero region overlapping end of buff i and start of buff i+1 // Region at end of buff is not long enough w/o beginning of next buff // So no trouble checking results: we get 5 regions in each buffer // except the last one, which has 4 regions i1 = 4; i2 = 6; for (i=1; i<=i1; i++) A[nwds-i] = 0; if (bufnum > 0) for (i=0; i= 0) // if tot numbufs==1, fd has init val -1 { wrtmp(fd, A, nwds); syntmp(fd); } } return; }