// Interactive test for barrier performance // accuracy of barrier performance measurement improves as the test proceeds // Dan Bonachea public class barrierperf { public static int initsize = 10; public static double epsilon = 0.001; public static double growfactor = 1.5; public static double getBarrierTime(int single numiters) { Ti.barrier(); // wait for everyone long starttime = System.currentTimeMillis(); for (int single i = 0; i < numiters; i++) { Ti.barrier(); } long endtime = System.currentTimeMillis(); return (endtime - starttime) / 1000.0 / numiters; } public static void main(String[]args) { if (Ti.thisProc() == 0) System.out.println("Testing barrier performance on " + Ti.numProcs() + " processors."); double numiters = initsize; double barrtime = getBarrierTime(broadcast ((int)numiters) from 0); double newtime; boolean single done = false; while (!done) { if (Ti.thisProc() == 0) System.out.println((barrtime * 1000.0) + " ms per barrier (" + (int)numiters + " iterations)" ); newtime = getBarrierTime(broadcast ((int)numiters) from 0); boolean temp = false; if (newtime * numiters < 0.1 || Math.abs(newtime-barrtime)/newtime > epsilon) { numiters *= growfactor; } else temp = true; done = broadcast temp from 0; barrtime = newtime; } } }