Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMult_4x4_13.c incorrect if clause #26

Open
horgerares opened this issue Sep 21, 2024 · 1 comment
Open

MMult_4x4_13.c incorrect if clause #26

horgerares opened this issue Sep 21, 2024 · 1 comment

Comments

@horgerares
Copy link

horgerares commented Sep 21, 2024

In MMult_4x4_13.c

for ( j=0; j<n; j+=4 ){        /* Loop over the columns of C, unrolled by 4 */
    for ( i=0; i<m; i+=4 ){        /* Loop over the rows of C */
      /* Update C( i,j ), C( i,j+1 ), C( i,j+2 ), and C( i,j+3 ) in
	 one routine (four inner products) */
      if ( j == 0 ) PackMatrixA( k, &A( i, 0 ), lda, &packedA[ i*k ] );
      AddDot4x4( k, &packedA[ i*k ], 4, &B( 0,j ), ldb, &C( i,j ), ldc );
    }
  }

I don't think this if ( j == 0 ) clause is correct, because the PackMatrixA function receives the i variable as an argument.
If this line is correct, could someone explain me why?

@FLASHSHIKI
Copy link

在 MMult_4x4_13.c 中

for ( j=0; j<n; j+=4 ){        /* Loop over the columns of C, unrolled by 4 */
    for ( i=0; i<m; i+=4 ){        /* Loop over the rows of C */
      /* Update C( i,j ), C( i,j+1 ), C( i,j+2 ), and C( i,j+3 ) in
	 one routine (four inner products) */
      if ( j == 0 ) PackMatrixA( k, &A( i, 0 ), lda, &packedA[ i*k ] );
      AddDot4x4( k, &packedA[ i*k ], 4, &B( 0,j ), ldb, &C( i,j ), ldc );
    }
  }

我认为这个子句不正确,因为 PackMatrixA 函数接收变量作为参数。如果这句话是正确的,有人可以解释我为什么吗?if ( j == 0 )``i

Because packedA can be reused when iterating over j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants