JP2011197876A - Program, apparatus and method for optimization processing - Google Patents

Program, apparatus and method for optimization processing Download PDF

Info

Publication number
JP2011197876A
JP2011197876A JP2010062312A JP2010062312A JP2011197876A JP 2011197876 A JP2011197876 A JP 2011197876A JP 2010062312 A JP2010062312 A JP 2010062312A JP 2010062312 A JP2010062312 A JP 2010062312A JP 2011197876 A JP2011197876 A JP 2011197876A
Authority
JP
Japan
Prior art keywords
loop
blocking
array
optimization
calculation formula
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2010062312A
Other languages
Japanese (ja)
Other versions
JP5402746B2 (en
Inventor
Shuichi Chiba
修一 千葉
Tomoko Shoji
智子 庄司
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2010062312A priority Critical patent/JP5402746B2/en
Publication of JP2011197876A publication Critical patent/JP2011197876A/en
Application granted granted Critical
Publication of JP5402746B2 publication Critical patent/JP5402746B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a technology capable of executing optimization by blocking even to a multiple loop not smaller than a triple loop, and the multiple loop including an array of a three-dimensional array or more.SOLUTION: A processing target loop analysis part 100 extracts a tight loop from a source program as a blocking target loop. An array analysis part 110 extracts an array included in the blocking target loop. When there is an array whose access pattern is a cross, an access pattern analysis part 120, determines that blocking to the blocking target loop is valid. A memory size calculation formula generation part 130 generates a calculation formula of a size of a memory to be accessed by the array. A divided block length calculation part 140 determines a divided block length by which a memory size not exceeding a cache size can be obtained by using the memory size calculation formula. An optimization execution part 17 executes blocking using the determined divided block length.

Description

本発明は,プログラミング言語で記述されたソースプログラムに含まれるループの最適化を行う最適化処理プログラム,最適化処理装置および最適化処理方法に関するものである。   The present invention relates to an optimization processing program, an optimization processing apparatus, and an optimization processing method for optimizing a loop included in a source program described in a programming language.

コンパイラには,キャッシュメモリをソフトウェアから有効活用するための技術として,ブロッキングと呼ばれる最適化の技術が用意されている。ブロッキングは,ソースプログラム中に存在する多重ループの処理構造に対して,その最内ループ内で使用する配列に対するメモリアクセスがキャッシュメモリのサイズに収まるように,多重ループの回転数を分割する技術である。コンパイラがソースプログラムに対してブロッキングによる最適化を実行することにより,配列のデータが常にキャッシュメモリ上に保持されるようになり,キャッシュヒット率が向上する。   The compiler provides an optimization technique called blocking as a technique for effectively using cache memory from software. Blocking is a technology that divides the number of rotations of a multi-loop so that memory access to the array used in the innermost loop is within the size of the cache memory for the multi-loop processing structure existing in the source program. is there. When the compiler performs blocking optimization on the source program, the array data is always held in the cache memory, and the cache hit rate is improved.

なお,最適化の対象となる多重ループについて,その最内ループと最内の1つ外側のループに関してのみ最適化を行うブロッキングの技術が知られている。また,3次元以上の配列を含む多重ループについて,その最内ループに関してのみ最適化を行うブロッキングの技術が知られている。   A blocking technique is known in which optimization is performed only for the innermost loop and the innermost loop outside the multiple loop to be optimized. In addition, there is known a blocking technique that optimizes only the innermost loop of a multiple loop including a three-dimensional array or more.

特開平5−265770号公報JP-A-5-265770

上述の従来のブロッキングによる多重ループの最適化の技術には,3重以上のループに対してブロッキングを適用することができない,3次元以上の配列を含む多重ループに対してブロッキングを適用することができないという問題があった。   In the conventional technique for optimizing multiple loops by blocking, it is not possible to apply blocking to three or more loops, and it is possible to apply blocking to multiple loops including arrays of three or more dimensions. There was a problem that I could not.

近年,ハードウェア性能の向上に合わせて,より高度で複雑な科学演算が行われる傾向がある。このようなニーズに答えるためには,上記の従来技術の問題を解決する必要がある。   In recent years, there has been a tendency for more sophisticated and complex scientific operations to be performed as hardware performance improves. In order to answer such needs, it is necessary to solve the above-mentioned problems of the prior art.

本発明は,上記の問題の解決を図り,3重ループ以上のループに対して,また3次元以上の配列を含む多重ループに対して,広範囲にブロッキングによる最適化の実行を可能とする技術を提供することを目的とする。   The present invention is a technique for solving the above-described problems and enabling optimization by blocking over a wide range for loops of three or more loops and for multiple loops including arrays of three or more dimensions. The purpose is to provide.

開示するプログラムは,プログラミング言語で記述されたソースプログラムをコンパイルするコンパイラにおいて,ソースプログラムに含まれる多重ループに対するブロッキングによる最適化の処理を行うコンピュータを,次のように機能させる。   In the disclosed program, a compiler that compiles a source program written in a programming language causes a computer that performs optimization processing by blocking against multiple loops included in the source program to function as follows.

すなわち,前記プログラムは,前記プログラムがインストールされて実行されるコンピュータに,ソースプログラムに含まれる多重ループから最内ループにのみ実行文を有する構造のループをブロッキング対象ループとして抽出する手順と,ブロッキング対象ループ内に存在する配列を抽出する手順と,抽出された配列の中に添え字として出現する制御変数の順序がブロッキング対象ループの最内ループから最外ループに向かって出現する制御変数の順序と異なる配列が存在する場合に,ブロッキング対象ループに対するブロッキングが有効であると判定する手順と,ブロッキングが有効であると判定されたブロッキング対象ループについて,ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を配列ごとに生成する手順と,配列ごとに生成された計算式からブロッキング対象ループに対するブロッキングによって最適化される範囲でブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式を生成する手順と,全配列が使用するメモリサイズを計算する計算式を用いて,ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する手順と,自動計算された分割ブロック長を用いてブロッキング対象ループに対するブロッキングによる最適化を行う手順とを実行させる。   That is, the program includes a procedure for extracting, as a blocking target loop, a loop having a structure having an executable statement only in the innermost loop from the multiple loops included in the source program on a computer on which the program is installed and executed. The procedure for extracting an array existing in a loop, and the order of control variables appearing as subscripts in the extracted array from the innermost loop of the blocking target loop to the outermost loop When there is a different sequence, the procedure for determining that blocking for the blocking target loop is effective and the blocking target loop for which blocking is determined to be effective are arranged within the range optimized by blocking for the blocking target loop. Memory used by Calculate the memory size used by all arrays in the blocking target loop within the range that is optimized by blocking for the blocking target loop from the calculation formula generated for each array Using the procedure for generating the calculation formula to be used and the calculation formula for calculating the memory size used by all arrays, the divided block length that does not cause a cache miss due to access to the array within the range optimized by blocking for the blocking loop is determined. A procedure for automatic calculation and a procedure for performing optimization by blocking the blocking target loop using the automatically calculated divided block length are executed.

上記の技術によって,3重以上のループに対して,最内ループ内に含まれる配列の次元数に影響なく,広範囲にブロッキングによる最適化を実行することが可能となる。これにより,従来はブロッキングによる最適化の実行が不可能であったループに対してもブロッキングを適用して,キャッシュメモリのヒット率が改善することで,最適化されるプログラムの実行性能が向上する。   With the above technique, it is possible to perform optimization by blocking over a wide range without affecting the number of dimensions of the array included in the innermost loop for a loop of three or more layers. This improves the execution performance of the optimized program by improving the cache memory hit rate by applying blocking to loops that could not be optimized by blocking. .

3重ループに対する従来のブロッキングの例を説明する図である。It is a figure explaining the example of the conventional blocking with respect to a triple loop. メモリアクセスの例を示す図である。It is a figure which shows the example of a memory access. 3重ループのすべてに対してブロッキングを行った場合のブロッキング後の最適化対象ループの例を示す図である。It is a figure which shows the example of the optimization object loop after blocking at the time of blocking with respect to all the triple loops. メモリアクセスの例を示す図である。It is a figure which shows the example of a memory access. 3次元の配列を含む多重ループに対する従来のブロッキングの例を説明する図である。It is a figure explaining the example of the conventional blocking with respect to the multiple loop containing a three-dimensional arrangement | sequence. 3次元の配列を含む多重ループに対して,最内ループ以外のループもブロッキングを行った場合のブロッキング後の最適化対象ループの例を示す図である。It is a figure which shows the example of the optimization object loop after blocking when loops other than innermost loop are also blocked with respect to the multiple loop containing a three-dimensional arrangement | sequence. 本実施の形態によるコンパイラの機能構成例を示す図である。It is a figure which shows the function structural example of the compiler by this Embodiment. 本実施の形態によるコンピュータのハードウェア構成例を示す図である。It is a figure which shows the hardware structural example of the computer by this Embodiment. 本実施の形態によるソース解析部の機能構成例を示す図である。It is a figure which shows the function structural example of the source analysis part by this Embodiment. 本実施の形態の最適化処理部によるブロッキング最適化処理フローチャートである。It is a blocking optimization process flowchart by the optimization process part of this Embodiment. 本実施の形態による最適化の対象となるループとブロッキングによる最適化実行後のループとの例を示す図である。It is a figure which shows the example of the loop used as the object of the optimization by this Embodiment, and the loop after the optimization execution by blocking. 本実施の形態によるループデータのデータ構造の例を示す図である。It is a figure which shows the example of the data structure of the loop data by this Embodiment. 本実施の形態によるタイトなループを説明する図である。It is a figure explaining the tight loop by this Embodiment. 本実施の形態の処理対象ループ解析部による処理対象ループ解析処理フローチャートである。It is a process target loop analysis process flowchart by the process target loop analysis part of this Embodiment. 本実施の形態による配列データの管理を説明する図である。It is a figure explaining management of arrangement data by this embodiment. 本実施の形態の配列解析部による配列解析処理フローチャートである。It is a sequence analysis processing flowchart by the sequence analysis unit of the present embodiment. 本実施の形態によるアクセスパターンを説明する図である。It is a figure explaining the access pattern by this Embodiment. 本実施の形態によるループデータにおける有効フラグを設定した例を示す図である。It is a figure which shows the example which set the valid flag in the loop data by this Embodiment. 本実施の形態のアクセスパターン解析部によるアクセスパターン解析処理フローチャートである。It is an access pattern analysis process flowchart by the access pattern analysis part of this Embodiment. 本実施の形態のアクセスパターン解析部による添え字の連鎖作成処理フローチャートである。It is a subscript chain creation processing flowchart by the access pattern analysis unit of the present embodiment. 本実施の形態による配列別メモリ計算式の生成を説明する図である。It is a figure explaining the production | generation of the memory calculation formula classified by arrangement | sequence by this Embodiment. 本実施の形態による配列別メモリ計算式からのメモリサイズ計算式の生成を説明する図である。It is a figure explaining the production | generation of the memory size calculation formula from the memory calculation formula classified by arrangement | sequence by this Embodiment. 本実施の形態のメモリサイズ計算式生成部によるメモリサイズ計算式生成処理フローチャートである。It is a memory size calculation formula production | generation process flowchart by the memory size calculation formula production | generation part of this Embodiment. 本実施の形態のメモリサイズ計算式生成部による配列別メモリ計算データ生成処理フローチャートである。It is a memory calculation data generation processing flowchart according to arrangement | sequence by the memory size calculation formula production | generation part of this Embodiment. 本実施の形態によるメモリサイズ計算式を用いて分割ブロック長を自動計算する例を説明する図である。It is a figure explaining the example which calculates a division | segmentation block length automatically using the memory size calculation formula by this Embodiment. 本実施の形態の分割ブロック長計算部による分割ブロック長計算処理フローチャートである。It is a divided block length calculation process flowchart by the divided block length calculation part of this Embodiment. 本実施の形態によるブロッキング指示部によるブロッキング指示処理フローチャートである。It is a blocking instruction | indication processing flowchart by the blocking instruction | indication part by this Embodiment. 本実施の形態のブロッキングによる最適化を3重以上のループに対して実行した例である。This is an example in which the optimization by blocking of the present embodiment is executed for a loop of three or more layers. 本実施の形態のブロッキングによる最適化を3次元以上の配列を含む多重ループに対して実行した例である。This is an example in which the optimization by blocking according to the present embodiment is performed on a multiple loop including an array of three or more dimensions. 本実施の形態のブロッキングによる最適化をブロッキング抑止の最適化指示行を含む多重ループに対して実行した例である。This is an example in which optimization by blocking according to the present embodiment is performed on a multiple loop including an optimization instruction line for blocking inhibition. 本実施の形態のブロッキングによる最適化を固定の分割ブロック長の最適化指示行を含む多重ループに対して実行した例である。This is an example in which the optimization by blocking according to the present embodiment is executed for a multiple loop including an optimization instruction line having a fixed divided block length.

以下,本実施の形態について,図を用いて説明する。   Hereinafter, the present embodiment will be described with reference to the drawings.

まず,本実施の形態によるブロッキングの技術を説明する前に,従来のブロッキングの技術について,簡単に説明する。   First, before describing the blocking technique according to the present embodiment, a conventional blocking technique will be briefly described.

図1は,3重ループに対する従来のブロッキングの例を説明する図である。   FIG. 1 is a diagram illustrating an example of conventional blocking for a triple loop.

図1(A)は,最適化対象ループの例を示す。図1(A)に示す最適化対象ループは,ループI,ループJ,ループKの3重ループである。図1(A)に示す最適化対象ループでは,最内ループ内にのみ,2次元の配列を用いた演算の実行文が含まれている。   FIG. 1A shows an example of the optimization target loop. The optimization target loop shown in FIG. 1A is a triple loop of loop I, loop J, and loop K. In the optimization target loop shown in FIG. 1A, only the innermost loop includes an execution statement for an operation using a two-dimensional array.

なお,本実施の形態では,制御変数をループの名称に用いるものとする。具体的には,本実施の形態では,制御変数IのループをループIと呼ぶものとする。   In this embodiment, the control variable is used as the name of the loop. Specifically, in the present embodiment, the loop of the control variable I is called a loop I.

図1(B)は,図1(A)に示す最適化対象ループに対して,インデックス交換を行った結果を示す。インデックスとは,制御変数のことである。インデックス交換は,配列へのアクセスがメモリ上の連続領域へのアクセスとなるように,内側のループと外側のループとを入れ換える処理である。ブロッキングは連続領域へのメモリアクセスに対して効果が高いため,インデックス交換により連続領域へのメモリアクセスとなる場合は,事前にインデックス交換を行う必要がある。インデックス交換の詳細については,特許文献1の段落[0034]〜[0043],図3に記載されている。   FIG. 1B shows the result of index exchange for the optimization target loop shown in FIG. An index is a control variable. The index exchange is a process of exchanging the inner loop and the outer loop so that access to the array is access to a continuous area in the memory. Since blocking is highly effective for memory access to the continuous area, if the memory access to the continuous area is caused by index exchange, it is necessary to exchange the index in advance. Details of the index exchange are described in paragraphs [0034] to [0043] of FIG.

図1(C)は,図1(B)に示すインデックス交換後の最適化対象ループに対して,従来のブロッキングを行った結果を示す。従来の技術では,最内ループとその1つ外側のループとに対してのみ,すなわち図1に示す例ではループIとループJとに対してのみ,ブロッキングが行われる。図1(C)に示すブロッキング後の最適化対象ループにおいて,ループの分割単位を示す分割ブロック長blockには,コンパイラのブロッキング機能によって,適切な値が求められる。   FIG. 1 (C) shows the result of performing conventional blocking on the optimization target loop after the index exchange shown in FIG. 1 (B). In the prior art, blocking is performed only for the innermost loop and the loop that is one outer side thereof, that is, only for the loop I and the loop J in the example shown in FIG. In the optimization target loop after blocking shown in FIG. 1C, an appropriate value is obtained for the divided block length block indicating the division unit of the loop by the blocking function of the compiler.

図2は,メモリアクセスの例を示す図である。   FIG. 2 is a diagram illustrating an example of memory access.

図2に示すメモリアクセスの例は,図1(C)に示すブロッキング後の最適化対象ループにおけるメモリアクセスの例である。図2において,太線の枠は,各配列のデータが記憶されたメモリ領域を示し,細線の枠は,一辺が分割ブロック長blockである領域を示している。図2において,網掛けの領域は,図1(C)に示すブロッキング後の最適化対象ループにおいて,制御変数JJ,IIを固定して,ループI,ループJ,ループKとが回転したときの,演算の実行文に含まれる配列ごとのアクセス領域を示す。   The example of memory access shown in FIG. 2 is an example of memory access in the optimization target loop after blocking shown in FIG. In FIG. 2, a thick line frame indicates a memory area in which data of each array is stored, and a thin line frame indicates an area whose one side is a divided block length block. In FIG. 2, the shaded area is when the control variables JJ and II are fixed and the loops I, J, and K are rotated in the optimization target loop after blocking shown in FIG. , Indicates the access area for each array included in the execution statement of the operation.

図2に示すように,ブロッキングが行われたループの制御変数IとJとを添え字とする配列Aについては,メモリアクセスが局所化されているため,キャッシュメモリに効率的にデータをのせることができる。しかし,ブロッキングが行われなかったループの制御変数Kを添え字に含む配列B,配列Cについては,メモリアクセスが局所化されないため,キャッシュメモリに効率的にデータをのせることができない。   As shown in FIG. 2, since the memory access is localized for the array A having the subscripts of the control variables I and J of the loop in which blocking is performed, the data is efficiently placed in the cache memory. be able to. However, since the memory access is not localized for the arrays B and C including the control variable K of the loop that has not been blocked as a subscript, data cannot be efficiently placed in the cache memory.

このように,従来のブロッキングの技術では,3重以上のループを対象としたブロッキングができないため,キャッシュメモリに効率的にデータをのせることができる配列の範囲が,狭い範囲に限られていた。   In this way, with the conventional blocking technique, since it is not possible to block over three or more loops, the range of arrays in which data can be efficiently placed in the cache memory has been limited to a narrow range. .

図3は,3重ループのすべてに対してブロッキングを行った場合のブロッキング後の最適化対象ループの例を示す図である。   FIG. 3 is a diagram illustrating an example of an optimization target loop after blocking when blocking is performed on all triple loops.

図3に示すブロッキング後の最適化対象ループの例は,図1(B)に示すインデックス交換後の最適化対象ループにおいて,3重ループのすべてに対してブロッキングを行ったと仮定した場合の結果の例である。   The example of the optimization target loop after blocking shown in FIG. 3 is the result of assuming that blocking is performed for all of the triple loops in the optimization target loop after index exchange shown in FIG. It is an example.

例えば,実行文に含まれる配列の添え字において,各ループの制御変数の登場回数があまり変わらないような場合には,すべてのループに対してブロッキングを行うことにより,よりよいメモリ効率が得られる場合がある。   For example, if the number of occurrences of control variables in each loop does not change much in the array subscripts included in the executable statement, better memory efficiency can be obtained by blocking all loops. There is a case.

図4は,メモリアクセスの例を示す図である。   FIG. 4 is a diagram illustrating an example of memory access.

図4に示すメモリアクセスの例は,図3に示すブロッキング後の最適化対象ループにおけるメモリアクセスの例である。すなわち,図4に示すメモリアクセスの例は,図1(B)に示すインデックス交換後の最適化対象ループにおいて,3重ループのすべてに対してブロッキングを行ったと仮定した場合のブロッキング後の最適化対象ループにおけるメモリアクセスの例である。   The memory access example shown in FIG. 4 is an example of memory access in the optimization target loop after blocking shown in FIG. That is, the example of the memory access shown in FIG. 4 is an optimization after blocking when it is assumed that all the triple loops are blocked in the optimization target loop after the index exchange shown in FIG. It is an example of the memory access in an object loop.

図4において,太線の枠は,各配列のデータが記憶されたメモリ領域を示し,細線の枠は,一辺が分割ブロック長blockである領域を示している。図2において,網掛けの領域は,図3に示すブロッキング後の最適化対象ループにおいて,制御変数JJ,II,KKとを固定して,ループI,ループJ,ループKとが回転したときの,演算の実行文に含まれる配列ごとのアクセス領域を示す。   In FIG. 4, a thick line frame indicates a memory area in which data of each array is stored, and a thin line frame indicates an area whose one side is a divided block length block. In FIG. 2, the shaded area is when the control variables JJ, II, and KK are fixed and the loops I, J, and K are rotated in the optimization target loop after blocking shown in FIG. , Indicates the access area for each array included in the execution statement of the operation.

図4に示すように,3重ループのすべてに対してブロッキングを行ったと仮定すると,配列A,配列B,配列Cのすべてについて,メモリアクセスが局所化されるため,すべての配列のデータを,キャッシュメモリに効率的にのせることができる。   As shown in FIG. 4, assuming that blocking is performed for all the triple loops, memory access is localized for all of the arrays A, B, and C. The cache memory can be loaded efficiently.

図3に示すような3重以上のループを対象としたブロッキングを行うことができれば,従来のブロッキングの技術と比較して,よりメモリ効率が高いループの最適化を行うことができるようになる。   If blocking for a loop of three or more loops as shown in FIG. 3 can be performed, a loop with higher memory efficiency can be optimized as compared with the conventional blocking technique.

図5は,3次元の配列を含む多重ループに対する従来のブロッキングの例を説明する図である。   FIG. 5 is a diagram for explaining an example of conventional blocking for a multiple loop including a three-dimensional array.

図5(A)は,最適化対象ループの例を示す。図5(A)に示す最適化対象ループは,ループI,ループJ,ループKの3重ループである。図5(A)に示す最適化対象ループでは,最内ループ内にのみ,3次元の配列を含む演算の実行文が含まれている。   FIG. 5A shows an example of the optimization target loop. The optimization target loop shown in FIG. 5A is a triple loop of loop I, loop J, and loop K. In the optimization target loop shown in FIG. 5A, only the innermost loop includes an execution statement for an operation including a three-dimensional array.

図5(B)は,図5(A)に示す最適化対象ループに対して,従来のブロッキングを行った結果を示す。従来の技術では,最内ループ内で3次元以上の配列が使用されている場合に,翻訳コストの問題から,最内ループのみ,すなわち図5に示す例ではループIのみをブロッキングの対象とする。しかし,実際には,制御変数Jを更新するループJに対してもブロッキングは有効である。   FIG. 5B shows the result of conventional blocking performed on the optimization target loop shown in FIG. In the conventional technique, when an array of three or more dimensions is used in the innermost loop, only the innermost loop, that is, only the loop I in the example shown in FIG. . However, in practice, blocking is also effective for the loop J that updates the control variable J.

このように,従来のブロッキングの技術では,3次元の配列を含む多重ループに対しては,最内ループを対象としたブロッキングしかできないため,あまり効果的なループの最適化はできなかった。   As described above, with the conventional blocking technique, it is only possible to block the innermost loop with respect to a multiple loop including a three-dimensional array. Therefore, the loop cannot be optimized very effectively.

図6は,3次元の配列を含む多重ループに対して,最内ループ以外のループもブロッキングを行った場合のブロッキング後の最適化対象ループの例を示す図である。   FIG. 6 is a diagram illustrating an example of an optimization target loop after blocking when a loop other than the innermost loop is also blocked with respect to a multiple loop including a three-dimensional array.

図6に示すブロッキング後の最適化対象ループの例は,図5(A)に示す3次元の配列を含む最適化対象ループにおいて,ループIとループJとに対してブロッキングを行ったと仮定した場合の結果の例である。   The example of the optimization target loop after blocking shown in FIG. 6 is based on the assumption that blocking is performed on loop I and loop J in the optimization target loop including the three-dimensional array shown in FIG. This is an example of the result.

図6に示すように,3次元以上の配列を含む多重ループにおいて,最内ループ以外のループもブロッキングの対象とすることで,よりメモリ効率が高いループの最適化を行うことができるようになる。   As shown in FIG. 6, in a multiple loop including a three-dimensional array or more, loops other than the innermost loop are also subject to blocking, so that the loop with higher memory efficiency can be optimized. .

近年,ハードウェア性能の向上に合わせて,より高度で複雑な科学演算が行われる傾向がある。このようなニーズに応えるためには,図3や図6に示すように,3重以上の多重ループや3次元以上の配列を含む多重ループに対しても,ブロッキングの範囲を広げることにより,プログラムの実行性能を向上させる必要がある。   In recent years, there has been a tendency for more sophisticated and complex scientific operations to be performed as hardware performance improves. In order to meet such needs, as shown in FIG. 3 and FIG. 6, the program can be expanded by broadening the blocking range even for multiple loops including three or more multiple loops and multiple loops including three-dimensional arrays. It is necessary to improve the execution performance.

以下では,3重以上の多重ループや3次元以上の配列を含む多重ループに対するブロッキングの問題の解決を図った,本実施の形態のブロッキングの技術について説明する。   In the following, a blocking technique according to the present embodiment for solving the blocking problem with respect to multiple loops having three or more layers or multiple loops including three-dimensional or more arrays will be described.

図7は,本実施の形態によるコンパイラの機能構成例を示す図である。   FIG. 7 is a diagram illustrating a functional configuration example of the compiler according to the present embodiment.

図7において,実線の矢印は主に制御の流れを示し,破線の矢印は主にデータの流れを示す。   In FIG. 7, the solid-line arrows mainly indicate the flow of control, and the broken-line arrows mainly indicate the data flow.

コンピュータ1は,コンパイラ10,記憶部20,リンカ30,オペレーティングシステム40を備える。オペレーティングシステム40は,アプリケーションが共通して利用する基本的な機能を提供する。   The computer 1 includes a compiler 10, a storage unit 20, a linker 30, and an operating system 40. The operating system 40 provides basic functions that are commonly used by applications.

記憶部20は,ソースプログラム21,オブジェクトファイル22,実行ファイル23などを記憶する,コンピュータ1がアクセス可能な記憶装置である。ソースプログラム21は,Fortranなどのプログラミング言語で記述されたアプリケーションのプログラムである。オブジェクトファイル22は,コンパイラ10によってソースプログラム21から生成された,アプリケーションのオブジェクトコードのファイルである。実行ファイル23は,リンカ30によってオブジェクトファイル22とライブラリとがリンクされた,アプリケーションの実行形式プログラムのファイルである。   The storage unit 20 is a storage device that can be accessed by the computer 1 and stores a source program 21, an object file 22, an execution file 23, and the like. The source program 21 is an application program described in a programming language such as Fortran. The object file 22 is an application object code file generated from the source program 21 by the compiler 10. The execution file 23 is an application executable program file in which the object file 22 and the library are linked by the linker 30.

コンパイラ10は,ソースプログラム21をコンパイルし,オブジェクトファイルを生成する。リンカ30は,オブジェクトファイル22とライブラリとをリンクし,実行ファイル23を生成する。   The compiler 10 compiles the source program 21 and generates an object file. The linker 30 links the object file 22 and the library, and generates an execution file 23.

コンパイラ10は,ソースプログラム入力部11,入出力制御部12,中間言語生成部13,中間言語記憶部14,最適化処理部15,コード生成部18,オブジェクトファイル出力部19を備える。   The compiler 10 includes a source program input unit 11, an input / output control unit 12, an intermediate language generation unit 13, an intermediate language storage unit 14, an optimization processing unit 15, a code generation unit 18, and an object file output unit 19.

ソースプログラム入力部11は,コンパイルが指定されたソースプログラム21をオープンする。入出力制御部12は,オプション,ファイルの種別に応じて必要な処理を選択する。   The source program input unit 11 opens a source program 21 in which compilation is specified. The input / output control unit 12 selects necessary processing according to the type of option and file.

中間言語生成部13は,ソースプログラム21を,最適化処理部15による最適化の処理で利用する中間コードに変換し,中間言語記憶部14に格納する。中間言語記憶部14は,中間言語生成部13によりソースプログラム21から変換された中間コードを記憶する,コンピュータ1がアクセス可能な記憶装置である。高級言語で記述されたソースプログラム21に対してそのまま最適化の処理を施すことは,非常に困難である。そのため,コンパイラ10は,最適化の処理が施しやすいデータ構造体でソースプログラム21を表現する中間コードに変換してから,その中間コードに対して最適化の処理を施す。   The intermediate language generation unit 13 converts the source program 21 into intermediate code used in the optimization process by the optimization processing unit 15 and stores it in the intermediate language storage unit 14. The intermediate language storage unit 14 is a storage device accessible by the computer 1 that stores the intermediate code converted from the source program 21 by the intermediate language generation unit 13. It is very difficult to perform the optimization process as it is on the source program 21 described in a high-level language. Therefore, the compiler 10 converts the source program 21 into an intermediate code that expresses the source program 21 with a data structure that can be easily optimized, and then performs optimization processing on the intermediate code.

最適化処理部15は,中間言語記憶部14に記憶された中間コードに対して,最適化の処理を行う。最適化処理部15は,ソース解析部16,最適化実行部17を備える。ソース解析部16は,中間言語記憶部14に記憶された中間コードを解析して,有効な最適化を選択し,最適化実行部17に指示する。最適化実行部17は,指示された最適化を,中間言語記憶部14に記憶された中間コードに対して適用する。   The optimization processing unit 15 performs optimization processing on the intermediate code stored in the intermediate language storage unit 14. The optimization processing unit 15 includes a source analysis unit 16 and an optimization execution unit 17. The source analysis unit 16 analyzes the intermediate code stored in the intermediate language storage unit 14, selects effective optimization, and instructs the optimization execution unit 17. The optimization execution unit 17 applies the instructed optimization to the intermediate code stored in the intermediate language storage unit 14.

コード生成部18は,最適化された中間コードから,アセンブラコードを生成する。オブジェクトファイル出力部19は,アセンブラコードからオブジェクトファイル22を生成する。   The code generation unit 18 generates assembler code from the optimized intermediate code. The object file output unit 19 generates an object file 22 from the assembler code.

図8は,本実施の形態によるコンピュータのハードウェア構成例を示す図である。   FIG. 8 is a diagram illustrating a hardware configuration example of a computer according to the present embodiment.

コンピュータ1は,CPU(Central Processing Unit )2,RAM(Random Access Memory)やROM(Read Only Memory)などのメモリ3,HDD(Hard Disk Drive )4などのハードウェアを備える。メモリ3の一部は,CPU2が高速にアクセス可能なキャッシュメモリである。また,コンピュータ1には,キーボードやマウスなどの入力装置5,ディスプレイなどの表示装置6が接続されている。   The computer 1 includes hardware such as a central processing unit (CPU) 2, a memory 3 such as a random access memory (RAM) and a read only memory (ROM) 3, and a hard disk drive (HDD) 4. A part of the memory 3 is a cache memory that the CPU 2 can access at high speed. Further, an input device 5 such as a keyboard and a mouse 5 and a display device 6 such as a display are connected to the computer 1.

図7に示すコンピュータ1が備えるコンパイラ10,記憶部20,リンカ30,オペレーティングシステム40等が提供する機能は,図8に示すコンピュータ1のハードウェアとソフトウェアプログラムとによって実現される。   Functions provided by the compiler 10, the storage unit 20, the linker 30, the operating system 40, and the like included in the computer 1 illustrated in FIG. 7 are realized by the hardware and software programs of the computer 1 illustrated in FIG.

図9は,本実施の形態によるソース解析部の機能構成例を示す図である。   FIG. 9 is a diagram illustrating a functional configuration example of the source analysis unit according to the present embodiment.

本実施の形態では,ソース解析部16は,多重ループを最適化するブロッキングに関する処理として,アクセスパターンの解析,メモリサイズ計算式の作成,分割ブロック長の算出などの処理を実施する。最適化処理部15は,ソース解析部16により得られた情報を最適化実行部17に伝播することで,ソースプログラム21に含まれるループの最適化を実行し,コンパイラ10により生成されるプログラムの高速化を図る。   In the present embodiment, the source analysis unit 16 performs processing such as access pattern analysis, creation of a memory size calculation formula, and calculation of a divided block length as processing related to blocking that optimizes multiple loops. The optimization processing unit 15 propagates the information obtained by the source analysis unit 16 to the optimization execution unit 17, thereby executing optimization of the loop included in the source program 21, and executing the program generated by the compiler 10. Increase speed.

ソース解析部16は,多重ループを最適化するブロッキングに関する処理として,中間言語記憶部14に記憶された中間コードを解析して,ブロッキングによるループ分割の単位である分割ブロック長を自動計算する。中間言語記憶部14は,ソースプログラム21に含まれるループに関する中間コードのデータとして,ループデータを記憶する。図9に示すループデータ記憶部200は,中間言語記憶部14におけるループデータの記憶領域である。   The source analysis unit 16 analyzes the intermediate code stored in the intermediate language storage unit 14 as a process related to blocking for optimizing multiple loops, and automatically calculates a divided block length which is a unit of loop division by blocking. The intermediate language storage unit 14 stores loop data as intermediate code data relating to a loop included in the source program 21. The loop data storage unit 200 shown in FIG. 9 is a loop data storage area in the intermediate language storage unit 14.

なお,本実施の形態では,最適化処理部15によるブロッキングに関する処理の前に,ループの内外を交換するインデックス変換や,並列するループを含む多重ループを直列の入れ子構造に変形するループ分割等の最適化が,すでに実行されているものとする。   In the present embodiment, before the processing related to blocking by the optimization processing unit 15, index conversion for exchanging the inside and outside of the loop, loop division for transforming multiple loops including parallel loops into a serial nested structure, and the like. Assume that optimization has already been performed.

ソース解析部16は,ブロッキングに関する機能部として,処理対象ループ解析部100,配列解析部110,アクセスパターン解析部120,メモリサイズ計算式生成部130,分割ブロック長計算部140,ブロッキング指示部150等の各機能部を有する。また,ソース解析部16は,配列情報記憶部160,配列別メモリ計算情報記憶部170,メモリサイズ計算情報記憶部180等の各記憶部を有する。ソース解析部16が有する各機能部,各記憶部は,コンピュータ1が備えるCPU2,メモリ3,HDD4等のハードウェアと,ソフトウェアプログラムとによって実現される。   The source analysis unit 16 includes, as functional units related to blocking, a processing target loop analysis unit 100, an array analysis unit 110, an access pattern analysis unit 120, a memory size calculation formula generation unit 130, a divided block length calculation unit 140, a blocking instruction unit 150, and the like. It has each functional part. The source analysis unit 16 includes storage units such as an array information storage unit 160, an array-specific memory calculation information storage unit 170, and a memory size calculation information storage unit 180. Each functional unit and each storage unit included in the source analysis unit 16 are realized by hardware such as the CPU 2, the memory 3, and the HDD 4 included in the computer 1, and a software program.

処理対象ループ解析部100は,最適化の対象となるループからタイトな構造を持つループを抽出する。以下では,中間コードで表現されたソースプログラム21に含まれる最適化の対象となるループを,最適化対象ループと呼ぶものとする。また,処理対象ループ解析部100によって,最適化対象ループから抽出されるタイトな構造を持つループを,ブロッキング対象ループと呼ぶものとする。   The processing target loop analysis unit 100 extracts a loop having a tight structure from the loop to be optimized. Hereinafter, a loop to be optimized included in the source program 21 expressed by the intermediate code is referred to as an optimization target loop. A loop having a tight structure extracted from the optimization target loop by the processing target loop analysis unit 100 is referred to as a blocking target loop.

配列解析部110は,ブロッキング対象ループの最内ループ内を解析し,ブロッキング対象ループ内に存在する配列を抽出する。配列解析部110は,ブロッキング対象ループ内から抽出された配列の情報を配列情報記憶部160に記憶する。配列情報記憶部160は,ブロッキング対象ループ内から抽出された配列の情報を記憶する,コンピュータがアクセス可能な記憶装置である。   The sequence analysis unit 110 analyzes the innermost loop of the blocking target loop and extracts a sequence existing in the blocking target loop. The sequence analysis unit 110 stores the sequence information extracted from the blocking target loop in the sequence information storage unit 160. The sequence information storage unit 160 is a storage device that can be accessed by a computer and stores sequence information extracted from the blocking target loop.

アクセスパターン解析部120は,ブロッキング対象ループにおいて最内ループから最外ループに向かって出現する制御変数の順序と,ブロッキング対象ループ内から抽出された配列の添え字に出現する制御変数の順序との関係を解析する。アクセスパターン解析部120は,添え字に出現する制御変数の順序が,最内ループから最外ループに向かって出現する制御変数の順序とは異なる配列が存在する場合に,ブロッキング対象ループに対するブロッキングによる最適化が有効であると判定する。   The access pattern analysis unit 120 determines the order of the control variables appearing from the innermost loop toward the outermost loop in the blocking target loop, and the order of the control variables appearing in the subscripts of the array extracted from the blocking target loop. Analyze the relationship. When there is an array in which the order of the control variables appearing in the subscript is different from the order of the control variables appearing from the innermost loop toward the outermost loop, the access pattern analysis unit 120 performs blocking on the blocking target loop. It is determined that optimization is effective.

メモリサイズ計算式生成部130は,ブロッキング対象ループ内の配列ごとに,ブロッキング対象ループに対するブロッキングによって最適化される範囲で,配列が使用するメモリサイズを算出する計算式を生成する。以下では,ブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,配列別メモリ計算式と呼ぶものとする。メモリサイズ計算式生成部130は,配列別メモリ計算式の情報を配列別メモリ計算情報記憶部170に記憶する。配列別メモリ計算情報記憶部170は,配列別メモリ計算式の情報を記憶する,コンピュータがアクセス可能な記憶装置である。   The memory size calculation formula generation unit 130 generates, for each array in the blocking target loop, a calculation formula for calculating the memory size used by the array within a range optimized by blocking the blocking target loop. Hereinafter, a calculation formula for calculating a memory size used by an array within a range optimized by blocking is referred to as an array-specific memory calculation formula. The memory size calculation formula generation unit 130 stores the memory calculation formula information for each array in the memory calculation information storage unit 170 for each array. The array-based memory calculation information storage unit 170 is a computer-accessible storage device that stores information on the array-specific memory calculation formula.

また,メモリサイズ計算式生成部130は,配列別メモリ計算式から,ブロッキング対象ループに対するブロッキングによって最適化される範囲で,ブロッキング対象ループ内の全配列が使用するメモリサイズを算出する計算式を生成する。以下では,ブロッキングによって最適化される範囲でブロッキング対象ループ内の全配列が使用するメモリサイズを算出する計算式を,メモリサイズ計算式と呼ぶものとする。メモリサイズ計算式生成部130は,メモリサイズ計算式の情報をメモリサイズ計算情報記憶部180に記憶する。メモリサイズ計算情報記憶部180は,メモリサイズ計算式の情報を記憶する,コンピュータがアクセス可能な記憶装置である。   In addition, the memory size calculation formula generation unit 130 generates a calculation formula for calculating the memory size used by all the arrays in the blocking target loop within the range optimized by blocking the blocking target loop from the array-specific memory calculation formula. To do. Hereinafter, a calculation formula for calculating the memory size used by all the arrays in the blocking target loop within a range optimized by blocking is referred to as a memory size calculation formula. The memory size calculation formula generation unit 130 stores the memory size calculation formula information in the memory size calculation information storage unit 180. The memory size calculation information storage unit 180 is a computer-accessible storage device that stores information on a memory size calculation formula.

分割ブロック長計算部140は,メモリサイズ計算式を用いて,ブロッキング対象ループに対するブロッキングによって最適化される範囲で,配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する。   The divided block length calculation unit 140 automatically calculates a divided block length that does not cause a cache miss due to access to the array, within a range optimized by blocking the blocking target loop, using a memory size calculation formula.

ブロッキング指示部150は,分割ブロック長計算部140によって得られた分割ブロック長を用いた,ブロッキング対象ループに対するブロッキングによる最適化の指示を行う。   The blocking instruction unit 150 issues an instruction for optimization by blocking the blocking target loop using the divided block length obtained by the divided block length calculation unit 140.

最適化実行部17は,ソース解析部16により求められた分割ブロック長を用いて,ブロッキング対象ループに対するブロッキングによる最適化を実行する。より具体的には,最適化実行部17は,ソース解析部16により求められた分割ブロック長を用いて分割数を指示するループをもとのブロッキング対象ループの外に生成して,もとのブロッキング対象ループを変形する。   The optimization execution unit 17 uses the divided block length obtained by the source analysis unit 16 to perform optimization by blocking on the blocking target loop. More specifically, the optimization execution unit 17 generates a loop for designating the number of divisions using the division block length obtained by the source analysis unit 16 outside the original blocking target loop. Deform the blocking loop.

図10は,本実施の形態の最適化処理部によるブロッキング最適化処理フローチャートである。   FIG. 10 is a flowchart of the blocking optimization process performed by the optimization processing unit according to this embodiment.

最適化処理部15のソース解析部16において,処理対象ループ解析部100は,処理対象ループ解析処理を行う(ステップS1)。処理対象ループ解析処理は,最適化の対象となるループからタイトな構造を持つループを抽出する処理である。処理対象ループ解析処理の詳細については,後述する。   In the source analysis unit 16 of the optimization processing unit 15, the processing target loop analysis unit 100 performs processing target loop analysis processing (step S1). The processing target loop analysis process is a process for extracting a loop having a tight structure from a loop to be optimized. Details of the processing target loop analysis processing will be described later.

配列解析部110は,配列解析処理を行う(ステップS2)。配列解析処理は,ブロッキング対象ループ内に存在する配列を抽出する処理である。配列解析処理の詳細については,後述する。   The sequence analysis unit 110 performs sequence analysis processing (step S2). The sequence analysis processing is processing for extracting a sequence existing in the blocking target loop. Details of the sequence analysis processing will be described later.

アクセスパターン解析部120は,アクセスパターン解析処理を行う(ステップS3)。アクセスパターン解析処理は,ブロッキング対象ループ内のループの制御変数の出現順と,ブロッキング対象ループ内の配列の制御変数の出現順との関係から,ブロッキング対象ループに対するブロッキングによる最適化の有効/無効を判定する処理である。アクセスパターン解析処理の詳細については,後述する。   The access pattern analysis unit 120 performs access pattern analysis processing (step S3). The access pattern analysis process determines whether the optimization for blocking is enabled or disabled based on the relationship between the order of appearance of control variables in the loop within the blocking target loop and the order of appearance of control variables in the array within the blocking target loop. This is a process of determining. Details of the access pattern analysis processing will be described later.

メモリサイズ計算式生成部130は,メモリサイズ計算式生成処理を行う(ステップS4)。メモリサイズ計算式生成処理は,ブロッキング対象ループに対するブロッキング対象ループに対するブロッキングによって最適化される範囲で,ブロッキング対象ループ内の全配列が使用するメモリサイズを算出する計算式を生成する処理である。メモリサイズ計算式生成処理の詳細については,後述する。   The memory size calculation formula generation unit 130 performs a memory size calculation formula generation process (step S4). The memory size calculation formula generation process is a process for generating a calculation formula for calculating the memory size used by all the arrays in the blocking target loop within a range optimized by blocking the blocking target loop with respect to the blocking target loop. Details of the memory size calculation formula generation processing will be described later.

分割ブロック長計算部140は,分割ブロック長計算処理を行う(ステップS5)。分割ブロック長計算処理は,メモリサイズ計算式を用いて,ブロッキング対象ループに対するブロッキングによって最適化される範囲のループの処理で,配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する処理である。分割ブロック長計算処理の詳細については,後述する。   The divided block length calculation unit 140 performs a divided block length calculation process (step S5). Divided block length calculation processing is a process of loops in the range optimized by blocking for the loop to be blocked using a memory size calculation formula, and automatically calculates the divided block length that does not cause cache misses due to access to the array. is there. Details of the division block length calculation processing will be described later.

ブロッキング指示部150は,ブロッキング指示処理を行う(ステップS6)。ブロッキング指示処理は,求めた分割ブロック長を用いた,ブロッキング対象ループに対するブロッキングによる最適化の指示を行う処理である。ブロッキング指示処理の詳細については,後述する。   The blocking instruction unit 150 performs a blocking instruction process (step S6). The blocking instruction process is a process for instructing an optimization by blocking the blocking target loop using the obtained divided block length. Details of the blocking instruction process will be described later.

最適化処理部15の最適化実行部17は,ソース解析部16により得られた分割ブロック長を用いた,ブロッキング対象ループに対するブロッキングによる最適化を実行する(ステップS7)。   The optimization execution unit 17 of the optimization processing unit 15 executes optimization by blocking the blocking target loop using the divided block length obtained by the source analysis unit 16 (step S7).

以下では,本実施の形態によるソース解析部16が備えるブロッキングに関する各機能部の処理について,具体的な例を用いて説明する。   Hereinafter, the processing of each functional unit related to blocking included in the source analysis unit 16 according to the present embodiment will be described using a specific example.

図11は,本実施の形態による最適化の対象となるループとブロッキングによる最適化実行後のループとの例を示す図である。   FIG. 11 is a diagram illustrating an example of a loop to be optimized according to the present embodiment and a loop after execution of optimization by blocking.

図11(A)は,ソースプログラム21における最適化の対象となるループの例を示す。以下では,最適化の対象となるループを,最適化対象ループと呼ぶものとする。図11(A)に示す最適化対象ループは,最内ループ内に3次元の配列を持つ,3重の多重ループである。   FIG. 11A shows an example of a loop to be optimized in the source program 21. Hereinafter, a loop to be optimized is referred to as an optimization target loop. The optimization target loop shown in FIG. 11A is a triple multiple loop having a three-dimensional array in the innermost loop.

図11(B)は,図11(A)に示す最適化対象ループに対して本実施の形態のブロッキングによる最適化を実行した場合の,目標となる最適化実行後のループの例を示す。図11(B)に示す最適化実行後のループは,図(A)に示す最適化対象ループのループI,ループJ,ループKのすべてのループについて,分割ブロック長blockを用いたブロッキングによる最適化が実行された状態となっている。   FIG. 11B shows an example of a loop after execution of optimization as a target when optimization by blocking of the present embodiment is executed on the optimization target loop shown in FIG. The loop after the optimization execution shown in FIG. 11B is the optimum by blocking using the divided block length block for all of the loops I, J, and K of the optimization target loop shown in FIG. Is in a state of being executed.

図11(B)に示すように,最適化実行後のループでは,分割ブロック長blockを用いて分割数を指示するループII,ループJJ,ループKKがもとのループI,ループJ,ループKの外に生成され,もとのループI,ループJ,ループKが変形されている。図11(B)における最適化実行後のループにおいて,内側のループI,ループJ,ループKからなる多重ループが,ブロッキングによって最適化される範囲のループとなる。本実施の形態によるソース解析部16では,ブロッキングによって最適化される範囲のループ内の処理では,配列に対するアクセスによってキャッシュミスが発生しないような分割ブロック長blockを,自動計算する。   As shown in FIG. 11B, in the loop after execution of optimization, the loop II, loop JJ, and loop KK that indicate the number of divisions using the divided block length block are the original loop I, loop J, and loop K. The original loop I, loop J, and loop K are transformed. In the loop after the optimization execution in FIG. 11B, the multiple loop composed of the inner loop I, loop J, and loop K becomes a loop in the range optimized by blocking. The source analysis unit 16 according to the present embodiment automatically calculates a divided block length block so that a cache miss does not occur due to access to the array in the processing in the loop optimized by blocking.

以下では,本実施の形態によるソース解析部16によって,図11(A)に示す最適化対象ループに対するブロッキングによる最適化で用いる分割ブロック長blockを,自動的に計算する例を説明する。   Hereinafter, an example in which the source analysis unit 16 according to the present embodiment automatically calculates the divided block length block used in the optimization by blocking with respect to the optimization target loop shown in FIG. 11A will be described.

なお,図11に示すループのプログラムは,ソースプログラム21の形式で表現しているが,実際の最適化処理部15では,中間コードに変換されたループのプログラムに対して処理が行われる。   The loop program shown in FIG. 11 is expressed in the form of the source program 21, but the actual optimization processing unit 15 performs processing on the loop program converted into the intermediate code.

図12は,本実施の形態によるループデータのデータ構造の例を示す図である。   FIG. 12 is a diagram illustrating an example of a data structure of loop data according to the present embodiment.

図12に示すループデータ210は,ソースプログラム21に含まれるループが中間コードに変換されたデータテーブルの例である。図12に示すループデータ210kは,図11(A)に示す最適化対象ループのループKについてのループデータ210である。図12に示すループデータ210jは,図11(A)に示す最適化対象ループのループJについてのループデータ210である。図12に示すループデータ210iは,図11(A)に示す最適化対象ループのループIについてのループデータ210である。   12 is an example of a data table in which a loop included in the source program 21 is converted into an intermediate code. The loop data 210k illustrated in FIG. 12 is the loop data 210 for the loop K of the optimization target loop illustrated in FIG. The loop data 210j shown in FIG. 12 is the loop data 210 for the loop J of the optimization target loop shown in FIG. The loop data 210i shown in FIG. 12 is the loop data 210 for the loop I of the optimization target loop shown in FIG.

図12に示すループデータ210は,ループ名,prev(previous),next,配列データ,ブロッキングフラグ,分割ブロック長,有効フラグ等の情報を有する。なお,実際のループデータ210は,ループに関する膨大な量の情報を有するデータである。図12には,ループに関する膨大な量の情報を有するループデータ210の一部のみが記載されている。   The loop data 210 shown in FIG. 12 includes information such as a loop name, prev (previous), next, array data, blocking flag, divided block length, and valid flag. The actual loop data 210 is data having an enormous amount of information regarding the loop. FIG. 12 shows only a part of the loop data 210 having a huge amount of information regarding the loop.

図12に示すループデータ210におけるループ名は,ループで値が更新される制御変数の名前を示す。   The loop name in the loop data 210 shown in FIG. 12 indicates the name of the control variable whose value is updated in the loop.

図12に示すループデータ210におけるprevは,外側のループのループデータ210に対するポインタを示す。図12において,例えばループデータ210jのprevにおける“*K”は,ループJの外側のループであるループKのループデータ210kに対するポインタを表している。なお,図12において,外側にループを持たないループKのループデータ210kのprevは,“NULL”である。   Prev in the loop data 210 shown in FIG. 12 indicates a pointer to the loop data 210 of the outer loop. In FIG. 12, for example, “* K” in prev of the loop data 210j represents a pointer to the loop data 210k of the loop K that is a loop outside the loop J. In FIG. 12, the prev of the loop data 210k of the loop K having no loop on the outside is “NULL”.

図12に示すループデータ210におけるnextは,内側のループのループデータ210に対するポインタを示す。例えば,ループデータ210jのnextにおける“*I”は,ループJの内側のループであるループIのループデータ210iに対するポインタを表している。なお,図12において,内側にループを持たないループIのループデータ210iのnextは,“NULL”である。   Next in the loop data 210 shown in FIG. 12 indicates a pointer to the loop data 210 of the inner loop. For example, “* I” in the next of the loop data 210j represents a pointer to the loop data 210i of the loop I that is a loop inside the loop J. In FIG. 12, the next of the loop data 210i of the loop I having no loop on the inside is “NULL”.

図12に示すループデータ210における配列データは,最内ループ内に存在する配列に関する情報である配列データに対するポインタを示す。ループデータ210の配列データのデフォルトは,“NULL”である。ループデータ210における配列データは,後述の配列解析部110の処理によって設定される。   The array data in the loop data 210 shown in FIG. 12 indicates a pointer to array data that is information relating to the array existing in the innermost loop. The default of the array data of the loop data 210 is “NULL”. The sequence data in the loop data 210 is set by processing of the sequence analysis unit 110 described later.

図12に示すループデータ210におけるブロッキングフラグは,ブロッキング実行可否の指示の有無を示す。本実施の形態では,ループごとに,外部的にブロッキングによる最適化の有無を指示できるケースも想定している。本実施の形態では,特に指示のないループについては,ループデータ210のブロッキングフラグに“TRUE”が設定される。最適化指示行などによりブロッキングが抑止されたループについては,ループデータ210のブロッキングフラグに“FALSE”が設定される。   The blocking flag in the loop data 210 shown in FIG. In the present embodiment, it is also assumed that for each loop, the presence or absence of optimization by blocking can be externally instructed. In the present embodiment, “TRUE” is set in the blocking flag of the loop data 210 for a loop that has no particular instruction. For a loop whose blocking is suppressed by an optimization instruction line or the like, “FALSE” is set in the blocking flag of the loop data 210.

図12に示すループデータ210における分割ブロック長は,ブロッキングで用いる分割ブロック長を示す。本実施の形態では,ループごとに,外部的に固定の分割ブロック長を指示できるケースも想定している。本実施の形態では,特に固定の分割ブロック長の指示がないループについては,ループデータ210の分割ブロック長に,ブロッキングで用いる分割ブロック長を自動計算することを示す“0”が設定される。最適化指示行などにより固定の分割ブロック長が指示されたループについては,ループデータ210の分割ブロック長に指示された値が設定される。なお,ループデータ210のブロッキングフラグが“FALSE”であるループについては,ループデータ210の分割ブロック長に,ブロッキングを実行しない旨を示す“−1”が設定される。   The divided block length in the loop data 210 shown in FIG. 12 indicates the divided block length used for blocking. In this embodiment, it is assumed that a fixed division block length can be externally designated for each loop. In the present embodiment, “0” indicating that the divided block length used for blocking is automatically calculated is set as the divided block length of the loop data 210 for a loop that does not instruct a fixed divided block length. For a loop for which a fixed division block length is designated by an optimization instruction line or the like, the value designated for the division block length of the loop data 210 is set. For a loop in which the blocking flag of the loop data 210 is “FALSE”, “−1” indicating that blocking is not executed is set in the divided block length of the loop data 210.

図12に示すループデータ210における有効フラグは,ブロッキングによる最適化が有効であるか否かを示す。ループデータ210の有効フラグのデフォルトは,“NULL”である。ループデータ210の有効フラグは,後述のアクセスパターン解析部120の処理によって設定される。   The valid flag in the loop data 210 shown in FIG. 12 indicates whether optimization by blocking is valid. The default valid flag of the loop data 210 is “NULL”. The valid flag of the loop data 210 is set by processing of the access pattern analysis unit 120 described later.

本実施の形態の処理対象ループ解析部100による処理の例を説明する。   An example of processing performed by the processing target loop analysis unit 100 according to the present embodiment will be described.

処理対象ループ解析部100は,まず,プログラムに含まれるDOループやFORループなどのループの入れ子関係を解析し,多重ループにおける最内ループを探し出す。より具体的には,処理対象ループ解析部100は,ループデータ記憶部200に記憶されたループデータ210を,外側のループから順にnextのポインタを辿って,nextが“NULL”である最内ループを見つけ出す。例えば,処理対象ループ解析部100は,図11(A)に示す最適化対象ループにおいて,最外のループKからループJ,ループIへと順に辿り,子ループがないループIを最内ループとして抽出する。   The processing target loop analysis unit 100 first analyzes the nesting relationship of loops such as DO loops and FOR loops included in the program to find the innermost loop in the multiple loop. More specifically, the processing target loop analysis unit 100 traces the loop data 210 stored in the loop data storage unit 200 by tracing the next pointer sequentially from the outer loop, and the next loop is “NULL”. Find out. For example, in the optimization target loop shown in FIG. 11A, the processing target loop analysis unit 100 sequentially traces from the outermost loop K to the loop J and loop I, and sets the loop I having no child loop as the innermost loop. Extract.

次に,処理対象ループ解析部100は,抽出された最内ループから順に外側にループを広げながら,タイトな構造を持つループの範囲を抽出する。処理対象ループ解析部100は,抽出されたタイトな構造を持つループの範囲を,ブロッキングによる最適化の対象ループとする。以下では,ブロッキングによる最適化の対象ループを,ブロッキング対象ループと呼ぶものとする。   Next, the processing target loop analysis unit 100 extracts a range of loops having a tight structure while expanding the loops outward in order from the extracted innermost loop. The processing target loop analysis unit 100 sets the extracted loop range having a tight structure as a target loop to be optimized by blocking. In the following, the optimization target loop is called a blocking target loop.

ループにおけるタイトな構造とは,ループが直列の入れ子構造をなし,最内ループにのみ実行文を有する構造である。本実施の形態では,タイトな構造を持つ多重ループをタイトなループと呼ぶものとする。途中のループとループとの間に実行文が含まれる場合には,実行文を含むループよりも下のループがタイトなループとみなされる。   A tight structure in a loop is a structure in which loops are serially nested and an executable statement is included only in the innermost loop. In the present embodiment, a multiple loop having a tight structure is called a tight loop. When an executable statement is included between loops in the middle, the loop below the loop containing the executable statement is regarded as a tight loop.

図13は,本実施の形態によるタイトなループを説明する図である。   FIG. 13 is a diagram for explaining a tight loop according to the present embodiment.

図13(A)に示すループは,ループXとループYからなる2重ループである。図13(A)に示すループは,最内のループYの内側にのみ演算の実行文を有している。すなわち,ループXとループYとからなる多重ループは,タイトなループである。   The loop shown in FIG. 13A is a double loop composed of a loop X and a loop Y. The loop shown in FIG. 13A has an execution statement for calculation only inside the innermost loop Y. That is, the multiple loop composed of the loop X and the loop Y is a tight loop.

図13(B)に示すループは,ループXとループYからなる2重ループである。図13(B)に示すループでは,ループXとループYとの間に演算の実行文が含まれている。そのため,ループXとループYとからなる多重ループは,タイトなループではない。   The loop shown in FIG. 13B is a double loop composed of a loop X and a loop Y. In the loop shown in FIG. 13B, an execution statement for the operation is included between the loop X and the loop Y. Therefore, the multiple loop composed of loop X and loop Y is not a tight loop.

図13(C)に示すループは,ループX,ループY,ループZからなる3重ループである。図13(C)に示すループでは,ループXとループYとの間に演算の実行文が含まれており,ループX,ループY,ループZからなる多重ループは,タイトなループではない。ただし,ループYとループZとの間には実行文が含まれていないので,ループYとループZとからなる多重ループは,タイトなループである。処理対象ループ解析部100は,このようなタイトなループの範囲を抽出する。   The loop shown in FIG. 13C is a triple loop including loop X, loop Y, and loop Z. In the loop shown in FIG. 13C, the execution statement of the operation is included between the loop X and the loop Y, and the multiple loop composed of the loop X, the loop Y, and the loop Z is not a tight loop. However, since an executable statement is not included between the loop Y and the loop Z, the multiple loop composed of the loop Y and the loop Z is a tight loop. The processing target loop analysis unit 100 extracts such a tight loop range.

例えば,図11(A)に示す最適化対象ループでは,最内のループIの内側にのみ演算の実行分が存在する。処理対象ループ解析部100は,図11(A)に示す最適化対象ループからループK,ループJ,ループIの3重ループをタイトなループとして抽出し, ブロッキング対象ループとする。すなわち,図11(A)に示す最適化対象ループは,そのままブロッキング対象ループとなる。   For example, in the optimization target loop shown in FIG. 11 (A), the execution amount of the calculation exists only inside the innermost loop I. The processing target loop analysis unit 100 extracts the loop K, loop J, and loop I from the optimization target loop shown in FIG. 11A as a tight loop and sets it as a blocking target loop. That is, the optimization target loop shown in FIG. 11A becomes a blocking target loop as it is.

図14は,本実施の形態の処理対象ループ解析部による処理対象ループ解析処理フローチャートである。   FIG. 14 is a processing target loop analysis processing flowchart by the processing target loop analysis unit of the present embodiment.

処理対象ループ解析部100は,処理対象の多重ループから最内ループを抽出する(ステップS10)。処理対象ループ解析部100は,抽出された最内ループをタイトな最外ループとする(ステップS11)。ここでのタイトな最外ループは,その時点でタイトなループであることが確認されているループのうち,最外のループを示す。   The processing target loop analysis unit 100 extracts the innermost loop from the multiple loops to be processed (step S10). The processing target loop analysis unit 100 sets the extracted innermost loop as a tight outermost loop (step S11). The tight outermost loop here indicates the outermost loop among the loops that are confirmed to be tight at that time.

処理対象ループ解析部100は,現在のタイトな最外ループの外側に,ループがあるかを判定する(ステップS12)。   The processing target loop analysis unit 100 determines whether there is a loop outside the current tight outermost loop (step S12).

現在のタイトな最外ループの外側にループがある場合には(ステップS12のYES),処理対象ループ解析部100は,現在のタイトな最外ループの1つ外側のループを含む多重ループがタイトなループであるかを判定する(ステップS13)。   If there is a loop outside the current tight outermost loop (YES in step S12), the processing target loop analysis unit 100 determines that the multiple loop including the outer loop one of the current tight outermost loop is tight. It is determined whether the loop is correct (step S13).

現在のタイトな最外ループの1つ外側のループを含む多重ループがタイトなループであれば(ステップS13のYES),処理対象ループ解析部100は,タイトな最外ループを,現在のタイトな最外ループのその1つ外側のループに更新する(ステップS14)。処理対象ループ解析部100は,ステップS12に戻って,更新されたタイトな最外ループの処理に移る。   If the multiple loop including the loop outside the current tight outermost loop is a tight loop (YES in step S13), the processing target loop analysis unit 100 converts the tight outermost loop to the current tight outer loop. The loop is updated to the outermost loop of the outermost loop (step S14). The processing target loop analysis unit 100 returns to Step S12 and proceeds to the processing of the updated tight outermost loop.

現在のタイトな最外ループの外側にループがない場合には(ステップS12のNO),処理対象ループ解析部100は,最内ループからタイトな最外ループまでのループをブロッキング対象ループとする(ステップS15)。また,現在のタイトな最外ループの1つ外側のループを含む多重ループがタイトなループでなければ(ステップS13のNO),処理対象ループ解析部100は,最内ループからタイトな最外ループまでのループをブロッキング対象ループとする(ステップS15)。   When there is no loop outside the current tight outermost loop (NO in step S12), the processing target loop analysis unit 100 sets the loop from the innermost loop to the tight outermost loop as a blocking target loop ( Step S15). If the multiple loop including the outer loop of the current tight outermost loop is not a tight loop (NO in step S13), the processing target loop analysis unit 100 performs a tight outermost loop from the innermost loop. The loop up to is set as a blocking target loop (step S15).

次に,本実施の形態の配列解析部110による処理の例を説明する。   Next, an example of processing by the sequence analysis unit 110 of this embodiment will be described.

配列解析部110は,処理対象ループ解析部100の処理によって抽出された,ブロッキング対象ループの最内ループ内で利用されている配列を抽出する。このとき,配列解析部110は,演算の実行によってメモリ3を更新する配列と,メモリ3を参照する配列とのすべてを列挙する。   The sequence analysis unit 110 extracts the sequence used in the innermost loop of the blocking target loop extracted by the processing of the processing target loop analysis unit 100. At this time, the array analysis unit 110 lists all the arrays that update the memory 3 and the arrays that refer to the memory 3 by executing the operation.

例えば,図11(A)のブロッキング対象ループにおいて,最内ループ内から,以下の6つの配列が抽出される。   For example, in the blocking target loop of FIG. 11A, the following six sequences are extracted from the innermost loop.

配列A(I,J,K)
配列A(I,J,K)
配列B(J,K,I)
配列C(K,I,J)
配列D(I,X,J)
配列D(I,Y,J)
このうち,最内ループ内の演算の実行文の左辺にある配列A(I,J,K)が演算の実行によってメモリ3を更新する配列であり,演算の実行文の右辺にある残りの5つの配列がメモリ3を参照する配列である。
Array A (I, J, K)
Array A (I, J, K)
Array B (J, K, I)
Array C (K, I, J)
Array D (I, X, J)
Array D (I, Y, J)
Among these, the array A (I, J, K) on the left side of the execution statement of the operation in the innermost loop is an array for updating the memory 3 by executing the operation, and the remaining 5 on the right side of the execution statement of the operation One array refers to the memory 3.

配列解析部110は,抽出された配列のうち,配列名と添え字とが全く同じ配列が複数ある場合には,それらの配列をまとめて1つの配列とみなす。配列名と添え字とが全く同じ配列に対するアクセスは,すべてメモリ3上の同じ領域へのアクセスとなる。すなわち,ブロッキング対象ループ内の処理で,配列名と添え字とが全く同じ配列に何度アクセスしても,アクセスするメモリ3は変わらない。そのため,後述のブロッキングによる最適化が行われたループ内の処理で配列が使用するメモリサイズを計算する手順では,配列名と添え字とが全く同じ配列が複数あっても,1つ分だけ計算すれば十分となる。   When there are a plurality of sequences having the same sequence name and subscript among the extracted sequences, the sequence analysis unit 110 collectively regards these sequences as one sequence. All accesses to arrays with exactly the same array name and subscript are access to the same area on the memory 3. That is, the accessed memory 3 does not change regardless of how many times the array name and the subscript are accessed in the process within the blocking target loop. Therefore, in the procedure for calculating the memory size used by an array in a loop that has been optimized by blocking, which will be described later, even if there are multiple arrays with exactly the same array name and subscript, only one is calculated. It will be enough.

例えば,図11(A)において,最内ループから抽出された配列には,配列A(I,J,K)が2つある。このとき,配列解析部110は,1つの配列A(I,J,K)が抽出されたものとみなす。   For example, in FIG. 11A, the arrays extracted from the innermost loop include two arrays A (I, J, K). At this time, the sequence analysis unit 110 assumes that one sequence A (I, J, K) has been extracted.

配列解析部110は,最内ループ内から抽出された各配列について,配列データを生成する。配列解析部110は,生成された配列データを,ブロッキング対象ループ内から抽出された配列の情報として,配列情報記憶部160に記憶する。   The sequence analysis unit 110 generates sequence data for each sequence extracted from the innermost loop. The sequence analysis unit 110 stores the generated sequence data in the sequence information storage unit 160 as sequence information extracted from the blocking target loop.

図15は,本実施の形態による配列データの管理を説明する図である。   FIG. 15 is a diagram for explaining management of array data according to the present embodiment.

図15に示す配列データ165は,配列解析部110によって,図11(A)における最内ループ内から抽出された配列データ165の例である。配列データ165aは,配列A(I,J,K)の配列データである。配列データ165bは,配列B(J,K,I)の配列データである。配列データ165cは,配列C(K,I,J)の配列データである。配列データ165d1 は,配列D(I,X,J)の配列データである。配列データ165d2 は,配列D(I,Y,J)の配列データである。このように,配列解析部110は,抽出された配列の数だけ,配列データ165を生成する。 The sequence data 165 shown in FIG. 15 is an example of the sequence data 165 extracted from the innermost loop in FIG. 11A by the sequence analysis unit 110. The array data 165a is array data of the array A (I, J, K). The array data 165b is array data of the array B (J, K, I). The array data 165c is array data of the array C (K, I, J). The array data 165d 1 is array data of the array D (I, X, J). The array data 165d 2 is array data of the array D (I, Y, J). As described above, the sequence analysis unit 110 generates the sequence data 165 by the number of the extracted sequences.

図15に示す配列データ165は,該当配列についての配列名,添え字等の情報を有する。配列データ165において,添え字のフィールドは,配列の次元数分だけ用意される。すなわち,図15に示すように,3次元の配列の配列データ165であれば,添え字#1,添え字#2,添え字#3の3つの添え字のフィールドが存在する。   The array data 165 shown in FIG. 15 has information such as an array name and a suffix for the corresponding array. In the array data 165, as many subscript fields as the number of dimensions of the array are prepared. That is, as shown in FIG. 15, in the case of array data 165 of a three-dimensional array, there are three subscript fields, subscript # 1, subscript # 2, and subscript # 3.

また,図15に示すように,配列解析部110は,ループデータ記憶部200に記憶されたループデータ210における配列データのフィールドに,生成した配列データ165へのポインタを設定する。ここでは,最内ループのループデータ210に対してのみ,生成した配列データ165へのポインタが設定されるものとする。例えば,図15に示すように,ブロッキング対象ループの最内ループであるループIのループデータ210iにおける配列データのフィールドに,5つの配列データ165へのポインタが設定される。   As shown in FIG. 15, the sequence analysis unit 110 sets a pointer to the generated sequence data 165 in the sequence data field in the loop data 210 stored in the loop data storage unit 200. Here, it is assumed that a pointer to the generated array data 165 is set only for the loop data 210 of the innermost loop. For example, as shown in FIG. 15, pointers to five array data 165 are set in the array data field in the loop data 210i of the loop I which is the innermost loop of the blocking target loop.

図16は,本実施の形態の配列解析部による配列解析処理フローチャートである。   FIG. 16 is a flowchart of sequence analysis processing by the sequence analysis unit of this embodiment.

配列解析部110は,ブロッキング対象ループの最内ループ内に存在する配列を1つ選択する(ステップS20)。配列解析部110は,選択した配列の配列名を取得する(ステップS21)。配列解析部110は,選択した配列の次元数,すなわち添え字の数を取得する(ステップS22),配列解析部110は,選択した配列の添え字を登場順に取得する(ステップS23)。   The sequence analysis unit 110 selects one sequence existing in the innermost loop of the blocking target loop (step S20). The sequence analysis unit 110 acquires the sequence name of the selected sequence (step S21). The sequence analysis unit 110 acquires the number of dimensions of the selected sequence, that is, the number of subscripts (step S22), and the sequence analysis unit 110 acquires the subscripts of the selected sequence in the order of appearance (step S23).

配列解析部110は,配列名と添え字とが,選択された配列と全く同じである配列の配列データ165がすでにあるかを判定する(ステップS24)。配列名と添え字とが,選択された配列と全く同じである配列の配列データ165がまだなければ(ステップS24のNO),配列解析部110は,選択された配列の配列データ165を生成する(ステップS25)。このとき,配列解析部110は,取得された配列の次元数分の添え字フィールドを有する配列データ165を用意する。生成された配列データ165は,配列情報記憶部160に記憶される。   The sequence analysis unit 110 determines whether there is already sequence data 165 having a sequence name and a subscript that are exactly the same as the selected sequence (step S24). If there is not yet array data 165 of the array whose array name and subscript are exactly the same as the selected array (NO in step S24), the array analysis unit 110 generates array data 165 of the selected array. (Step S25). At this time, the array analysis unit 110 prepares array data 165 having subscript fields for the number of dimensions of the acquired array. The generated array data 165 is stored in the array information storage unit 160.

配列解析部110は,最内ループ内に存在するすべての配列について処理が終了したかを判定する(ステップS26)。すべての配列についてまだ処理が終了していなければ(ステップS26のNO),配列解析部110は,ステップS20に戻って次の配列の処理に移る。すべての配列について処理が終了していれば(ステップS26のYES),配列解析部110は,処理を終了する。   The sequence analysis unit 110 determines whether the processing has been completed for all sequences existing in the innermost loop (step S26). If the processing has not yet been completed for all the arrays (NO in step S26), the array analysis unit 110 returns to step S20 and proceeds to processing for the next array. If the processing has been completed for all the arrays (YES in step S26), the array analysis unit 110 ends the processing.

次に,本実施の形態のアクセスパターン解析部120による処理の例を説明する。   Next, an example of processing by the access pattern analysis unit 120 of this embodiment will be described.

アクセスパターン解析部120は,配列解析部110によって抽出された配列のアクセスパターンを解析する。   The access pattern analysis unit 120 analyzes the access pattern of the sequence extracted by the sequence analysis unit 110.

アクセスパターンは,配列に対するメモリアクセスのパターンを示す。本実施の形態では,配列に対するメモリアクセスにおいて,アドレスに沿って順次メモリ3にアクセスするパターンをストレートと呼び,アドレスの間隔を空けて点々とメモリ3にアクセスするパターンをクロスと呼ぶものとする。アクセスパターンは,配列の添え字に登場する制御変数によって判断することができる。   The access pattern indicates a memory access pattern for the array. In the present embodiment, in memory access to an array, a pattern that sequentially accesses the memory 3 along the address is referred to as straight, and a pattern that accesses the memory 3 at intervals with an address interval is referred to as cross. The access pattern can be determined by the control variable appearing in the array subscript.

図17は,本実施の形態によるアクセスパターンを説明する図である。   FIG. 17 is a diagram for explaining an access pattern according to the present embodiment.

図17に示すループK,ループJ,ループIからなる多重ループにおいて,制御変数K,J,Iを更新するテンポが速い順に並べると,最内ループから最外ループに向かって出現する制御変数の順序で,I→J→Kとなる。本実施の形態では,ブロッキング対象ループの最内ループから最外ループに向かう順序で出現する制御変数を並べたものを,制御変数の連鎖と呼ぶものとする。   In the multiple loop composed of loop K, loop J, and loop I shown in FIG. 17, when control variables K, J, and I are arranged in order of increasing tempo, control variables that appear from the innermost loop toward the outermost loop are displayed. In order, I → J → K. In this embodiment, an arrangement of control variables that appear in the order from the innermost loop to the outermost loop of the blocking target loop is called a chain of control variables.

図17(A)に示す多重ループにおいて,最内のループIの内側には配列A(I,J,K)が存在する。この配列A(I,J,K)の添え字として使われている制御変数を,その登場する次元の順に並べると,I→J→Kとなる。本実施の形態では,ブロッキング対象ループの最内ループ内にある配列において,その配列に添え字として使われている制御変数をその出現順に並べたものを,添え字の連鎖と呼ぶものとする。このように,添え字の連鎖が制御変数の連鎖と同じ配列のアクセスパターンが,ストレートである。   In the multiple loop shown in FIG. 17A, the array A (I, J, K) exists inside the innermost loop I. When the control variables used as subscripts of this array A (I, J, K) are arranged in the order of their appearing dimensions, I → J → K. In the present embodiment, in an array in the innermost loop of the blocking target loop, a control variable used as a subscript in the array in the order of appearance is called a subscript chain. Thus, an access pattern in which the subscript chain is the same as the control variable chain is straight.

図17(B)に示すブロッキング対象ループにおいて,上述したように制御変数の連鎖は,I→J→Kである。また,最内ループ内にある配列B(J,K,I)の添え字の連鎖は,J→K→Iである。このように,添え字の連鎖が制御変数の連鎖と異なる配列のアクセスパターンが,クロスである。   In the blocking target loop shown in FIG. 17B, as described above, the chain of control variables is I → J → K. The subscript chain of the array B (J, K, I) in the innermost loop is J → K → I. Thus, an access pattern of an array in which the subscript chain is different from the control variable chain is cross.

ブロッキングによる最適化は,配列に対するメモリアクセスがメモリ3のアドレス順序ではなく,点在するようなケースにおいて,メモリ3へのアクセス範囲を局所化することで,キャッシュヒット率を向上させる最適化である。そのため,アクセスパターンがメモリ3を順次アクセスするストレートの配列しかないような多重ループに対してブロッキングによる最適化を適用しても,効果が出ない場合が多い。   The optimization by blocking is an optimization that improves the cache hit rate by localizing the access range to the memory 3 in the case where the memory access to the array is scattered not in the address order of the memory 3. . For this reason, even if the optimization by blocking is applied to a multiple loop in which the access pattern has only a straight array that sequentially accesses the memory 3, there is often no effect.

そこで,本実施の形態では,アクセスパターン解析部120によって,ブロッキング対象ループ内の各配列のアクセスパターンを解析することにより,ブロッキング対象ループに対してブロッキングによる最適化を適用することの有効性をチェックする。アクセスパターン解析部120は,ブロッキング対象ループが,アクセスパターンがメモリ3を点々とアクセスするクロスの配列を内側に持つような場合に,そのブロッキング対象ループに対するブロッキングによる最適化が有効であると判定する。   Therefore, in this embodiment, the access pattern analysis unit 120 analyzes the access pattern of each array in the blocking target loop, thereby checking the effectiveness of applying the optimization by blocking to the blocking target loop. To do. The access pattern analysis unit 120 determines that the optimization by blocking for the blocking target loop is effective when the blocking target loop has an array of crosses in which the access pattern accesses the memory 3 point by point. .

アクセスパターン解析部120は,ブロッキング対象ループに対するブロッキングによる最適化が有効であると判定すれば,そのブロッキング対象ループの最内ループのループデータ210における有効フラグを“TRUE”に設定する。   If the access pattern analysis unit 120 determines that the optimization by blocking for the blocking target loop is effective, the access pattern analysis unit 120 sets the effective flag in the loop data 210 of the innermost loop of the blocking target loop to “TRUE”.

例えば,前述したように,配列解析部110は,図11(A)に示すブロッキング対象ループの内部から5つの配列を抽出し,5つの配列データ165を作成する。アクセスパターン解析部120は,配列解析部110により生成された5つの配列データ165を配列情報記憶部160から取得し,取得された配列データ165から各配列の添え字の連鎖を作成する。   For example, as described above, the sequence analysis unit 110 extracts five sequences from the inside of the blocking target loop shown in FIG. 11A and creates five sequence data 165. The access pattern analysis unit 120 acquires the five array data 165 generated by the array analysis unit 110 from the array information storage unit 160, and creates a subscript chain for each array from the acquired array data 165.

このとき,アクセスパターン解析部120は,添え字にブロッキング対象ループ内で値が不変のものがあれば,その添え字を省いて添え字の連鎖を作成する。ブロッキング対象ループ内で値が不変のものは,ブロッキング対象ループに含まれるループの制御変数以外のもの,例えば固定値やブロッキング対象ループより外側のループの制御変数などである。   At this time, if there is a subscript whose value does not change in the blocking target loop, the access pattern analysis unit 120 omits the subscript and creates a subscript chain. Those whose values do not change in the blocking target loop are those other than the control variables of the loop included in the blocking target loop, such as a fixed value or a control variable of a loop outside the blocking target loop.

図11(A)に示すブロッキング対象ループの内部から抽出された5つの配列についての添え字の連鎖は,次のようになる。   The subscript chain for the five sequences extracted from the inside of the blocking target loop shown in FIG. 11A is as follows.

配列A(I,J,K): I→J→K
配列B(J,K,I): J→K→I
配列C(K,I,J): K→I→J
配列D(I,X,J): I→J
配列D(I,Y,J): I→J
配列D(I,X,J),配列D(I,Y,J)については,それぞれX,Yがブロッキング対象ループ内で不変値であるので,添え字の連鎖から省かれる。
Array A (I, J, K): I → J → K
Array B (J, K, I): J → K → I
Array C (K, I, J): K → I → J
Array D (I, X, J): I → J
Array D (I, Y, J): I → J
The arrays D (I, X, J) and D (I, Y, J) are omitted from the chain of subscripts because X and Y are invariant values in the blocking target loop, respectively.

ここで,図11(A)に示すブロッキング対象ループに含まれるループは,内側から順に,ループI,ループJ,ループKである。よって,図11(A)に示すブロッキング対象ループの制御変数の連鎖は,I→J→Kとなる。   Here, the loops included in the blocking target loop shown in FIG. 11A are loop I, loop J, and loop K in order from the inside. Therefore, the chain of control variables in the blocking target loop shown in FIG. 11A is I → J → K.

図11(A)に示すブロッキング対象ループの制御変数の連鎖と,各配列の添え字の連鎖とを比較すると,各配列のアクセスパターンは,次のようになる。   When the chain of control variables in the blocking target loop shown in FIG. 11A is compared with the chain of subscripts of each array, the access pattern of each array is as follows.

配列A(I,J,K): ストレート
配列B(J,K,I): クロス
配列C(K,I,J): クロス
配列D(I,X,J): ストレート
配列D(I,Y,J): ストレート
このように,配列B(J,K,I)と配列C(K,I,J)のアクセスパターンがクロスであるので,アクセスパターン解析部120は,図11(A)に示すブロッキング対象ループに対するブロッキングによる最適化が有効であると判定する。
Array A (I, J, K): Straight Array B (J, K, I): Cross Array C (K, I, J): Cross Array D (I, X, J): Straight Array D (I, Y) , J): Straight In this way, since the access patterns of the array B (J, K, I) and the array C (K, I, J) are crosses, the access pattern analysis unit 120 is shown in FIG. It is determined that optimization by blocking is effective for the blocking target loop shown.

