cpp: void init_array(int ni, int nj, int nk, int nl,\nDATA_TYPE *alpha,\nDATA_TYPE *beta,\nDATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nl),\nDATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj),\nDATA_TYPE POLYBENCH_2D(C,NL,NJ,nl,nj),\nDATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl))\n{\nint i, j;\n\n*alpha = 32412;\n*beta = 2123;\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 < nl; i++)\nfor (j = 0; j < nj; j++)\nC[i][j] = ((DATA_TYPE) i*(j+3)) / nl;\nfor (i = 0; i < ni; i++)\nfor (j = 0; j < nl; j++)\nD[i][j] = ((DATA_TYPE) i*(j+2)) / nk;\n}
fortran: subroutine init_array(alpha, beta, a, b, c ,d, ni, nj,  &\nnk, nl)\nimplicit none\n\nDATA_TYPE, dimension(nk, ni) :: a\nDATA_TYPE, dimension(nj, nk) :: b\nDATA_TYPE, dimension(nl, nj) :: c\nDATA_TYPE, dimension(nl, ni) :: d\nDATA_TYPE :: alpha, beta\ninteger :: ni, nj, nk, nl\ninteger :: i, j\n\nalpha = 32412;\nbeta = 2123;\n\ndo i = 1, ni\ndo j = 1, nk\na(j,i) = DBLE((i-1) * (j-1)) / ni\nend do\nend do\n\ndo i = 1, nk\ndo j = 1, nj\nb(j,i) = (DBLE((i-1) * (j)))/ nj\nend do\nend do\n\ndo i = 1, nl\ndo j = 1, nj\nc(j,i) = (DBLE(i-1) * (j+2))/ nl\nend do\nend do\n\ndo i = 1, ni\ndo j = 1, nl\nd(j,i) = (DBLE(i-1) * (j+1))/ nk\nend do\nend do\nend subroutine