In compiler theory, loop interchange is the process of exchanging the order of two iteration variables used by a nested loop. The variable used in the inner loop switches to the outer loop, and vice versa. It is often done to ensure that the elements of a multi-dimensional array are accessed in the order in which they are present in memory, improving locality of reference. For example, in the code fragment: for i from 0 to 10 for j from 0 to 20 a[i,j] = i + j loop interchange would result in: for j from 0 to 20 for i from 0 to 10 a[i,j] = i + j
Attributes | Values |
---|
rdf:type
| |
rdfs:label
| - Loop interchange (en)
- Перестановка циклов (ru)
|
rdfs:comment
| - In compiler theory, loop interchange is the process of exchanging the order of two iteration variables used by a nested loop. The variable used in the inner loop switches to the outer loop, and vice versa. It is often done to ensure that the elements of a multi-dimensional array are accessed in the order in which they are present in memory, improving locality of reference. For example, in the code fragment: for i from 0 to 10 for j from 0 to 20 a[i,j] = i + j loop interchange would result in: for j from 0 to 20 for i from 0 to 10 a[i,j] = i + j (en)
- Перестановка циклов (англ. Loop interchange) — оптимизация компилятора при которой меняется порядок итерационных переменных, относящихся к группе вложенных циклов. Итерационная переменная, используемая во внутреннем цикле, перемещается во внешний цикл, и наоборот. Это часто делается, чтобы гарантировать, что элементы многомерных массивов доступны в том порядке, в котором они хранятся в памяти, т.е. для улучшения локальности ссылок. Например, следующий код: for (int j=0; j<10; j++){ for (int i=0; i<20; i++) { y[i][j] = i + j; }} в результате применения оптимизации может быть преобразован в: (ru)
|
foaf:depiction
| |
dcterms:subject
| |
Wikipage page ID
| |
Wikipage revision ID
| |
Link from a Wikipage to another Wikipage
| |
sameAs
| |
dbp:wikiPageUsesTemplate
| |
thumbnail
| |
has abstract
| - In compiler theory, loop interchange is the process of exchanging the order of two iteration variables used by a nested loop. The variable used in the inner loop switches to the outer loop, and vice versa. It is often done to ensure that the elements of a multi-dimensional array are accessed in the order in which they are present in memory, improving locality of reference. For example, in the code fragment: for i from 0 to 10 for j from 0 to 20 a[i,j] = i + j loop interchange would result in: for j from 0 to 20 for i from 0 to 10 a[i,j] = i + j On occasion, such a transformation may create opportunities to further optimize, such as automatic vectorization of the array assignments. (en)
- Перестановка циклов (англ. Loop interchange) — оптимизация компилятора при которой меняется порядок итерационных переменных, относящихся к группе вложенных циклов. Итерационная переменная, используемая во внутреннем цикле, перемещается во внешний цикл, и наоборот. Это часто делается, чтобы гарантировать, что элементы многомерных массивов доступны в том порядке, в котором они хранятся в памяти, т.е. для улучшения локальности ссылок. Например, следующий код: for (int j=0; j<10; j++){ for (int i=0; i<20; i++) { y[i][j] = i + j; }} в результате применения оптимизации может быть преобразован в: for (int i=0; i<20; i++){ for (int j=0; j<10; j++) { y[i][j] = i + j; }} В отдельных случаях, такое преобразование может создать контекст для дальнейших оптимизаций, например для векторизации. В то же время, как и любая другая оптимизация компилятора, данная оптимизация может привести к ухудшению производительности. Рассмотрим следующий пример: for (int i=0; i<10; i++){ for (int j=0; j<20; j++) { a[i] = a[i] + b[j][i] * c[i] }} Применение оптимизации в данном случае может улучшить производительность доступа к b[j][i], однако появятся повторные чтения a[i] и c[i] во внутреннем цикле в течение каждой итерации. В результате, эффективность работы может ухудшиться. (ru)
|
prov:wasDerivedFrom
| |
page length (characters) of wiki page
| |
foaf:isPrimaryTopicOf
| |
is Link from a Wikipage to another Wikipage
of | |
is foaf:primaryTopic
of | |