図18は,本実施の形態によるループデータにおける有効フラグを設定した例を示す図である。   FIG. 18 is a diagram showing an example in which a valid flag is set in loop data according to the present embodiment.

図18に示すように,アクセスパターン解析部120は,ブロッキングによる最適化が有効であると判定された図11(A)に示すブロッキング対象ループについて,最内ループIのループデータ210iにおける有効フラグを,“TRUE”に設定する。   As shown in FIG. 18, the access pattern analysis unit 120 sets the validity flag in the loop data 210i of the innermost loop I for the blocking target loop shown in FIG. , “TRUE”.

図19は,本実施の形態のアクセスパターン解析部によるアクセスパターン解析処理フローチャートである。   FIG. 19 is a flowchart of access pattern analysis processing by the access pattern analysis unit of the present embodiment.

アクセスパターン解析部120は,ブロッキング対象ループの最内ループのループデータ210における有効フラグを,無効を示す“FALSE”で初期化する(ステップS30)。   The access pattern analysis unit 120 initializes the valid flag in the loop data 210 of the innermost loop of the blocking target loop with “FALSE” indicating invalidity (step S30).

アクセスパターン解析部120は,ブロッキング対象ループが多重ループであるかを判定する(ステップS31)。ブロッキング対象ループが多重ループでなければ(ステップS31のNO),アクセスパターン解析部120は,処理を終了する。ブロッキング対象ループが1重のループである場合には,そのブロッキング対象ループにブロッキングによる最適化を適用しても,効果が出ない場合が多い。本実施の形態では,このような1重ループであるブロッキング対象ループに対するブロッキングを行わない。なお,上述の処理対象ループ解析部100の処理において,タイトなループが1重ループである場合に,ブロッキング対象ループから外すようにしてもよい。   The access pattern analysis unit 120 determines whether the blocking target loop is a multiple loop (step S31). If the blocking target loop is not a multiple loop (NO in step S31), the access pattern analysis unit 120 ends the process. When the blocking target loop is a single loop, there is often no effect even if the optimization by blocking is applied to the blocking target loop. In this embodiment, blocking is not performed on such a blocking target loop that is a single loop. In the processing of the processing target loop analysis unit 100 described above, when the tight loop is a single loop, it may be removed from the blocking target loop.

