cpp: void init_array (int nx, int ny,\nDATA_TYPE POLYBENCH_2D(A,NX,NY,nx,ny),\nDATA_TYPE POLYBENCH_1D(r,NX,nx),\nDATA_TYPE POLYBENCH_1D(p,NY,ny))\n{\nint i, j;\n\nfor (i = 0; i < ny; i++)\np[i] = i * M_PI;\nfor (i = 0; i < nx; i++) {\nr[i] = i * M_PI;\nfor (j = 0; j < ny; j++)\nA[i][j] = ((DATA_TYPE) i*(j+1))/nx;\n}\n}
fortran: subroutine init_array(nx, ny, a, r, p)\nimplicit none\n\ndouble precision :: M_PI\nparameter(M_PI = 3.14159265358979323846D0)\nDATA_TYPE, dimension(ny, nx) :: a\nDATA_TYPE, dimension(nx) :: r\nDATA_TYPE, dimension(ny) :: p\ninteger :: nx, ny\ninteger :: i, j\n\ndo i = 1, ny\np(i) = DBLE(i - 1) * M_PI\nend do\n\ndo i = 1, nx\nr(i) = DBLE(i - 1) * M_PI\ndo j = 1, ny\na(j, i) = (DBLE(i - 1) * DBLE(j)) / nx\nend do\nend do\nend subroutine