public class scattergatherbw{ public static void runGather(int sz){ int maxMB = 100; int MBpertest = maxMB; int maxiters = 10000; int numProcs = Ti.numProcs(); int halfProcs = numProcs / 2; int startIndex; int thisProc = Ti.thisProc(); if (Ti.thisProc() < halfProcs){ startIndex = halfProcs; } else{ startIndex = 0; } double [1d] single [1d] allArrs = new double[0:Ti.numProcs()-1][1d]; double [1d] myArr = new double[1:sz]; int iters = (MBpertest * 1048576) / (sz*8); if (iters > maxiters) iters = maxiters; allArrs.exchange(myArr); double [1d] local dest = new double[1:sz]; Point <1>[1d] local points = new Point<1>[dest.domain()]; foreach (p in points.domain()){ points[p] = p; } Ti.barrier(); if (Ti.thisProc() < halfProcs){ long starttime = System.currentTimeMillis(); for (int i = 0; i < iters; i++) { for (int j = 0; j < halfProcs; j++){ double [1d] peerArr = allArrs[(j + thisProc) % halfProcs + startIndex]; peerArr.gather(dest, points); } } long endtime = System.currentTimeMillis(); double totalsec = ((double)endtime - starttime) / 1000.0; double totalMB = ((double)iters) * (sz * 8 * halfProcs) / 1048576.0; System.out.println("gather bandwidth ("+ (sz * halfProcs) +" doubles per thread) = " + (totalMB/totalsec) + " MB/sec"); } Ti.barrier(); } public static void runScatter(int sz){ int maxMB = 100; int MBpertest = maxMB; int maxiters = 10000; int numProcs = Ti.numProcs(); int halfProcs = numProcs / 2; int startIndex; int thisProc = Ti.thisProc(); if (Ti.thisProc() < halfProcs){ startIndex = halfProcs; } else{ startIndex = 0; } double [1d] single [1d] allArrs = new double[0:Ti.numProcs()-1][1d]; double [1d] myArr = new double[1:sz]; int iters = (MBpertest * 1048576) / (sz*8); if (iters > maxiters) iters = maxiters; allArrs.exchange(myArr); double [1d] local dest = new double[1:sz]; Point <1>[1d] local points = new Point<1>[dest.domain()]; foreach (p in points.domain()){ points[p] = p; } Ti.barrier(); if (Ti.thisProc() < halfProcs){ long starttime = System.currentTimeMillis(); for (int i = 0; i < iters; i++) { for (int j = 0; j < halfProcs; j++){ double [1d] peerArr = allArrs[(j + thisProc) % halfProcs + startIndex]; peerArr.scatter(dest, points); } } long endtime = System.currentTimeMillis(); double totalsec = ((double)endtime - starttime) / 1000.0; double totalMB = ((double)iters) * (sz * 8 * halfProcs) / 1048576.0; System.out.println("scatter bandwidth ("+ (sz * halfProcs) +" doubles per thread) = " + (totalMB/totalsec) + " MB/sec"); } Ti.barrier(); } public static single void main(String[] args){ int single max; int single min; int single sz; max = 1048576; min = 256; for (sz = min; sz <= max; sz*=2){ runGather(sz); } if (Ti.thisProc() == 0){ System.out.println(); } Ti.barrier(); for (sz = min; sz <= max; sz*=2){ runScatter(sz); } } }