         boundB -= BLK_K;
         
         #pragma unroll
-        for (n = 0; n < BLK_K / DIM_YA; n++)
-            #pragma unroll
-            for (m = 0; m < BLK_M / DIM_XA; m++)
+        for (n = 0; n < BLK_K / DIM_YA; n++) {
+            #pragma unroll
+            for (m = 0; m < BLK_M / DIM_XA; m++) {
                 ra[n][m] = offs_dA[n * DIM_YA * M + m * DIM_XA];
-
-        #pragma unroll
-        for (n = 0; n < BLK_N / DIM_YB; n++)
-            #pragma unroll
-            for (m = 0; m < BLK_K / DIM_XB; m++)
+            }
+        }
+
+        #pragma unroll
+        for (n = 0; n < BLK_N / DIM_YB; n++) {
+            #pragma unroll
+            for (m = 0; m < BLK_K / DIM_XB; m++) {
                 rb[n][m] = offs_dB[n * DIM_YB * K + m * DIM_XB];
+            }
+        }
 
         // multiply
         #pragma unroll
         for (k = 0; k < BLK_K; k++)
         {
             #pragma unroll
-            for (m = 0; m < THR_M; m++)
+            for (m = 0; m < THR_M; m++) {
                 rA[m] = sA[k][m * DIM_X + idx];
+            }
             
             #pragma unroll
-            for (n = 0; n < THR_N; n++)
+            for (n = 0; n < THR_N; n++) {
                 rB[n] = sB[n * DIM_Y + idy][k];
+            }
 
             #pragma unroll
             for (n = 0; n < THR_N; n++) {

    int m, n, k, kk;
    
    #pragma unroll
    for (n = 0; n < THR_N; n++)
        #pragma unroll
        for (m = 0 ; m < THR_M; m++)
            rC[n][m] = 0;

    // blockwise transpose to transpose load
    #pragma unroll
    for (n = 0; n < BLK_K; n += DIM_YA)
        #pragma unroll
        for (m = 0; m < BLK_M; m += DIM_XA)
            sA[n + idyA][m + idxA] = offs_dA[n * M + m];
    // blockwise transpose to transpose load
    #pragma unroll
    for (n = 0; n < BLK_N; n += DIM_YB)
        #pragma unroll
        for (m = 0; m < BLK_K; m += DIM_XB)
            sB[n + idyB][m + idxB] = offs_dB[n * K + m];
    __syncthreads();

    for (kk = 0; kk < K - BLK_K; kk += BLK_K)

        // store A regs->smem
        #pragma unroll
        for (n = 0; n < BLK_K / DIM_YA; n++)
        {
            #pragma unroll
            for (m = 0; m < BLK_M / DIM_XA; m++)
            {
                sA[n * DIM_YA + idyA][m * DIM_XA + idxA] = ra[n][m];
            }
        }

        #pragma unroll
        for (n = 0; n < BLK_N / DIM_YB; n++)
        {
            #pragma unroll
            for (m = 0; m < BLK_K / DIM_XB; m++)
            {
                if (BLK_N <= n * DIM_YB + idyB)
                    printf("aaa %d %d\n", BLK_N, n * DIM_YB + idyB);
                if ((BLK_K + 1) <= (m * DIM_XB + idxB))
                    printf("bbb %d %d %d %d\n", BLK_K + 1, m * DIM_XB + idxB, m, BLK_K / DIM_XB);
                sB[n * DIM_YB + idyB][m * DIM_XB + idxB] = rb[n][m];
            }
        }
        __syncthreads();
    }

