Опубликован: 12.07.2012 | Доступ: свободный | Студентов: 338 / 21 | Оценка: 4.00 / 4.20 | Длительность: 11:07:00
Специальности: Программист
Лекция 4:

Optimizing compiler. Loop optimizations

< Лекция 3 || Лекция 4: 123456 || Лекция 5 >
INTEGER,PARAMETER :: N=100
INTEGER,PARAMETER :: REPEAT=1000
INTEGER :: A(N,N,N), B(N,N,N)
INTEGER :: REP,I,J,K

A=1
B=1

DO REP=1,REPEAT

  DO I=1,N
    DO J=1,N
      DO K=1,N
        A(J,K,I) = A(J,K,I)+B(J,K,I)
      END DO
    END DO
  END DO

END DO

PRINT *,A(1,1,1)
END
The example of the effectiveness of optimization of loop interchange

Рис. 4.12. The example of the effectiveness of optimization of loop interchange

Loop blocking is a loop optimization which divides a loop iteration space into smaller chunks or blocks, so the loop data stays in the cache until it is reused. The partitioning of loop iteration space leads to partitioning the array used, so array elements fit the cache better, it enhancing cache reuse and decreasing required cache size.


Рис. 4.15.
< Лекция 3 || Лекция 4: 123456 || Лекция 5 >
Мария Зайцева
Мария Зайцева
Россия, Воронеж, ВГУ