110 - Longer Vector Length - 2D Array Description
You can write it as 2D array in C.
$ diff vlen2d.c vlen2.c // 2d means '2 Dimensional`
https://gyazo.com/8ba1ce71bbbd333a2edb2eaf60ed3cb4
cat -n vlen2d.c
code:vlen2d.c
6 #define PAD 1 /* padding in column to skew column in neighbour rows */ 14 double aMN+PAD; /* 2 dim array, 64M + pad */ 17 void myloop(int m, int n) {
18 int i, j;
19 for(i = 0; i < m; i++) {
20 for(j = 0; j < n; j++) {
22 }
23 }
24 }
27 double start = get_dtime();
28 myloop(M, N);
29 printf("elapsed time = %.3f sec\n",get_dtime() - start);
$ gcc -O vlen2.c
$ a.out // 0.246 sec
$ ncc -ftrace vlen2.c -o n.out
$ n.out // 0.002 sec = 116 times speed against gcc.
$ ncc -ftrace vlen2d.c -o n2d.out
$ n2d.out // 0.002 sec = 123 times speed against gcc.
$ ftrace -f ftrace.out
https://gyazo.com/593fc1b1157f743be2a1da3502c2b6a2