ブロッキング対象ループが多重ループであれば(ステップS31のYES),アクセスパターン解析部120は,ブロッキング対象ループのループデータ210から,制御変数の連鎖を作成する(ステップS32)。   If the blocking target loop is a multiple loop (YES in step S31), the access pattern analysis unit 120 creates a chain of control variables from the loop data 210 of the blocking target loop (step S32).

アクセスパターン解析部120は,配列情報記憶部160から,ブロッキング対象ループの最内ループ内にある配列の配列データ165を1つ選択する(ステップS33)。アクセスパターン解析部120は,選択された配列データ165の添え字の連鎖作成処理を行う(ステップS34)。添え字の連鎖作成処理については,後述する。   The access pattern analysis unit 120 selects one sequence data 165 of the sequence in the innermost loop of the blocking target loop from the sequence information storage unit 160 (step S33). The access pattern analysis unit 120 performs a chain creation process for the subscript of the selected array data 165 (step S34). Subscript chain creation processing will be described later.

アクセスパターン解析部120は,制御変数の連鎖と選択された配列データ165の添え字の連鎖とを比較し,アクセスパターンを確認する(ステップS35)。アクセスパターンがクロスであれば(ステップS35のクロス),アクセスパターン解析部120は,ブロッキング対象ループの最内ループのループデータ210における有効フラグに,有効を示す“TRUE”を設定し(ステップS36),処理を終了する。   The access pattern analysis unit 120 compares the chain of control variables with the chain of subscripts of the selected sequence data 165, and confirms the access pattern (step S35). If the access pattern is cross (cross in step S35), the access pattern analysis unit 120 sets “TRUE” indicating validity in the valid flag in the loop data 210 of the innermost loop of the blocking target loop (step S36). , Terminate the process.

