public class transpose { public static void main(String[]args) { int output = 0; int S = 128; int iters = 10; if (args.length >= 1) try { output = Integer.parseInt(args[0]); } catch (Throwable x) {} if (args.length >= 2) try { S = Integer.parseInt(args[1]); } catch (Throwable x) {} if (args.length >= 3) try { iters = Integer.parseInt(args[2]); } catch (Throwable x) {} Double.setPrecision(5); System.out.println("3-D Transpose test: sz="+[S,S,S]+ "("+(S*S*S)+" elements, "+(S*S*S*8)+" bytes) iters="+iters); double [3d] src = new double[[0,0,0]:[S-1,S-1,S-1]]; double [3d] dst = new double[[0,0,0]:[S-1,S-1,S-1]]; double [1d][3d] srcs = new double[0:5][3d]; double [1d][3d] dsts = new double[0:5][3d]; Point<3>[1d] ps = new Point<3>[0:5]; ps[0] = [1,2,3]; ps[1] = [1,3,2]; ps[2] = [2,1,3]; ps[3] = [2,3,1]; ps[4] = [3,1,2]; ps[5] = [3,2,1]; foreach (i in ps.domain()) { srcs[i] = src.permute(ps[i]); dsts[i] = dst.permute(ps[i]); } foreach (p in src.domain()) { src[p] = 1000000*p[1] + 1000*p[2] + p[3]; } foreach (i in ps.domain()) { foreach (j in ps.domain()) { Timer t = new Timer(); dst.set(0); t.start(); for (int x=0;x" + ps[j] + ": " + (output != 0 ? ""+(t.millis()/iters) + " ms/iter":"")); foreach (p in dsts[j].domain()) { if (srcs[i][p] != dsts[j][p]) { System.out.println("VERIFICATION FAILED: srcs["+i+"]"+p+"="+srcs[i][p]+ " dsts["+i+"]"+p+"="+dsts[i][p]); } } }} }}