cpp: void init_array(int ni, int nj, int nk, int nl, int nm,\nDATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk),\nDATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj),\nDATA_TYPE POLYBENCH_2D(C,NJ,NM,nj,nm),\nDATA_TYPE POLYBENCH_2D(D,NM,NL,nm,nl))\n{\nint i, j;\n\nfor (i = 0; i < ni; i++)\nfor (j = 0; j < nk; j++)\nA[i][j] = ((DATA_TYPE) i*j) / ni;\nfor (i = 0; i < nk; i++)\nfor (j = 0; j < nj; j++)\nB[i][j] = ((DATA_TYPE) i*(j+1)) / nj;\nfor (i = 0; i < nj; i++)\nfor (j = 0; j < nm; j++)\nC[i][j] = ((DATA_TYPE) i*(j+3)) / nl;\nfor (i = 0; i < nm; i++)\nfor (j = 0; j < nl; j++)\nD[i][j] = ((DATA_TYPE) i*(j+2)) / nk;\n}
fortran: subroutine init_array(ni, nj, nk, nl, nm, a, b, c , d)\nimplicit none\n\nDATA_TYPE, dimension(nk, ni) :: a\nDATA_TYPE, dimension(nj, nk) :: b\nDATA_TYPE, dimension(nm, nj) :: c\nDATA_TYPE, dimension(nl, nm) :: d\ninteger :: ni, nj, nk, nl, nm\ninteger :: i, j\n\ndo i = 1, ni\ndo j = 1, nk\na(j,i) = DBLE(i-1) * DBLE(j-1) / ni\nend do\nend do\n\ndo i = 1, nk\ndo j = 1, nj\nb(j,i) = (DBLE(i-1) * DBLE(j))/ nj\nend do\nend do\n\ndo i = 1, nj\ndo j = 1, nm\nc(j,i) = (DBLE(i-1) * DBLE(j+2))/ nl\nend do\nend do\n\ndo i = 1, nm\ndo j = 1, nl\nd(j,i) = (DBLE(i-1) * DBLE(j+1))/ nk\nend do\nend do\nend subroutine