アクセスパターンがストレートであれば(ステップS35のストレート),アクセスパターン解析部120は,ブロッキング対象ループの最内ループ内にあるすべての配列の配列データ165について処理が終了したかを判定する(ステップS37)。すべての配列データ165についてまだ処理が終了していなければ(ステップS37のNO),アクセスパターン解析部120は,ステップS33に戻って次の配列データ165の処理に移る。すべての配列データ165について処理が終了していれば(ステップS37のYES),アクセスパターン解析部120は,処理を終了する。   If the access pattern is straight (straight in step S35), the access pattern analysis unit 120 determines whether the processing has been completed for the array data 165 of all the arrays in the innermost loop of the blocking target loop (step S37). ). If the processing has not been completed for all the array data 165 (NO in step S37), the access pattern analysis unit 120 returns to step S33 and proceeds to the processing of the next array data 165. If the processing has been completed for all the array data 165 (YES in step S37), the access pattern analysis unit 120 ends the processing.

図20は,本実施の形態のアクセスパターン解析部による添え字の連鎖作成処理フローチャートである。   FIG. 20 is a flowchart of subscript chain creation processing by the access pattern analysis unit of this embodiment.

アクセスパターン解析部120は,添え字の連鎖を作成する対象配列の配列データ165から,出現順に添え字を1つ取得する(ステップS340)。アクセスパターン解析部120は,取得された添え字がブロッキング対象ループに含まれるループの制御変数であるかを判定する(ステップS341)。   The access pattern analysis unit 120 acquires one subscript in the order of appearance from the array data 165 of the target sequence for creating a subscript chain (step S340). The access pattern analysis unit 120 determines whether the acquired subscript is a control variable of a loop included in the blocking target loop (step S341).

