cpp: void kernel_dynprog(int tsteps, int length,\nDATA_TYPE POLYBENCH_2D(c,LENGTH,LENGTH,length,length),\nDATA_TYPE POLYBENCH_2D(W,LENGTH,LENGTH,length,length),\nDATA_TYPE POLYBENCH_3D(sum_c,LENGTH,LENGTH,LENGTH,length,length,length),\nDATA_TYPE *out)\n{\nint iter, i, j, k;\n\nDATA_TYPE out_l = 0;\n\n#pragma scop\nfor (iter = 0; iter < _PB_TSTEPS; iter++)\n{\nfor (i = 0; i <= _PB_LENGTH - 1; i++)\nfor (j = 0; j <= _PB_LENGTH - 1; j++)\nc[i][j] = 0;\n\nfor (i = 0; i <= _PB_LENGTH - 2; i++)\n{\nfor (j = i + 1; j <= _PB_LENGTH - 1; j++)\n{\nsum_c[i][j][i] = 0;\nfor (k = i + 1; k <= j-1; k++)\nsum_c[i][j][k] = sum_c[i][j][k - 1] + c[i][k] + c[k][j];\nc[i][j] = sum_c[i][j][j-1] + W[i][j];\n}\n}\nout_l += c[0][_PB_LENGTH - 1];\n}\n#pragma endscop\n\n*out = out_l;\n}
fortran: subroutine kernel_dynprog(tsteps , length, c, w, sumC, output)\nimplicit none\n\nDATA_TYPE, dimension(length, length) :: w, c\nDATA_TYPE, dimension(length, length, length) :: sumC\ninteger :: i, j, iter, k\ninteger :: length, tsteps\nDATA_TYPE :: output\n\n!$pragma scop\noutput = 0\n\ndo iter = 1, _PB_TSTEPS\ndo i = 1, _PB_LENGTH\ndo j = 1, _PB_LENGTH\nc(j, i) = 0\nend do\nend do\n\ndo i = 1, _PB_LENGTH - 1\ndo j = i + 1, _PB_LENGTH\nsumC(i, j, i) = 0\ndo k = i + 1, j - 1\nsumC(k, j, i) = sumC(k - 1, j, i) + c(k, i) + c(j, k)\nend do\nc(j, i) = sumC(j - 1, j, i) + w(j, i)\nend do\nend do\noutput = output + c(_PB_LENGTH, 1)\nend do\n!$pragma endscop\nend subroutine