cpp: void kernel_adi(int tsteps,\nint n,\nDATA_TYPE POLYBENCH_2D(X,N,N,n,n),\nDATA_TYPE POLYBENCH_2D(A,N,N,n,n),\nDATA_TYPE POLYBENCH_2D(B,N,N,n,n))\n{\nint t, i1, i2;\n\n#pragma scop\nfor (t = 0; t < _PB_TSTEPS; t++)\n{\nfor (i1 = 0; i1 < _PB_N; i1++)\nfor (i2 = 1; i2 < _PB_N; i2++)\n{\nX[i1][i2] = X[i1][i2] - X[i1][i2-1] * A[i1][i2] / B[i1][i2-1];\nB[i1][i2] = B[i1][i2] - A[i1][i2] * A[i1][i2] / B[i1][i2-1];\n}\n\nfor (i1 = 0; i1 < _PB_N; i1++)\nX[i1][_PB_N-1] = X[i1][_PB_N-1] / B[i1][_PB_N-1];\n\nfor (i1 = 0; i1 < _PB_N; i1++)\nfor (i2 = 0; i2 < _PB_N-2; i2++)\nX[i1][_PB_N-i2-2] = (X[i1][_PB_N-2-i2] - X[i1][_PB_N-2-i2-1] * A[i1][_PB_N-i2-3]) / B[i1][_PB_N-3-i2];\n\nfor (i1 = 1; i1 < _PB_N; i1++)\nfor (i2 = 0; i2 < _PB_N; i2++) {\nX[i1][i2] = X[i1][i2] - X[i1-1][i2] * A[i1][i2] / B[i1-1][i2];\nB[i1][i2] = B[i1][i2] - A[i1][i2] * A[i1][i2] / B[i1-1][i2];\n}\n\nfor (i2 = 0; i2 < _PB_N; i2++)\nX[_PB_N-1][i2] = X[_PB_N-1][i2] / B[_PB_N-1][i2];\n\nfor (i1 = 0; i1 < _PB_N-2; i1++)\nfor (i2 = 0; i2 < _PB_N; i2++)\nX[_PB_N-2-i1][i2] = (X[_PB_N-2-i1][i2] - X[_PB_N-i1-3][i2] * A[_PB_N-3-i1][i2]) / B[_PB_N-2-i1][i2];\n}\n#pragma endscop\n\n}
fortran: subroutine kernel_adi(tsteps, n, x, a, b)\nimplicit none\n\nDATA_TYPE, dimension(n, n) :: a\nDATA_TYPE, dimension(n, n) :: x\nDATA_TYPE, dimension(n, n) :: b\ninteger :: n, tsteps\ninteger :: i1, i2, t\n\n!$pragma scop\ndo t = 1, _PB_TSTEPS\ndo i1 = 1, _PB_N\ndo i2 = 2, _PB_N\nx(i2, i1) = x(i2, i1) - ((x(i2 - 1, i1) * a(i2, i1)) / &\nb(i2 - 1, i1))\nb(i2, i1) = b(i2, i1) - ((a(i2, i1) * a(i2, i1)) / &\nb(i2 - 1, i1))\nend do\nend do\n\ndo i1 = 1, _PB_N\nx(_PB_N, i1) = x(_PB_N, i1) / b(_PB_N, i1)\nend do\n\ndo i1 = 1, _PB_N\ndo i2 = 1, _PB_N - 2\nx(_PB_N - i2, i1) = (x(_PB_N - i2, i1) - &\n(x(_PB_N - i2 - 1, i1) * &\na(_PB_N - i2 - 1, i1))) / &\nb(_PB_N - i2 - 1, i1)\nend do\nend do\n\ndo i1 = 2, _PB_N\ndo i2 = 1, _PB_N\nx(i2, i1) = x(i2, i1) - x(i2, i1 - 1) * a(i2, i1) / &\nb(i2, i1 - 1)\nb(i2, i1) = b(i2, i1) - a(i2, i1) * a(i2, i1) / &\nb(i2, i1 - 1)\n\nend do\nend do\n\ndo i2 = 1, _PB_N\nx(i2, _PB_N) = x(i2, _PB_N) / b(i2, _PB_N)\nend do\n\ndo i1 = 1, _PB_N - 2\ndo i2 = 1, _PB_N\nx(i2, _PB_N - i1) = (x(i2, _PB_N - i1) - &\nx(i2, _PB_N - i1 - 1) * &\na(i2, _PB_N - i1 - 1)) / &\nb(i2, _PB_N - i1)\nend do\nend do\nend do\n!$pragma endscop\nend subroutine