取得された添え字がブロッキング対象ループに含まれるループの制御変数であれば(ステップS341のYES),アクセスパターン解析部120は,取得された添え字を添え字の連鎖に追加する(ステップS342)。   If the acquired subscript is a control variable of a loop included in the blocking target loop (YES in step S341), the access pattern analysis unit 120 adds the acquired subscript to the subscript chain (step S342). .

アクセスパターン解析部120は,配列データ165内のすべての添え字について処理が終了したかを判定する(ステップS343)。すべての添え字についてまだ処理が終了していなければ(ステップS343のNO),アクセスパターン解析部120は,ステップS340に戻って次の添え字の処理に移る。すべての添え字について処理が終了していれば(ステップS343のYES),アクセスパターン解析部120は,処理を終了する。   The access pattern analysis unit 120 determines whether processing has been completed for all subscripts in the array data 165 (step S343). If the processing has not been completed for all the subscripts (NO in step S343), the access pattern analysis unit 120 returns to step S340 and proceeds to the processing of the next subscript. If the processing has been completed for all the subscripts (YES in step S343), the access pattern analysis unit 120 ends the processing.

次に,本実施の形態のメモリサイズ計算式生成部130による処理の例を説明する。   Next, an example of processing by the memory size calculation formula generation unit 130 of this embodiment will be described.

メモリサイズ計算式生成部130は,アクセスパターン解析部120による判定の結果,ループデータ210における有効フラグが“TRUE”となっているブロッキング対象ループについて,メモリサイズ計算式を生成する。メモリサイズ計算式は,ブロッキング対象ループに対するブロッキングによって最適化される範囲で,ブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式である。   As a result of the determination by the access pattern analysis unit 120, the memory size calculation formula generation unit 130 generates a memory size calculation formula for the blocking target loop whose effective flag in the loop data 210 is “TRUE”. The memory size calculation formula is a calculation formula for calculating the memory size used by all the arrays in the blocking target loop within a range optimized by blocking the blocking target loop.

例えば,図11(B)に示すブロッキング後の最適化対象ループにおいて,ループK,ループJ,ループIが,分割ブロック長blockを用いたブロッキングによって最適化された範囲である。このとき,メモリサイズ計算式は,図11(B)に示すブロッキング後の最適化対象ループにおけるループK,ループJ,ループIのみが回転する範囲で,その最内ループ内の全配列が使用するメモリサイズを計算する計算式である。   For example, in the optimization target loop after blocking shown in FIG. 11B, loop K, loop J, and loop I are ranges optimized by blocking using the divided block length block. At this time, the memory size calculation formula is used by all the arrays in the innermost loop within a range in which only the loop K, loop J, and loop I in the optimization target loop after blocking shown in FIG. This is a calculation formula for calculating the memory size.

メモリサイズ計算式生成部130は,ブロッキング対象ループ内の配列ごとに生成される配列別メモリ計算式から,メモリサイズ計算式を生成する。配列別メモリ計算式は,配列ごとに生成される,ブロッキング対象ループに対するブロッキングによって最適化される範囲で,それぞれの配列が使用するメモリサイズを計算する計算式である。   The memory size calculation formula generation unit 130 generates a memory size calculation formula from the array-specific memory calculation formula generated for each array in the blocking target loop. The memory calculation formula for each array is a calculation formula for calculating the memory size used by each array within a range that is generated for each array and is optimized by blocking the blocking target loop.

図21は,本実施の形態による配列別メモリ計算式の生成を説明する図である。   FIG. 21 is a diagram for explaining the generation of the memory calculation formula for each array according to the present embodiment.

図21(A)は,最内ループIの内側に4次元の配列A(I,J,K,L)を有する,ループL,ループK,ループJ,ループIからなるタイトな4重ループの例を示す。ここでは,図21に示す4重ループに対してブロッキングによる最適化を行った場合に,ブロッキングによって最適化された範囲で,配列A(I,J,K,L)が使用するメモリサイズを計算する計算式を生成する例を説明する。   FIG. 21A shows a tight quadruple loop consisting of loop L, loop K, loop J, and loop I having a four-dimensional array A (I, J, K, L) inside the innermost loop I. An example is shown. Here, when optimization by blocking is performed on the quadruple loop shown in FIG. 21, the memory size used by the array A (I, J, K, L) is calculated within the range optimized by blocking. An example of generating a calculation formula is described.

なお,図21(A)に示すように,配列A(I,J,K,L)は,配列の型が実数(real)であることが宣言されており,配列A(I,J,K,L)の型サイズは,8バイトとなる。また,ループLにはブロッキングを実行しない旨が指示されており,そのループデータ210におけるブロッキングフラグには,“FALSE”が設定されている。また,ループJには固定の分割ブロック長20が指示されており,そのループデータ210における分割ブロック長のフィールドには,20が設定されている。ループKとループIに対しては,特定の指示がないので,そのループデータ210における分割ブロック長のフィールドには,自動計算を示す0が設定されている。   As shown in FIG. 21A, the array A (I, J, K, L) is declared that the type of the array is a real number, and the array A (I, J, K) , L) type size is 8 bytes. Further, the loop L is instructed not to execute blocking, and “FALSE” is set in the blocking flag in the loop data 210. Further, a fixed divided block length 20 is instructed to the loop J, and 20 is set in the divided block length field in the loop data 210. Since there is no specific instruction for the loop K and the loop I, 0 indicating automatic calculation is set in the field of the divided block length in the loop data 210.

図21(B)は,配列別メモリ計算データ175の例を示す。配列別メモリ計算データ175は,本実施の形態において,配列別メモリ計算式を表すデータである。配列別メモリ計算データ175は,可変部と固定部とを有する。   FIG. 21B shows an example of memory calculation data 175 for each array. The array-specific memory calculation data 175 is data representing an array-specific memory calculation formula in the present embodiment. The array-specific memory calculation data 175 has a variable part and a fixed part.

可変部は,配列別メモリ計算式において,自動計算される分割ブロック長の値によって,配列が使用するメモリサイズが変化する部分を示している。図21(B)に示す配列別メモリ計算データ175において,nは自動計算する分割ブロック長を示す。計算式を生成する配列において,自動計算される分割ブロック長で最適化を行うループの制御変数である添え字の個数をZとすると,配列別メモリ計算データ175の可変部は,nZ で表される。ここでは,Zを指数部と呼ぶ。 The variable part indicates a part where the memory size used by the array changes depending on the value of the automatically calculated divided block length in the memory calculation formula for each array. In the memory calculation data 175 for each array shown in FIG. 21B, n indicates the divided block length to be automatically calculated. In the array for generating the calculation formula, if the number of subscripts that are control variables of the loop that performs optimization with the automatically calculated divided block length is Z, the variable part of the array-specific memory calculation data 175 is represented by n Z. Is done. Here, Z is called an exponent part.

固定部は,配列別メモリ計算式において,自動計算される分割ブロック長の値によって,配列が使用するメモリサイズが変化しない部分を示している。配列別メモリ計算データ175の固定部は,計算式を生成する配列において固定の分割ブロック長が指定されたループの制御変数が添え字に含まれていない場合には,配列の型サイズの値となる。また,配列別メモリ計算データ175の固定部は,計算式を生成する配列において固定の分割ブロック長が指定されたループの制御変数が添え字に含まれている場合には,その固定のブロック長と配列の型サイズとを掛け合わせた値となる。   The fixed portion indicates a portion where the memory size used by the array does not change depending on the value of the automatically calculated divided block length in the memory calculation formula for each array. The fixed part of the array-specific memory calculation data 175 includes the value of the type size of the array if the subscript does not include a loop control variable for which a fixed divided block length is specified in the array that generates the calculation formula. Become. Also, the fixed part of the array-specific memory calculation data 175 is the fixed block length if the subscript includes a loop control variable for which a fixed divided block length is specified in the array for generating the calculation formula. And the type size of the array.

なお,ブロッキングを実行しない旨が指定されたループの制御変数である添え字は,配列別メモリ計算式に含めない。また,ブロッキング対象ループ内で値が不変の添え字は,ブロッキングによる最適化の影響を受けないので,配列別メモリ計算式の生成では無視される。   A subscript that is a control variable of a loop in which blocking is not executed is not included in the memory calculation for each array. In addition, subscripts whose values do not change in the blocking target loop are not affected by the optimization due to blocking, and are therefore ignored when generating memory formulas for each array.

例えば,図21(A)に示す多重ループ内の配列A(I,J,K,L)において,添え字Iと添え字Kの2つが,自動計算される分割ブロック長で最適化を行うループの制御変数である。よって,指数部Z=2となり,配列別メモリ計算式における可変部は,n2 となる。また,添え字Jは,固定の分割ブロック長として20が指定されたループの制御変数である。配列Aの型サイズが8バイトであるので,配列別メモリ計算式における固定部は,8(配列の型サイズ)×20(固定の分割ブロック長)=160となる。なお,添え字Lについては,ブロッキングを実行しない旨が指定されたループの制御変数であるので,配列別メモリ計算式における可変部にも固定部にも含まれない。 For example, in the array A (I, J, K, L) in the multiple loop shown in FIG. 21A, a loop in which two subscripts I and K are optimized with the automatically calculated divided block length. Control variable. Therefore, the exponent part Z = 2, and the variable part in the memory calculation formula for each array is n 2 . The subscript J is a control variable of a loop in which 20 is designated as a fixed divided block length. Since the type size of the array A is 8 bytes, the fixed part in the memory calculation formula for each array is 8 (array type size) × 20 (fixed divided block length) = 160. Note that the subscript L is a control variable of a loop in which it is specified that blocking is not executed, and thus is not included in the variable part or the fixed part in the memory calculation formula for each array.

配列別メモリ計算データ175には,可変部の計算結果を示すフィールドに,固定部の計算結果が格納される。すなわち,図21(B)に示すように,可変部の計算結果n2 のフィールドに,固定部の計算結果160が格納される。なお,配列別メモリ計算データ175において,各フィールドの固定部の初期値は0である。 In the memory calculation data 175 for each array, the calculation result of the fixed part is stored in the field indicating the calculation result of the variable part. That is, as shown in FIG. 21B, the calculation result 160 of the fixed part is stored in the field of the calculation result n 2 of the variable part. In the memory calculation data 175 for each array, the initial value of the fixed part of each field is 0.

図21(B)に示す配列別メモリ計算データ175が表す配列別メモリ計算式は,
(n0 ×0)+(n1 ×0)+(n2 ×160)+(n3 ×0)+(n4 ×0)
=160n2
となる。この配列別メモリ計算式160n2 が,図21(A)に示す多重ループに対して分割ブロック長nを用いたブロッキングによる最適化を実行した場合の,配列A(I,J,K,L)が使用するメモリサイズを計算する計算式となる。
The memory calculation formula for each array represented by the memory calculation data for each array 175 shown in FIG.
(N 0 × 0) + (n 1 × 0) + (n 2 × 160) + (n 3 × 0) + (n 4 × 0)
= 160n 2
It becomes. This array memory calculation formula 160n 2 is an array A (I, J, K, L) in the case where optimization by blocking using the divided block length n is performed on the multiple loop shown in FIG. Is a calculation formula for calculating the memory size used.

図22は,本実施の形態による配列別メモリ計算式からのメモリサイズ計算式の生成を説明する図である。   FIG. 22 is a diagram for explaining generation of a memory size calculation formula from an array-specific memory calculation formula according to the present embodiment.

メモリサイズ計算式生成部130は,図11(A)に示すブロッキング対象ループから抽出された各配列について,配列情報記憶部160に記憶された各配列データ165と,ループデータ記憶部200に記憶された各ループデータ210とを用いて,配列別メモリ計算式を生成する。   The memory size calculation formula generation unit 130 stores each array data 165 stored in the array information storage unit 160 and each loop data storage unit 200 for each array extracted from the blocking target loop shown in FIG. Using each loop data 210, an array-specific memory calculation formula is generated.

ここでは,配列A,配列B,配列C,配列Dのすべてについて,配列の型としてreal型が宣言されており,すべての配列の型サイズが8バイトであるものとする。   Here, it is assumed that the real type is declared as the array type for all of the arrays A, B, C, and D, and the type size of all the arrays is 8 bytes.

配列A(I,J,K),配列B(J,K,I),配列C(K,I,J)については,すべての添え字がブロッキング対象ループに含まれるループの制御変数であるので,配列別メモリ計算式の可変部はn3 となる。また,ブロッキング対象ループに固定の分割ブロック長が指示されたループがないので,配列別メモリ計算式の固定部は配列の型サイズのみで8となる。なお,ブロッキング対象ループに含まれる各ループのループデータ210におけるブロッキングフラグは,すべて“TRUE”である。よって,配列A(I,J,K),配列B(J,K,I),配列C(K,I,J)の配列別メモリ計算式は,すべて8n3 となる。 For array A (I, J, K), array B (J, K, I), and array C (K, I, J), all subscripts are control variables for the loops included in the blocking target loop. The variable part of the memory calculation formula for each array is n 3 . Further, since there is no loop for which a fixed divided block length is instructed in the blocking target loop, the fixed part of the memory calculation formula for each array is 8 only in the array type size. Note that all blocking flags in the loop data 210 of each loop included in the blocking target loop are “TRUE”. Therefore, the array-specific memory calculation formulas for array A (I, J, K), array B (J, K, I), and array C (K, I, J) are all 8n 3 .

配列D(I,X,J),配列D(I,Y,J)については,それぞれ,添え字X,添え字Yが,ブロッキング対象ループに含まれるループの制御変数ではなく,ブロッキング対象ループ内で不変の値となる。添え字Iと添え字Jはブロッキング対象ループに含まれるループの制御変数であるので,配列別メモリ計算式の可変部はn2 となる。また,ブロッキング対象ループに固定の分割ブロック長が指示されたループがないので,配列別メモリ計算式の固定部は配列の型サイズのみで8となる。よって,配列D(I,X,J),配列D(I,Y,J)の配列別メモリ計算式は,それぞれ8n2 となる。 For array D (I, X, J) and array D (I, Y, J), subscript X and subscript Y are not control variables of the loop included in the blocking target loop, but are in the blocking target loop, respectively. It becomes an invariant value. Since subscript I and subscript J are control variables of the loop included in the blocking target loop, the variable part of the memory calculation formula for each array is n 2 . Further, since there is no loop for which a fixed divided block length is instructed in the blocking target loop, the fixed part of the memory calculation formula for each array is 8 only in the array type size. Therefore, the memory calculation formula for each of the arrays D (I, X, J) and D (I, Y, J) is 8n 2 .

