cpp: void kernel_reg_detect(int niter, int maxgrid, int length,\nDATA_TYPE POLYBENCH_2D(sum_tang,MAXGRID,MAXGRID,maxgrid,maxgrid),\nDATA_TYPE POLYBENCH_2D(mean,MAXGRID,MAXGRID,maxgrid,maxgrid),\nDATA_TYPE POLYBENCH_2D(path,MAXGRID,MAXGRID,maxgrid,maxgrid),\nDATA_TYPE POLYBENCH_3D(diff,MAXGRID,MAXGRID,LENGTH,maxgrid,maxgrid,length),\nDATA_TYPE POLYBENCH_3D(sum_diff,MAXGRID,MAXGRID,LENGTH,maxgrid,maxgrid,length))\n{\nint t, i, j, cnt;\n\n#pragma scop\nfor (t = 0; t < _PB_NITER; t++)\n{\nfor (j = 0; j <= _PB_MAXGRID - 1; j++)\nfor (i = j; i <= _PB_MAXGRID - 1; i++)\nfor (cnt = 0; cnt <= _PB_LENGTH - 1; cnt++)\ndiff[j][i][cnt] = sum_tang[j][i];\n\nfor (j = 0; j <= _PB_MAXGRID - 1; j++)\n{\nfor (i = j; i <= _PB_MAXGRID - 1; i++)\n{\nsum_diff[j][i][0] = diff[j][i][0];\nfor (cnt = 1; cnt <= _PB_LENGTH - 1; cnt++)\nsum_diff[j][i][cnt] = sum_diff[j][i][cnt - 1] + diff[j][i][cnt];\nmean[j][i] = sum_diff[j][i][_PB_LENGTH - 1];\n}\n}\n\nfor (i = 0; i <= _PB_MAXGRID - 1; i++)\npath[0][i] = mean[0][i];\n\nfor (j = 1; j <= _PB_MAXGRID - 1; j++)\nfor (i = j; i <= _PB_MAXGRID - 1; i++)\npath[j][i] = path[j - 1][i - 1] + mean[j][i];\n}\n#pragma endscop\n\n}
fortran: subroutine kernel_reg_detect(niter, maxgrid, length, &\nsumTang, mean, path, diff, sumDiff)\nimplicit none\n\ninteger :: maxgrid, niter, length\nDATA_TYPE, dimension (maxgrid, maxgrid) :: sumTang, mean, path\nDATA_TYPE, dimension (length, maxgrid, maxgrid) :: sumDiff, diff\ninteger :: i, j, t, cnt\n\n!$pragma scop\ndo t = 1, _PB_NITER\ndo j = 1, _PB_MAXGRID\ndo i = j, _PB_MAXGRID\ndo cnt = 1, _PB_LENGTH\ndiff(cnt, i, j) = sumTang(i, j)\nend do\nend do\nend do\n\ndo j = 1, _PB_MAXGRID\ndo i = j, _PB_MAXGRID\nsumDiff(1, i, j) = diff(1, i, j)\ndo cnt = 2, _PB_LENGTH\nsumDiff(cnt, i, j) = sumDiff(cnt - 1, i, j) + &\ndiff(cnt, i, j)\nend do\nmean(i, j) = sumDiff(_PB_LENGTH, i, j)\nend do\nend do\n\ndo i = 1, _PB_MAXGRID\npath(i, 1) = mean(i, 1)\nend do\n\ndo j = 2, _PB_MAXGRID\ndo i = j, _PB_MAXGRID\npath(i, j) = path(i - 1, j - 1) + mean(i, j)\nend do\nend do\nend do\n!$pragma endscop\nend subroutine