How cache memory works?

前端 未结 5 783
[愿得一人]
[愿得一人] 2021-02-06 02:10

Today when I was in computer organization class, teacher talked about something interesting to me. When it comes to talk about Why cache memory works, he said that:



        
5条回答
  •  终归单人心
    2021-02-06 02:33

    In C, n-dimensional matrices are row major, meaning the last index into the matrix represents adjacent spaces in memory. This is different than some other languages, FORTRAN for example, which are column major. In FORTRAN, it's more efficient to iterate through a 2D matrix like this:

    do jj = 1,N
      do ii = 1,M
        x(ii,jj) = x(ii,jj) + K;
      enddo
    enddo
    

提交回复
热议问题