各配列について生成された配列別メモリ計算式を表す配列別メモリ計算データ175は,図22に示す通りとなる。配列別メモリ計算データ175aは,配列A(I,J,K)が使用するメモリサイズを計算する配列別メモリ計算式を表すデータである。配列別メモリ計算データ175bは,配列B(J,K,I)が使用するメモリサイズを計算する配列別メモリ計算式を表すデータである。配列別メモリ計算データ175cは,配列C(K,I,J)が使用するメモリサイズを計算する配列別メモリ計算式を表すデータである。配列別メモリ計算データ175d1 は,配列D(I,X,J)が使用するメモリサイズを計算する配列別メモリ計算式を表すデータである。配列別メモリ計算データ175d2 は,配列D(I,Y,J)が使用するメモリサイズを計算する配列別メモリ計算式を表すデータである。メモリサイズ計算式生成部130は,生成された各配列別メモリ計算データ175を,配列別メモリ計算情報記憶部170に記憶する。 The array-specific memory calculation data 175 representing the array-specific memory calculation formula generated for each array is as shown in FIG. The array-specific memory calculation data 175a is data representing an array-specific memory calculation formula for calculating the memory size used by the array A (I, J, K). The array-specific memory calculation data 175b is data representing an array-specific memory calculation formula for calculating the memory size used by the array B (J, K, I). The array-specific memory calculation data 175c is data representing an array-specific memory calculation formula for calculating the memory size used by the array C (K, I, J). The array-specific memory calculation data 175d 1 is data representing an array-specific memory calculation formula for calculating the memory size used by the array D (I, X, J). The array-specific memory calculation data 175d 2 is data representing an array-specific memory calculation formula for calculating the memory size used by the array D (I, Y, J). The memory size calculation formula generation unit 130 stores the generated memory calculation data 175 for each array in the memory calculation information storage unit 170 for each array.

次に,メモリサイズ計算式生成部130は,配列ごとの配列別メモリ計算式から,全配列が使用するメモリサイズを計算するメモリサイズ計算式を生成する。メモリサイズ計算式は,配列ごとに生成されたすべての配列別メモリ計算式を加算することで得られる。   Next, the memory size calculation formula generation unit 130 generates a memory size calculation formula for calculating the memory size used by all the arrays from the array-specific memory calculation formula for each array. The memory size calculation formula is obtained by adding all the memory calculation formulas for each array generated for each array.

図22において,メモリサイズ計算データ185は,メモリサイズ計算式を表すデータである。メモリサイズ計算データ185のデータ構造は,配列別メモリ計算データ175のデータ構造と同様である。   In FIG. 22, memory size calculation data 185 is data representing a memory size calculation formula. The data structure of the memory size calculation data 185 is the same as the data structure of the memory calculation data 175 for each array.

メモリサイズ計算式生成部130は,図22に示すように,配列別メモリ計算情報記憶部170に記憶された全配列の配列別メモリ計算データ175の固定部を,メモリサイズ計算データ185上でマージする。なお,メモリサイズ計算データ185において,各フィールドの固定部の初期値は0である。   As shown in FIG. 22, the memory size calculation formula generation unit 130 merges the fixed portion of the memory calculation data 175 for each array stored in the memory calculation information storage unit 170 for each array on the memory size calculation data 185. To do. In the memory size calculation data 185, the initial value of the fixed part of each field is 0.

このように,メモリサイズ計算式生成部130により,図11に示すブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式を表すデータとして,図22に示すメモリサイズ計算データ185が生成される。メモリサイズ計算式生成部130は,生成されたメモリサイズ計算データ185を,メモリサイズ計算情報記憶部180に記憶する。   As described above, the memory size calculation formula generation unit 130 generates the memory size calculation data 185 shown in FIG. 22 as data representing the calculation formula for calculating the memory size used by all the arrays in the blocking target loop shown in FIG. Is done. The memory size calculation formula generation unit 130 stores the generated memory size calculation data 185 in the memory size calculation information storage unit 180.

図22に示すメモリサイズ計算データ185が表すメモリサイズ計算式は,
(n0 ×0)+(n1 ×0)+(n2 ×16)+(n3 ×24)
=16n2 +24n3
となる。なお,配列の型サイズの単位をバイトで計算しているので,このメモリサイズ計算式で得られるサイズの単位は,バイトである。
The memory size calculation formula represented by the memory size calculation data 185 shown in FIG.
(N 0 × 0) + (n 1 × 0) + (n 2 × 16) + (n 3 × 24)
= 16n 2 + 24n 3
It becomes. Since the unit of the array type size is calculated in bytes, the unit of size obtained by this memory size calculation formula is bytes.

図23は,本実施の形態のメモリサイズ計算式生成部によるメモリサイズ計算式生成処理フローチャートである。   FIG. 23 is a flowchart of a memory size calculation formula generation process by the memory size calculation formula generation unit of the present embodiment.

メモリサイズ計算式生成部130は,配列情報記憶部160に記憶された,ブロッキング対象ループ内から抽出された配列の配列データ165を,1つ選択する(ステップS40)。メモリサイズ計算式生成部130は,選択された配列データ165について,配列別メモリ計算データ生成処理を行う(ステップS41)。配列別メモリ計算データ生成処理の詳細については,後述する。   The memory size calculation formula generation unit 130 selects one array data 165 of the array extracted from the blocking target loop stored in the array information storage unit 160 (step S40). The memory size calculation formula generation unit 130 performs an array-specific memory calculation data generation process for the selected array data 165 (step S41). Details of the memory calculation data generation processing for each array will be described later.

メモリサイズ計算式生成部130は,ブロッキング対象ループ内から抽出されたすべての配列の配列データ165について処理が終了したかを判定する(ステップS42)。すべての配列の配列データ165についてまだ処理が終了していなければ(ステップS42のNO),メモリサイズ計算式生成部130は,ステップS40に戻って次の配列の配列データ165の処理に移る。   The memory size calculation formula generation unit 130 determines whether the processing has been completed for the array data 165 of all the arrays extracted from within the blocking target loop (step S42). If the processing has not been completed for all the array data 165 of the arrays (NO in step S42), the memory size calculation formula generation unit 130 returns to step S40 and proceeds to the processing of the array data 165 of the next array.

すべての配列の配列データ165について処理が終了していれば(ステップS42のYES),メモリサイズ計算式生成部130は,生成されたすべての配列別メモリ計算データ175から,固定部に値が格納された可変部における最大の指数部の値を取得する(ステップS43)。メモリサイズ計算式生成部130は,指数部が,0から取得された最大の指数部までの可変部のフィールドを有するメモリサイズ計算データ185を生成する(ステップS44)。   If processing has been completed for array data 165 of all arrays (YES in step S42), the memory size calculation formula generation unit 130 stores values from all the generated memory calculation data 175 for each array in a fixed part. The value of the maximum exponent part in the obtained variable part is acquired (step S43). The memory size calculation formula generation unit 130 generates memory size calculation data 185 in which the exponent part has a variable part field from 0 to the maximum exponent part acquired (step S44).

メモリサイズ計算式生成部130は,配列別メモリ計算データ175を1つ選択する(ステップS45)。メモリサイズ計算式生成部130は,選択された配列別メモリ計算データ175を,メモリサイズ計算データ185にマージする(ステップS46)。   The memory size calculation formula generation unit 130 selects one array-specific memory calculation data 175 (step S45). The memory size calculation formula generation unit 130 merges the selected array-specific memory calculation data 175 with the memory size calculation data 185 (step S46).

メモリサイズ計算式生成部130は,生成されたすべての配列別メモリ計算データ175について処理が終了したかを判定する(ステップS47)。すべての配列別メモリ計算データ175についてまだ処理が終了していなければ(ステップS47のNO),メモリサイズ計算式生成部130は,ステップS45に戻って次の配列別メモリ計算データ175の処理に移る。すべての配列別メモリ計算データ175について処理が終了していれば(ステップS47のYES),メモリサイズ計算式生成部130は,処理を終了する。   The memory size calculation formula generation unit 130 determines whether the processing has been completed for all the generated array-based memory calculation data 175 (step S47). If the processing has not been completed for all the array-specific memory calculation data 175 (NO in step S47), the memory size calculation formula generation unit 130 returns to step S45 and proceeds to the processing of the next array-specific memory calculation data 175. . If the processing has been completed for all the array-specific memory calculation data 175 (YES in step S47), the memory size calculation formula generation unit 130 ends the processing.

図24は,本実施の形態のメモリサイズ計算式生成部による配列別メモリ計算データ生成処理フローチャートである。   FIG. 24 is a memory calculation data generation processing flowchart for each array by the memory size calculation formula generation unit of this embodiment.

メモリサイズ計算式生成部130は,aを1に,Zを0に初期化する(ステップS410)。   The memory size calculation formula generation unit 130 initializes a to 1 and Z to 0 (step S410).

メモリサイズ計算式生成部130は,配列データ165から添え字を1つ選択する(ステップS411)。   The memory size calculation formula generation unit 130 selects one subscript from the array data 165 (step S411).

メモリサイズ計算式生成部130は,ループデータ記憶部200に記憶されたブロッキング対象ループのループデータ210を参照し,選択された添え字がブロッキング対象ループに含まれるループの制御変数であるかを判定する(ステップS412)。選択された添え字が制御変数でなければ(ステップS412のNO),メモリサイズ計算式生成部130は,ステップS417の処理に進む。   The memory size calculation formula generation unit 130 refers to the loop data 210 of the blocking target loop stored in the loop data storage unit 200 and determines whether the selected subscript is a control variable of a loop included in the blocking target loop. (Step S412). If the selected subscript is not a control variable (NO in step S412), the memory size calculation formula generation unit 130 proceeds to the process of step S417.

選択された添え字が制御変数であれば(ステップS412のYES),メモリサイズ計算式生成部130は,選択された添え字を制御変数とするループのループデータ210におけるブロッキングフラグが“TRUE”であるかを判定する(ステップS413)。ブロッキングフラグが“TRUE”でなければ(ステップS413のNO),メモリサイズ計算式生成部130は,ステップS417の処理に進む。   If the selected subscript is a control variable (YES in step S412), the memory size calculation formula generation unit 130 indicates that the blocking flag in the loop data 210 of the loop having the selected subscript as a control variable is “TRUE”. It is determined whether or not there is (step S413). If the blocking flag is not “TRUE” (NO in step S413), the memory size calculation formula generation unit 130 proceeds to the process in step S417.

ブロッキングフラグが“TRUE”であれば(ステップS413のYES),メモリサイズ計算式生成部130は,選択された添え字を制御変数とするループのループデータ210における分割ブロック長に固定の分割ブロック長が設定されているかを判定する(ステップS414)。固定の分割ブロック長が設定されていれば(ステップS414のYES),メモリサイズ計算式生成部130は,aの値を,a×指定された固定の分割ブロック長の値で更新する(ステップS415)。固定の分割ブロック長が指定されていなければ(ステップS414のNO),メモリサイズ計算式生成部130は,Zの値をインクリメントする(ステップS416)。   If the blocking flag is “TRUE” (YES in step S413), the memory size calculation formula generation unit 130 sets the divided block length fixed to the divided block length in the loop data 210 of the loop using the selected subscript as a control variable. Is set (step S414). If a fixed division block length is set (YES in step S414), the memory size calculation formula generation unit 130 updates the value of a with a value of a designated division block length (step S415). ). If the fixed divided block length is not specified (NO in step S414), the memory size calculation formula generation unit 130 increments the value of Z (step S416).

メモリサイズ計算式生成部130は,配列データ165のすべての添え字について処理が終了したかを判定する(ステップS417)。すべての添え字についてまだ処理が終了していなければ(ステップS417のNO),メモリサイズ計算式生成部130は,ステップS411に戻って次の添え字の処理に移る。   The memory size calculation formula generation unit 130 determines whether the processing has been completed for all subscripts of the array data 165 (step S417). If the processing has not been completed for all the subscripts (NO in step S417), the memory size calculation formula generation unit 130 returns to step S411 and proceeds to the processing of the next subscript.

すべての添え字について処理が終了していれば(ステップS417のYES),メモリサイズ計算式生成部130は,配列の型サイズbを取得する(ステップS418)。メモリサイズ計算式生成部130は,c=a×bを計算する(ステップS419)。メモリサイズ計算式生成部130は,配列別メモリ計算データ175の可変部がnZ であるフィールドの固定部に,算出されたcを設定する(ステップS420)。 If the processing has been completed for all the subscripts (YES in step S417), the memory size calculation formula generation unit 130 acquires the array type size b (step S418). The memory size calculation formula generation unit 130 calculates c = a × b (step S419). The memory size calculation formula generation unit 130 sets the calculated c to the fixed part of the field whose variable part of the array-specific memory calculation data 175 is n Z (step S420).

次に,本実施の形態の分割ブロック長計算部140による処理の例を説明する。   Next, an example of processing performed by the divided block length calculation unit 140 according to the present embodiment will be described.

分割ブロック長計算部140は,メモリサイズ計算式生成部130により生成されたメモリサイズ計算式に,分割ブロック長を入力し,メモリサイズを計算する。このとき,分割ブロック長計算部140は,メモリサイズ計算式に入力する分割ブロック長を小さい値から徐々に大きくしていき,得られたメモリサイズがキャッシュメモリのサイズを超えない,適切な分割ブロック長を求める。   The divided block length calculation unit 140 inputs the divided block length to the memory size calculation formula generated by the memory size calculation formula generation unit 130 and calculates the memory size. At this time, the divided block length calculation unit 140 gradually increases the divided block length input to the memory size calculation formula from a small value and the obtained memory size does not exceed the size of the cache memory. Find the length.

図25は,本実施の形態によるメモリサイズ計算式を用いて分割ブロック長を自動計算する例を説明する図である。   FIG. 25 is a diagram illustrating an example in which the divided block length is automatically calculated using the memory size calculation formula according to this embodiment.

図25において,メモリサイズ計算データ185は,図11(A)に示すブロッキング対象ループに基づいて生成された,図22に示すメモリサイズ計算データ185である。すなわち,図25に示すメモリサイズ計算データ185は,メモリサイズ計算式16n2 +24n3 を表すメモリサイズ計算データ185である。 25, the memory size calculation data 185 is the memory size calculation data 185 shown in FIG. 22 generated based on the blocking target loop shown in FIG. That is, the memory size calculation data 185 shown in FIG. 25 is the memory size calculation data 185 representing the memory size calculation formula 16n 2 + 24n 3 .

図25において,キャッシュサイズは,コンピュータ1が備える階層型のメモリ3における1次キャッシュメモリのサイズを示す。ここでは,キャッシュサイズが131072バイトであるものとする。   In FIG. 25, the cache size indicates the size of the primary cache memory in the hierarchical memory 3 provided in the computer 1. Here, it is assumed that the cache size is 131072 bytes.

分割ブロック長計算部140は,メモリサイズ計算データ185のnに,分割ブロック長として仮定した値を入力し,メモリサイズを算出する。分割ブロック長計算部140は,算出されたメモリサイズとキャッシュサイズとを比較し,メモリサイズがキャッシュサイズを超えているかをチェックする。   The divided block length calculation unit 140 inputs a value assumed as the divided block length to n of the memory size calculation data 185, and calculates the memory size. The divided block length calculation unit 140 compares the calculated memory size with the cache size, and checks whether the memory size exceeds the cache size.

メモリサイズ計算データ185に分割ブロック長と仮定して入力する値は,任意である。本実施の形態では,キャッシュラインやアライメントを意識して,メモリサイズ計算データ185に8の倍数を入力していくものとする。また,図25では,算出されたメモリサイズとキャッシュサイズとの比較結果として,メモリサイズがキャッシュサイズ以下の場合には○が,メモリサイズがキャッシュサイズを超えている場合には×が記載されている。   The value that is input to the memory size calculation data 185 on the assumption that the divided block length is arbitrary. In this embodiment, it is assumed that a multiple of 8 is input to the memory size calculation data 185 in consideration of cache lines and alignment. In FIG. 25, as a result of comparison between the calculated memory size and the cache size, “◯” is described when the memory size is equal to or smaller than the cache size, and “X” is described when the memory size exceeds the cache size. Yes.

まず,分割ブロック長計算部140は,メモリサイズ計算データ185のnに,分割ブロック長として8を入力する。このとき,メモリサイズ計算データ185によって得られるメモリサイズは,13312バイトとなる。算出されたメモリサイズは,キャッシュサイズ以下であるので,比較結果は○となる。   First, the divided block length calculation unit 140 inputs 8 as the divided block length to n of the memory size calculation data 185. At this time, the memory size obtained from the memory size calculation data 185 is 13312 bytes. Since the calculated memory size is equal to or smaller than the cache size, the comparison result is ◯.

次に,分割ブロック長計算部140は,メモリサイズ計算データ185のnに,分割ブロック長として16を入力する。このとき,メモリサイズ計算データ185によって得られるメモリサイズは,102400バイトとなる。算出されたメモリサイズは,キャッシュサイズ以下であるので,比較結果は○となる。   Next, the divided block length calculation unit 140 inputs 16 as the divided block length to n of the memory size calculation data 185. At this time, the memory size obtained from the memory size calculation data 185 is 102400 bytes. Since the calculated memory size is equal to or smaller than the cache size, the comparison result is ◯.

次に,分割ブロック長計算部140は,メモリサイズ計算データ185のnに,分割ブロック長として24を入力する。このとき,メモリサイズ計算データ185によって得られるメモリサイズは,340992バイトとなる。算出されたメモリサイズは,キャッシュサイズを超えているので,比較結果は×となる。   Next, the divided block length calculation unit 140 inputs 24 as the divided block length to n of the memory size calculation data 185. At this time, the memory size obtained from the memory size calculation data 185 is 340992 bytes. Since the calculated memory size exceeds the cache size, the comparison result is x.

分割ブロック長計算部140は,キャッシュサイズを超えない最大のメモリサイズが得られた入力値16を,図11(A)に示すブロッキング対象ループに対するブロッキングによる最適化で用いる,自動計算された分割ブロック長として決定する。   The divided block length calculation unit 140 uses the input value 16 from which the maximum memory size not exceeding the cache size is obtained in the optimization by blocking for the blocking target loop shown in FIG. Determine as long.

図26は,本実施の形態の分割ブロック長計算部による分割ブロック長計算処理フローチャートである。   FIG. 26 is a divided block length calculation processing flowchart by the divided block length calculation unit of the present embodiment.

分割ブロック長計算部140は,分割ブロック長の値を−1に設定する(ステップS50)。分割ブロック長計算部140は,−1に設定された分割ブロック長を,メモリ3上の退避領域に退避する(ステップS51)。ここまでの処理は,メモリサイズ計算データ185に入力する分割ブロック長の値を初期化する処理である。メモリサイズ計算データ185に最初の分割ブロック長を入力して得られるメモリサイズがキャッシュサイズを超えてしまうような場合には,ブロッキング対象ループに対する自動計算されたブロック長を用いたブロッキングは行われない。そのため,分割ブロック長の初期値として,ブロッキングによる最適化を実行しない旨を示す−1が設定される。   The divided block length calculation unit 140 sets the value of the divided block length to −1 (step S50). The divided block length calculation unit 140 saves the divided block length set to −1 in the save area on the memory 3 (step S51). The processing so far is processing for initializing the value of the divided block length input to the memory size calculation data 185. When the memory size obtained by inputting the first divided block length to the memory size calculation data 185 exceeds the cache size, blocking using the automatically calculated block length for the blocking target loop is not performed. . Therefore, −1 indicating that optimization by blocking is not executed is set as the initial value of the divided block length.

分割ブロック長計算部140は,分割ブロック長に最初の入力値を設定する(ステップS52)。分割ブロック長計算部140は,オペレーティングシステム40に対して問い合わせを行い,キャッシュサイズを取得する(ステップS53)。   The divided block length calculation unit 140 sets the first input value as the divided block length (step S52). The divided block length calculation unit 140 makes an inquiry to the operating system 40 and acquires the cache size (step S53).

