JP7040187B2 - compiler - Google Patents
compiler Download PDFInfo
- Publication number
- JP7040187B2 JP7040187B2 JP2018053204A JP2018053204A JP7040187B2 JP 7040187 B2 JP7040187 B2 JP 7040187B2 JP 2018053204 A JP2018053204 A JP 2018053204A JP 2018053204 A JP2018053204 A JP 2018053204A JP 7040187 B2 JP7040187 B2 JP 7040187B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- vector
- address
- list
- array
- 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.)
- Active
Links
Images
Description
本発明は、コンパイラ、コンピュータ、およびコンピュータのコード生成方法に関する。 The present invention relates to a compiler, a computer, and a computer code generation method.
一般に、命令処理の高速化を目的としたベクトル計算機(ベクトル処理装置)においては、メモリアクセス命令の追い越し制御が行われている。メモリアクセス命令の追い越し制御は、メモリアクセス系の命令で先行するメモリストア系命令がアクセスする領域に、続いて発行されるメモリロード系命令のアクセス領域が重複していない場合、後続のメモリロード系命令のメモリアクセスを先に実行させることにより実現される。これにより、メモリアクセス性能の向上を図ることができる。対象となるメモリアクセス系の命令は、ベクトルロード命令、ベクトルストア命令の他に、ベクトルスキャッター命令およびベクトルギャザー命令といったリストベクトル命令がある。リストベクトル命令は、複数のアクセス先のアドレスを配列等により間接参照させるリストアドレスにより、アクセス先のアドレスを指定する。 Generally, in a vector computer (vector processing device) for the purpose of speeding up instruction processing, overtaking control of a memory access instruction is performed. The overtaking control of the memory access instruction is performed when the access area of the memory load instruction issued subsequently does not overlap with the area accessed by the memory store instruction preceding by the memory access instruction, the subsequent memory load system. It is realized by executing the memory access of the instruction first. This makes it possible to improve the memory access performance. In addition to the vector load instruction and the vector store instruction, the target memory access type instructions include a list vector instruction such as a vector scatter instruction and a vector gather instruction. The list vector instruction specifies the access destination address by the list address that indirectly refers to the addresses of a plurality of access destinations by an array or the like.
例えば、特許文献1では、リストベクトルを繰り返し処理するループ制御文を含むソースプログラムのコンパイル時、リストベクトル命令によってアクセスする配列の先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定する。そして、ベクトル計算機では、リストベクトル命令の命令語に設定された先頭アドレスおよび終端アドレスを使用して、他のメモリアクセス系命令がアクセスするメモリのアドレス範囲との重複の有無を判定し、追い越し制御の実行を制御している。特許文献2にも、特許文献1と同様の技術が記載されている。
For example, in
上述したように特許文献1では、リストベクトル命令によってアクセスする配列の先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定している。即ち、リストベクトル命令は、アクセスする配列の全範囲をアクセスするものとしている。しかしながら、リストベクトル命令は配列の一部分だけをアクセスする場合がある。そのため、リストベクトル命令によってアクセスする配列の先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定する構成では、リストベクトル命令によってアクセスするメモリのアドレス範囲が実際よりも広くなる場合がある。そうなると、他のメモリアクセス系命令がリストベクトル命令によってアクセスする配列と同じ配列をアクセスする場合、実際には同じ配列の異なる部分を互いにアクセスしている場合であっても、アクセスするメモリのアドレス範囲が互いに重複すると判定される。その結果、実際には追い越し可能な場合であっても、追い越し不可と判定される場合があった。
As described above, in
本発明の目的は、上述した課題、即ちメモリアクセス命令の適切な追い越し制御が困難である、という課題を解決するコンパイラを提供することにある。 An object of the present invention is to provide a compiler that solves the above-mentioned problem, that is, the problem that appropriate overtaking control of a memory access instruction is difficult.
本発明の一形態に係るコンパイラは、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータに、
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳する処理を行わせ、
前記処理では、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する。
The compiler according to one embodiment of the present invention is
To a computer that generates an object program for a vector computer from a source program,
The source program is analyzed, and the loop control statement that repeatedly processes the list vector is translated into a series of instruction lists including the list vector instruction.
In the process, the start address and the end address of the memory accessed by the list vector instruction are calculated every time the loop of the loop control statement is repeated, and the start address and the end address are set as the command words of the list vector instruction. do.
また本発明の他の形態に係るコンピュータは、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータであって、
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を認識するループ解析部と、
前記ループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳するコード生成部と、を含み、
前記コード生成部は、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する。
Further, the computer according to another embodiment of the present invention is
A computer that generates an object program for a vector computer from a source program.
A loop analysis unit that analyzes the source program and recognizes a loop control statement that repeatedly processes the list vector.
Includes a code generator that translates the loop control statement into a series of instruction lists, including list vector instructions.
The code generation unit calculates the start address and the end address of the memory accessed by the list vector instruction for each loop repetition of the loop control statement, and the start address and the end address are the command words of the list vector instruction. Set to.
また本発明の他の形態に係るコンピュータのコード生成方法は、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータが実行するコード生成方法であって、
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を認識し、
前記ループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳し、
前記翻訳では、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する。
Further, the computer code generation method according to another embodiment of the present invention is described.
It is a code generation method executed by a computer that generates an object program for a vector computer from a source program.
Analyzing the source program, recognizing the loop control statement that iterates over the list vector,
The loop control statement is translated into a series of instruction lists including list vector instructions.
In the translation, the start address and the end address of the memory accessed by the list vector instruction are calculated for each loop repetition of the loop control statement, and the start address and the end address are set as the command words of the list vector instruction. do.
本発明は上述した構成を有することにより、メモリアクセス命令の適切な追い越し制御が可能である。 By having the above-mentioned configuration, the present invention enables appropriate overtaking control of the memory access instruction.
次に本発明の実施の形態について図面を参照して詳細に説明する。
[第1の実施形態]
先ず、本発明の第1の実施形態について説明する。
Next, embodiments of the present invention will be described in detail with reference to the drawings.
[First Embodiment]
First, the first embodiment of the present invention will be described.
<本実施形態の背景>
一般に、高速なプロセッサ性能と低速なメモリ性能とのギャップが計算機としての実効性能に大きな影響を及ぼしている。メモリ性能については、メモリロード命令のレイテンシが特に重要な要素である。
<Background of this embodiment>
In general, the gap between high-speed processor performance and low-speed memory performance has a great influence on the effective performance of a computer. For memory performance, the latency of memory load instructions is a particularly important factor.
また、命令処理の高速化を目的としたベクトル処理方式においては、メモリアクセス命令の追い越し制御が行われている。メモリアクセス命令の追い越し制御は、メモリアクセス系の命令で先行するメモリストア系命令がアクセスする領域に、続いて発行されるメモリロード系命令のアクセス領域が重複していない場合、後続のメモリロード系命令のメモリアクセスを先に実行させることにより実現される。これにより、メモリアクセス性能の向上を図ることができる。しかし、リストベクトルによるランダムなアクセスをともなうベクトルギャザー命令、および、ベクトルスキャッター命令は、メモリアクセスに規則性がなくアドレス依存の解析が難しく、効果的な追い越し制御が困難という問題がある。 Further, in the vector processing method for the purpose of speeding up the instruction processing, the overtaking control of the memory access instruction is performed. The overtaking control of the memory access instruction is performed when the access area of the memory load instruction issued subsequently does not overlap with the area accessed by the memory store instruction preceding by the memory access instruction, the subsequent memory load system. It is realized by executing the memory access of the instruction first. This makes it possible to improve the memory access performance. However, the vector gather instruction and the vector scatter instruction with random access by the list vector have a problem that the memory access is not regular and the address dependence analysis is difficult, and the effective overtaking control is difficult.
特許文献1では、ベクトルギャザー命令、および、ベクトルスキャッター命令がアクセスするメモリの先頭アドレスは、リストアドレスが指定された配列がメモリに割り付けられた値とし、その終端アドレスは、その先頭アドレスに配列のサイズを加算した値としている。即ち、リストアドレスの内容によらず配列全体をアクセスする範囲として、命令の追い越しの可否を決めている。このため同一配列へのロードとストアがループ中に混在する場合、決して追い越しが行われない。これに対して、本実施形態ではリストアドレス指定された次元のループの繰返しごとの先頭アドレスから終端アドレスまでをベクトルギャザー命令、および、ベクトルスキャッター命令がアクセスするメモリの範囲と設定することで、リストアドレスによってアクセスされる範囲と重ならない領域にアクセスする命令においては命令の追い越しが可能となり、特許文献1に記載の発明に比べて追い越し可能な命令が増え、メモリアクセス系の処理時間のさらなる改善とプログラムの高速化が見込まれる。
In
<本実施形態の特徴>
本実施形態では、ベクトルギャザー命令、または、ベクトルスキャッター命令がアクセスするアドレス領域を解析し、同一ループ内の他のメモリアクセス系命令がアクセスする領域と重なりのある範囲を判定する機能を有するコンパイラを提供する。ベクトルギャザー命令、ベクトルスキャッター命令にこのコンパイラが判定したメモリアクセスに重なりのある範囲の情報を付与することで、ハードウェアにおけるベクトルギャザー命令、ベクトルスキャッター命令の追い越しの制御を簡単にするとともに、追い越し可能な命令の数を増加させる。これにより、メモリアクセスの処理時間を改善し、プログラムを高速化できる。
<Characteristics of this embodiment>
The present embodiment has a function of analyzing an address area accessed by a vector gather instruction or a vector scatter instruction and determining a range overlapping with an area accessed by another memory access system instruction in the same loop. Provides a compiler. By adding a range of information that overlaps the memory access determined by this compiler to the vector gather instruction and vector scatter instruction, it is easy to control the overtaking of the vector gather instruction and vector scatter instruction in hardware. At the same time, increase the number of commands that can be overtaken. This can improve the processing time of memory access and speed up the program.
<本実施形態が解決しようとする課題>
ベクトルギャザー命令やベクトルスキャッター命令では、ベクトルレジスタの各要素を実行アドレスとしてメモリにアクセスするため、メモリアクセスに規則性がなくアドレス依存の解析が難しい。この問題を解決するために、例えば、特許文献1で提案されている追い越し制御機能の場合、ベクトルギャザー命令やベクトルスキャッター命令がアクセスする配列の先頭アドレスから終端アドレスまでを命令のアクセス範囲であるとし、このアクセス範囲が他のメモリアクセス系命令のアクセス範囲と重なりがなければハードウェアは追い越し可能と判定して追い越し制御を行っている。しかし、この方法では、ベクトルギャザー命令やベクトルスキャッター命令によってアクセスするメモリのアドレス範囲が実際よりも広くなって、実際には追い越し可能な場合であっても、追い越し不可と判定されるケースが発生する。
<Problems to be solved by this embodiment>
In the vector gather instruction and the vector scatter instruction, since each element of the vector register is used as the execution address to access the memory, there is no regularity in the memory access and it is difficult to analyze the address dependence. In order to solve this problem, for example, in the case of the overtaking control function proposed in
例えば、図7に示すコード例の(1)の式では配列Aと配列Bの間に依存関係はなく、配列Bのベクトルギャザー命令は配列Aのベクトルスキャッター命令を追い越してよいと判断できる。しかし、特許文献1の技術では、(1)と(2)の間では配列Aの参照定義の依存関係があるため追い越しできないと判断してしまう。
For example, in the equation (1) of the code example shown in FIG. 7, there is no dependency between the array A and the array B, and it can be determined that the vector gather instruction of the array B may overtake the vector scatter instruction of the array A. .. However, in the technique of
図8に上記の例のコードのJ=2のとき、および、J=3のときの命令列と、配列Aのデータ並びを示す。J=2のとき、配列Aのストア命令がアクセスする領域は図8の領域5-2であり、配列Aのロード命令がアクセスする領域は図8の領域5-1であるため、アクセスする領域に重なりはなく、ストア命令とロード命令の間に依存関係はない。また、J=3のときはストア命令がアクセスする領域は領域5-3、ロード命令がアクセスする領域は領域5-2となり、やはりストア命令とロード命令がアクセスする領域に重なりはない。つまり、JがM(2≦M≦N)のとき、(2)でロードする配列A(I,M-1)の要素は、(1)のストア先である配列A(L(I),M)とはメモリ上重なりはないため、(2)のロード命令は(1)を追い越すことができる。しかし、特許文献1では上述の通り配列Aの先頭アドレスから終端アドレスまでをアクセス範囲と設定するため、(1)と(2)がアクセスする領域は同じ配列Aで重なりありとみなされ、追い越し不可と判定されていた。
FIG. 8 shows the instruction sequence when J = 2 and J = 3 in the code of the above example, and the data sequence of the array A. When J = 2, the area accessed by the store instruction of the array A is the area 5-2 of FIG. 8, and the area accessed by the load instruction of the array A is the area 5-1 of FIG. There is no overlap and there is no dependency between the store instruction and the load instruction. Further, when J = 3, the area accessed by the store instruction is the area 5-3, the area accessed by the load instruction is the area 5-2, and the area accessed by the store instruction and the load instruction does not overlap. That is, when J is M (2 ≦ M ≦ N), the elements of the array A (I, M-1) loaded in (2) are the array A (L (I), which is the store destination of (1). Since there is no memory overlap with M), the load instruction of (2) can overtake (1). However, in
<本実施形態による解決手段>
まず始めに、本実施形態が必要とするハードウェア、および、コンパイラの要件を述べる。本実施形態は、リストベクトルで指定されたベクトルレジスタの各要素に格納されたメモリ上のアドレスが指し示すデータをロード先のベクトルレジスタにロードするベクトルギャザー命令、および、リストベクトルで指定されたベクトルレジスタの各要素に格納されたメモリ上のストア先のアドレスにベクトルレジスタ上のデータをストアするベクトルスキャッター命令を命令セットに備えたCPUを有するハードウェア(ベクトル計算機)を対象としている。このハードウェアは、ベクトルロード/ストア命令のメモリアクセスの重なりがなければ命令の追い越しを可能とする追い越し制御機能を備えているものとする。また、コンパイラは、配列の宣言情報より配列の次元数や要素数、サイズなどの情報を静的に取得できる機能を有しているものとする。以上が、本実施形態が必要とするハードウェア、およびコンパイラの要件である。これらは従来技術でも用いられているものである。
<Solution by the present embodiment>
First, the hardware required by this embodiment and the requirements of the compiler will be described. In this embodiment, a vector gather instruction for loading the data pointed to by the address on the memory stored in each element of the vector register specified by the list vector into the vector register to be loaded, and the vector register specified by the list vector. The target is hardware (vector computer) having a CPU equipped with a vector scatter instruction for storing data on a vector register at a store destination address on the memory stored in each element of the instruction set. It is assumed that this hardware has an overtaking control function that enables overtaking of instructions if there is no overlap of memory access of vector load / store instructions. Further, it is assumed that the compiler has a function of statically acquiring information such as the number of dimensions, the number of elements, and the size of the array from the declaration information of the array. The above are the requirements of the hardware and the compiler required by this embodiment. These are also used in the prior art.
本実施形態は、リストベクトルでアクセスされる配列、および、リストベクトルに関する情報の解析を行うリストベクトル解析部と、解析で得られたリストアクセスを行うメモリ領域の先頭アドレスと終端アドレスを命令語中にもつベクトルギャザー命令、および、ベクトルスキャッター命令を生成する手段と、命令語にセットしたアドレスを用いて他のメモリアクセス系命令との間にアクセスするメモリ領域に重なりがないかどうかを判定するリストアドレス重なり判定部とを有するコンパイラを提供することにより、リストアクセスを行うベクトル命令の追い越し制御を簡単、かつ効果的にすることで、プログラムを高速化する。 In this embodiment, an array accessed by a list vector, a list vector analysis unit that analyzes information about the list vector, and a start address and an end address of a memory area that performs list access obtained by the analysis are used as commands. It is determined whether or not the memory area to be accessed between the means for generating the vector gather instruction and the vector scatter instruction and the address set in the instruction term overlaps with other memory access system instructions. By providing a compiler having a list address overlap determination unit, the overtaking control of the vector instruction for list access can be made simple and effective, thereby speeding up the program.
<本実施形態の構成>
図1は、本発明の第1の実施形態に係るコンパイラ100の構成図である。コンパイラ100は、ソースプログラム101を翻訳して命令語102を生成する。命令語102は、オブジェクトコードとも呼ばれる。命令語102は、ベクトル計算機で実行される。このようにコンパイラ100は、ベクトル計算機に対するオブジェクトプログラムを生成する。
<Structure of this embodiment>
FIG. 1 is a block diagram of a
コンパイラ100は、ループ内命令生成処理部110とリストベクトル解析部120とを含んで構成されている。またループ内命令生成処理部110は、先行命令生成部111、ベクトルギャザー/スキャッター命令生成部112、後続命令生成部113、およびリストアドレス重なり判定部114を含んで構成されている。
The
コンパイラ100は、ソースプログラム101を解析してリストベクトルを繰り返し処理するループ制御文を認識すると、そのループ制御文に対してループ内命令生成処理部110とリストベクトル解析部120とを適用するように構成されている。
When the
リストベクトル解析部120は、ループ制御文のループの繰返しごとにリストベクトルによってアクセスされうるアドレスの先頭アドレスと終端アドレスを算出するように構成されている。
The list
ループ内命令生成処理部110は、ループ制御文を、リストベクトル命令(ベクトルギャザー命令またはベクトルスキャッター命令)を含む一連の命令リスト130に翻訳するように構成されている。その際、先行命令生成部111は、ベクトルギャザー命令またはベクトルスキャッター命令に先行する命令を生成する。また、ベクトルギャザー/スキャッター命令生成部112は、ベクトルギャザー命令またはベクトルスキャッター命令を生成する。またベクトルギャザー/スキャッター命令生成部112は、生成したベクトルギャザー命令またはベクトルスキャッター命令の命令語に、リストベクトル解析部120で算出された先頭アドレスと終端アドレスを格納したレジスタをセットする。また、後続命令生成部113は、ベクトルギャザー命令またはベクトルスキャッター命令の後続の命令を生成する。また、リストアドレス重なり判定部114は、リストベクトル解析部120で算出したリストアドレスの先頭から終端までの範囲をリストベクトル命令(ベクトルギャザー命令、および、ベクトルスキャッター命令)のメモリアクセス範囲とし、ベクトルギャザー命令の場合は先行のストア命令、ベクトルスキャッター命令の場合は後続のロード命令がアクセスするメモリ領域との間に重なりがないかどうかを判定する。そしてリストアドレス重なり判定部114は、その判定結果に基づいて、リストベクトル命令の命令語中に、メモリアクセスのアドレス領域のプログラム上での重なりの有無に応じて所定の値が設定される追い越しビットを設定する。
The in-loop instruction
図2は、リストベクトル命令の命令語の一部の構造の一例を示す。この例の命令語は、オペコードOP、追い越しビットV、メモリをアクセスするアドレスが格納されているベクトルレジスタを指定するフィールドVR、リストベクトル解析部120が算出した先頭アドレスを格納したレジスタを指定するフィールドSmin、リストベクトル解析部120が算出した終端アドレスを格納したレジスタを指定するフィールドSmaxを含んで構成されている。コンパイル時に重なりがないことが確定となるリストベクトル命令の場合、追い越しビットVは“1”になり、それ以外は“0”になる。
FIG. 2 shows an example of the structure of a part of the instruction word of the list vector instruction. The instruction words in this example are the opcode OP, the overtaking bit V, the field VR that specifies the vector register that stores the address that accesses the memory, and the field that specifies the register that stores the start address calculated by the list
従って、上記命令語を実行するハードウェア(ベクトル計算機)では、命令語の追い越しビットVが“1”のときは無条件で追い越し制御を行う。また、命令語の追い越しビットVが“0”のときは、ハードウェア(ベクトル計算機)は、重なり範囲の先頭アドレスと終端アドレスを命令語のSmin、Smaxで指定されたレジスタから取得して、命令の追い越しを禁止する範囲を認識する。そのため、ハードウェア(ベクトル計算機)上でリストアドレスの解析を行わずとも命令の追い越し制御が可能となる。 Therefore, in the hardware (vector computer) that executes the above command word, when the overtaking bit V of the command word is "1", the overtaking control is unconditionally performed. When the overtaking bit V of the instruction word is "0", the hardware (vector computer) acquires the start address and end address of the overlap range from the registers specified by the instruction words Smin and Smax, and gives an instruction. Recognize the range that prohibits overtaking. Therefore, it is possible to control the overtaking of instructions without analyzing the list address on the hardware (vector computer).
<本実施形態の動作>
次に本実施形態の動作を、図3に示したソースプログラムを例にして説明する。
<Operation of this embodiment>
Next, the operation of this embodiment will be described by taking the source program shown in FIG. 3 as an example.
図3に示すソースプログラムは、フォートランソースコードのDOループの一例である。式3-1の左辺の配列Aは、リストベクトルLによって1次元目の要素が指定されている。コンパイラ100は、図3に示すソースプログラムを機械語(命令語)レベルに翻訳する。
The source program shown in FIG. 3 is an example of a DO loop of Fortran source code. In the array A on the left side of Equation 3-1 the first-dimensional element is designated by the list vector L. The
図4は図3のソースプログラムの翻訳結果の一部を示す。図3の式3-1は、図4の4-1~4-5のように翻訳され、図3の式3-2は、図4の4-6~4-7のように翻訳される。 FIG. 4 shows a part of the translation result of the source program of FIG. Equation 3-1 in FIG. 3 is translated as 4-1 to 4-5 in FIG. 4, and Equation 3-2 in FIG. 3 is translated as 4-6 to 4-7 in FIG. ..
特許文献1では、式3-1に対してベクトルスキャッター命令4-5を生成する際、配列A全体をアクセスする範囲に設定するため、後続の式3-2に対して生成する配列Aのロード命令4-6とメモリアクセス領域に重なりがあり、追い越し不可と判定する。本実施形態では、式3-1に対してベクトルスキャッター命令4-5を生成する際、リストベクトル解析部120は、配列Aについて以下の解析処理を実施する。
In
先ず、リストベクトル解析部120は、配列の宣言情報から次の情報を取得する。
(a)配列のベースアドレス
(b)配列の一つの要素のサイズ
(c)配列の次元数
(d)各次元の情報(要素の数、要素間の距離、下限)
First, the list
(A) Base address of the array (b) Size of one element of the array (c) Number of dimensions of the array (d) Information of each dimension (number of elements, distance between elements, lower limit)
次に、リストベクトル解析部120は、上記取得した情報を用いてループの繰返しごとの1次元目の先頭アドレスと終端アドレスを以下のように求める。
先頭アドレス=ベースアドレス+((1次元目の要素数×要素のサイズ)×(2次元目のインデックス-1))
終端アドレス=先頭アドレス+(1次元目の要素数×要素のサイズ)
Next, the list
Start address = base address + ((number of elements in the first dimension x size of elements) x (index in the second dimension-1))
End address = start address + (number of elements in the first dimension x element size)
ベクトルギャザー/スキャッター命令生成部112は、リストベクトル解析部120で算出された先頭アドレスと終端アドレスを、配列Aに対して生成したベクトルスキャッター命令4-5の命令語にセットする。
The vector gather / scatter
図5は、図3の外側ループでJ=3のときの配列Aのメモリイメージを示す。外側ループのJ=3の繰返しでリストアクセスを行うメモリ領域は、図5のA(L(I),3)で指し示した斜線の範囲となる。よって、リストベクトル解析部120で算出した先頭アドレスと終端アドレスは、図5の斜線の範囲の先頭と終端のアドレスとなる。図3の式3-2に対して、A(I,J-1)のロード命令4-6が生成されるが、J=3のとき、ロード命令4-6は、図5のA(I,2)で指し示した点線で囲まれた範囲にアクセスする。リストアクセスされる斜線の範囲と重なりがないため、A(I,2)のロード命令4-6は、先行するA(L(I),3)のベクトルスキャッター命令4-5を追い越すことが可能であることが分かる。
FIG. 5 shows a memory image of the array A when J = 3 in the outer loop of FIG. The memory area for list access by repeating J = 3 in the outer loop is within the range of the diagonal line indicated by A (L (I), 3) in FIG. Therefore, the start address and the end address calculated by the list
リストベクトル解析部120は、上記の通りループの繰返しごとにリストアクセスするアドレスの先頭と終端を求め、ベクトルギャザー/スキャッター命令生成部112は、それをベクトルスキャッター命令4-5の命令語にセットする。
As described above, the list
リストアドレス重なり判定部114は、上記セットされた先頭アドレスと終端アドレスをベクトルスキャッター命令4-5の命令語から取得し、その範囲と後続のロード命令4-6がアクセスする範囲との間に重なりがないかどうかの判定を行う。図3のループの場合、図5に示したように式3-2に対応する配列Aのロード命令4-6のアクセス範囲は配列Aの2次元目がJ-1の範囲であり、式3-1に対応するベクトルスキャッター命令4-5は配列Aの2次元目がJの範囲である。よって、リストアドレス重なり判定部114は、このループにおいて配列Aの定義参照の依存関係はなく、式3-2に対応するロード命令4-6は、式3-1に対応するベクトルスキャッター命令4-5を追い越すことができると判断する。リストアドレス重なり判定部114は、後続のロード命令との間にアクセスするメモリ領域の重なりが見つからなかった場合は、ベクトルスキャッター命令4-5の命令語の追い越しビットVを“1”にする。リストアドレス重なり判定部114は、コンパイル時に静的に取得できる配列情報からアクセス領域の重なりの有無の判別がつかない場合は、命令語の追い越しビットVを“0”にする。
The list address
上記の手法により生成したリストベクトル命令の命令語の情報を用いて、ハードウェア(ベクトル計算機)は追い越し制御を行う。ハードウェアでは、まずコンパイラが命令語にセットした追い越しビットVを確認し、追い越しビットVの値が“1”であればその命令に対して無条件で追い越し制御を行う。追い越しビットVの値が“0”の場合、ハードウェアは命令語のフィールドSmin、Smaxにセットされたレジスタからアクセス範囲の先頭アドレスと終端アドレスを取得し、ベクトルスキャッター命令の重なり範囲のアドレスと後続のロード命令がアクセスするアドレスとの比較を行うことで追い越し可否の判断を行い、追い越し可能なとき追い越し制御を行う。 The hardware (vector computer) performs overtaking control using the information of the instruction word of the list vector instruction generated by the above method. In the hardware, first, the overtaking bit V set by the compiler in the instruction word is confirmed, and if the value of the overtaking bit V is "1", the overtaking control is unconditionally performed for the instruction. When the value of the overtaking bit V is "0", the hardware obtains the start address and the end address of the access range from the register set in the instruction field fields Smin and Smax, and the address of the overlap range of the vector scatter instruction. By comparing with the address accessed by the subsequent load instruction, it is judged whether or not overtaking is possible, and overtaking control is performed when overtaking is possible.
図3に示したソースプログラムを例にベクトルスキャッター命令の場合について説明したが、本発明はベクトルギャザー命令についても同様に処理を実行し、先行するメモリストア系命令の追い越しが可能か否かをコンパイラ100で判定し、ハードウェアでの判定に必要な情報を命令語にセットすることができる。
The case of the vector scatter instruction has been described by taking the source program shown in FIG. 3 as an example. However, the present invention also executes the processing for the vector gather instruction, and whether or not it is possible to overtake the preceding memory store instruction. Can be determined by the
<本実施形態の効果>
特許文献1では、図3に示したソースプログラムの場合、式3-1に対応するベクトルスキャッター命令4-5は配列Aの先頭アドレスから終端アドレスまでをアクセス範囲と設定するため、ベクトルスキャッター命令4-5とロード命令4-6がアクセスする領域は同じ配列Aで重なりありとみなされ、追い越し不可と判定されていた。即ち、実際にはアドレスの重複がない領域にアクセスするにも関わらず追い越し不可と判定していた。これに対して、本実施形態では、ループの繰返し単位でのメモリアクセス範囲の解析機能により、特許文献1で追い越し不可と判定していた命令であっても追い越し制御が可能となる。これにより、ロード命令がストア命令を待ち合わせることによるメモリアクセスの性能低下が軽減され、プログラムの実行が高速化される。また、コンパイラでアドレスの重なりの判定を行うことで、ハードウェアで同様の処理を行う場合に比べハードウェアで消費するリソースを節約できること、および、ハードウェア資源の物理的な制約を受けないというメリットがある。さらに、命令の並べ換えなど命令の順序の変更を伴う最適化の適用が促進される効果もある。
<Effect of this embodiment>
In
[第2の実施形態]
次に、本発明の第2の実施形態について説明する。
[Second Embodiment]
Next, a second embodiment of the present invention will be described.
第1の実施形態では、リストベクトル解析部120は、リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出するために必要な情報を配列の宣言情報から取得した。しかし、フォートランの形状引継ぎ配列など、コンパイル時には配列の情報は不明であり、実行時にならないと分からない場合がある。本実施形態では、必要な情報が得られない場合、コンパイラ100は、リストベクトル解析部120でアクセス領域のアドレスを算出する代わりに、実行時にそれらの値を計算する命令(機械語)を生成し、オブジェクトコードに追加する処理を行う。また、コンパイル時にアドレス値が確定しないため、リストアドレス重なり判定部114では追い越しビットVに“0”をセットする。また、Smin、Smaxが指し示すレジスタの内容は例えばNULL値としておく。具体的には、段落[0033]に記載された、(a)配列のベースアドレス、(b)配列の一つの要素のサイズ、(c)配列の次元数、(d)各次元の情報(要素の数、要素間の距離、下限)といった配列の構成に関する情報は、実行時には配列記述子というデータ構造に格納されている。そこで、コンパイラ100のリストベクトル解析部120は、リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出するために必要な情報を配列記述子から取得し、例えば段落[0033]に記載した計算式と同様の計算式を使用してリストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、当該リストベクトル命令の命令語のSmin、Smaxが指し示すレジスタに格納する命令を生成するように構成されている。
In the first embodiment, the list
コンパイラ100がリストベクトル解析部120で生成した上記命令により、ベクトル計算機におけるオブジェクトプログラムの実行時にリストベクトル命令がアクセスするメモリの先頭アドレスと終端アドレスが計算され、レジスタに格納される。ベクトル計算機は、追い越し制御装置においてそのレジスタを参照することで、リストベクトル命令のメモリアクセスの範囲を取得して命令の追い越し制御を実施する。これにより、コンパイル時に静的にアクセス領域のアドレスを算出した場合と同様に命令の追い越し制御を行うことが可能となる。
The instruction generated by the
[第3の実施形態]
次に、本発明の第3の実施形態について説明する。
[Third Embodiment]
Next, a third embodiment of the present invention will be described.
図6は、本実施形態に係るコンピュータのブロック図である。本実施形態に係るコンピュータ200は、ソースプログラム201からベクトル計算機に対するオブジェクトコード202を生成するように構成されている。コンピュータ200は、ループ解析部210とコード生成部220とを含んで構成される。
FIG. 6 is a block diagram of a computer according to the present embodiment. The
ループ解析部210は、ソースプログラム201を解析して、リストベクトルを繰り返し処理するループ制御文を認識するように構成されている。
The
コード生成部220は、ループ解析部210によって認識されたループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳するように構成されている。またコード生成部220は、ループ制御文のループの繰返し毎に、リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定するように構成されている。
The
コンピュータ200は、CPU等のプロセッサとメモリとを有し、ハードディスク等に記録されたプログラムを実行することにより、ループ解析部210およびコード生成部220をコンピュータ上に実現する。
The
このように構成された本実施形態に係るコンピュータ200は、以下のように機能する。即ち、ソースプログラム201がコンピュータ200に入力されると、先ず、ループ解析部210は、ソースプログラム201を解析して、リストベクトルを繰り返し処理するループ制御文を認識する。次に、コード生成部220は、ループ解析部210によって認識されたループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳する。その際、コード生成部220は、ループ制御文のループの繰返し毎に、リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定する。
The
このように本実施形態によれば、適切な追い越し制御が可能である。その理由は、ループ制御文のループの繰返し毎に、リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、先頭アドレスと終端アドレスをリストベクトル命令の命令語に設定するためである。 As described above, according to the present embodiment, appropriate overtaking control is possible. The reason is that the start address and the end address of the memory accessed by the list vector instruction are calculated every time the loop of the loop control statement is repeated, and the start address and the end address are set as the command words of the list vector instruction.
本発明は、コンパイラに適用でき、特にソースプログラムを翻訳してベクトル計算機向けのオブジェクトプログラムを生成するコンパイラに利用できる。 The present invention can be applied to a compiler, and can be particularly used for a compiler that translates a source program to generate an object program for a vector computer.
100…コンパイラ
101…ソースプログラム
102…命令語
110…ループ内命令生成処理部
111…先行命令生成部
112…ベクトルギャザー/スキャッター命令生成部
113…後続命令生成部
114…リストアドレス重なり判定部
120…リストベクトル解析部
130…命令リスト
200…コンピュータ
201…ソースプログラム
202…オブジェクトコード
210…ループ解析部
220…コード生成部
OP…オペコード
V…追い越しビット
VR…アドレスを格納したベクトルレジスタを指定するフィールド
Smin…先頭アドレスを格納したレジスタを指定するフィールド
Smax…終端アドレスを格納したレジスタを指定するフィールド
100 ...
Claims (10)
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳する処理を行わせ、
前記処理では、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する、
コンパイラ。 To a computer that generates an object program for a vector computer from a source program,
The source program is analyzed, and the loop control statement that repeatedly processes the list vector is translated into a series of instruction lists including the list vector instruction.
In the process, the start address and the end address of the memory accessed by the list vector instruction are calculated every time the loop of the loop control statement is repeated, and the start address and the end address are set as the command words of the list vector instruction. do,
compiler.
請求項1に記載のコンパイラ。 In the calculation, when an element of a specific dimension of the array is specified by the list vector, the base address, the size of one element of the array, and the dimension of the array are obtained from the declaration information of the array of the source program. The number and the information of each dimension of the array are acquired, and the start address and the end address are calculated based on the acquired information.
The compiler according to claim 1.
請求項1または2に記載のコンパイラ。 In the process, further, an address range from the start address set in the instruction word of the list vector instruction to the end address and an address range of the memory accessed by another memory access system instruction included in the instruction list. The presence or absence of duplication is determined, and based on the determination result, an overtaking bit in which a predetermined value is set according to the presence or absence of overlap in the program of the address area of the memory access is set in the instruction word.
The compiler according to claim 1 or 2.
請求項3に記載のコンパイラ。 In the determination, when the list vector instruction is a vector gather instruction, the other memory access system instruction is a store instruction preceding the list vector instruction.
The compiler according to claim 3.
請求項3に記載のコンパイラ。 In the determination, when the list vector instruction is a vector scatter instruction, the other memory access system instruction is a load instruction following the list vector instruction.
The compiler according to claim 3.
請求項1乃至5の何れかに記載のコンパイラ。 In the process, if the information required for the calculation cannot be acquired at compile time, the information required for the calculation is acquired at the time of executing the object program, the start address and the end address are calculated, and stored in a predetermined register. Generate instructions,
The compiler according to any one of claims 1 to 5.
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を認識するループ解析部と、
前記ループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳するコード生成部と、を含み、
前記コード生成部は、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する、
コンピュータ。 A computer that generates an object program for a vector computer from a source program.
A loop analysis unit that analyzes the source program and recognizes a loop control statement that repeatedly processes the list vector.
Includes a code generator that translates the loop control statement into a series of instruction lists, including list vector instructions.
The code generation unit calculates the start address and the end address of the memory accessed by the list vector instruction for each loop repetition of the loop control statement, and the start address and the end address are the command words of the list vector instruction. Set to,
Computer.
請求項7に記載のコンピュータ。 When the element of a specific dimension of the array is specified by the list vector, the code generator can obtain the base address, the size of one element of the array, and the array from the declaration information of the array of the source program. The number of dimensions and the information of each dimension of the array are acquired, and the start address and the end address are calculated based on the acquired information.
The computer according to claim 7.
請求項7または8に記載のコンピュータ。 The code generation unit further includes an address range from the start address set in the instruction word of the list vector instruction to the end address and the address of the memory accessed by another memory access system instruction included in the instruction list. The presence or absence of overlap with the range is determined, and based on the determination result, an overtaking bit is set in the instruction word in which a predetermined value is set according to the presence or absence of overlap in the program of the address area of the memory access. do,
The computer according to claim 7 or 8.
前記ソースプログラムを解析して、リストベクトルを繰り返し処理するループ制御文を認識し、
前記ループ制御文を、リストベクトル命令を含む一連の命令リストに翻訳し、
前記翻訳では、前記ループ制御文のループの繰返し毎に、前記リストベクトル命令によってアクセスするメモリの先頭アドレスと終端アドレスを算出し、前記先頭アドレスと前記終端アドレスを前記リストベクトル命令の命令語に設定する、
コンピュータのコード生成方法。 It is a code generation method executed by a computer that generates an object program for a vector computer from a source program.
Analyzing the source program, recognizing the loop control statement that iterates over the list vector,
The loop control statement is translated into a series of instruction lists including list vector instructions.
In the translation, the start address and the end address of the memory accessed by the list vector instruction are calculated for each loop repetition of the loop control statement, and the start address and the end address are set as the command words of the list vector instruction. do,
How to generate code for your computer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018053204A JP7040187B2 (en) | 2018-03-20 | 2018-03-20 | compiler |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018053204A JP7040187B2 (en) | 2018-03-20 | 2018-03-20 | compiler |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2019164704A JP2019164704A (en) | 2019-09-26 |
JP7040187B2 true JP7040187B2 (en) | 2022-03-23 |
Family
ID=68066192
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2018053204A Active JP7040187B2 (en) | 2018-03-20 | 2018-03-20 | compiler |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP7040187B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021161978A1 (en) * | 2020-02-10 | 2021-08-19 | 日本電気株式会社 | Recording medium, instruction generating method, and instruction generating device |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3698027B2 (en) | 2000-07-19 | 2005-09-21 | 日本電気株式会社 | Vector collection / spread instruction execution order controller |
JP3789320B2 (en) | 2001-06-12 | 2006-06-21 | エヌイーシーコンピュータテクノ株式会社 | Vector processing apparatus and overtaking control method using the same |
-
2018
- 2018-03-20 JP JP2018053204A patent/JP7040187B2/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3698027B2 (en) | 2000-07-19 | 2005-09-21 | 日本電気株式会社 | Vector collection / spread instruction execution order controller |
JP3789320B2 (en) | 2001-06-12 | 2006-06-21 | エヌイーシーコンピュータテクノ株式会社 | Vector processing apparatus and overtaking control method using the same |
Also Published As
Publication number | Publication date |
---|---|
JP2019164704A (en) | 2019-09-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11216258B2 (en) | Direct function call substitution using preprocessor | |
US9798528B2 (en) | Software solution for cooperative memory-side and processor-side data prefetching | |
US9015683B2 (en) | Method and apparatus for transforming program code | |
US9176760B2 (en) | Fast, combined forwards-backwards pass global optimization framework for dynamic compilers | |
US9329867B2 (en) | Register allocation for vectors | |
US20190121625A1 (en) | Dynamic compiler parallelism techniques | |
US8402429B2 (en) | Generating object code that uses calculated contents for a variable determined from a predicate | |
US20070226723A1 (en) | Efficient generation of SIMD code in presence of multi-threading and other false sharing conditions and in machines having memory protection support | |
JPH11259437A (en) | Reducing system for unnecessary barrier instruction | |
US9424004B2 (en) | Execution guards in dynamic programming | |
JP2002091777A (en) | Compiler and register assigning method therefor | |
CN114416045A (en) | Method and device for automatically generating operator | |
KR20160074154A (en) | Compiler | |
Su et al. | An efficient GPU implementation of inclusion-based pointer analysis | |
JP7040187B2 (en) | compiler | |
US8516468B2 (en) | Multiversioning if statement merging and loop fusion | |
JP2002297399A (en) | METHOD FOR GIVING ϕ FUNCTION FOR PERFORMING STATIC SINGLE SUBSTITUTION | |
Ştirb et al. | Improving performance and energy consumption with loop fusion optimization and parallelization | |
US20030135535A1 (en) | Transferring data between threads in a multiprocessing computer system | |
CN114041116A (en) | Method and device for optimizing data movement task | |
US20200409746A1 (en) | Information processing apparatus and recording medium | |
US20170344351A1 (en) | Information processing apparatus, compiling management method, and recording medium | |
US11922152B2 (en) | Workload oriented constant propagation for compiler | |
US11734003B2 (en) | Non-transitory computer-readable recording medium, compilation method, and compiler device | |
US20210157638A1 (en) | Method and apparatus for functional unit assignment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20210209 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20220126 |
|
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: 20220208 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220221 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 7040187 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |