cpp: void kernel_3mm(int ni, int nj, int nk, int nl, int nm,\nDATA_TYPE POLYBENCH_2D(E,NI,NJ,ni,nj),\nDATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk),\nDATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj),\nDATA_TYPE POLYBENCH_2D(F,NJ,NL,nj,nl),\nDATA_TYPE POLYBENCH_2D(C,NJ,NM,nj,nm),\nDATA_TYPE POLYBENCH_2D(D,NM,NL,nm,nl),\nDATA_TYPE POLYBENCH_2D(G,NI,NL,ni,nl))\n{\nint i, j, k;\n\n#pragma scop\n/* E := A*B */\nfor (i = 0; i < _PB_NI; i++)\nfor (j = 0; j < _PB_NJ; j++)\n{\nE[i][j] = 0;\nfor (k = 0; k < _PB_NK; ++k)\nE[i][j] += A[i][k] * B[k][j];\n}\n/* F := C*D */\nfor (i = 0; i < _PB_NJ; i++)\nfor (j = 0; j < _PB_NL; j++)\n{\nF[i][j] = 0;\nfor (k = 0; k < _PB_NM; ++k)\nF[i][j] += C[i][k] * D[k][j];\n}\n/* G := E*F */\nfor (i = 0; i < _PB_NI; i++)\nfor (j = 0; j < _PB_NL; j++)\n{\nG[i][j] = 0;\nfor (k = 0; k < _PB_NJ; ++k)\nG[i][j] += E[i][k] * F[k][j];\n}\n#pragma endscop\n\n}
fortran: subroutine kernel_3mm(ni, nj, nk, nl, nm, e, a, b, f, c, d, g)\nimplicit none\n\nDATA_TYPE, dimension(nk, ni) :: a\nDATA_TYPE, dimension(nj, nk) :: b\nDATA_TYPE, dimension(nm, nj) :: c\nDATA_TYPE, dimension(nl, nm) :: d\nDATA_TYPE, dimension(nj, ni) :: e\nDATA_TYPE, dimension(nl, nj) :: f\nDATA_TYPE, dimension(nl, ni) :: g\ninteger :: ni, nj, nk, nl, nm\ninteger :: i, j, k\n\n!$pragma scop\n! E := A*B\ndo i = 1, _PB_NI\ndo j = 1, _PB_NJ\ne(j,i) = 0.0\ndo k = 1, _PB_NK\ne(j,i) = e(j,i) + a(k,i) * b(j,k)\nend do\nend do\nend do\n\n! F := C*D\ndo i = 1, _PB_NJ\ndo j = 1, _PB_NL\nf(j,i) = 0.0\ndo k = 1, _PB_NM\nf(j,i) = f(j,i) + c(k,i) * d(j,k)\nend do\nend do\nend do\n\n! G := E*F\ndo i = 1, _PB_NI\ndo j = 1, _PB_NL\ng(j,i) = 0.0\ndo k = 1, _PB_NJ\ng(j,i) = g(j,i) + e(k,i) * f(j,k)\nend do\nend do\nend do\n!$pragma endscop\n\nend subroutine