分割ブロック長計算部140は,メモリサイズ計算データ185に分割ブロック長を入力して,メモリサイズを算出する(ステップS54)。分割ブロック長計算部140は,算出されたメモリサイズが,取得されたキャッシュサイズを超えているかを判定する(ステップS55)。   The divided block length calculation unit 140 inputs the divided block length to the memory size calculation data 185 and calculates the memory size (step S54). The divided block length calculation unit 140 determines whether the calculated memory size exceeds the acquired cache size (step S55).

メモリサイズがキャッシュサイズを超えていなければ(ステップS55のNO),分割ブロック長計算部140は,分割ブロック長の値をメモリ3上の退避領域に退避する(ステップS56)。この処理で,退避領域に前に退避された分割ブロック長が更新される。分割ブロック長計算部140は,メモリサイズ計算データ185に入力する分割ブロック長の値を増加し(ステップS57),ステップS54に戻って,増加された分割ブロック長の処理に移る。   If the memory size does not exceed the cache size (NO in step S55), the divided block length calculation unit 140 saves the value of the divided block length in the save area on the memory 3 (step S56). In this process, the divided block length previously saved in the save area is updated. The divided block length calculation unit 140 increases the value of the divided block length input to the memory size calculation data 185 (step S57), returns to step S54, and proceeds to processing of the increased divided block length.

メモリサイズがキャッシュサイズを超えていれば(ステップS55のYES),分割ブロック長計算部140は,その時点でメモリ3の退避領域に退避されている値を,自動計算された分割ブロック長の値として決定し(ステップS58),処理を終了する。   If the memory size exceeds the cache size (YES in step S55), the divided block length calculation unit 140 uses the value saved in the save area of the memory 3 at that time as the automatically calculated divided block length value. (Step S58), and the process ends.

次に,本実施の形態のブロッキング指示部150による処理の例を説明する。   Next, an example of processing by the blocking instruction unit 150 of the present embodiment will be described.

ブロッキング指示部150は,分割ブロック長計算部140により決定された分割ブロック長を用いたブロッキングによる最適化実行の指示を行う。より具体的には,ブロッキング指示部150は,ループデータ記憶部200に記憶されたブロッキング対象ループの各ループデータ210における分割ブロック長に対して,自動計算された分割ブロック長の値を設定する。このとき,ブロッキング指示部150は,ループデータ210における分割ブロック長に自動計算を示す0が設定されているものについてのみ,自動計算された分割ブロック長の設定を行う。   The blocking instruction unit 150 instructs optimization execution by blocking using the divided block length determined by the divided block length calculation unit 140. More specifically, the blocking instruction unit 150 sets the automatically calculated division block length value for the division block length in each loop data 210 of the blocking target loop stored in the loop data storage unit 200. At this time, the blocking instruction unit 150 sets the automatically calculated divided block length only for those in which 0 indicating automatic calculation is set as the divided block length in the loop data 210.

例えば,本実施の形態では,ブロッキング指示部150は,図12に示すブロッキング対象ループの各ループデータ210における分割ブロック長に対して,図25に示す例で決定された分割ブロック長の値16を設定する。   For example, in the present embodiment, the blocking instruction unit 150 sets the divided block length value 16 determined in the example shown in FIG. 25 to the divided block length in each loop data 210 of the blocking target loop shown in FIG. Set.

図27は,本実施の形態によるブロッキング指示部によるブロッキング指示処理フローチャートである。   FIG. 27 is a flowchart of a blocking instruction process by the blocking instruction unit according to this embodiment.

ブロッキング指示部150は,ループデータ記憶部200に記憶された,ブロッキング対象ループに含まれるループのループデータ210を,1つ選択する(ステップS60)。   The blocking instruction unit 150 selects one loop data 210 of the loop included in the blocking target loop stored in the loop data storage unit 200 (step S60).

ブロッキング指示部150は,選択されたループデータ210におけるブロッキングフラグが“TRUE”であるかを判定する(ステップS61)。また,ブロッキング指示部150は,選択されたループデータ210における分割ブロック長に,固定の分割ブロック長が設定されているかを判定する(ステップS62)。   The blocking instruction unit 150 determines whether the blocking flag in the selected loop data 210 is “TRUE” (step S61). Further, the blocking instruction unit 150 determines whether a fixed divided block length is set as the divided block length in the selected loop data 210 (step S62).

ブロッキングフラグが“TRUE”であり(ステップS61のYES),かつ分割ブロック長に固定の分割ブロック長が設定されていない場合には(ステップS62のNO),ブロッキング指示部150は,選択されたループデータ210の分割ブロック長に,自動計算された分割ブロック長の値を設定する(ステップS63)。   When the blocking flag is “TRUE” (YES in step S61) and a fixed divided block length is not set as the divided block length (NO in step S62), the blocking instruction unit 150 selects the selected loop. The value of the automatically calculated divided block length is set as the divided block length of the data 210 (step S63).

ブロッキング指示部150は,ブロッキング対象ループに含まれるループのすべてのループデータ210について処理が終了したかを判定する(ステップS64)。すべてのループデータ210についてまだ処理が終了していなければ(ステップS64のNO),ブロッキング指示部150は,ステップS60に戻って次のループデータ210の処理に移る。すべてのループデータ210について処理が終了していれば(ステップS64のYES),ブロッキング指示部150は,処理を終了する。   The blocking instruction unit 150 determines whether the processing has been completed for all the loop data 210 of the loop included in the blocking target loop (step S64). If the processing has not been completed for all the loop data 210 (NO in step S64), the blocking instruction unit 150 returns to step S60 and proceeds to the processing of the next loop data 210. If the processing has been completed for all the loop data 210 (YES in step S64), the blocking instruction unit 150 ends the processing.

最適化実行部17は,中間コードの一部としてループデータ記憶部200に記憶されたループデータ210における分割ブロック長の値を用いて,ブロッキング対象ループに対するブロッキングによる最適化を実行する。   The optimization execution unit 17 performs optimization by blocking the blocking target loop using the value of the divided block length in the loop data 210 stored in the loop data storage unit 200 as a part of the intermediate code.

以下,図28〜図31を用いて,本実施の形態のブロッキングによる最適化の具体的な実施例をいくつか説明する。   Hereinafter, some specific examples of optimization by blocking according to the present embodiment will be described with reference to FIGS. 28 to 31.

図28は,本実施の形態のブロッキングによる最適化を3重以上のループに対して実行した例である。   FIG. 28 shows an example in which the optimization by blocking according to the present embodiment is executed for a loop of three or more layers.

図28に示す最適化対象ループは,ループK,ループJ,ループIからなる。図28に示す最適化対象ループは,最内のループI内にのみ演算の実行文を有するタイトなループであるので,処理対象ループ解析部100は,図28に示す最適化対象ループをそのままブロッキング対象ループとする。配列解析部110は,3つの配列を抽出する。アクセスパターン解析部120は,抽出された配列C(K,J)のアクセスパターンがクロスであるので,図28に示す最適化対象ループに対するブロッキングによる最適化が有効であると判定する。   The optimization target loop shown in FIG. 28 includes a loop K, a loop J, and a loop I. Since the optimization target loop shown in FIG. 28 is a tight loop having an execution statement for computation only in the innermost loop I, the processing target loop analysis unit 100 blocks the optimization target loop shown in FIG. 28 as it is. The target loop. The sequence analysis unit 110 extracts three sequences. Since the access pattern of the extracted array C (K, J) is a cross, the access pattern analysis unit 120 determines that the optimization by blocking for the optimization target loop shown in FIG. 28 is effective.

抽出された3つの配列の型は,すべてreal(配列の型サイズは8バイト)で宣言されているものとする。また,3つの配列は,すべてブロッキング対象ループに含まれるループの制御変数を添え字とする,2次元の配列である。メモリサイズ計算式生成部130は,メモリサイズ計算式24n2 を生成する。 The extracted three array types are all declared as real (the array type size is 8 bytes). In addition, the three arrays are two-dimensional arrays in which the control variables of the loops included in the blocking target loop are used as subscripts. The memory size calculation formula generation unit 130 generates a memory size calculation formula 24n 2 .

キャッシュサイズとして,131072バイトが取得されたものとする。分割ブロック長計算部140は,メモリサイズ計算式24n2 に8の倍数を小さい値から順に入力していく。分割ブロック長計算部140は,メモリサイズ計算式24n2 から得られるメモリサイズが,キャッシュサイズを超えない最大のnを,自動計算された分割ブロック長として,決定する。ここでは,n=72のときに得られるメモリサイズ124416バイトが,キャッシュサイズを超えない最大のメモリサイズとなる。 It is assumed that 131072 bytes are acquired as the cache size. The divided block length calculation unit 140 sequentially inputs multiples of 8 from the smallest value to the memory size calculation formula 24n 2 . The divided block length calculation unit 140 determines the maximum n that the memory size obtained from the memory size calculation formula 24n 2 does not exceed the cache size as the automatically calculated divided block length. Here, the memory size of 124416 bytes obtained when n = 72 is the maximum memory size that does not exceed the cache size.

ブロッキング指示部150は,得られた値72を自動計算される分割ブロック長として,最適化実行部17に指示する。最適化実行部17は,自動計算された分割ブロック長block=72を用いて,図28に示す最適化対象ループに対するブロッキングによる最適化を実行する。図28に示す最適化対象ループに対するブロッキングによる最適化の実行結果として,図28に示すブロッキング後ループが得られる。   The blocking instruction unit 150 instructs the optimization execution unit 17 to use the obtained value 72 as the automatically calculated divided block length. The optimization execution unit 17 executes optimization by blocking on the optimization target loop shown in FIG. 28 using the automatically calculated divided block length block = 72. The post-blocking loop shown in FIG. 28 is obtained as an execution result of the optimization by blocking the optimization target loop shown in FIG.

このように,本実施の形態のブロッキングによる最適化の技術によって,3重ループ以上に対するブロッキングによる最適化が可能となる。   As described above, the optimization by blocking according to the present embodiment enables optimization by blocking with respect to three or more loops.

図29は,本実施の形態のブロッキングによる最適化を3次元以上の配列を含む多重ループに対して実行した例である。   FIG. 29 shows an example in which the optimization by blocking according to the present embodiment is performed on a multiple loop including a three-dimensional array or more.

図29に示す最適化対象ループは,ループK,ループJ,ループIからなる。図29に示す最適化対象ループは,最内のループI内にのみ,3次元の配列を持つ演算の実行文を有するタイトなループであるので,処理対象ループ解析部100は,図29に示す最適化対象ループをそのままブロッキング対象ループとする。配列解析部110は,5つの配列を抽出する。アクセスパターン解析部120は,抽出された配列B(J,K,I)のアクセスパターンがクロスであるので,図29に示す最適化対象ループに対するブロッキングによる最適化が有効であると判定する。   The optimization target loop shown in FIG. 29 includes a loop K, a loop J, and a loop I. Since the optimization target loop shown in FIG. 29 is a tight loop having an execution statement of an operation having a three-dimensional array only in the innermost loop I, the processing target loop analysis unit 100 is shown in FIG. The optimization target loop is directly used as a blocking target loop. The sequence analysis unit 110 extracts five sequences. Since the access pattern of the extracted array B (J, K, I) is a cross, the access pattern analysis unit 120 determines that optimization by blocking for the optimization target loop shown in FIG. 29 is effective.

抽出された5つの配列の型は,すべてreal(配列の型サイズは8バイト)で宣言されているものとする。また,5つの配列のうちの3つは,すべてブロッキング対象ループに含まれるループの制御変数を添え字とする,3次元の配列である。5つの配列のうちの2つは,ブロッキング対象ループに含まれるループの制御変数でない添え字を1つ含む,3次元の配列である。メモリサイズ計算式生成部130は,メモリサイズ計算式16n2 +24n3 を生成する。 The extracted five array types are all declared as real (the array type size is 8 bytes). In addition, three of the five arrays are three-dimensional arrays that have subscripts as control variables of the loops included in the blocking target loop. Two of the five arrays are three-dimensional arrays including one subscript that is not a control variable of a loop included in the blocking target loop. The memory size calculation formula generation unit 130 generates a memory size calculation formula 16n 2 + 24n 3 .

キャッシュサイズとして,131072バイトが取得されたものとする。分割ブロック長計算部140は,メモリサイズ計算式16n2 +24n3 に8の倍数を小さい値から順に入力していく。分割ブロック長計算部140は,メモリサイズ計算式16n2 +24n3 から得られるメモリサイズが,キャッシュサイズを超えない最大のnを,自動計算された分割ブロック長として,決定する。ここでは,n=16のときに得られるメモリサイズ102400バイトが,キャッシュサイズを超えない最大のメモリサイズとなる。 It is assumed that 131072 bytes are acquired as the cache size. The divided block length calculation unit 140 sequentially inputs multiples of 8 from the smallest value to the memory size calculation formula 16n 2 + 24n 3 . The divided block length calculation unit 140 determines, as the automatically calculated divided block length, the maximum n that the memory size obtained from the memory size calculation formula 16n 2 + 24n 3 does not exceed the cache size. Here, the memory size of 102400 bytes obtained when n = 16 is the maximum memory size that does not exceed the cache size.

ブロッキング指示部150は,得られた値16を自動計算される分割ブロック長として,最適化実行部17に指示する。最適化実行部17は,自動計算された分割ブロック長block=16を用いて,図29に示す最適化対象ループに対するブロッキングによる最適化を実行する。図29に示す最適化対象ループに対するブロッキングによる最適化の実行結果として,図29に示すブロッキング後ループが得られる。   The blocking instruction unit 150 instructs the optimization execution unit 17 to set the obtained value 16 as the automatically calculated divided block length. The optimization execution unit 17 executes optimization by blocking the optimization target loop shown in FIG. 29 using the automatically calculated divided block length block = 16. The post-blocking loop shown in FIG. 29 is obtained as an execution result of the optimization by blocking on the optimization target loop shown in FIG.

このように,本実施の形態のブロッキングによる最適化の技術によって,3次元以上の配列を含む多重ループに対するブロッキングによる最適化が可能となる。   As described above, the optimization by blocking according to the present embodiment enables the optimization by blocking with respect to multiple loops including arrays of three or more dimensions.

図30は,本実施の形態のブロッキングによる最適化をブロッキング抑止の最適化指示行を含む多重ループに対して実行した例である。   FIG. 30 shows an example in which the optimization by blocking according to the present embodiment is executed for a multiple loop including an optimization instruction line for blocking inhibition.

図30に示す最適化対象ループは,ループK,ループJ,ループIからなる。図30に示す最適化対象ループは,最内のループI内にのみ,2次元の配列を持つ演算の実行文を有するタイトなループであるので,処理対象ループ解析部100は,図30に示す最適化対象ループをそのままブロッキング対象ループとする。配列解析部110は,3つの配列を抽出する。アクセスパターン解析部120は,抽出された配列C(K,J)のアクセスパターンがクロスであるので,図30に示す最適化対象ループに対するブロッキングによる最適化が有効であると判定する。   The optimization target loop shown in FIG. 30 includes a loop K, a loop J, and a loop I. Since the optimization target loop shown in FIG. 30 is a tight loop having an execution statement of an operation having a two-dimensional array only in the innermost loop I, the processing target loop analysis unit 100 is shown in FIG. The optimization target loop is directly used as a blocking target loop. The sequence analysis unit 110 extracts three sequences. Since the access pattern of the extracted array C (K, J) is a cross, the access pattern analysis unit 120 determines that the optimization by blocking for the optimization target loop shown in FIG. 30 is effective.

抽出された3つの配列の型は,すべてreal(配列の型サイズは8バイト)で宣言されているものとする。また,図30に示す最適化対象ループは,ループJに対するブロッキング抑止の最適化指示行を含んでいる。3つの配列のうちの1つは,すべてブロッキング抑止の対象となっていない,ブロッキング対象ループに含まれるループの制御変数を添え字とする,2次元の配列である。3つの配列のうちの2つは,ブロッキング抑止の対象となっているループの制御変数を1つ含む,すべてブロッキング対象ループに含まれるループの制御変数を添え字とする,2次元の配列である。メモリサイズ計算式生成部130は,メモリサイズ計算式8n2 +16nを生成する。 The extracted three array types are all declared as real (the array type size is 8 bytes). Further, the optimization target loop shown in FIG. 30 includes an optimization instruction line for blocking suppression for the loop J. One of the three arrays is a two-dimensional array in which all of the control variables of the loop included in the blocking target loop are not subscripted and are subscripts. Two of the three arrays are two-dimensional arrays that contain one control variable for the loop that is subject to blocking suppression, and that are subscripted from the control variables for the loops that are all included in the blocking target loop. . The memory size calculation formula generation unit 130 generates a memory size calculation formula 8n 2 + 16n.

キャッシュサイズとして,131072バイトが取得されたものとする。分割ブロック長計算部140は,メモリサイズ計算式8n2 +16nに8の倍数を小さい値から順に入力していく。分割ブロック長計算部140は,メモリサイズ計算式8n2 +16nから得られるメモリサイズが,キャッシュサイズを超えない最大のnを,自動計算された分割ブロック長として,決定する。ここでは,n=120のときに得られるメモリサイズ117120バイトが,キャッシュサイズを超えない最大のメモリサイズとなる。 It is assumed that 131072 bytes are acquired as the cache size. The divided block length calculation unit 140 inputs multiples of 8 in order from the smallest value to the memory size calculation formula 8n 2 + 16n. The divided block length calculation unit 140 determines, as the automatically calculated divided block length, the maximum n that the memory size obtained from the memory size calculation formula 8n 2 + 16n does not exceed the cache size. Here, the memory size 117120 bytes obtained when n = 120 is the maximum memory size that does not exceed the cache size.

ブロッキング指示部150は,得られた値120を自動計算される分割ブロック長として,最適化実行部17に指示する。最適化実行部17は,自動計算された分割ブロック長block=120を用いて,図30に示す最適化対象ループに対するブロッキングによる最適化を実行する。このとき,最適化実行部17は,ブロッキング抑止の対象となっているループJに対しては,ブロッキングによる最適化を実行しない。図30に示す最適化対象ループに対するブロッキングによる最適化の実行結果として,図30に示すブロッキング後ループが得られる。   The blocking instruction unit 150 instructs the optimization execution unit 17 to use the obtained value 120 as the automatically calculated divided block length. The optimization execution unit 17 executes optimization by blocking on the optimization target loop shown in FIG. 30 using the automatically calculated divided block length block = 120. At this time, the optimization execution unit 17 does not execute the optimization by blocking the loop J that is the object of blocking inhibition. A post-blocking loop shown in FIG. 30 is obtained as a result of execution of optimization by blocking the optimization target loop shown in FIG.

このように,本実施の形態のブロッキングによる最適化の技術によって,あらかじめブロッキング抑止が指示されたループを除いた,最適化対象ループに対するブロッキングによる最適化が可能となる。   As described above, the optimization by blocking of the optimization target loop can be performed except for the loop for which blocking suppression is instructed in advance by the optimization technique by blocking according to the present embodiment.

図31は,本実施の形態のブロッキングによる最適化を固定の分割ブロック長の最適化指示行を含む多重ループに対して実行した例である。   FIG. 31 shows an example in which the optimization by blocking according to the present embodiment is performed on a multiple loop including an optimization instruction line having a fixed divided block length.

図31に示す最適化対象ループは,ループK,ループJ,ループIからなる。図31に示す最適化対象ループは,最内のループI内にのみ,2次元の配列を持つ演算の実行文を有するタイトなループであるので,処理対象ループ解析部100は,図31に示す最適化対象ループをそのままブロッキング対象ループとする。配列解析部110は,3つの配列を抽出する。アクセスパターン解析部120は,抽出された配列C(K,J)のアクセスパターンがクロスであるので,図31に示す最適化対象ループに対するブロッキングによる最適化が有効であると判定する。   The optimization target loop shown in FIG. 31 includes a loop K, a loop J, and a loop I. Since the optimization target loop shown in FIG. 31 is a tight loop having an execution statement of an operation having a two-dimensional array only in the innermost loop I, the processing target loop analysis unit 100 is shown in FIG. The optimization target loop is directly used as a blocking target loop. The sequence analysis unit 110 extracts three sequences. Since the access pattern of the extracted array C (K, J) is a cross, the access pattern analysis unit 120 determines that the optimization by blocking for the optimization target loop shown in FIG. 31 is effective.

