// tiArray performance tester, Dan Bonachea public class arrperf { public static void report(String desc, Timer t, int iters) { System.out.println(desc + ": " + t.micros()/iters + " us per iteration (" + t.secs() + " secs total)"); } public single static void main(String[]args) { int iters = 10000; int sz = 100; if (args.length > 0) try { iters = Integer.parseInt(args[0]); } catch (Throwable exn) {} if (args.length > 1) try { sz = Integer.parseInt(args[1]); } catch (Throwable exn) {} System.out.println("Running " + iters + " iterations of tiArray performance test(sz="+sz+")..."); Timer t = new Timer(); RectDomain<1> rd1 = [1:sz]; RectDomain<1> rd1a = [2:sz-1]; RectDomain<2> rd2 = [[1,1]:[sz,sz]]; RectDomain<2> rd2a = [[2,2]:[sz-1,sz-1]]; RectDomain<3> rd3 = [[1,1,1]:[sz,sz,sz]]; RectDomain<3> rd3a = [[2,2,2]:[sz-1,sz-1,sz-1]]; //------------------------------------------------------------------------------------ // non-contiguous copy benchmark int [1d] local ltiarr1a = new int[rd1]; int [2d] local ltiarr2a = new int[rd2]; int [3d] local ltiarr3a = new int[rd3]; int [1d] local ltiarr1b = new int[rd1]; int [2d] local ltiarr2b = new int[rd2]; int [3d] local ltiarr3b = new int[rd3]; int [1d] tiarr1a = broadcast ltiarr1a from 0; int [2d] tiarr2a = broadcast ltiarr2a from 0; int [3d] tiarr3a = broadcast ltiarr3a from 0; int [1d] tiarr1b = broadcast ltiarr1b from 0; int [2d] tiarr2b = broadcast ltiarr2b from 0; int [3d] tiarr3b = broadcast ltiarr3b from 0; ltiarr1b = ltiarr1b.restrict(rd1a); ltiarr2b = ltiarr2b.restrict(rd2a); ltiarr3b = ltiarr3b.restrict(rd3a); tiarr1b = tiarr1b.restrict(rd1a); tiarr2b = tiarr2b.restrict(rd2a); tiarr3b = tiarr3b.restrict(rd3a); t.reset(); t.start(); for (int i=0; i < iters; i++) { tiarr1a.copy(tiarr1b); } t.stop(); report("non-contiguous local 1-d global array copy", t, iters); t.reset(); t.start(); for (int i=0; i < iters; i++) { ltiarr1a.copy(ltiarr1b); } t.stop(); report("non-contiguous local 1-d local array copy", t, iters); t.reset(); t.start(); for (int i=0; i < iters; i++) { tiarr2a.copy(tiarr2b); } t.stop(); report("non-contiguous local 2-d global array copy", t, iters); t.reset(); t.start(); for (int i=0; i < iters; i++) { ltiarr2a.copy(ltiarr2b); } t.stop(); report("non-contiguous local 2-d local array copy", t, iters); t.reset(); t.start(); for (int i=0; i < iters; i++) { tiarr3a.copy(tiarr3b); } t.stop(); report("non-contiguous local 3-d global array copy", t, iters); t.reset(); t.start(); for (int i=0; i < iters; i++) { ltiarr3a.copy(ltiarr3b); } t.stop(); report("non-contiguous local 3-d local array copy", t, iters); }}