インテルのみ表示可能 — GUID: uvd1473351497751
Ixiasoft
10.3.1. ループ分析例
High Level Design レポート (report.html) ファイル例は、transpose_and_fold.cpp ( <quartus_installdir>/hls/examples/tutorials/best_practices/loop_memory_dependencyで提供されるチュートリアル・ファイルの一部 ) から取得した HLS コンポーネントのデザインのループ分析を表示します。
transpose_and_fold.cppで次のコードスぺニット例を考察します。
01: #include "HLS/hls.h" 02: #include <stdio.h> 03: #include <stdlib.h> 04: 05: #define SIZE 32 06: 07: typedef ihc::stream_in<int> my_operand; 08: typedef ihc::stream_out<int> my_result; 09: 10: component void transpose_and_fold(my_operand &data_in, my_result &res) 11: { 12: int i; 13: int j; 14: int in_buf[SIZE][SIZE]; 15: int tmp_buf[SIZE][SIZE]; 16: for (i = 0; i < SIZE * SIZE; i++) { 17: in_buf[i / SIZE][i % SIZE] = data_in.read(); 18: tmp_buf[i / SIZE][i % SIZE] = 0; 19: } 20: 21: #ifdef USE_IVDEP 22: #pragma ivdep safelen(SIZE) 23: #endif 24: for (j = 0; j < SIZE * SIZE * SIZE; j++) { 25: #pragma unroll 26: for (i = 0; i < SIZE; i++) { 27: tmp_buf[j % SIZE][i] += in_buf[i][j % SIZE]; 28: } 29: } 30: for (i = 0; i < SIZE * SIZE; i++) { 31: res.write(tmp_buf[i / SIZE][i % SIZE]); 32: } 33: }
図 4. transpose_and_fold コンポーネントのループ分析レポート

transpose_and_foldコンポーネントはループが 4 つのあります。ループ分析レポートは、コンパイラーが異なる種類のループ最適化の結果を表示します。
- 24 行目のループは #pragma unrollの定義として、すべて展開されています。
- 16 行目と 30 行目のループは、II の値が 1 でパイプラインされています。
ループ分析レポート内のBlock1.startループはコード内には現れません。これは、コンポーネントが 1 回のみではなく連続的に実行できるようにコンパイラーが追加する暗黙的な無限ループです。