抽出された3つの配列の型は,すべてreal(配列の型サイズは8バイト)で宣言されているものとする。また,図31に示す最適化対象ループは,ループJに対して固定の分割ブロック長(値48)を指示した最適化指示行を含んでいる。3つの配列のうちの1つは,すべて固定の分割ブロック長が指示されていない,ブロッキング対象ループに含まれるループの制御変数を添え字とする,2次元の配列である。3つの配列のうちの2つは,固定の分割ブロック長が指示されたループの制御変数を1つ含む,すべてブロッキング対象ループに含まれるループの制御変数を添え字とする,2次元の配列である。メモリサイズ計算式生成部130は,メモリサイズ計算式8n2 +768nを生成する。 The extracted three array types are all declared as real (the array type size is 8 bytes). Further, the optimization target loop shown in FIG. 31 includes an optimization instruction row instructing a fixed divided block length (value 48) for the loop J. One of the three arrays is a two-dimensional array in which a fixed variable block length is not specified and the control variable of the loop included in the blocking target loop is used as a subscript. Two of the three arrays are two-dimensional arrays that contain one control variable for the loop for which a fixed division block length is specified and that are subscripted from the control variables for the loops that are all included in the blocking target loop. is there. The memory size calculation formula generation unit 130 generates a memory size calculation formula 8n 2 + 768n.

キャッシュサイズとして,131072バイトが取得されたものとする。分割ブロック長計算部140は,メモリサイズ計算式8n2 +768nに8の倍数を小さい値から順に入力していく。分割ブロック長計算部140は,メモリサイズ計算式8n2 +768nから得られるメモリサイズが,キャッシュサイズを超えない最大のnを,自動計算された分割ブロック長として,決定する。ここでは,n=88のときに得られるメモリサイズ129536バイトが,キャッシュサイズを超えない最大のメモリサイズとなる。 It is assumed that 131072 bytes are acquired as the cache size. The divided block length calculation unit 140 sequentially inputs multiples of 8 from the smallest value to the memory size calculation formula 8n 2 + 768n. The divided block length calculation unit 140 determines, as the automatically calculated divided block length, the maximum n that the memory size obtained from the memory size calculation formula 8n 2 + 768n does not exceed the cache size. Here, the memory size 129536 bytes obtained when n = 88 is the maximum memory size that does not exceed the cache size.

ブロッキング指示部150は,得られた値88を自動計算される分割ブロック長として,最適化実行部17に指示する。最適化実行部17は,自動計算された分割ブロック長block=88を用いて,図31に示す最適化対象ループに対するブロッキングによる最適化を実行する。このとき,最適化実行部17は,固定の分割ブロック長が指示されたループJに対しては,その指示された固定の分割ブロック長の値48を用いて,ブロッキングによる最適化を実行する。図31に示す最適化対象ループに対するブロッキングによる最適化の実行結果として,図31に示すブロッキング後ループが得られる。   The blocking instruction unit 150 instructs the optimization execution unit 17 to use the obtained value 88 as the automatically calculated divided block length. The optimization execution unit 17 executes optimization by blocking on the optimization target loop shown in FIG. 31 using the automatically calculated divided block length block = 88. At this time, the optimization execution unit 17 executes the optimization by blocking for the loop J for which the fixed division block length is instructed, using the value 48 of the instructed fixed division block length. As a result of execution of optimization by blocking the optimization target loop shown in FIG. 31, a post-blocking loop shown in FIG. 31 is obtained.

このように,本実施の形態のブロッキングによる最適化の技術によって,あらかじめ固定の分割ブロック長が指示されたループにはそれを用いて,それ以外のループには自動計算された分割ブロック長を用いて,最適化対象ループに対するブロッキングによる最適化が可能となる。   As described above, by using the optimization technique based on blocking according to the present embodiment, the fixed division block length is used in advance for the loop, and the automatically calculated division block length is used for other loops. Therefore, it is possible to optimize the loop to be optimized by blocking.

以上説明した本実施の形態の最適化処理部15による処理は,コンピュータが備えるCPU,メモリ等のハードウェアとソフトウェアプログラムとにより実現することができ,そのプログラムをコンピュータ読み取り可能な記録媒体に記録することも,ネットワークを通して提供することも可能である。   The processing by the optimization processing unit 15 of the present embodiment described above can be realized by hardware such as CPU and memory provided in the computer and a software program, and the program is recorded on a computer-readable recording medium. It can also be provided through a network.

以上,本実施の形態について説明したが,本発明はその主旨の範囲において種々の変形が可能であることは当然である。   Although the present embodiment has been described above, the present invention can naturally be modified in various ways within the scope of the gist thereof.

1 コンピュータ
2 CPU
3 メモリ
4 HDD
5 入力装置
6 表示装置
10 コンパイラ
11 ソースプログラム入力部
12 入出力制御部
13 中間言語生成部
14 中間言語記憶部
200 ループデータ記憶部
15 最適化処理部
16 ソース解析部
100 処理対象ループ解析部
110 配列解析部
120 アクセスパターン解析部
130 メモリサイズ計算式生成部
140 分割ブロック長計算部
150 ブロッキング指示部
160 配列情報記憶部
170 配列別メモリ計算情報記憶部
180 メモリサイズ計算情報記憶部
17 最適化実行部
18 コード生成部
19 オブジェクトファイル出力部
20 記憶部
21 ソースプログラム
22 オブジェクトファイル
23 実行ファイル
30 リンカ
40 オペレーティングシステム
1 Computer 2 CPU
3 Memory 4 HDD
DESCRIPTION OF SYMBOLS 5 Input device 6 Display apparatus 10 Compiler 11 Source program input part 12 Input / output control part 13 Intermediate language production | generation part 14 Intermediate language memory | storage part 200 Loop data memory | storage part 15 Optimization processing part 16 Source analysis part 100 Processing object loop analysis part 110 Array Analysis unit 120 Access pattern analysis unit 130 Memory size calculation formula generation unit 140 Division block length calculation unit 150 Blocking instruction unit 160 Array information storage unit 170 Memory calculation information storage unit by array 180 Memory size calculation information storage unit 17 Optimization execution unit 18 Code generation unit 19 Object file output unit 20 Storage unit 21 Source program 22 Object file 23 Execution file 30 Linker 40 Operating system

Claims (5)

プログラミング言語で記述されたソースプログラムをコンパイルするコンパイラにおいて,ソースプログラムに含まれる多重ループに対するブロッキングによる最適化の処理をコンピュータに実行させるためのプログラムであって,
前記コンピュータに,
前記ソースプログラムに含まれる多重ループから,最内ループにのみ実行文を有する構造のループを,ブロッキング対象ループとして抽出する手順と,
前記ブロッキング対象ループ内に存在する配列を抽出する手順と,
前記抽出された配列の中に,添え字として出現する制御変数の順序が,前記ブロッキング対象ループの最内ループから最外ループに向かって出現する制御変数の順序と異なる配列が存在する場合に,前記ブロッキング対象ループに対するブロッキングが有効であると判定する手順と,
ブロッキングが有効であると判定された前記ブロッキング対象ループについて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,前記配列ごとに生成する手順と,
前記配列ごとに生成された計算式から,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で前記ブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式を生成する手順と,
前記全配列が使用するメモリサイズを計算する計算式を用いて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で,配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する手順と,
前記自動計算された分割ブロック長を用いて,前記ブロッキング対象ループに対するブロッキングによる最適化を行う手順とを
実行させるための最適化処理プログラム。
In a compiler for compiling a source program written in a programming language, a program for causing a computer to perform optimization processing by blocking multiple loops included in the source program,
In the computer,
A procedure for extracting, from the multiple loops included in the source program, a loop having a structure having an executable statement only in the innermost loop as a blocking target loop;
Extracting a sequence present in the blocking loop;
In the extracted array, if there is an array in which the order of control variables appearing as subscripts is different from the order of control variables appearing from the innermost loop to the outermost loop of the blocking target loop, A procedure for determining that blocking for the blocking target loop is effective;
A procedure for generating, for each array, a calculation formula for calculating a memory size used by the array in a range optimized by blocking with respect to the blocking target loop for the blocking target loop determined to be effective.
Generating a calculation formula for calculating a memory size used by all the arrays in the blocking target loop from a calculation formula generated for each array in a range optimized by blocking with respect to the blocking target loop;
A procedure for automatically calculating a divided block length in which a cache miss does not occur due to access to an array within a range optimized by blocking for the blocking target loop, using a calculation formula for calculating a memory size used by all the arrays;
An optimization processing program for executing a procedure for performing optimization by blocking on the blocking target loop using the automatically calculated divided block length.
前記配列ごとに計算式を生成する手順では,ブロッキングが有効であると判定された前記ブロッキング対象ループについて,ブロッキングを実行しない旨が指示されたループを除いた前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,前記配列ごとに生成し,
前記ブロッキングによる最適化を行う手順では,前記自動計算された分割ブロック長を用いて,前記ブロッキングを実行しない旨が指示されたループを除外して,前記ブロッキング対象ループに対するブロッキングによる最適化を行う
ことを特徴とする請求項1に記載された最適化処理プログラム。
In the procedure for generating the calculation formula for each array, the blocking target loop that is determined to be effective for blocking is optimized by blocking the blocking target loop except the loop instructed not to execute blocking. Generate a calculation formula for each array to calculate the memory size used by the array
In the procedure for performing the optimization by blocking, using the automatically calculated divided block length, the loop instructed not to execute the blocking is excluded, and the blocking target loop is optimized by the blocking. The optimization processing program according to claim 1, wherein:
前記配列ごとに計算式を生成する手順では,ブロッキングが有効であると判定された前記ブロッキング対象ループについて,固定の分割ブロック長が指示されたループを含む前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,前記配列ごとに生成し,
前記ブロッキングによる最適化を行う手順では,前記ブロッキング対象ループに含まれる前記固定の分割ブロック長が指示されたループに対しては,前記指示された固定のブロック長を用いてブロッキングによる最適化を行い,前記ブロッキング対象ループに含まれる前記固定の分割ブロック長が指示されていないループに対しては,前記自動計算された分割ブロック長を用いてブロッキングによる最適化を行う
ことを特徴とする請求項1または請求項2に記載された最適化処理プログラム。
In the procedure for generating the calculation formula for each array, the blocking target loop that is determined to be effective for blocking is optimized by blocking the blocking target loop including a loop in which a fixed division block length is indicated. Generate a calculation formula for each array to calculate the memory size used by the array in the range,
In the procedure for performing the optimization by blocking, for the loop designated by the fixed divided block length included in the loop to be blocked, optimization by blocking is performed using the designated fixed block length. The optimization by blocking is performed using the automatically calculated divided block length for a loop in which the fixed divided block length included in the blocking target loop is not specified. Alternatively, the optimization processing program according to claim 2.
プログラミング言語で記述されたソースプログラムをコンパイルするコンパイラにおいて,ソースプログラムに含まれる多重ループに対するブロッキングによる最適化の処理を実行する最適化処理装置であって,
前記ソースプログラムに含まれる多重ループから,最内ループにのみ実行文を有する構造のループを,ブロッキング対象ループとして抽出する処理対象ループ解析部と,
前記ブロッキング対象ループ内に存在する配列を抽出する配列解析部と,
前記抽出された配列の中に,添え字として出現する制御変数の順序が,前記ブロッキング対象ループの最内ループから最外ループに向かって出現する制御変数の順序と異なる配列が存在する場合に,前記ブロッキング対象ループに対するブロッキングが有効であると判定するアクセスパターン解析部と,
ブロッキングが有効であると判定された前記ブロッキング対象ループについて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,前記配列ごとに生成し,その配列ごとに生成された計算式から,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で前記ブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式を生成するメモリサイズ計算式生成部と,
前記全配列が使用するメモリサイズを計算する計算式を用いて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で,配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する分割ブロック長計算部と,
前記自動計算された分割ブロック長を用いて,前記ブロッキング対象ループに対するブロッキングによる最適化を行う最適化実行部とを備える
ことを特徴とする最適化処理装置。
In a compiler for compiling a source program described in a programming language, an optimization processing device that executes optimization processing by blocking against multiple loops included in the source program,
A processing target loop analysis unit that extracts a loop having an executable statement only in the innermost loop as a blocking target loop from the multiple loops included in the source program;
A sequence analysis unit for extracting a sequence existing in the blocking target loop;
In the extracted array, if there is an array in which the order of control variables appearing as subscripts is different from the order of control variables appearing from the innermost loop to the outermost loop of the blocking target loop, An access pattern analyzer that determines that blocking is effective for the blocking loop;
For each of the arrays for which the blocking is determined to be effective, a calculation formula for calculating the memory size used by the array within a range optimized by the blocking for the blocking target loop is generated for each array. A memory size calculation formula generation unit that generates a calculation formula for calculating a memory size used by all the arrays in the blocking target loop within a range optimized by blocking with respect to the blocking target loop, from the calculation formula generated for each block; ,
Divided block length that automatically calculates a divided block length that does not cause a cache miss due to access to the array within a range optimized by blocking for the blocking target loop, using a calculation formula that calculates the memory size used by the entire array A calculation unit;
An optimization processing device comprising: an optimization execution unit that performs optimization by blocking the blocking target loop using the automatically calculated divided block length.
プログラミング言語で記述されたソースプログラムをコンパイルするコンパイラにおいて,ソースプログラムに含まれる多重ループに対するブロッキングによる最適化の処理を,コンピュータが実行する最適化処理方法であって,
前記コンピュータが,
前記ソースプログラムに含まれる多重ループから,最内ループにのみ実行文を有する構造のループを,ブロッキング対象ループとして抽出する過程と,
前記ブロッキング対象ループ内に存在する配列を抽出する過程と,
前記抽出された配列の中に,添え字として出現する制御変数の順序が前記ブロッキング対象ループの最内ループから最外ループに向かって出現する制御変数の順序と異なる配列が存在する場合に,前記ブロッキング対象ループに対するブロッキングが有効であると判定する過程と,
ブロッキングが有効であると判定された前記ブロッキング対象ループについて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で配列が使用するメモリサイズを算出する計算式を,前記配列ごとに生成する過程と,
前記配列ごとに生成された計算式から,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で前記ブロッキング対象ループ内の全配列が使用するメモリサイズを計算する計算式を生成する過程と,
前記全配列が使用するメモリサイズを計算する計算式を用いて,前記ブロッキング対象ループに対するブロッキングによって最適化される範囲で,配列に対するアクセスによってキャッシュミスが発生しない分割ブロック長を自動計算する過程と,
前記自動計算された分割ブロック長を用いて,前記ブロッキング対象ループに対するブロッキングによる最適化を行う過程とを実行する
ことを特徴とする最適化処理方法。
In a compiler that compiles a source program written in a programming language, an optimization processing method in which a computer executes optimization processing by blocking against multiple loops included in the source program,
The computer is
Extracting a loop having a structure having an executable statement only in the innermost loop as a blocking target loop from multiple loops included in the source program;
Extracting a sequence present in the blocking loop;
When there is an array in the extracted array in which the order of control variables appearing as subscripts is different from the order of control variables appearing from the innermost loop to the outermost loop of the blocking target loop, A process for determining that blocking is effective for a blocking target loop;
A step of generating, for each array, a calculation formula for calculating a memory size used by the array within a range optimized by blocking with respect to the blocking target loop for the blocking target loop determined to be effective;
Generating a calculation formula for calculating a memory size used by all the arrays in the blocking target loop from a calculation formula generated for each array in a range optimized by blocking with respect to the blocking target loop;
A process of automatically calculating a divided block length in which a cache miss does not occur due to an access to an array within a range optimized by blocking for the blocking target loop, using a calculation formula for calculating a memory size used by the entire array;
The optimization processing method is characterized in that, using the automatically calculated divided block length, a process of performing optimization by blocking the blocking target loop is executed.
JP2010062312A 2010-03-18 2010-03-18 Optimization processing program, optimization processing apparatus, and optimization processing method Expired - Fee Related JP5402746B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010062312A JP5402746B2 (en) 2010-03-18 2010-03-18 Optimization processing program, optimization processing apparatus, and optimization processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010062312A JP5402746B2 (en) 2010-03-18 2010-03-18 Optimization processing program, optimization processing apparatus, and optimization processing method

Publications (2)

Publication Number Publication Date
JP2011197876A true JP2011197876A (en) 2011-10-06
JP5402746B2 JP5402746B2 (en) 2014-01-29

Family

ID=44876022

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010062312A Expired - Fee Related JP5402746B2 (en) 2010-03-18 2010-03-18 Optimization processing program, optimization processing apparatus, and optimization processing method

Country Status (1)

Country Link
JP (1) JP5402746B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020524318A (en) * 2017-06-19 2020-08-13 グーグル エルエルシー Alternate loop limit

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05265770A (en) * 1992-03-18 1993-10-15 Fujitsu Ltd Computer language processing method
JPH09128245A (en) * 1995-10-30 1997-05-16 Hitachi Ltd Compiling processing system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05265770A (en) * 1992-03-18 1993-10-15 Fujitsu Ltd Computer language processing method
JPH09128245A (en) * 1995-10-30 1997-05-16 Hitachi Ltd Compiling processing system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CSNG200400319001; 寒川 光: '並列性の追及-プログラマから見たRISC計算機の内側-' 並列処理シンポジウム JSPP2001 招待講演、チュートリアル資料, 20010608, pp.16〜17 *
JPN6013048174; 寒川 光: '並列性の追及-プログラマから見たRISC計算機の内側-' 並列処理シンポジウム JSPP2001 招待講演、チュートリアル資料, 20010608, pp.16〜17 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020524318A (en) * 2017-06-19 2020-08-13 グーグル エルエルシー Alternate loop limit
JP7035080B2 (en) 2017-06-19 2022-03-14 グーグル エルエルシー Alternate loop limit

Also Published As

Publication number Publication date
JP5402746B2 (en) 2014-01-29

Similar Documents

Publication Publication Date Title
US11048502B1 (en) Systems, devices, and methods for source code generation from binary files
Sagarna et al. Scatter search in software testing, comparison and collaboration with estimation of distribution algorithms
Han et al. Exploiting locality for irregular scientific codes
CN102314370B (en) Indexable type converts
Davis et al. Performance assessment of OpenMP compilers targeting NVIDIA V100 GPUs
JP6384331B2 (en) Information processing apparatus, information processing method, and information processing program
KR20140001864A (en) Tile communication operator
TW201303730A (en) Vectorization of scalar functions including vectorization annotations and vectorized function signatures matching
Oancea et al. Financial software on GPUs: between Haskell and Fortran
JP7355123B2 (en) Program generation device, program generation method, and program
Singh et al. SWAPPER: A framework for automatic generation of formula simplifiers based on conditional rewrite rules
JP5402746B2 (en) Optimization processing program, optimization processing apparatus, and optimization processing method
JP6366033B2 (en) Optimization method of IF statement in program
JP2005122481A (en) Compiler system and linker system
JP7310943B2 (en) Program generation device, program generation method and program
US20170206068A1 (en) Program optimization based on directives for intermediate code
JP5244750B2 (en) Test case generation apparatus and method
CN112558977A (en) Polyhedron optimization method for heterogeneous many-core rear-end cost-based model
Wang et al. A learning algorithm for Bayesian networks and its efficient implementation on GPUs
Ren et al. Nuwa: a quantum circuit transpiler based on a finite-horizon heuristic for placement and routing
JP2009301453A (en) Distributed memory type multiprocessor system, masked reverse shift communication method and program
Pietroń et al. GPGPU for difficult black-box problems
Marrero et al. DIGNEA: A tool to generate diverse and discriminatory instance suites for optimisation domains
Voglis et al. p-MEMPSODE: Parallel and irregular memetic global optimization
Dal et al. Investigation of the impact of different versions of GCC on various metaheuristic-based solvers for traveling salesman problem

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20130108

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130826

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20131001

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20131014

R150 Certificate of patent or registration of utility model

Ref document number: 5402746

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees