JP2010244204A - Compiler program and compiler device - Google Patents
Compiler program and compiler device Download PDFInfo
- Publication number
- JP2010244204A JP2010244204A JP2009090479A JP2009090479A JP2010244204A JP 2010244204 A JP2010244204 A JP 2010244204A JP 2009090479 A JP2009090479 A JP 2009090479A JP 2009090479 A JP2009090479 A JP 2009090479A JP 2010244204 A JP2010244204 A JP 2010244204A
- Authority
- JP
- Japan
- Prior art keywords
- loop
- data
- cache
- source program
- unit
- 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
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
この発明は、コンパイラプログラムおよびコンパイラ装置に関する。 The present invention relates to a compiler program and a compiler apparatus.
従来より、グリッドコンピューティングや企業間で構築される業務システムでは、ソースプログラムからコンパイラによって生成されたアプリケーションプログラムが、様々なハードウェア構成のシステム上で動作することで科学演算や業務に利用されている。ここで、科学演算や業務に利用されるアプリケーションプログラムに対しては、高速に処理を実行することが要求される。 Traditionally, in business systems built between grid computing and companies, application programs generated by compilers from source programs are used for scientific computation and business by running on systems with various hardware configurations. Yes. Here, it is required to execute processing at high speed for an application program used for scientific computation or business.
処理速度を向上させるための方法としては、一般的には、CPU(Central Processing Unit)とメモリとの間に高速アクセスが可能である小容量のキャッシュを配置し、キャッシュに保存したデータを用いることが行なわれている。 As a method for improving the processing speed, generally, a small-capacity cache capable of high-speed access is arranged between a CPU (Central Processing Unit) and a memory, and data stored in the cache is used. Has been done.
しかし、近年、アプリケーションプログラムの処理対象となるデータは、例えば、動画配信などのストリームデータのように、キャッシュのサイズに収まらない大量のデータである場合が増えてきている。このため、キャッシュ上にデータが保存された場合でも、CPUのアクセス時にキャッシュヒットする確率は、非常に低い。 However, in recent years, the data to be processed by the application program is increasing in the case of a large amount of data that does not fit in the cache size, for example, stream data for moving image distribution or the like. For this reason, even when data is stored on the cache, the probability of a cache hit when accessing the CPU is very low.
ここで、CPUが、プログラムにしたがって、ストリームデータを繰り返してアクセスする場合のキャッシュの状況について、図26を用いて説明する。なお、図26は、ストリームデータを繰り返してアクセスする場合のキャッシュの状況について説明するための図である。 Here, the cache status when the CPU repeatedly accesses the stream data in accordance with the program will be described with reference to FIG. FIG. 26 is a diagram for explaining the cache status when the stream data is repeatedly accessed.
例えば、CPUは、プログラムにしたがって、メモリからレジスタにストリームデータを順次読み出して所定の処理を実行し、処理後のストリームデータをキャッシュに格納したのちメモリにストアする。この場合、CPUは、図26の(A)に示すように、処理後のストリームデータ1をキャッシュに格納したのちにメモリにストアし、さらに、処理後のストリームデータ2〜ストリームデータnを、順次、キャッシュに上書きしたのちにメモリにストアする。
For example, the CPU sequentially reads stream data from the memory to a register according to a program, executes predetermined processing, stores the processed stream data in a cache, and then stores the data in the memory. In this case, as shown in FIG. 26A, the CPU stores the
しかし、CPUが、プログラムにしたがって、次の処理においてストリームデータのロードを実行する場合、キャッシュが保存しているデータは、図26の(B)に示すように、前の処理における最終部分のデータ(ストリームデータn)となる。したがって、CPUが次の処理において最初にストリームデータ1のロードを実行する場合においては、図26の(B)に示すように、キャッシュミスが発生する。
However, when the CPU executes loading of stream data in the next process according to the program, the data stored in the cache is the last part of the previous process as shown in FIG. (Stream data n). Therefore, when the CPU first loads the
このように、ストリームデータなど、プログラムの処理対象となるデータサイズがキャッシュのサイズに収まらない場合では、データの再アクセス時に、キャッシュヒットが期待できず、キャッシュを用いたデータの再利用性が低くなり、プログラムの実行性能が低下してしまう。 In this way, when the data size to be processed by the program, such as stream data, does not fit within the cache size, a cache hit cannot be expected when data is re-accessed, and the reusability of data using the cache is low. As a result, the execution performance of the program is degraded.
このため、プログラムの実行性能を向上させる解決策の1つとして、プリフェッチ命令を利用した方法がある(例えば、特許文献1および2参照)。具体的には、処理に用いられるデータを先読みしてプリフェッチ命令をソースプログラム内に挿入することにより、処理に用いられるデータを予めメモリからキャッシュに格納してキャッシュミスを軽減させる方法である。
For this reason, as one of solutions for improving the execution performance of the program, there is a method using a prefetch instruction (see, for example,
しかし、ストリームデータのように連続性のあるデータにおいては、再利用されるデータをプリフェッチ命令で精度よくキャッシュに取り込むのは難しい。このため、プログラムの実行性能を向上させる解決策の別の方法として、ブロックストア命令を用いた方法がある。 However, in continuous data such as stream data, it is difficult to accurately retrieve data to be reused into a cache with a prefetch instruction. For this reason, as another method for improving the execution performance of the program, there is a method using a block store instruction.
ブロックストア命令とは、図27に示すように、キャッシュへの保存を行わず、データ(ストリームデータ1、ストリームデータ2、〜、ストリームデータn)を直接メモリに書き込むことで、転送時間を短縮し、プログラムの実行性能を向上させる方法である。ブロックストア命令を利用することで、プリフェッチ命令をプログラム内に挿入するといった複雑な計算を実行することなく、プログラムの実行性能を向上させることができる。なお、図27は、ブロックストア命令を説明するための図である。
As shown in FIG. 27, the block store instruction reduces the transfer time by directly writing data (
ところで、上記した従来の技術は、キャッシュを有効的に利用することができないため、プログラムの実行性能が低下してしまう場合があるという課題があった。例えば、上記した従来の技術により、ストリームデータに対する全てのストア命令をブロックストア命令に置き換えた場合、CPUは、ロード命令の実行時にキャッシュが全く利用できなくなってしまい、その結果、ロードの実行性能が著しく低下する。特に、ストリームデータに対し、プログラムが繰り返して更新処理を実行する場合、ブロックストア命令を用いることでキャッシュを活用できないと、プログラムの実行性能が低下してしまう。 However, the above-described conventional technique has a problem that the execution performance of the program may be deteriorated because the cache cannot be used effectively. For example, when all store instructions for stream data are replaced with block store instructions by the above-described conventional technique, the CPU cannot use the cache at the time of executing the load instruction, and as a result, the load execution performance is improved. It drops significantly. In particular, when a program repeatedly executes update processing on stream data, the execution performance of the program is degraded if the cache cannot be utilized by using a block store instruction.
なお、上記では、ストリームデータが処理対象である場合に、キャッシュを有効的に利用することができないため、プログラムの実行性能が低下してしまう場合があるという課題があったことを説明した。しかし、キャッシュのサイズに収まらない大容量の連続したデータが処理対象であるならば、上記した従来の技術を用いても、同様の課題があった。 In the above description, it has been described that there is a problem that the execution performance of the program may be deteriorated because the cache cannot be effectively used when the stream data is a processing target. However, if large-capacity continuous data that does not fit in the size of the cache is a processing target, there is a similar problem even if the conventional technique described above is used.
そこで、開示の技術は、上述した従来技術の課題を解決するためになされたものであり、キャッシュを有効的に利用することによりプログラムの実行性能を向上することが可能となるコンパイラプログラムおよびコンパイラ装置を提供することを目的とする。 Accordingly, the disclosed technique has been made to solve the above-described problems of the prior art, and a compiler program and a compiler apparatus that can improve the execution performance of a program by effectively using a cache. The purpose is to provide.
上述した課題を解決し、目的を達成するため、このプログラムは、ソースプログラムにおける各ループのデータへのアクセスパターンを解析するアクセスパターン解析手順と、
前記アクセスパターン解析手順によって解析された前記アクセスパターンから、現ループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する依存関係解析手順と、前記依存関係解析手順によって解析された前記依存関係に基づいて、前記現ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する格納先決定手順と、前記格納先決定手順によって格納先が決定された現ループを、前記メモリに処理済みデータを格納するための第一ループおよび前記キャッシュに処理済みデータを格納するための第二ループに置き換えることにより、前記ソースプログラムから新規ソースプログラムを生成する新規ソースプログラム生成手順と、前記新規ソースプログラム生成手順によって生成された前記新規ソースプログラムからオブジェクトファイルを生成するオブジェクトファイル生成手順と、をコンピュータに実行させることを要件とする。
In order to solve the above-described problems and achieve the object, this program includes an access pattern analysis procedure for analyzing an access pattern to data of each loop in the source program,
From the access pattern analyzed by the access pattern analysis procedure, a dependency analysis procedure for analyzing a dependency relationship between data processed in the current loop and data processed in the next loop is analyzed by the dependency analysis procedure. Based on the dependency, a storage destination determination procedure for allocating a storage destination of data processed in the current loop to either a memory or a cache, and a storage destination is determined by the storage destination determination procedure A new source that generates a new source program from the source program by replacing the current loop with a first loop for storing processed data in the memory and a second loop for storing processed data in the cache Program generation procedure and the new source program And an object file generation step of generating object files from the new source program generated by the formation procedures, and the requirements that cause a computer to execute the.
開示のプログラムによれば、キャッシュを有効的に利用することによりプログラムの実行性能を向上することが可能となる。 According to the disclosed program, it is possible to improve the execution performance of the program by effectively using the cache.
以下に添付図面を参照して、本願の開示するコンパイラプログラムおよびコンパイラ装置の実施例を詳細に説明する。なお、以下では、本願の開示するコンパイラプログラムを実行するコンパイラ装置を実施例として説明する。 Exemplary embodiments of a compiler program and a compiler apparatus disclosed in the present application will be described below in detail with reference to the accompanying drawings. In the following, a compiler apparatus that executes a compiler program disclosed in the present application will be described as an embodiment.
まず、本実施例におけるコンパイラ装置による処理の概念について説明する。図1は、本実施例におけるコンパイラ装置による処理の概念を説明するための図である。 First, the concept of processing by the compiler apparatus in this embodiment will be described. FIG. 1 is a diagram for explaining the concept of processing by the compiler apparatus in this embodiment.
本実施例におけるコンパイラ装置は、ソースプログラムに記述されているループ単位の処理の間で、「前のループ」がストアしたデータを「後のループ」がロードする場合はキャッシュが有効に活用できると判断する。そして、本実施例におけるコンパイラ装置は、「後のループ」にて実行される処理の先頭で要求されるデータ(ロードするデータ)については、「前のループ」にて実行される処理の最後にアクセスし、かつ、キャッシュにストアするように、「前のループ」を変形する。「前のループ」の変形処理を行なったソースプログラムを実行する場合、「後のループ」にて実行される処理の先頭にてロードされるデータは、キャッシュヒットとなる。 The compiler apparatus according to the present embodiment can effectively use the cache when the “following loop” loads the data stored by the “previous loop” during the processing of the loop unit described in the source program. to decide. Then, the compiler apparatus according to the present embodiment, at the end of the process executed in the “previous loop”, is requested for data (data to be loaded) requested at the head of the process executed in the “later loop”. Transform the "previous loop" to access and store in the cache. When a source program that has been subjected to the “previous loop” transformation process is executed, the data loaded at the head of the process executed in the “subsequent loop” is a cache hit.
例えば、本実施例におけるコンパイラ装置は、図1の(A)に示すように、「後のループ」の先頭にて処理されるストリームデータ1を「前のループ」の最後にて処理し、かつ、ストリームデータ1のみキャッシュに格納されるように「前のループ」を変形する。また、本実施例におけるコンパイラ装置は、例えば、図1の(A)に示すように、「前のループ」にて処理されるストリームデータ1以外のストリームデータ2〜nについては、直接メモリに格納するブロックストア命令を利用するように「前のループ」を変形する。これにより、図1の(A)に示すように、「後のループ」における処理の先頭にロードされるストリームデータ1は、キャッシュヒットとなる。
For example, as shown in FIG. 1A, the compiler apparatus according to the present embodiment processes the
図1の(B)に示すソースプログラムの具体例を用いて上述した処理をより具体的に説明する。図1の(B)に示すようなソースプログラムを実行する場合、ループXにおいて、配列a、配列bおよび配列cのデータが初期設定され、ループYにおいて、配列aのデータが確定され、ループZにおいて、配列aのデータが参照される。ここで、配列a、配列bおよび配列cのデータがキャッシュに収まらないストリームデータであるとすると、通常のストア命令によりキャッシュを利用した場合、配列aのデータは、「a(n−キャッシュサイズ)からa(n)」の範囲でキャッシュに保存される。しかし、次に実行されるループZでは、配列aをデータの先頭からロードするため、キャッシュのデータを利用することはできない。一方、ブロックストア命令を利用した場合、配列aのデータは、キャッシュには保存されていないので、キャッシュを有効的に用いることができない。 The above-described processing will be described more specifically using a specific example of the source program shown in FIG. When the source program as shown in FIG. 1B is executed, the data of the array a, the array b, and the array c are initialized in the loop X, the data of the array a is determined in the loop Y, and the loop Z The data of the array a is referred to. Here, assuming that the data of the array a, the array b, and the array c is stream data that does not fit in the cache, when the cache is used by a normal store instruction, the data of the array a is “a (n−cache size)”. To a (n) ". However, in the next loop Z to be executed, since the array a is loaded from the beginning of the data, the cache data cannot be used. On the other hand, when the block store instruction is used, the data of the array a is not stored in the cache, so that the cache cannot be used effectively.
そこで、本実施例におけるコンパイラ装置は、ソースプログラムにおける前後のループ間におけるデータのアクセスパターンの依存関係を解析し、例えば、図1の(B)に示すソースプログラムのループZにおいて、ループYにて処理された配列aのデータが参照されると判定する。そして、本実施例におけるコンパイラ装置は、図1の(B)に示すように、ループYとループZとの間で、キャッシュを部分利用すると決定する。そして、本実施例におけるコンパイラ装置は、ループYを、キャッシュストア命令が書き込まれたループと、ブロックストア命令が書き込まれたループとの2つのループに変形する。 Therefore, the compiler apparatus in the present embodiment analyzes the dependency of the data access pattern between the loops before and after in the source program. For example, in the loop Z of the source program shown in FIG. It is determined that the data of the processed array a is referred to. Then, the compiler apparatus according to the present embodiment determines to partially use the cache between the loop Y and the loop Z as shown in FIG. The compiler apparatus according to the present embodiment transforms the loop Y into two loops, that is, a loop in which a cache store instruction is written and a loop in which a block store instruction is written.
そして、本実施例におけるコンパイラ装置は、ループ変形されたソースプログラムを最適化処理したのちにオブジェクトファイルを生成する。これにより、本実施例におけるコンパイラ装置から出力されたオブジェクトファイルを実行する情報処理装置においては、部分的ではあるがキャッシュを有効的に利用することにより、ストリームデータに対するアクセスが効率化され、プログラムの実行性能を向上することが可能となる。 The compiler apparatus according to the present embodiment generates an object file after optimizing the loop-modified source program. As a result, in the information processing apparatus that executes the object file output from the compiler apparatus according to the present embodiment, access to the stream data is made efficient by using the cache effectively although it is partial, and the program Execution performance can be improved.
次に、本実施例におけるコンパイラ装置の構成について、図2を用いて説明する。図2は、本実施例におけるコンパイラ装置の構成を示すブロック図である。 Next, the configuration of the compiler apparatus in this embodiment will be described with reference to FIG. FIG. 2 is a block diagram showing the configuration of the compiler apparatus in this embodiment.
図2に示すように、本実施例におけるコンパイラ装置10は、ソースプログラム入力部11と、オブジェクトファイル出力部12と、通信部13と、入出力制御I/F部14と、記憶部20と、処理部30とを有する。また、本実施例におけるコンパイラ装置10は、図2に示すように、情報処理装置40と接続される。
As shown in FIG. 2, the
情報処理装置40は、コンパイラ装置10から出力されたオブジェクトファイルを実行するPC(Personal computer)などの装置である。なお、本実施例では、コンパイラ装置10と情報処理装置40とが独立した装置である場合について説明するが、本実施例はこれに限定されるものではなく、コンパイラ装置10が情報処理装置40に組み込まれている場合であってもよい。
The
ソースプログラム入力部11は、プログラマが作成したソースプログラムを受け付け、オブジェクトファイル出力部12は、処理部30により生成されたオブジェクトファイルを、情報処理装置40に出力する。通信部13は、情報処理装置40から後述するハードウェア情報を受信する。
The source
通信部13は、情報処理装置40から後述するハードウェア情報を受信する。
The
入出力制御I/F部14は、ソースプログラム入力部11、オブジェクトファイル出力部12および通信部13と、記憶部20および処理部30との間におけるデータ転送を制御する。
The input / output control I /
記憶部20は、ソースプログラム入力部11が受け付けたソースプログラムや後述する処理部30による各種処理結果を記憶する。ここで、記憶部20は、特に本実施例に密接に関連するものとして、図2に示すように、ソースプログラム記憶部21と、ループデータ記憶部22と、配列データ記憶部23と、ハードウェア情報記憶部24と、新規ソースプログラム記憶部25とを有する。
The
ソースプログラム記憶部21は、ソースプログラム入力部11が受け付けたソースプログラムを記憶する。例えば、ソースプログラム記憶部21は、図1の(B)に示すようなソースプログラムを記憶する。
The source
なお、ループデータ記憶部22と、配列データ記憶部23と、ハードウェア情報記憶部24と、新規ソースプログラム記憶部25とについては、処理部30を説明する際に、詳述する。
The loop
処理部30は、入出力制御I/F部14から転送されたソースプログラムがソースプログラム記憶部21に格納された際に、各種処理を実行する。ここで、処理部30は、特に本実施例に密接に関連するものとして、図2に示すように、ループ構造解析部31と、配列解析部32と、アクセスパターン解析部33と、依存関係解析部34と、部分キャッシュ指示部35とを有する。さらに、処理部30は、特に本実施例に密接に関連するものとして、図2に示すように、最適化部36と、オブジェクトファイル生成部37とを有する。なお、ループ構造解析部31、配列解析部32、アクセスパターン解析部33、依存関係解析部34および部分キャッシュ指示部35は、ソースプログラムの解析処理を分散して実行する処理部である。
The
ループ構造解析部31は、ソースプログラム記憶部21が記憶するソースプログラムにおけるループ構造を解析する。具体的には、ループ構造解析部31は、ソースプログラムにおけるDOループやFORループなどを抽出し、抽出したループ間の処理の大まかな流れを解析する。ここで、ループ構造解析部31は、抽出したループが多重ループである場合、データ配列の演算が記載されているループの中で、最も内側にあるループ(最内のループ)を、後続する処理の対象であるループ(対象ループ)とする。なお、多重ループである場合の処理については、後に詳述する。
The loop
例えば、ループ構造解析部31は、図1の(B)に示すソースプログラムを解析し、最内のループである「ループX(do j)」、「ループY(do j)」および「ループZ(do j)」を抽出する。そして、ループ構造解析部31は、図3に示すように、図1の(B)に示すソースプログラムが、「ループX」から「ループY」へ、「ループY」から「ループZ」へと処理が進行するループ構造であると解析する。なお、図3は、ループ構造解析部を説明するための図である。
For example, the loop
そして、ループ構造解析部31は、解析結果に基づいて、ループデータ記憶部22にて記憶されるループデータの初期設定を行なう。例えば、ループ構造解析部31は、図4に示すように、「ループX」、「ループY」および「ループZ」それぞれのループデータを初期設定する。なお、図4は、ループデータ記憶部を説明するための図である。
Then, the loop
すなわち、ループ構造解析部31は、ループデータ記憶部22において、図4に示すように、「ループ名:X」、「ループ名:Y」および「ループ名:Z」となる3つのループデータを初期設定する。ここで、ループデータには、ループ構造解析部31の解析結果として、ループ間処理の流れを示す「prev」および「next」の項目が用意される。「prev」および「next」の項目が設定されることにより、各ループデータには、ループ間の連鎖に関する情報が格納されることとなる。
That is, as shown in FIG. 4, the loop
例えば、「ループ名:X」のループデータには、「ループX」の前に実行されるループが無いことから「prev:NULL」が格納される。また、「ループ名:X」のループデータには、「ループX」の後に実行されるループが「ループY」であることから「next:*Y」が格納される。 For example, “prev: NULL” is stored in the loop data of “loop name: X” because there is no loop executed before “loop X”. The loop data “loop name: X” stores “next: * Y” because the loop executed after “loop X” is “loop Y”.
また、「ループ名:Y」のループデータには、「prev:*X」および「next:*Z」が格納され、「ループ名:Z」のループデータには、「prev:*Y」および「next:NULL」が格納される。 Further, “prev: * X” and “next: * Z” are stored in the loop data of “loop name: Y”, and “prev: * Y” and “prev: * Y” are stored in the loop data of “loop name: Z”. “Next: NULL” is stored.
なお、ループデータにおいて、図4に示す「配列データ」に格納されるデータは、後述する処理により決定されるため、ループ構造解析部31による初期設定時では、すべて「NULL」となる。
In the loop data, the data stored in the “array data” shown in FIG. 4 is determined by the processing described later, and therefore all of the data is “NULL” at the time of initial setting by the loop
ここで、ループ構造解析部31による詳細な処理の手順について、図5および図6を用いて説明する。なお、図5は、ループ構造解析部による処理を説明するためのフローチャートであり、図6は、ループの種類を説明するための図である。
Here, a detailed processing procedure by the loop
図5に示すように、ループ構造解析部31は、ソースプログラムが入力されると(ステップS101肯定)、ソースプログラム記憶部21からソースプログラムを読み出して、関数内の外側ループを検索する(ステップS102)。すなわち、ループ構造解析部31は、ソースプログラムにおいて、関数の直下のスコープにあるループをソースプログラムから検索する。
As shown in FIG. 5, when the source program is input (Yes at Step S101), the loop
そして、ループ構造解析部31は、検索した外側ループが多重ループであるか否かを解析する(ステップS103)。なお、ループ構造解析部31は、ソースプログラムにおける出現順に、検索した外側ループを処理する。
Then, the loop
ここで、検索した外側ループが多重ループでない場合(ステップS103否定)、ループ構造解析部31は、検索したループ(外側ループ)を対象ループに含め(ステップS104)、ループデータの作成を実行する(ステップS107)。具体的には、ループ構造解析部31は、対象ループのループ名が設定されたループデータを作成する。
Here, when the searched outer loop is not a multiple loop (No at Step S103), the loop
一方、検索した外側ループが多重ループである場合(ステップS103肯定)、ループ構造解析部31は、多重ループがタイトリループであるか否かを解析する(ステップS105)。
On the other hand, when the searched outer loop is a multiple loop (Yes at Step S103), the loop
ここで、タイトリループ(タイトリなループ)とは、ループとループとの間で処理がないループのことである。例えば、図6の(A)の左側に示す外側ループ「ループX」は、「A=A+B」を実行する「ループY」を含む多重ループであるが、「ループX」と「ループY」との間で実行される処理がないため、タイトリなループとなる。一方、図6の(A)の右側に示す外側ループ「ループX」は、「A=A+B」を実行する「ループY」を含む多重ループであるが、「ループX」において「C=C+D」の処理が実行されるため、タイトリでないループとなる。 Here, a title loop (a title loop) is a loop in which no processing is performed between the loops. For example, the outer loop “loop X” shown on the left side of FIG. 6A is a multiple loop including “loop Y” that executes “A = A + B”, but “loop X” and “loop Y” Since there is no processing executed between the two, it becomes a tight loop. On the other hand, the outer loop “loop X” shown on the right side of FIG. 6A is a multiple loop including “loop Y” for executing “A = A + B”, but “C = C + D” in “loop X”. Since this process is executed, the loop is not a title.
図5に戻って、ループ構造解析部31は、検索した外側ループが多重ループであるが、タイトリループでない場合(ステップS105否定)、検索した外側ループを後続処理の対象外であるとし、検索した外側ループをすべて処理したか否かを判定する(ステップS108)。例えば、図6の(B)の右側に示す「ループX」は、対象外とされる。
Returning to FIG. 5, if the searched outer loop is a multiple loop, but is not a title loop (No in step S <b> 105), the loop
一方、ループ構造解析部31は、検索した外側ループが多重ループであり、タイトリループである場合(ステップS105肯定)、タイトリループの最内のループを対象ループに含め(ステップS106)、ループデータの作成を実行する(ステップS107)。そして、ループ構造解析部31は、検索した外側ループをすべて処理したか否かを判定する(ステップS108)。
On the other hand, if the searched outer loop is a multiple loop and is a title loop (Yes in step S105), the loop
例えば、図6の(A)の左側に示す外側「ループX」においては、「ループY」が対象ループとされる。また、タイトリループ内のループが兄弟ループである場合、対象ループが複数となる。例えば、図6の(B)の左側に示すように、同一階層にある「ループA」および「ループB」は、兄弟ループとなり、ループ構造解析部31は、「ループA」および「ループB」を対象ループとする。一方、図6の(B)の右側に示すように、同一階層にない「ループA」および「ループB」は、兄弟ループではなく、ループ構造解析部31は、「ループB」より内側にある「ループA」を対象ループとする。
For example, in the outer “loop X” shown on the left side of FIG. 6A, “loop Y” is the target loop. When the loop in the title loop is a sibling loop, there are a plurality of target loops. For example, as shown on the left side of FIG. 6B, “Loop A” and “Loop B” in the same hierarchy are sibling loops, and the loop
図5に戻って、ループ構造解析部31は、未処理の外側ループがある場合(ステップS108否定)、ステップS103に戻って、次の外側ループに対する処理を実行する。
Returning to FIG. 5, when there is an unprocessed outer loop (No at Step S <b> 108), the loop
一方、ループ構造解析部31は、検索した外側ループをすべて処理した場合(ステップS108肯定)、処理を終了する。なお、ループ構造解析部31は、対象ループのループ名が設定された順に応じて、ループデータの「prev」および「next」に、前後にあるループのループ名を設定する。
On the other hand, when all the searched outer loops have been processed (Yes at Step S108), the loop
図2に戻って、配列解析部32は、ループ構造解析部31による解析の結果、ループデータに設定された対象ループを再解析し、対象ループで利用されているデータの配列(以下、配列と記す)を列挙する。
Returning to FIG. 2, the
例えば、配列解析部32は、図1の(B)に示すソースプログラムを解析し、図7に示すように、「ループX」において利用されている配列が「配列a、配列b、配列c」の3つの配列であると列挙する。また、配列解析部32は、図1の(B)に示すソースプログラムを解析し、図7に示すように、「ループY」において利用されている配列が「配列a、配列b、配列c」の3つの配列であると列挙する。また、配列解析部32は、図1の(B)に示すソースプログラムを解析し、図7に示すように、「ループZ」において利用されている配列が「配列a」の1つの配列であると列挙する。なお、図7は、配列解析部を説明するための図である。
For example, the
そして、配列解析部32は、解析結果を、ループデータ記憶部22のループデータに設定するとともに、配列データ記憶部23において配列データを初期設定する。
Then, the
例えば、配列解析部32は、図8に示すように、「ループ名:ループX」のループデータにおける項目「配列データ」に利用されている配列数が3つであることを示す「array[3]」を設定する。同様に、配列解析部32は、図8に示すように、「ループ名:ループY」のループデータにおける項目「配列データ」に「array[3]」を設定し、「ループ名:ループZ」のループデータにおける項目「配列データ」に「array[1]」を設定する。なお、図8は、配列解析部による処理後におけるループデータ記憶部および配列データ記憶部を説明するための図である。
For example, as illustrated in FIG. 8, the
さらに、配列解析部32は、図8に示すように、「ループ名:X」のループデータに連鎖して、「配列名」が『「a」、「b」、「c」』からなる配列データを初期設定する。同様に、配列解析部32は、図8に示すように、「ループ名:Y」のループデータに連鎖して、「配列名」が『「a」、「b」、「c」』からなる配列データを初期設定し、「ループ名:ループZ」のループデータに連鎖して、「配列名」が「a」からなる配列データを初期設定する。
Further, as shown in FIG. 8, the
なお、図8に示すように、配列データには、「初期値」、「終値」および「増分値」からなる項目がある。「初期値」、「終値」および「増分値」の項目は、後述するアクセスパターン解析部33の処理により設定されるため、配列解析部32による配列データの初期設定時においては、すべて「NULL」と設定される。
As shown in FIG. 8, the array data includes items including “initial value”, “final value”, and “increment value”. Since the items of “initial value”, “final value”, and “increment value” are set by processing of the access
ここで、配列解析部32による詳細な処理の手順について、図9を用いて説明する。なお、図9は、配列解析部による処理を説明するためのフローチャートである。
Here, a detailed processing procedure by the
図9に示すように、配列解析部32は、ループ構造解析部31により対象ループが抽出されると(ステップS201肯定)、対象ループに記載されている配列名から配列データの設定処理を開始する(ステップS202)。すなわち、配列解析部32は、抽出された対象ループごとに以下の処理を開始する。
As illustrated in FIG. 9, when the target loop is extracted by the loop structure analysis unit 31 (Yes in step S201), the
そして、配列解析部32は、配列の1次元目の添え字に利用されている変数名を抽出し(ステップS203)、抽出した変数名の変数が対象ループの制御変数であるか否かを判定する(ステップS204)。例えば、配列解析部32は、図1の(B)に示すソースプログラムにおいて、対象ループである「ループX(do j)」において、「配列a」の制御変数に「変数名:j」が登場するか否かを判定する。
Then, the
ここで、変数が対象ループの制御変数でない場合(ステップS204否定)、配列解析部32は、対象ループをループデータの連鎖から削除する(ステップS206)。
Here, when the variable is not a control variable of the target loop (No at Step S204), the
一方、変数が対象ループの制御変数である場合(ステップS204肯定)、配列解析部32は、ループデータと連鎖した配列データを設定する(ステップ205)。例えば、配列解析部32は、図1の(B)に示すソースプログラムにおいて、対象ループである「ループX(do j)」において、「配列a〜c」の制御変数に「変数名:j」が登場すると判定する。これにより、配列解析部32は、「ループ名:ループX」のループデータに連鎖して、「配列名」が『「a」、「b」、「c」』からなる配列データを初期設定する。
On the other hand, if the variable is a control variable of the target loop (Yes at Step S204), the
ステップS205およびステップS206の処理ののち、配列解析部32は、対象ループをすべて処理したか否かを判定する(ステップS207)。
After the processing of step S205 and step S206, the
未処理の対象ループがある場合(ステップS207否定)、配列解析部32は、ステップS202に戻って、次の対象ループに対する処理を開始する。
If there is an unprocessed target loop (No at Step S207), the
一方、配列解析部32は、対象ループをすべて処理した場合(ステップS207肯定)、処理を終了する。
On the other hand, the arrangement |
図2に戻って、アクセスパターン解析部33は、配列データが設定された対象ループの配列におけるデータのアクセスパターンを解析する。例えば、アクセスパターン解析部33は、「配列名:a」の配列データが設定された図1の(B)に示すソースプログラムの「ループX(do j)」における「配列a」のアクセスパターンを解析する。
Returning to FIG. 2, the access
そして、アクセスパターン解析部33は、図10に示すように、「ループX」における「配列a」の制御変数「j」が「1」から「n」に1ずつ増分して変化するパターンであると解析する。同様に、アクセスパターン解析部33は、「ループX」における「配列b、c」と、「ループY」における「配列a、b、c」と、「ループZ」における「配列a」との制御変数「j」それぞれが「1」から「n」に1ずつ増分して変化するパターンであると解析する。なお、図10は、アクセスパターン解析部を説明するための図である。
Then, as shown in FIG. 10, the access
そして、アクセスパターン解析部33は、図11の(A)に示すように、例えば、「ループ名:ループX」のループデータと連鎖して配列データ記憶部23に格納されている配列データに、「初期値:1」、「終値:n」および「増分値:1」を設定する。なお、図11は、アクセスパターン解析部による処理後における配列データ記憶部を説明するための図である。
Then, as shown in FIG. 11A, for example, the access
また、配列名が異なっていても領域が同じである場合に対処するために、アクセスパターン解析部33は、配列データ記憶部23において、配列データとは別に、アドレス変換テーブルを格納する。なお、アクセスパターン解析部33は、領域を特定するためのメモリ上にアドレスを、ソースプログラムを解析することにより獲得する。これにより、アクセスパターン解析部33は、例えば、図11の(B)に示すように、「配列名:a」のアドレスが「0xaaaaaaa」であり、「配列名:b」のアドレスが「0xbbbbbbb」であり、「配列名:c」のアドレスが「0xcccccccc」であることを獲得する。そして、アクセスパターン解析部33は、取得したアドレスを配列名に対応付けたアドレス変換テーブルとして配列データ記憶部23に格納する。なお、アクセスパターン解析部33は、アドレスが獲得されなかった場合、配列名に対応付けて「アドレス:NULL」をアドレス変換テーブルに格納する。
In order to cope with the case where the regions are the same even if the array names are different, the access
なお、対象ループ内で同一配列に対するデータのアクセスパターンが複数存在する場合、アクセスパターン解析部33は、同一配列名の配列データを、アクセスパターンごとに設定する。例えば、ループ内で「配列名:a」に対して、制御変数が「1」から「n」に1ずつ増分して変化するパターン、制御変数が「n」から「1」に1ずつ減少して変化するパターンおよび制御変数が「2」から「n」に1ずつ増分して変化するパターンがあるとする。この場合、アクセスパターン解析部33は、図11の(C)に示すように、「配列名:a」において、「初期値:1、終値:n、増分値:1」、「初期値:n、終値:1、増分値:−1」および「初期値:2、終値:n、増分値:1」の3つの配列データを設定する。
When there are a plurality of data access patterns for the same sequence in the target loop, the access
ここで、アクセスパターン解析部33による詳細な処理の手順について、図12を用いて説明する。なお、図12は、アクセスパターン解析部による処理を説明するためのフローチャートである。
Here, a detailed processing procedure by the access
図12に示すように、アクセスパターン解析部33は、配列解析部32により配列データが設定されると(ステップS301肯定)、配列データごとに処理を開始する。
As shown in FIG. 12, when the sequence data is set by the sequence analysis unit 32 (Yes in step S301), the access
まず、アクセスパターン解析部33は、配列名からアドレスを獲得し、アドレス変換テーブルを配列データ記憶部23に構築する(ステップS302)。
First, the access
そして、アクセスパターン解析部33は、配列ごとに制御変数の初期値、終値および増分値を取得し、配列データを更新する(ステップS303)。なお、対象ループ内で同一配列に対するデータのアクセスパターンが複数存在する場合、アクセスパターン解析部33は、同一配列名の配列データを、アクセスパターンごとに設定して更新する。
Then, the access
そののち、アクセスパターン解析部33は、配列解析部32により設定された配列データをすべて更新処理したか否かを判定する(ステップS304)。
After that, the access
ここで、未処理の配列データがあった場合(ステップS304否定)、アクセスパターン解析部33は、ステップS302に戻って、次の配列データに対する処理を開始する。
If there is unprocessed array data (No at Step S304), the access
一方、配列データをすべて更新処理した場合(ステップS304肯定)、アクセスパターン解析部33は、処理を終了する。
On the other hand, when all the array data has been updated (Yes at Step S304), the access
図2に戻って、依存関係解析部34は、アクセスパターン解析部33が解析した対象ループの配列におけるデータのアクセスパターンから、前後のループ間で処理される配列のデータにおける依存関係を解析する。例えば、アクセスパターン解析部33は、図1の(B)に示すソースプログラムの「配列a」におけるループ間の依存関係を解析する。
Returning to FIG. 2, the dependency
すなわち、依存関係解析部34は、図13の(A)に示すように、ループXとループYとの間において、ループXにて1からnの順に処理された「配列a」のデータが、ループYにて1からnの順に処理される依存関係であると解析する。また、依存関係解析部34は、図13の(A)に示すように、ループYとループZとの間において、ループYにて1からnの順に処理された「配列a」のデータが、ループZにて1からnの順に処理される依存関係であると解析する。なお、図13は、依存関係解析部を説明するための図である。
That is, as shown in FIG. 13A, the dependency
具体的には、依存関係解析部34は、前後のループそれぞれにおいて設定されたループデータと、ループデータと連鎖している配列データと、アドレス変換テーブルとを参照して、同一配列のデータにおけるループ間の依存関係を解析する。
Specifically, the dependency
例えば、依存関係解析部34は、図13の(B)に示すように、「ループ名:X」および「ループ名:Y」のループデータと、「ループ名:X」のループデータと連鎖する「配列名:a」の配列データおよび「ループ名:Y」のループデータと連鎖する「配列名:a」の配列データと、アドレス変換テーブルとを読み出す。そして、依存関係解析部34は、図13の(B)に示すように、アドレス変換テーブルを参照してアドレスから配列の一致を判断したうえで、配列データを比較する。
For example, as shown in FIG. 13B, the dependency
この際、依存関係解析部34は、各配列データの増分値を参照し、図13の(B)に示すように、アクセス方向がそれぞれ増分する「+」であると判断し、ループXおよびループYのアクセス方向が一致する順方向であると解析する。そして、依存関係解析部34は、図13の(B)に示すように、「ループ名:X」のループデータと連鎖した「配列a」の配列データに、新たに「次ループ:順方向」を設定する。
At this time, the dependency
図13の(B)を用いて説明した処理により、依存関係解析部34は、ループX、YおよびZのループデータと連鎖する「配列a」の配列データに新たに「次ループ」の項目を設定する。例えば、依存関係解析部34は、図14に示すように、ループXのループデータと連鎖する「配列a」の配列データに「次ループ:順方向」を設定し、ループYのループデータと連鎖する「配列a」の配列データに「次ループ:順方向」を設定する。また、依存関係解析部34は、図14に示すように、ループZのループデータと連鎖する「配列a」の配列データに「次ループ:なし」を設定する。なお、図14は、依存関係解析部による処理後における配列データ記憶部を説明するための図である。
By the processing described with reference to FIG. 13B, the dependency
なお、依存関係解析部34は、複数のアクセスパターンがあるために同一配列に対して複数の配列データが存在する場合、アクセスパターンが同一のものを検索して比較することで、順方向または逆方向の方向性を決定する。初期値、終値および増分値に関しては、変数であったとしても、変数のアドレスで比較するために、同一性を確保できる。
In addition, when there are a plurality of sequence data for the same sequence because there are a plurality of access patterns, the dependency
ここで、依存関係解析部34による詳細な方向性の判断処理の手順について、図15を用いて説明する。なお、図15は、依存関係解析部による方向性の判断処理を説明するためのフローチャートである。
Here, the detailed procedure for determining the directionality by the dependency
図15に示すように、依存関係解析部34は、アクセスパターン解析部33により、すべての配列データにおいて、初期値、終値および増分値が更新されると(ステップS401肯定)、カウンタにおける順方向および逆方向の値を初期化する(ステップS402)。この際、依存関係解析部34は、処理対象とするループ(以下、自ループと記す)のループデータと連鎖する配列データを配列データ記憶部23から抽出したうえで、カウンタにおける順方向および逆方向の値を初期化する。
As shown in FIG. 15, when the initial value, the final value, and the increment value are updated in all the array data by the access pattern analyzing unit 33 (Yes in step S401), the dependency
そして、依存関係解析部34は、自ループの次にあるループである次ループと連鎖する配列データに同一配列名があるか否かを判定する(ステップS403)。
Then, the dependency
ここで、次ループに同一配列名がある場合(ステップS403肯定)、依存関係解析部34は、次ループにおける同一配列名の配列データのアクセス方向は、順方向であるか否かを判定する(ステップS404)。なお、ステップS404以降の処理は、同一配列名の配列データ一つずつに対して、順次実行される。
If the next loop has the same sequence name (Yes at step S403), the
順方向であり(ステップS404肯定)、自ループの初期値と次ループの初期値とが同じであるならば(ステップS405肯定)、依存関係解析部34は、順方向カウンタの値をインクリメントする(ステップS406)。
If the current direction is the forward direction (Yes at Step S404) and the initial value of the own loop and the initial value of the next loop are the same (Yes at Step S405), the dependency
また、逆方向であり(ステップS404否定)、自ループの初期値と次ループの初期値とが同じであるならば(ステップS407肯定)、依存関係解析部34は、逆方向カウンタの値をインクリメントする(ステップS408)。
In the reverse direction (No at Step S404), if the initial value of the own loop and the initial value of the next loop are the same (Yes at Step S407), the dependency
ここで、「順方向であり(ステップS404肯定)、自ループの初期値と次ループの初期値とが異なる場合(ステップS405否定)」、依存関係解析部34は、ステップS403に戻って、次ループに未処理の同一配列名の配列データがあるか否かを判定する。
Here, when “the forward direction (Yes at Step S404) and the initial value of the own loop and the initial value of the next loop are different (No at Step S405)”, the dependency
また、依存関係解析部34は、「逆方向であり(ステップS404否定)、自ループの初期値と次ループの初期値とが異なる場合(ステップS407否定)」も、ステップS403に戻って、次ループに未処理の同一配列名の配列データがあるか否かを判定する。
Also, the dependency
また、依存関係解析部34は、「ステップS406の処理を終了した場合」および「ステップS408の処理を終了した場合も、ステップS403に戻って、次ループに未処理の同一配列名の配列データがあるか否かを判定する。
Also, the dependency
一方、次ループに未処理の同一配列名の配列データがない場合(ステップS403否定)、依存関係解析部34は、順方向および逆方向のカウンタの値がともに「0」であるか否かを判定する(ステップS409)。
On the other hand, when there is no unprocessed array data with the same array name in the next loop (No in step S403), the dependency
順方向および逆方向のカウンタの値がともに「0」である場合(ステップS409肯定)、依存関係解析部34は、配列データにおける次ループの項目を「なし」として更新し(ステップS410)、処理を終了する。
When both the forward and backward counter values are “0” (Yes at Step S409), the
また、順方向および逆方向のカウンタの値のいずれか一方が「0」でない場合(ステップS409否定)、順方向のカウンタの値が、逆方向の値以上であるか否かを判定する(ステップS411)。 If one of the forward and backward counter values is not “0” (No in step S409), it is determined whether or not the forward counter value is greater than or equal to the backward value (step S409). S411).
ここで、順方向のカウンタの値が、逆方向の値以上である場合(ステップS411肯定)、依存関係解析部34は、配列データにおける次ループの項目を「順方向」として更新し(ステップS412)、処理を終了する。
If the value of the forward counter is greater than or equal to the backward value (Yes at Step S411), the dependency
一方、順方向のカウンタの値が、逆方向の値未満である場合(ステップS411否定)、依存関係解析部34は、配列データにおける次ループの項目を「逆方向」として更新し(ステップS413)、処理を終了する。
On the other hand, if the value of the forward counter is less than the value in the reverse direction (No in step S411), the
図2に戻って、ハードウェア情報記憶部24は、通信部13が受信した情報処理装置40のハードウェア情報を記憶する。ここで、ハードウェア情報は、コンパイラ装置10の起動時、初期化処理の延長で、通信部13が、情報処理装置40のOSに問い合わせることで、ハードウェア情報記憶部24に格納される。
Returning to FIG. 2, the hardware
例えば、ハードウェア情報記憶部24は、図16に示すように、情報処理装置40に搭載されているキャッシュの容量(キャッシュサイズ)が「cashe」とするハードウェア情報を記憶する。なお、図16は、ハードウェア情報記憶部を説明するための図である。
For example, as illustrated in FIG. 16, the hardware
また、ハードウェア情報記憶部24は、図16に示すように、情報処理装置40のCPUが逆方向ハードウェアプリフェッチを実行可能であるか不可能であるかの情報として「可」または「不可」とするハードウェア情報を記憶する。なお、逆方向ハードウェアプリフェッチとは、ハードウェアプリフェッチにおいて、アドレスを減算する方向でデータアクセスが可能である機能のことである。
Further, as shown in FIG. 16, the hardware
図2に戻って、部分キャッシュ指示部35は、依存関係解析部34による依存関係の解析結果から、自ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する。すなわち、部分キャッシュ指示部35は、依存関係の解析結果から、キャッシュサイズを考慮したアクセスパターンにループを変形するように後述する最適化部36に指示する。具体的には、部分キャッシュ指示部35は、次ループの方向性と、キャッシュサイズと、逆方向ハードウェアプリフェッチ機能の有無から変形する形を決定する。
Returning to FIG. 2, the partial
ここで、部分キャッシュ指示部35について、図17〜図22を用いて詳細に説明する。なお、図17は、部分キャッシュ指示部による処理を説明するためのフローチャートであり、図18は、パターン1〜4のループ変形指示の概要を説明するための図である。また、図19は、パターン1のループ変形指示を説明するための図であり、図20は、パターン2のループ変形指示を説明するための図である。また、図21は、パターン3のループ変形指示を説明するための図であり、図22は、パターン4のループ変形指示を説明するための図である。
Here, the partial
図17に示すように、部分キャッシュ指示部35は、配列データの依存関係(項目:次ループ)が更新されると(ステップS501肯定)、処理対象となる配列データにて更新された次ループの方向性が順方向であるか否かを判定する(ステップS502)。
As shown in FIG. 17, when the dependency relationship (item: next loop) of the array data is updated (Yes at step S501), the partial
次ループの方向性が順方向である場合(ステップS502肯定)、部分キャッシュ指示部35は、ハードウェア情報を参照して、情報処理装置40が逆方向ハードウェアプリフェッチ処理可であるか否かを判定する(ステップS503)。
If the direction of the next loop is the forward direction (Yes at Step S502), the partial
逆方向ハードウェアプリフェッチ処理可である場合(ステップS503肯定)、部分キャッシュ指示部35は、パターン1のループ変形処理を最適化部36に指示して(ステップS504)、処理を終了する。
If the backward hardware prefetch process is possible (Yes at Step S503), the partial
また、逆方向ハードウェアプリフェッチ処理不可である場合(ステップS503否定)、部分キャッシュ指示部35は、パターン2のループ変形処理を最適化部36に指示して(ステップS505)、処理を終了する。
If the backward hardware prefetch process is not possible (No at Step S503), the partial
一方、次ループの方向性が逆方向である場合(ステップS502否定)、部分キャッシュ指示部35は、ハードウェア情報を参照して、情報処理装置40が逆方向ハードウェアプリフェッチ処理可であるか否かを判定する(ステップS506)。
On the other hand, when the directionality of the next loop is the reverse direction (No in step S502), the partial
逆方向ハードウェアプリフェッチ処理可である場合(ステップS506肯定)、部分キャッシュ指示部35は、パターン3のループ変形処理を最適化部36に指示して(ステップS507)、処理を終了する。
If the backward hardware prefetch process is possible (Yes at Step S506), the partial
また、逆方向ハードウェアプリフェッチ処理不可である場合(ステップS506否定)、部分キャッシュ指示部35は、パターン4のループ変形処理を最適化部36に指示して(ステップS508)、処理を終了する。
If the backward hardware prefetch process is not possible (No at Step S506), the partial
パターン1〜4のループ変形指示の概要について、図18を用いて説明する。なお、図18において、「A」は、変形するループの初期値であり、「B」は、変形するループの初期値にキャッシュサイズ(cashe)分の値を加算した値である。また、図18において、「C」は、変形するループの終値からキャッシュサイズ(cashe)分の値を減算した値であり、「D」は、変形するループの終値である。なお、図18では、変形されるループにて作成される「キャッシュ利用を実行する新たなループ」を「別ループ」として記載してある。
The outline of the loop deformation instructions for
次ループが順方向であり、逆方向ハードウェアプリフェッチ可である場合に実行されるパターン1のループ変形指示においては、図18に示すように、別ループの作成位置が「先頭」とされる。具体的には、パターン1のループ変形指示においては、変形されるループにて処理されるデータのキャッシュサイズに対応する前半部分がキャッシュ利用のループにより処理されるように指示される。また、パターン1のループ変形指示においては、別ループの初期値が「B」、別ループの終値が「A」とされ、逆方向ハードウェアプリフェッチ機能を有することから、別ループの制御変数の回転の方向性が「逆方向」となる。
In the loop modification instruction of
パターン1のループ変形指示の具体例を、図19を用いて説明する。入力されたソースプログラムが図19の(A)の左側に示すように記述されていた場合、後ループにて処理される配列aの方向性は、前ループと順方向である。ここで、配列aのデータサイズがキャッシュサイズに収まらない場合、図19の(B)の左側に示すように、前ループの処理のあとキャッシュの最後尾にあるデータの制御変数は、「ej」である。すなわち、後ループの処理の先頭において処理される制御変数「sj」のデータは、キャッシュから落ちており、キャッシュミスが発生する。したがって、従来では、キャッシュ不用として、ブロックストア命令を用いていた。
A specific example of the loop deformation instruction for
そこで、パターン1のループ変形指示では、図19の(A)の右側に示すように、前ループの先頭(前半部分)においてキャッシュサイズに相当するデータをキャッシュ利用とし、かつ、制御変数を1つずつ減算(−1)とする新ループを作成する。また、キャッシュサイズに相当する前半部分以外の後半部分のデータに関しては、前ループにおいて、ブロックストア命令とする。
Therefore, in the loop modification instruction of
また、部分キャッシュ指示部35は、ブロックストアのループがキャッシュ利用の新ループの前に実行されるように指示する。
In addition, the partial
これにより、図19の(B)の右側に示すように、プログラム実行時においては、最初に、前ループにてキャッシュサイズに相当する前半部分以外の後半部分のデータが処理されて、キャッシュ不使用のブロックストアで、メモリに直接格納される。そして、次に、逆方向回転の新ループにてキャッシュサイズに相当する前半部分のデータが処理されてキャッシュに格納される。これにより、前ループによって処理された初期値のデータがキャッシュの最後に格納され、後ループにおいて確実にキャッシュヒットとなる。また、キャッシュ不使用のデータに関しては、メモリに直接アクセスすることでデータをロードすることができるので、処理が高速化される。 As a result, as shown on the right side of FIG. 19B, at the time of program execution, the data in the second half other than the first half corresponding to the cache size is first processed in the previous loop, and the cache is not used. Stored directly in memory. Then, the first half of the data corresponding to the cache size is processed and stored in the cache in a new reverse rotation loop. As a result, the initial value data processed by the previous loop is stored at the end of the cache, and a cache hit is reliably obtained in the subsequent loop. In addition, with respect to data not using the cache, the data can be loaded by directly accessing the memory, so that the processing speed is increased.
図18に戻って、次ループが順方向であり、逆方向ハードウェアプリフェッチ不可である場合に実行されるパターン2のループ変形指示においては、パターン1と同様に、別ループの作成位置が「先頭」とされる。すなわち、パターン2のループ変形指示においても、パターン1と同様に、変形されるループにて処理されるデータのキャッシュサイズに対応する前半部分がキャッシュ利用のループにより処理されるように指示される。また、パターン2のループ変形指示においては、別ループの初期値が「A」、別ループの終値が「B」とされ、逆方向ハードウェアプリフェッチ機能がないことから、別ループの制御変数の回転の方向性が「順方向」となる。
Returning to FIG. 18, in the loop modification instruction for
パターン2のループ変形指示の具体例を、図20を用いて説明する。なお、図20の(A)の左側に示すソースプログラムは、図19の(A)の左側に示すソースプログラムと同じであるので、説明を省略する。また、図20の(B)の左側では、図20の(A)の左側に示すソースプログラムを実行した場合、キャッシュを利用すると後ループにてキャッシュミスが発生することを示しているが、図19の(B)の左側を用いて説明した内容と同じであるので、説明を省略する。
A specific example of the
そこで、パターン1と逆方向ハードウェアプリフェッチ機能がない点が異なるパターン2のループ変形指示では、図20の(A)の右側に示すように、前ループの先頭(前半部分)においてキャッシュサイズに相当するデータをキャッシュ利用とし、かつ、制御変数を1つずつ増分する新ループを作成する。また、キャッシュサイズに相当する前半部分以外の後半部分のデータに関しては、前ループにおいて、ブロックストア命令とする。
Therefore, in the loop modification instruction of
また、パターン1と同様に、部分キャッシュ指示部35は、ブロックストアのループがキャッシュ利用の新ループの前に実行されるように指示する。
Similarly to the
これにより、図20の(B)の右側に示すように、プログラム実行時においては、最初に、前ループにてキャッシュサイズに相当する前半部分以外の後半部分のデータが処理されて、キャッシュ不使用のブロックストアで、メモリに直接格納される。そして、次に、順方向回転の新ループにてキャッシュサイズに相当する前半部分のデータが処理されてキャッシュに格納される。これにより、前ループによって処理された初期値のデータがキャッシュにて最初に格納されたとしても、キャッシュから落ちることが防止され、後ループにおいて確実にキャッシュヒットとなる。また、キャッシュ不使用のデータに関しては、メモリに直接アクセスすることでデータをロードすることができるので、処理が高速化される。 As a result, as shown on the right side of FIG. 20B, at the time of program execution, the data in the second half other than the first half corresponding to the cache size is first processed in the previous loop, and the cache is not used. Stored directly in memory. Then, in the new forward rotation loop, the first half of the data corresponding to the cache size is processed and stored in the cache. As a result, even if the initial value data processed by the previous loop is first stored in the cache, it is prevented from falling out of the cache, and a cache hit is surely made in the subsequent loop. In addition, with respect to data not using the cache, the data can be loaded by directly accessing the memory, so that the processing speed is increased.
図18に戻って、次ループが逆方向であり、逆方向ハードウェアプリフェッチ可である場合に実行されるパターン3のループ変形指示においては、別ループの作成位置が「最終」とされる。具体的には、パターン1のループ変形指示においては、変形されるループにて処理されるデータのキャッシュサイズに対応する後半部分がキャッシュ利用のループにより処理されるように指示される。また、パターン3のループ変形指示においては、別ループの初期値が「D」、別ループの終値が「C」とされ、逆方向ハードウェアプリフェッチ機能を有することから、別ループの制御変数の回転の方向性が「逆方向」となる。
Returning to FIG. 18, in the loop modification instruction of the
パターン3のループ変形指示の具体例を、図21を用いて説明する。入力されたソースプログラムが図21の(A)の左側に示すように記述されていた場合、後ループにて処理される配列aの方向性は、前ループと逆方向である。ここで、配列aのデータサイズがキャッシュサイズに収まらない場合、図21の(B)の左側に示すように、前ループの処理のあとキャッシュの最後尾にあるデータの制御変数は、「ej」である。すなわち、後ループの処理の先頭において処理される制御変数「ej」のデータは、キャッシュヒットとなるが、前ループにて処理されるデータのキャッシュサイズに対応する後半部分以外のデータに関しては、キャッシュヒットが期待できない。従来では、キャッシュ不用として、ブロックストア命令を用いていた。
A specific example of the
そこで、パターン3のループ変形指示では、図21の(A)の右側に示すように、前ループの最終(後半部分)においてキャッシュサイズに相当するデータをキャッシュ利用とし、かつ、制御変数を1つずつ減算(−1)とする新ループを作成する。また、キャッシュサイズに相当する後半部分以外の前半部分のデータに関しては、前ループにおいて、ブロックストア命令とする。
Therefore, in the loop deformation instruction of
また、部分キャッシュ指示部35は、パターン1および2と同様に、ブロックストアのループがキャッシュ利用の新ループの前に実行されるように指示する。
Similarly to the
これにより、図21の(B)の右側に示すように、プログラム実行時においては、最初に、前ループにてキャッシュサイズに相当する後半部分以外の前半部分のデータが処理されて、キャッシュ不使用のブロックストアで、メモリに直接格納される。そして、次に、逆方向回転の新ループにてキャッシュサイズに相当する後半部分のデータが処理されてキャッシュに格納される。これにより、前ループによって処理された終値のデータがキャッシュの最後に格納され、後ループにおいて確実にキャッシュヒットとなる。また、キャッシュ不使用のデータに関しては、メモリに直接アクセスすることでデータをロードすることができるので、処理が高速化される。 As a result, as shown on the right side of FIG. 21B, at the time of program execution, data in the first half other than the second half corresponding to the cache size is first processed in the previous loop, and the cache is not used. Stored directly in memory. Then, the second half of the data corresponding to the cache size is processed and stored in the cache in a new reverse rotation loop. As a result, the closing price data processed by the previous loop is stored at the end of the cache, and a cache hit is surely made in the subsequent loop. In addition, with respect to data not using the cache, the data can be loaded by directly accessing the memory, so that the processing speed is increased.
図18に戻って、次ループが逆方向であり、逆方向ハードウェアプリフェッチ不可である場合に実行されるパターン4のループ変形指示においては、パターン3と同様に、別ループの作成位置が「最終」とされる。すなわち、パターン4のループ変形指示においても、パターン3と同様に、変形されるループにて処理されるデータのキャッシュサイズに対応する後半部分がキャッシュ利用のループにより処理されるように指示される。また、パターン4のループ変形指示においては、別ループの初期値が「C」、別ループの終値が「D」とされ、逆方向ハードウェアプリフェッチ機能がないことから、別ループの制御変数の回転の方向性が「順方向」となる。
Returning to FIG. 18, in the loop modification instruction for
パターン4のループ変形指示の具体例を、図22を用いて説明する。なお、図22の(A)の左側に示すソースプログラムは、図21の(A)の左側に示すソースプログラムと同じであるので、説明を省略する。また、図22の(B)の左側では、図21の(B)の左側で説明したように、図22の(A)の左側に示すソースプログラムを実行した場合、キャッシュを利用すると後ループにてキャッシュヒットするものの、前ループにて処理されるデータのキャッシュサイズに対応する後半部分以外のデータに関しては、キャッシュヒットが期待できないことを示している。
A specific example of the
そこで、パターン3と逆方向ハードウェアプリフェッチ機能がない点が異なるパターン4のループ変形指示では、図22の(A)の右側に示すように、前ループの最終(後半部分)においてキャッシュサイズに相当するデータをキャッシュ利用とし、かつ、制御変数を1つずつ増分する新ループを作成する。また、キャッシュサイズに相当する後半部分以外の前半部分のデータに関しては、前ループにおいて、ブロックストア命令とする。
Therefore, in the loop modification instruction of
また、パターン1〜3と同様に、部分キャッシュ指示部35は、ブロックストアのループがキャッシュ利用の新ループの前に実行されるように指示する。
Similarly to the
これにより、図22の(B)の右側に示すように、プログラム実行時においては、最初に、前ループにてキャッシュサイズに相当する後半部分以外の前半部分のデータが処理されて、キャッシュ不使用のブロックストアで、メモリに直接格納される。そして、次に、順方向回転の新ループにてキャッシュサイズに相当する後半部分のデータが処理されてキャッシュに格納される。これにより、前ループによって処理された終値のデータがキャッシュにて最初に格納されたとしても、キャッシュから落ちることが防止され、後ループにおいて確実にキャッシュヒットとなる。また、キャッシュ不使用のデータに関しては、メモリに直接アクセスすることでデータをロードすることができるので、処理が高速化される。 As a result, as shown on the right side of FIG. 22B, at the time of program execution, data in the first half other than the second half corresponding to the cache size is first processed in the previous loop, and the cache is not used. Stored directly in memory. Then, in the new forward rotation loop, the latter half of the data corresponding to the cache size is processed and stored in the cache. As a result, even if the closing price data processed by the previous loop is first stored in the cache, it is prevented from falling out of the cache, and a cache hit is surely made in the subsequent loop. In addition, with respect to data not using the cache, the data can be loaded by directly accessing the memory, so that the processing speed is increased.
図2に戻って、最適化部36は、部分キャッシュ指示部35によるループ変形指示にしたがって、ソースプログラムに新ループを挿入したソースプログラムを生成する。そして、最適化部36は、新ループを挿入したソースプログラムに対して、ソフトウェアプリフェッチなどの従来の最適化処理を実行することで、新規ソースプログラムを生成し、生成した新規ソースプログラムを新規ソースプログラム記憶部25に格納する。
Returning to FIG. 2, the
オブジェクトファイル生成部37は、新規ソースプログラム記憶部25が記憶する新規ソースプログラムからオブジェクトファイルを生成し、生成したオブジェクトファイルを、オブジェクトファイル出力部12に対して出力する。
The object
続いて、本実施例におけるコンパイル装置10の処理の流れについて、図23を用いて説明する。なお、図23は、本実施例におけるコンパイラ装置の処理を説明するためのフローチャートである。
Next, the flow of processing of the compiling
図23に示すように、本実施例におけるコンパイラ装置10は、ソースプログラム入力部11からソースプログラムが入力されると(ステップS601肯定)、ループ構造解析部31は、対象ループを抽出し、ループデータを設定する(ステップS602)。なお、コンパイラ装置10は、自装置の起動時などに、情報処理装置40から、ハードウェア情報を獲得する。
As shown in FIG. 23, in the
そして、配列解析部32は、対象ループを解析して、対象ループで利用されているデータの配列を列挙することで、ループデータと連鎖する配列データを設定する(ステップS603)。
Then, the
そののち、アクセスパターン解析部33は、設定された配列データの配列名に基づいて、アドレス変換テーブルの構築と、配列データの初期値、終値および増分値の更新を行なう(ステップS604)。
After that, the access
さらに、依存関係解析部34は、設定されたループデータと、ループデータと連鎖している配列データと、アドレス変換テーブルとを参照して、ループ間の同一配列名を有する配列データの依存関係(次ループの項目)を更新する(ステップS605)。
Further, the dependency
そして、部分キャッシュ指示部35は、配列データの依存関係と、キャッシュサイズと、逆方向ハードウェアプリフェッチ機能とに応じてループ変形指示を行なう(ステップS606)。
Then, the partial
そののち、最適化部36は、ループ変形指示にしたがって、新ループをソースプログラムに挿入して最適化処理を行なって、新規ソースプログラムを生成する(ステップS607)。
Thereafter, the
さらに、オブジェクトファイル生成部37は、新規ソースプログラムからオブジェクトファイルを生成し(ステップS608)、処理を終了する。
Furthermore, the object
上述してきたように、本実施例によれば、ループ構造解析部31、配列解析部32およびアクセスパターン解析部33は、ソースプログラムの各ループの前後関係、各ループにて利用される配列およびデータのアクセスパターンを解析し、依存関係解析部34は、アクセスパターンから、前のループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する。そして、部分キャッシュ指示部35は、依存関係に基づいて、前のループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定し、最適化部36は、格納先が決定された前のループを、キャッシュ利用のループおよびブロックストア命令のループに置き換えた新規ソースプログラムを生成し、オブジェクトファイル生成部37は、新規ソースプログラムからオブジェクトファイルを生成する。
As described above, according to the present embodiment, the loop
したがって、プログラム実行時において、キャッシュを利用すべきデータと、メモリに直接格納したほうがよいデータとを同一ループ内で分割することができ、キャッシュを有効的に利用することによりプログラムの実行性能を向上することが可能となる。 Therefore, at the time of program execution, the data that should use the cache and the data that should be stored directly in the memory can be divided in the same loop, and the execution performance of the program is improved by using the cache effectively It becomes possible to do.
また、本実施例では、依存関係解析部34は、依存関係として、前ループにおいて処理されるデータの順番と、前ループの処理済みデータが次ループにおいて処理される順番とが順方向であるか逆方向であるかを解析し、部分キャッシュ指示部35は、依存関係が順方向である場合、前ループの処理済みデータのうちキャッシュ容量に相当する前半部分をキャッシュ利用として決定し、依存関係が逆方向である場合、前ループの処理済みデータのうちキャッシュ容量に相当する後半部分をキャッシュ利用として決定する。
In the present embodiment, the dependency
したがって、プログラム実行時において、キャッシュに格納されたデータが次ループにおいて確実にキャッシュヒットとなり、プログラムの実行性能をより向上することが可能となる。 Therefore, when the program is executed, the data stored in the cache is surely a cache hit in the next loop, and the execution performance of the program can be further improved.
また、本実施例では、部分キャッシュ指示部35は、ブロックストアのループの次に、キャッシュのループを入れるように最適化部36を指示するので、キャッシュに格納されたデータが次ループにおいてより確実にキャッシュヒットとなり、プログラムの実行性能をより向上することが可能となる。
Further, in this embodiment, the partial
また、本実施例では、部分キャッシュ指示部35は、逆方向ハードウェアプリフェッチ処理実行可能ならば、キャッシュ利用のループにおけるデータの処理順番を逆にするように指示する。また、部分キャッシュ指示部35は、逆方向ハードウェアプリフェッチ処理実行不可ならば、キャッシュ利用のループにおけるデータの処理順番を同一とするように指示する。
In this embodiment, the partial
したがって、プログラムを実行する装置の機能に応じて、キャッシュに格納されたデータが次ループにおいて確実にキャッシュヒットとなるキャッシュ利用のループを作成することができ、プログラムの実行性能を適切に向上することが可能となる。 Therefore, according to the function of the device that executes the program, it is possible to create a cache use loop in which the data stored in the cache reliably causes a cache hit in the next loop, and appropriately improve the execution performance of the program Is possible.
なお、上記では、ループ変形指示が、配列データの依存関係と、キャッシュサイズと、逆方向ハードウェアプリフェッチ機能と応じてキャッシュ利用の新ループにおける回転の方向性を順方向または逆方向に設定する場合について説明した。しかし、本実施例はこれに限定されるものではなく、例えば、動画などのストリームデータのように、処理する順番が順方向となることが望ましいならば、異なる基準にてループ変形指示が実行される場合であってもよい。これについて、図24を用いて説明する。なお、図24は、部分キャッシュ指示部による処理の変形例を説明するためのフローチャートである。 In the above, when the loop transformation instruction sets the directionality of rotation in a new loop using cache according to the dependency relationship of array data, the cache size, and the backward hardware prefetch function. Explained. However, the present embodiment is not limited to this. For example, if it is desirable that the processing order be in the forward direction as in stream data such as moving images, the loop deformation instruction is executed based on different criteria. It may be the case. This will be described with reference to FIG. FIG. 24 is a flowchart for explaining a modification of the processing by the partial cache instruction unit.
図24に示すように、変形例における部分キャッシュ指示部35は、配列データの依存関係が更新されると(ステップS701肯定)、配列データのデータが、順次アクセスのパターンを保証する必要があるか否かを判定する(ステップS702)。
As shown in FIG. 24, the partial
ここで、順次アクセスのパターンを保証する必要がない場合(ステップS702否定)、部分キャッシュ指示部35は、図17を用いて説明したステップS502以降の処理を実行し、処理を終了する。
Here, when it is not necessary to guarantee the sequential access pattern (No at Step S702), the partial
一方、順次アクセスのパターンを保証する必要がある場合(ステップS702肯定)、部分キャッシュ指示部35は、変形指示を行なう対象ループにおいて、キャッシュ利用のループの初期値、終値および増分値の設定を行なう(ステップS704)。すなわち、部分キャッシュ指示部35は、順次アクセスのパターンを保証するように、キャッシュ利用のループの初期値、終値および増分値の設定を行なう。
On the other hand, when it is necessary to guarantee the sequential access pattern (Yes in step S702), the partial
そして、部分キャッシュ指示部35は、ループインデックス計算の補正を行い(ステップS705)、対象ループから新規で作成したキャッシュ利用のループ分の回転を除外する(ステップS706)。
Then, the partial
そののち、部分キャッシュ指示部35は、キャッシュ利用のループにて処理されるデータ以外のデータを処理する対象ループのストアをブロックストアに変更し(ステップS707)、処理を終了する。
After that, the partial
これにより、再利用されるストリームデータにおいて、順次アクセスのパターンを保証する必要がある場合であっても、キャッシュを有効利用して、プログラムの実行処理を向上することが可能となる。 As a result, even when it is necessary to guarantee the sequential access pattern in the stream data to be reused, it is possible to improve the program execution process by effectively using the cache.
また、本実施例において説明した各処理のうち、自動的におこなわれるものとして説明した処理の全部または一部を手動的に行なうこともできる(例えば、ハードウェア情報を、プログラマが手動で入力するなど)。あるいは、本実施例において説明した各処理のうち、手動的におこなわれるものとして説明した処理の全部または一部を公知の方法で自動的におこなうこともできる。この他、上記文書中や図面中で示した処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて任意に変更することができる。 In addition, among the processes described in the present embodiment, all or a part of the processes described as being automatically performed can be manually performed (for example, a programmer manually inputs hardware information). Such). Alternatively, among the processes described in the present embodiment, all or a part of the processes described as being performed manually can be automatically performed by a known method. In addition, the processing procedure, control procedure, specific name, and information including various data and parameters shown in the above-described document and drawings can be arbitrarily changed unless otherwise specified.
また、図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各装置の分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。例えば、ループ構造解析部31、配列解析部32、アクセスパターン解析部33および依存関係解析部34を統合して、ソースプログラム解析部としてもよい。さらに、各装置にて行なわれる各処理機能は、その全部または任意の一部が、CPUおよび当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。
Each component of each illustrated device is functionally conceptual and does not necessarily need to be physically configured as illustrated. In other words, the specific form of distribution / integration of each device is not limited to that shown in the figure, and all or a part thereof may be functionally or physically distributed or arbitrarily distributed in arbitrary units according to various loads or usage conditions. Can be integrated and configured. For example, the loop
ところで上記の実施例では、ハードウェアロジックによって各種の処理を実現する場合を説明したが、本発明はこれに限定されるものではなく、あらかじめ用意されたプログラムをコンピュータで実行するようにしてもよい。そこで以下では、図25を用いて、上記の実施例に示したコンパイラ装置10と同様の機能を有するコンパイラプログラムを実行するコンピュータの一例を説明する。図25は、本実施例のコンパイラプログラムを実行するコンピュータを示す図である。
In the above embodiment, the case where various processes are realized by hardware logic has been described. However, the present invention is not limited to this, and a program prepared in advance may be executed by a computer. . In the following, an example of a computer that executes a compiler program having the same function as that of the
図25に示すように、情報処理装置としてのコンピュータ100は、キーボード101、ディスプレイ102、CPU103、ROM104、HDD105、RAM106を有する。そして、キーボード101、ディスプレイ102、CPU103、ROM104、HDD105およびRAM106は、バス107などで接続される。また、コンピュータ100は、情報処理装置40と接続される。
As shown in FIG. 25, a
ROM104には、上記の実施例に示したコンパイラ装置10と同様の機能を発揮するコンパイラプログラム、つまり、図25に示すように、ループ構造解析プログラム104a、配列解析プログラム104bが予め記憶されている。また、ROM104には、アクセスパターン解析プログラム104c、依存関係解析プログラム104d、部分キャッシュ指示プログラム104eが予め記憶されている。また、ROM104には、最適化プログラム104f、オブジェクトファイル生成プログラム104gが予め記憶されている。なお、これらのプログラム104a〜104gについては、図2に示したコンパイラ装置10の各構成要素と同様、適宜統合または分散してもよい。
The
そして、CPU103が、これらのプログラム104a〜104gをROM104から読み出して実行する。これにより、図25に示すように、プログラム104aおよびプログラム104bは、ループ構造解析プロセス103aおよび配列解析プロセス103bとして機能するようになる。また、プログラム104c〜104eは、アクセスパターン解析プロセス103c、依存関係解析プロセス103d、部分キャッシュ指示プロセス103eとして機能するようになる。また、プログラム104fおよびプログラム104gは、最適化プロセス103fおよびオブジェクトファイル生成プロセス103gとして機能するようになる。なお、各プロセス103a〜103gは、図2に示した、ループ構造解析部31、配列解析部32、アクセスパターン解析部33、依存関係解析部34、部分キャッシュ指示部35、最適化部36、オブジェクトファイル生成部37にそれぞれ対応する。
Then, the
また、HDD105には、図25に示すように、ソースプログラムデータ105a、ループデータ105b、配列データ105c、ハードウェア情報データ105d、新規ソースプログラムデータ105eが設けられる。各データ105a〜105eは、図2に用いたソースプログラム記憶部21、ループデータ記憶部22、配列データ記憶部23、ハードウェア情報記憶部24、新規ソースプログラム記憶部25にそれぞれ対応する。そしてCPU103は、ソースプログラムデータ106aをソースプログラムデータ105aに対して登録し、ループデータ106bをループデータ105bに対して登録し、配列データ106cを配列データ105cに対して登録する。また、CPU103は、ハードウェア情報データ106dをハードウェア情報データ105dに対して登録し、新規ソースプログラムデータ106eを新規ソースプログラムデータ105eに対して登録する。そして、CPU103は、登録したデータを読み出してRAM106に格納し、RAM106に格納されたソースプログラムデータ106a、ループデータ106b、配列データ106c、ハードウェア情報データ106dおよび新規ソースプログラムデータ106eに基づいてコンパイル処理を実行する。
As shown in FIG. 25, the
なお、上記した各プログラム104a〜104gについては、必ずしも最初からROM104に記憶させておく必要はなく、例えばコンピュータ100に挿入されるフレキシブルディスク(FD)、CD−ROM、MOディスク、DVDディスク、光磁気ディスク、ICカードなどの「可搬用の物理媒体」、または、コンピュータ100の内外に備えられるHDDなどの「固定用物理媒体」、さらには、公衆回線、インターネット、LAN、WANなどを介してコンピュータ100に接続される「他のコンピュータ(またはサーバ)」などに各プログラムを記憶させておき、コンピュータ100がこれらから各プログラムを読み出して実行するようにしてもよい。
The above-described
以上の各実施例を含む実施形態に関し、さらに以下の付記を開示する。 The following supplementary notes are further disclosed with respect to the embodiments including the above examples.
(付記1)ソースプログラムにおける各ループのデータへのアクセスパターンを解析するアクセスパターン解析手順と、
前記アクセスパターン解析手順によって解析された前記アクセスパターンから、現ループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する依存関係解析手順と、
前記依存関係解析手順によって解析された前記依存関係に基づいて、前記現ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する格納先決定手順と、
前記格納先決定手順によって格納先が決定された現ループを、前記メモリに処理済みデータを格納するための第一ループおよび前記キャッシュに処理済みデータを格納するための第二ループに置き換えることにより、前記ソースプログラムから新規ソースプログラムを生成する新規ソースプログラム生成手順と、
前記新規ソースプログラム生成手順によって生成された前記新規ソースプログラムからオブジェクトファイルを生成するオブジェクトファイル生成手順と、
をコンピュータに実行させることを特徴とするコンパイラプログラム。
(Supplementary Note 1) Access pattern analysis procedure for analyzing access pattern to data of each loop in source program;
From the access pattern analyzed by the access pattern analysis procedure, a dependency analysis procedure for analyzing a dependency relationship between data processed in the current loop and data processed in the next loop;
A storage location determination procedure for determining to allocate a storage location of data processed in the current loop to either a memory or a cache based on the dependency relationship analyzed by the dependency relationship analysis procedure;
By replacing the current loop whose storage location is determined by the storage location determination procedure with a first loop for storing processed data in the memory and a second loop for storing processed data in the cache, A new source program generation procedure for generating a new source program from the source program;
An object file generation procedure for generating an object file from the new source program generated by the new source program generation procedure;
A compiler program characterized by causing a computer to execute.
(付記2)前記依存関係解析手順は、前記依存関係として、前記現ループにおいて処理されるデータの順番と、当該現ループの処理済みデータが前記次ループにおいて処理される順番とが順方向であるか逆方向であるかを解析し、
前記格納先決定手順は、前記依存関係解析手順によって解析された前記依存関係が順方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する前半部分を前記キャッシュに格納すると決定し、前記依存関係解析手順によって解析された前記依存関係が逆方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する後半部分を前記キャッシュに格納すると決定することを特徴とする付記1に記載のコンパイラプログラム。
(Supplementary Note 2) In the dependency relationship analysis procedure, as the dependency relationship, the order of data processed in the current loop and the order in which processed data of the current loop are processed in the next loop are forward. Or reverse direction,
The storage location determination procedure determines that the first half portion corresponding to the cache capacity of the processed data of the current loop is stored in the cache when the dependency relationship analyzed by the dependency relationship analysis procedure is forward. When the dependency relationship analyzed by the dependency relationship analysis procedure is in the reverse direction, it is determined that the second half portion corresponding to the cache capacity of the processed data of the current loop is stored in the cache. The compiler program according to 1.
(付記3)前記格納先決定手順は、前記第一ループの次に前記第二ループを実行する新規ソースプログラムを生成するように、前記新規ソースプログラム生成手順を指示することを特徴とする付記2に記載のコンパイラプログラム。 (Additional remark 3) The said storage location determination procedure directs the said new source program production | generation procedure so that the new source program which performs said 2nd loop after the said 1st loop may be produced | generated. The compiler program described in.
(付記4)前記オブジェクトファイルを実行する情報処理装置のハードウェア情報を収集して、当該情報処理装置が逆方向ハードウェアプリフェッチ処理実行可能であるか否かを判定する判定手順をさらにコンピュータに実行させ、
前記格納先決定手順は、前記判定手順により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行可能であるとして判定された場合、前記第二のループにおけるデータの処理順番を、前記現ループにおける処理順番に対して逆にしたうえで前記新規ソースプログラムを生成し、前記判定手順により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行不可として判定された場合、前記第二のループにおけるデータの処理順番を、前記現ループにおける処理順番と同一にしたうえで前記新規ソースプログラムを生成するように、前記新規ソースプログラム生成手順を指示することを特徴とする付記3に記載のコンパイラプログラム。
(Supplementary Note 4) Collecting hardware information of an information processing apparatus that executes the object file, and further executing a determination procedure for determining whether or not the information processing apparatus is capable of executing backward hardware prefetch processing on the computer Let
In the storage location determination procedure, when it is determined by the determination procedure that the information processing apparatus can execute backward hardware prefetch processing, the data processing order in the second loop is changed to the processing order in the current loop. When the information processing apparatus determines that the backward hardware prefetch process cannot be executed by the determination procedure, the data processing order in the second loop is changed. The compiler program according to
(付記5)ソースプログラムにおける各ループのデータへのアクセスパターンを解析するアクセスパターン解析部と、
前記アクセスパターン解析部によって解析された前記アクセスパターンから、現ループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する依存関係解析部と、
前記依存関係解析部によって解析された前記依存関係に基づいて、前記現ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する格納先決定部と、
前記格納先決定部によって格納先が決定された現ループを、前記メモリに処理済みデータを格納するための第一ループおよび前記キャッシュに処理済みデータを格納するための第二ループに置き換えた新規ソースプログラムを生成する新規ソースプログラム生成部と、
前記新規ソースプログラム生成部によって生成された前記新規ソースプログラムからオブジェクトファイルを生成するオブジェクトファイル生成部と、
を有することを特徴とするコンパイラ装置。
(Supplementary Note 5) An access pattern analysis unit that analyzes an access pattern to data of each loop in the source program;
From the access pattern analyzed by the access pattern analysis unit, a dependency analysis unit that analyzes a dependency relationship between data processed in the current loop and data processed in the next loop;
A storage location determination unit that determines to allocate a storage location of data processed in the current loop to either a memory or a cache based on the dependency relationship analyzed by the dependency relationship analysis unit;
A new source in which the current loop whose storage destination is determined by the storage destination determination unit is replaced with a first loop for storing processed data in the memory and a second loop for storing processed data in the cache A new source program generator for generating a program;
An object file generation unit that generates an object file from the new source program generated by the new source program generation unit;
A compiler apparatus comprising:
(付記6)前記依存関係解析部は、前記依存関係として、前記現ループにおいて処理されるデータの順番と、当該現ループの処理済みデータが前記次ループにおいて処理される順番とが順方向であるか逆方向であるかを解析し、
前記格納先決定部は、前記依存関係解析部によって解析された前記依存関係が順方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する前半部分を前記キャッシュに格納すると決定し、前記依存関係解析部によって解析された前記依存関係が逆方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する後半部分を前記キャッシュに格納すると決定することを特徴とする付記5に記載のコンパイラ装置。
(Additional remark 6) The said dependence analysis part is a forward direction as said dependence, the order of the data processed in the said current loop, and the order in which the processed data of the said current loop are processed in the said next loop. Or reverse direction,
The storage destination determining unit determines to store, in the cache, the first half portion corresponding to the cache capacity of the processed data of the current loop when the dependency relationship analyzed by the dependency relationship analyzing unit is forward. When the dependency relationship analyzed by the dependency relationship analysis unit is in the reverse direction, it is determined that the second half portion corresponding to the cache capacity of the processed data of the current loop is stored in the cache. 5. The compiler apparatus according to 5.
(付記7)前記格納先決定部は、前記第一ループの次に前記第二ループを実行する新規ソースプログラムを生成するように、前記新規ソースプログラム生成部を指示することを特徴とする付記6に記載のコンパイラ装置。 (Supplementary note 7) The storage destination determination unit instructs the new source program generation unit to generate a new source program that executes the second loop after the first loop. The compiler apparatus described in 1.
(付記8)前記オブジェクトファイルを実行する情報処理装置のハードウェア情報を収集して、当該情報処理装置が逆方向ハードウェアプリフェッチ処理実行可能であるか否かを判定する判定部をさらに有し、
前記格納先決定部は、前記判定部により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行可能であるとして判定された場合、前記第二ループにおけるデータの処理順番を、前記現ループにおける処理順番に対して逆にしたうえで前記新規ソースプログラムを生成し、前記判定部により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行不可として判定された場合、前記第二ループにおけるデータの処理順番を、前記現ループにおける処理順番と同一にしたうえで前記新規ソースプログラムを生成するように、前記新規ソースプログラム生成部を指示することを特徴とする付記7に記載のコンパイラ装置。
(Additional remark 8) It further has the determination part which collects the hardware information of the information processing apparatus which performs the said object file, and determines whether the said information processing apparatus can perform reverse direction hardware prefetch processing,
When the information processing apparatus determines that the information processing apparatus can execute backward hardware prefetch processing by the determination unit, the storage destination determination unit changes the data processing order in the second loop to the processing order in the current loop. On the other hand, when generating the new source program and the determination unit determines that the information processing apparatus cannot execute backward hardware prefetch processing, the processing order of the data in the second loop is The compiler apparatus according to appendix 7, wherein the new source program generation unit is instructed to generate the new source program in the same processing order as in the current loop.
10 コンパイラ装置
11 ソースプログラム入力部
12 オブジェクトファイル出力部
13 通信部
14 入出力制御I/F部
20 記憶部
21 ソースプログラム記憶部
22 ループデータ記憶部
23 配列データ記憶部
24 ハードウェア情報記憶部
25 新規ソースプログラム記憶部
30 処理部
31 ループ構造解析部
32 配列解析部
33 アクセスパターン解析部
34 依存関係解析部
35 部分キャッシュ指示部
36 最適化部
37 オブジェクトファイル生成部
40 情報処理装置
DESCRIPTION OF
Claims (5)
前記アクセスパターン解析手順によって解析された前記アクセスパターンから、現ループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する依存関係解析手順と、
前記依存関係解析手順によって解析された前記依存関係に基づいて、前記現ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する格納先決定手順と、
前記格納先決定手順によって格納先が決定された現ループを、前記メモリに処理済みデータを格納するための第一ループおよび前記キャッシュに処理済みデータを格納するための第二ループに置き換えることにより、前記ソースプログラムから新規ソースプログラムを生成する新規ソースプログラム生成手順と、
前記新規ソースプログラム生成手順によって生成された前記新規ソースプログラムからオブジェクトファイルを生成するオブジェクトファイル生成手順と、
をコンピュータに実行させることを特徴とするコンパイラプログラム。 An access pattern analysis procedure for analyzing the access pattern to the data of each loop in the source program;
From the access pattern analyzed by the access pattern analysis procedure, a dependency analysis procedure for analyzing a dependency relationship between data processed in the current loop and data processed in the next loop;
A storage location determination procedure for determining to allocate a storage location of data processed in the current loop to either a memory or a cache based on the dependency relationship analyzed by the dependency relationship analysis procedure;
By replacing the current loop whose storage location is determined by the storage location determination procedure with a first loop for storing processed data in the memory and a second loop for storing processed data in the cache, A new source program generation procedure for generating a new source program from the source program;
An object file generation procedure for generating an object file from the new source program generated by the new source program generation procedure;
A compiler program characterized by causing a computer to execute.
前記格納先決定手順は、前記依存関係解析手順によって解析された前記依存関係が順方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する前半部分を前記キャッシュに格納すると決定し、前記依存関係解析手順によって解析された前記依存関係が逆方向である場合、前記現ループの処理済みデータのうちキャッシュ容量に相当する後半部分を前記キャッシュに格納すると決定することを特徴とする請求項1に記載のコンパイラプログラム。 In the dependency relationship analyzing procedure, as the dependency relationship, the order of data processed in the current loop and the order in which processed data of the current loop are processed in the next loop are forward or backward. Analyzing whether there is
The storage location determination procedure determines that the first half portion corresponding to the cache capacity of the processed data of the current loop is stored in the cache when the dependency relationship analyzed by the dependency relationship analysis procedure is forward. When the dependency relationship analyzed by the dependency relationship analysis procedure is in the reverse direction, it is determined that the second half portion corresponding to the cache capacity of the processed data of the current loop is stored in the cache. Item 1. The compiler program according to item 1.
前記格納先決定手順は、前記判定手順により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行可能であるとして判定された場合、前記第二ループにおけるデータの処理順番を、前記現ループにおける処理順番に対して逆にしたうえで前記新規ソースプログラムを生成し、前記判定手順により前記情報処理装置が逆方向ハードウェアプリフェッチ処理実行不可として判定された場合、前記第二ループにおけるデータの処理順番を、前記現ループにおける処理順番と同一にしたうえで前記新規ソースプログラムを生成するように、前記新規ソースプログラム生成手順を指示することを特徴とする請求項3に記載のコンパイラプログラム。 Collecting hardware information of the information processing apparatus that executes the object file, and causing the computer to further execute a determination procedure for determining whether or not the information processing apparatus is capable of executing backward hardware prefetch processing,
In the storage location determination procedure, when it is determined by the determination procedure that the information processing apparatus can execute backward hardware prefetch processing, the data processing order in the second loop is changed to the processing order in the current loop. On the other hand, the new source program is generated and when the information processing apparatus is determined not to be able to execute backward hardware prefetch processing by the determination procedure, the processing order of the data in the second loop is 4. The compiler program according to claim 3, wherein the new source program generation procedure is instructed to generate the new source program in the same processing order as in the current loop.
前記アクセスパターン解析部によって解析された前記アクセスパターンから、現ループにおいて処理されるデータと次ループにおいて処理されるデータとの依存関係を解析する依存関係解析部と、
前記依存関係解析部によって解析された前記依存関係に基づいて、前記現ループにおいて処理されたデータの格納先をメモリまたはキャッシュのいずれかに割り振るように決定する格納先決定部と、
前記格納先決定部によって格納先が決定された現ループを、前記メモリに処理済みデータを格納するための第一ループおよび前記キャッシュに処理済みデータを格納するための第二ループに置き換えた新規ソースプログラムを生成する新規ソースプログラム生成部と、
前記新規ソースプログラム生成部によって生成された前記新規ソースプログラムからオブジェクトファイルを生成するオブジェクトファイル生成部と、
を有することを特徴とするコンパイラ装置。 An access pattern analysis unit for analyzing the access pattern to the data of each loop in the source program;
From the access pattern analyzed by the access pattern analysis unit, a dependency analysis unit that analyzes a dependency relationship between data processed in the current loop and data processed in the next loop;
A storage location determination unit that determines to allocate a storage location of data processed in the current loop to either a memory or a cache based on the dependency relationship analyzed by the dependency relationship analysis unit;
A new source in which the current loop whose storage destination is determined by the storage destination determination unit is replaced with a first loop for storing processed data in the memory and a second loop for storing processed data in the cache A new source program generator for generating a program;
An object file generation unit that generates an object file from the new source program generated by the new source program generation unit;
A compiler apparatus comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009090479A JP5251688B2 (en) | 2009-04-02 | 2009-04-02 | Compiler program and compiler device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009090479A JP5251688B2 (en) | 2009-04-02 | 2009-04-02 | Compiler program and compiler device |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2010244204A true JP2010244204A (en) | 2010-10-28 |
JP5251688B2 JP5251688B2 (en) | 2013-07-31 |
Family
ID=43097177
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009090479A Expired - Fee Related JP5251688B2 (en) | 2009-04-02 | 2009-04-02 | Compiler program and compiler device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5251688B2 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2012056835A1 (en) | 2010-10-29 | 2012-05-03 | 日本電気株式会社 | Data storage control system, data storage control method, and data storage control program |
US9483244B2 (en) | 2014-05-15 | 2016-11-01 | Fujitsu Limited | Compiling method and compiling device |
US9830268B2 (en) | 2014-05-14 | 2017-11-28 | Fujitsu Limited | Arithmetic processing device for disabling an unnecessary prefetch command and control method of arithmetic processing device for disabling an unnecessary prefetch command |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0492928A (en) * | 1990-08-06 | 1992-03-25 | Nec Corp | Optimizing system for loop dividing |
JPH09128245A (en) * | 1995-10-30 | 1997-05-16 | Hitachi Ltd | Compiling processing system |
WO1999030231A1 (en) * | 1997-12-10 | 1999-06-17 | Hitachi, Ltd. | Memory access optimizing method |
JP2000207224A (en) * | 1999-01-14 | 2000-07-28 | Hitachi Ltd | Software prefetching method |
JP2004303113A (en) * | 2003-04-01 | 2004-10-28 | Hitachi Ltd | Compiler provided with optimization processing for hierarchical memory and code generating method |
JP2008102733A (en) * | 2006-10-19 | 2008-05-01 | Hitachi Ltd | Code generation method and compiler |
-
2009
- 2009-04-02 JP JP2009090479A patent/JP5251688B2/en not_active Expired - Fee Related
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0492928A (en) * | 1990-08-06 | 1992-03-25 | Nec Corp | Optimizing system for loop dividing |
JPH09128245A (en) * | 1995-10-30 | 1997-05-16 | Hitachi Ltd | Compiling processing system |
WO1999030231A1 (en) * | 1997-12-10 | 1999-06-17 | Hitachi, Ltd. | Memory access optimizing method |
JP2000207224A (en) * | 1999-01-14 | 2000-07-28 | Hitachi Ltd | Software prefetching method |
JP2004303113A (en) * | 2003-04-01 | 2004-10-28 | Hitachi Ltd | Compiler provided with optimization processing for hierarchical memory and code generating method |
JP2008102733A (en) * | 2006-10-19 | 2008-05-01 | Hitachi Ltd | Code generation method and compiler |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2012056835A1 (en) | 2010-10-29 | 2012-05-03 | 日本電気株式会社 | Data storage control system, data storage control method, and data storage control program |
US9830268B2 (en) | 2014-05-14 | 2017-11-28 | Fujitsu Limited | Arithmetic processing device for disabling an unnecessary prefetch command and control method of arithmetic processing device for disabling an unnecessary prefetch command |
US9483244B2 (en) | 2014-05-15 | 2016-11-01 | Fujitsu Limited | Compiling method and compiling device |
Also Published As
Publication number | Publication date |
---|---|
JP5251688B2 (en) | 2013-07-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8443171B2 (en) | Run-time updating of prediction hint instructions | |
Grayson et al. | Evolution of the samsung exynos cpu microarchitecture | |
JP6488711B2 (en) | Arithmetic processing device and control method of arithmetic processing device | |
US6269438B1 (en) | Method for identifying hard-to-predict branches to enhance processor performance | |
US9798528B2 (en) | Software solution for cooperative memory-side and processor-side data prefetching | |
JP4027620B2 (en) | Branch prediction apparatus, processor, and branch prediction method | |
US7624258B2 (en) | Using computation histories to make predictions | |
Panda et al. | Memory data organization for improved cache performance in embedded processor applications | |
CN103513957A (en) | High-performance cache system and method | |
JP4751510B2 (en) | Memory access optimization method | |
JP3681647B2 (en) | Cache memory system device | |
US10318172B2 (en) | Cache operation in a multi-threaded processor | |
JP3812258B2 (en) | Cache storage | |
JP5392689B2 (en) | Code optimization using a bi-endian compiler | |
JP5251688B2 (en) | Compiler program and compiler device | |
US6516462B1 (en) | Cache miss saving for speculation load operation | |
CA2762563A1 (en) | Data prefetching and coalescing for partitioned global address space languages | |
US20150193348A1 (en) | High-performance data cache system and method | |
US8166252B2 (en) | Processor and prefetch support program | |
US7966474B2 (en) | System, method and computer program product for translating storage elements | |
Cheng et al. | Exploiting memory-level parallelism in reconfigurable accelerators | |
Sazeides | Modeling value speculation | |
JP2012150634A (en) | Vector instruction control circuit and overtaking control method for list vector | |
Kyriacou et al. | Cacheflow: A short-term optimal cache management policy for data driven multithreading | |
Fung et al. | Improving cache locality for thread-level speculation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20111205 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130305 |
|
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: 20130319 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20130401 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20160426 Year of fee payment: 3 |
|
LAPS | Cancellation because of no payment of annual fees |