JP2019012324A - compiler - Google Patents

compiler Download PDF

Info

Publication number
JP2019012324A
JP2019012324A JP2017127370A JP2017127370A JP2019012324A JP 2019012324 A JP2019012324 A JP 2019012324A JP 2017127370 A JP2017127370 A JP 2017127370A JP 2017127370 A JP2017127370 A JP 2017127370A JP 2019012324 A JP2019012324 A JP 2019012324A
Authority
JP
Japan
Prior art keywords
list structure
structure data
register
vector
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2017127370A
Other languages
Japanese (ja)
Other versions
JP6907761B2 (en
Inventor
健人 岩川
Taketo Iwakawa
健人 岩川
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP2017127370A priority Critical patent/JP6907761B2/en
Publication of JP2019012324A publication Critical patent/JP2019012324A/en
Application granted granted Critical
Publication of JP6907761B2 publication Critical patent/JP6907761B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

To eliminate the limitations on an increase in speed of a method for vectorizing a loop control statement by using a work array.SOLUTION: A computer which generates an object program to a vector computer from a source program comprises: a loop analysis unit which recognizes a loop control statement which repeatedly processes list structure data by analyzing the source program; and a vectorization execution unit which vectorizes the loop control statement. The vectorization execution unit inserts a first program portion and a second program portion into the object program. The first program portion writes the initial address of each node of the list structure data in a vector register, and writes the number of nodes of the list structure data in a scalar register. The second program portion vectorizes the loop control statement, by using the initial address of each node of the list structure data written in the vector register and the number of nodes of the list structure data written in the scalar register.SELECTED DRAWING: Figure 15

Description

本発明は、コンパイラ、コンピュータ、およびコンピュータのコード生成方法に関する。   The present invention relates to a compiler, a computer, and a computer code generation method.

リスト構造データは、自分自身と同じ型の構造体へのポインタをメンバに持つデータであり、自己参照構造体とも呼ばれる。リスト構造データは、追加や削除が頻繁に行われる大量のデータを処理するのに適している。   The list structure data is data having a pointer to a structure of the same type as itself as a member, and is also called a self-reference structure. The list structure data is suitable for processing a large amount of data that is frequently added and deleted.

図1は、リスト構造データstruct Aにより形成されるリストのメモリ上の構成を示す図である。図1中、1つの矩形が1つの構造体1−1を表す。構造体はノードとも呼ばれる。この例の構造体は、double型データx,y,zとポインタnextをメンバにもつ。firstは、リスト構造データstruct Aの並びの区間の先頭のアドレスを表す。addr1,…,addrNは、各構造体の先頭アドレスを表す。lastは、リスト構造データstruct Aの並びの区間の終了アドレスを表す。   FIG. 1 is a diagram showing a structure of a list formed by list structure data struct A on a memory. In FIG. 1, one rectangle represents one structure 1-1. Structures are also called nodes. The structure of this example has double type data x, y, z and a pointer next as members. “first” represents the head address of the section of the list structure data “struct A”. addr1,..., addrN represent the head addresses of the respective structures. “last” represents the end address of the section of the list structure data “struct A”.

図2は、リスト構造データstruct Aを処理するループ制御文を持つC言語のソースプログラムの一例を示す図である。文2−1は、リスト構造データstruct Aのデータ宣言文である。リスト構造データstruct Aが自分自身を再帰的に指している。文4−2は、リストをたどりリスト構造データstruct Aを繰り返し処理するループ制御文である。   FIG. 2 is a diagram illustrating an example of a C language source program having a loop control statement for processing the list structure data struct A. A statement 2-1 is a data declaration statement of the list structure data struct A. The list structure data struct A points to itself recursively. A statement 4-2 is a loop control statement for repeatedly processing the list structure data struct A by following the list.

そして、図2に示すようなリスト構造データstruct Aを処理するループ制御文を含むプログラムの高速化を可能にするコンパイラが、例えば特許文献1に記載されている。図13は、特許文献1に記載のコンパイラによるループ制御文の変形結果を示す図である。図13を参照すると、特許文献1に記載のコンパイラは、ループ制御文13−1を文13−2〜13−5のように変形することによって、リスト構造データを含むループをベクトル化している。ここで、文13−2は、リスト構造データstruct Aのノード数をカウントする制御文である。また、文13−3は、メモリ上に作業配列を確保する宣言文である。また、文13−4は、確保した作業配列にリスト構造データstruct Aの各ノードの先頭アドレスを登録する制御文である。そして、文13−5が、作業配列の配列要素を参照するための添字を使って元のループ制御文13−1と等価な処理を行うループ制御文である。   For example, Patent Document 1 discloses a compiler that can speed up a program including a loop control statement that processes list structure data struct A as shown in FIG. FIG. 13 is a diagram illustrating a modification result of the loop control statement by the compiler described in Patent Document 1. In FIG. Referring to FIG. 13, the compiler described in Patent Document 1 vectorizes a loop including list structure data by transforming the loop control statement 13-1 into statements 13-2 to 13-5. Here, the sentence 13-2 is a control sentence that counts the number of nodes of the list structure data struct A. A statement 13-3 is a declaration statement that secures a work array on the memory. A statement 13-4 is a control statement for registering the head address of each node of the list structure data struct A in the secured work array. The statement 13-5 is a loop control statement that performs processing equivalent to the original loop control statement 13-1 using a subscript for referring to the array element of the work array.

特開2003−337707号公報JP 2003-337707 A

特許文献1に記載のコンパイラは、リスト構造データの先頭アドレスをメモリ上の作業配列に割り当てるようにして、リスト構造データを繰り返し処理するループ制御文のベクトル化を行っている。しかしながら、プログラム実行時にメモリ上の作業配列へのアクセスが行われるため、実行速度の高速化には限度がある。   The compiler described in Patent Document 1 vectorizes a loop control statement that repeatedly processes list structure data by assigning the head address of the list structure data to a work array on the memory. However, since access to the work array on the memory is performed when the program is executed, there is a limit to increasing the execution speed.

本発明の目的は、上述した課題、即ち、作業配列を使ってループ制御文をベクトル化する方法では高速化に限度がある、という課題を解決するコンパイラを提供することにある。   An object of the present invention is to provide a compiler that solves the above-mentioned problem, that is, the problem that the method of vectorizing a loop control statement using a work array has a limitation in speeding up.

本発明の一形態に係るコンパイラは、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータに、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識する処理と、
前記ループ制御文をベクトル化する処理を行わせ、
前記ベクトル化する処理では、
前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入する。
A compiler according to one aspect of the present invention
To a computer that generates an object program for a vector computer from a source program,
Processing for recognizing a loop control statement for repeatedly processing list structure data by analyzing the source program;
Let the loop control statement be vectorized,
In the process of vectorization,
During the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
insert.

また、本発明の他の形態に係るコンピュータは、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータであって、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識するループ解析部と、
前記ループ制御文をベクトル化するベクトル化実行部と、
を含み、
前記ベクトル化実行部は、前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入するように構成されている。
A computer according to another embodiment of the present invention is also provided.
A computer that generates an object program for a vector computer from a source program,
A loop analysis unit that recognizes a loop control statement that analyzes the source program and repeatedly processes the list structure data;
A vectorization execution unit for vectorizing the loop control statement;
Including
The vectorization execution unit includes the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
Configured to insert.

また、本発明の他の形態に係るコンピュータのコード生成方法は、
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータが実行するコード生成方法であって、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識し、
前記ループ制御文をベクトル化し、
前記ベクトル化では、
前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入する。
A computer code generation method according to another aspect of the present invention includes:
A code generation method executed by a computer that generates an object program for a vector computer from a source program,
Recognizing a loop control statement that repeatedly processes list structure data by analyzing the source program,
Vectorize the loop control statement;
In the vectorization,
During the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
insert.

本発明は上述した構成を有することにより、作業配列を使ってループ制御文をベクトル化するのに比べて、ループ制御文の実行速度の高速化が可能になる。   Since the present invention has the above-described configuration, it is possible to increase the execution speed of the loop control statement as compared with the case where the loop control statement is vectorized using the work arrangement.

リスト構造データstruct Aにより形成されるリストのメモリ上の構成を示す図である。It is a figure which shows the structure on the memory of the list | wrist formed by list structure data struct A. FIG. リスト構造データstruct Aを処理するループ制御文を持つC言語のソースプログラムの一例を示す図である。It is a figure which shows an example of the C language source program which has a loop control statement which processes list structure data struct A. FIG. ベクトル化するリスト構造データの各先頭アドレスを格納するベクトルレジスタとベクトル収集命令の処理の説明図である。It is explanatory drawing of the process of the vector register which stores each head address of the list structure data to vectorize, and a vector collection command. ベクトル化するリスト構造データの各先頭アドレスを格納するベクトルレジスタとベクトル拡散命令の処理の説明図である。It is explanatory drawing of the process of the vector register which stores each head address of the list structure data to vectorize, and a vector spread instruction. 本発明の第1の実施形態に係るコンパイラの構成例を示す図である。It is a figure which shows the structural example of the compiler which concerns on the 1st Embodiment of this invention. 本発明の第1の実施形態におけるVLIST2命令の対象となる、区間の最後がNULL(終端文字)と決めているリスト構造データにより形成されるリストのメモリ上の構成とベクトルレジスタの内容を示す図である。The figure which shows the structure on the memory of the list | wrist formed by the list structure data which the object of the VLIST2 instruction in the 1st Embodiment of this invention determines the last of the area as NULL (terminal character), and the content of the vector register It is. 本発明の第1の実施形態におけるVLIST2命令の対象となる、リスト構造データにより形成されるリストのメモリ上の構成とベクトルレジスタの内容を示す図である。It is a figure which shows the structure on the memory of the list | wrist formed by list structure data used as the object of the VLIST2 instruction | indication in the 1st Embodiment of this invention, and the content of a vector register. 本発明の第1の実施形態におけるソースプログラムから生成される命令列の例を示す図である。It is a figure which shows the example of the command sequence produced | generated from the source program in the 1st Embodiment of this invention. 本発明の第1の実施形態におけるソースプログラムから生成される他の命令列の例を示す図である。It is a figure which shows the example of the other instruction sequence produced | generated from the source program in the 1st Embodiment of this invention. 本発明の第1の実施形態におけるソースプログラムから生成される別の命令列の例を示す図である。It is a figure which shows the example of another instruction sequence produced | generated from the source program in the 1st Embodiment of this invention. 本発明の第1の実施形態で使用するマスク生成命令とマスク先行ゼロカウント命令の処理の説明図である。It is explanatory drawing of a process of the mask production | generation instruction | indication and mask leading zero count instruction | indication used in the 1st Embodiment of this invention. 本発明の第1の実施形態におけるソースプログラムから生成される更に別の命令列の例を示す図である。It is a figure which shows the example of another instruction sequence produced | generated from the source program in the 1st Embodiment of this invention. 本発明に関連するコンパイラによってソースプログラムから生成される命令列の例を示す図である。It is a figure which shows the example of the instruction sequence produced | generated from the source program by the compiler relevant to this invention. 本発明の第1の実施形態に係るコンパイラを実現するコンピュータのハードウェア構成の一例を示す図である。It is a figure which shows an example of the hardware constitutions of the computer which implement | achieves the compiler which concerns on the 1st Embodiment of this invention. 本発明の第2の実施形態に係るコンパイラのブロック図である。It is a block diagram of the compiler which concerns on the 2nd Embodiment of this invention.

次に本発明の実施の形態について図面を参照して詳細に説明する。
[第1の実施形態]
図5を参照すると、本発明の第1の実施形態に係るコンパイラ5は、ソースプログラム5−3を翻訳してオブジェクトコード5−4を生成する。生成されたオブジェクトコードは、ベクトル計算機で実行される。このようにコンパイラ5は、ベクトル計算機に対するオブジェクトプログラムを生成する。
Next, embodiments of the present invention will be described in detail with reference to the drawings.
[First embodiment]
Referring to FIG. 5, the compiler 5 according to the first embodiment of the present invention translates the source program 5-3 to generate an object code 5-4. The generated object code is executed by a vector computer. Thus, the compiler 5 generates an object program for the vector computer.

コンパイラ5は、ループ解析部5−1とベクトル化実行部5−2とを含んで構成されている。   The compiler 5 includes a loop analysis unit 5-1 and a vectorization execution unit 5-2.

ループ解析部5−1は、ソースプログラム5−3を解析してリスト構造データを含むループのベクトル化ができるか否かを判定する。ループ解析部5−1は、リスト構造データを含むループの認識手段(以下、認識手段と呼ぶ)5−1−1、リスト構造データの構造解析手段(以下、構造解析手段と呼ぶ)5−1−2、および、ベクトル化判定手段5−1−3を含んで構成されている。   The loop analysis unit 5-1 analyzes the source program 5-3 and determines whether or not the loop including the list structure data can be vectorized. The loop analysis unit 5-1 includes a loop recognizing unit (hereinafter referred to as a recognizing unit) 5-1-1 including list structure data, and a structure analyzing unit for list structure data (hereinafter referred to as a structural analyzing unit) 5-1. -2 and vectorization determination means 5-1-3.

認識手段5−1−1は、ソースプログラム5−3中のリスト構造データを含むループを検出する。構造解析手段5−1−2は、認識手段5−1−1で検出したループに含まれるリスト構造を解析する。ベクトル化判定手段5−1−3は、認識手段5−1−1で検出したループがベクトル化できるか否かを判定する。   The recognition unit 5-1-1 detects a loop including the list structure data in the source program 5-3. The structure analysis unit 5-1-2 analyzes the list structure included in the loop detected by the recognition unit 5-1-1. The vectorization determination unit 5-1-3 determines whether the loop detected by the recognition unit 5-1-1 can be vectorized.

ベクトル化実行部5−2は、ループ解析部5−1の解析結果に基づきループをベクトル化する。ベクトル化実行部5−2は、リスト構造先頭アドレス・リスト構造ノード数取得命令生成手段(以下、VLIST命令生成手段と呼ぶ)5−2−1、ベクトル長ロード命令生成手段5−2−2、ベクトル収集命令生成手段5−2−3、ベクトル演算命令生成手段5−2−4、および、ベクトル拡散命令生成手段5−2−5を含んで構成されている。   The vectorization execution unit 5-2 vectorizes the loop based on the analysis result of the loop analysis unit 5-1. The vectorization execution unit 5-2 includes a list structure start address / list structure node number acquisition instruction generation unit (hereinafter referred to as a VLIST instruction generation unit) 5-2-1, a vector length load instruction generation unit 5-2-2, A vector collection instruction generation unit 5-2-3, a vector operation instruction generation unit 5-2-4, and a vector diffusion instruction generation unit 5-2-5 are included.

VLIST命令生成手段5−2−1は、リスト構造の先頭アドレスのリストおよびリスト構造データのノード数を取得するベクトル命令であるリスト構造先頭アドレス・リスト構造ノード数取得命令(以下、VLIST命令と呼ぶ)を生成する。ベクトル長ロード命令生成手段5−2−2は、VLIST命令によって取得されたノード数をベクトル長に設定するベクトル長ロード命令を生成する。ベクトル収集命令生成手段5−2−3は、メモリ上のリスト構造データをベクトルレジスタにロードするベクトル収集命令を生成する。ベクトル演算命令生成手段5−2−4は、ベクトルレジスタにロードされたデータの演算を行い、演算結果をベクトルレジスタに格納するベクトル演算命令を生成する。ベクトル拡散命令生成手段5−2−5は、ベクトルレジスタに格納された演算結果を、メモリ上のリスト構造データにストアするベクトル拡散命令を生成する。   The VLIST instruction generation means 5-2-1 is a list structure start address / list structure node number acquisition instruction (hereinafter referred to as a VLIST instruction) which is a vector instruction for acquiring the list of list structure start addresses and the number of nodes of list structure data. ) Is generated. The vector length load instruction generating unit 5-2-2 generates a vector length load instruction for setting the number of nodes acquired by the VLIST instruction as a vector length. The vector collection instruction generation unit 5-2-3 generates a vector collection instruction for loading the list structure data on the memory into the vector register. The vector operation instruction generation unit 5-2-4 performs an operation on the data loaded in the vector register, and generates a vector operation instruction for storing the operation result in the vector register. The vector spread instruction generating unit 5-2-5 generates a vector spread instruction for storing the operation result stored in the vector register in the list structure data on the memory.

コンパイラ5は、例えば図14に示すようなパーソナルコンピュータ等の情報処理装置14−1とプログラム14−2とで実現することができる。情報処理装置14−1は、キーボードやマウスなどの操作入力部14−1−1と、液晶ディスプレイ等の画面表示部14−1−2と、通信インタフェース部14−1−3と、メモリやハードディスク等の記憶部14−1−4と、1以上のマイクロプロセッサ等の演算処理部14−1−5とを有する。プログラム14−2は、情報処理装置14−1の立ち上げ時等に外部のコンピュータ読み取り可能な記憶媒体から記憶部14−1−4に読み込まれ、演算処理部14−1−5の動作を制御することにより、演算処理部14−1−5上に、コンパイラ5を実現する。   The compiler 5 can be realized by an information processing device 14-1 such as a personal computer and a program 14-2 as shown in FIG. The information processing apparatus 14-1 includes an operation input unit 14-1-1 such as a keyboard and a mouse, a screen display unit 14-1-2 such as a liquid crystal display, a communication interface unit 14-1-3, a memory and a hard disk. Storage unit 14-1-4 and the like, and an arithmetic processing unit 14-1-5 such as one or more microprocessors. The program 14-2 is read from an external computer-readable storage medium into the storage unit 14-1-4 when the information processing apparatus 14-1 is started up, and controls the operation of the arithmetic processing unit 14-1-5. Thus, the compiler 5 is realized on the arithmetic processing unit 14-1-5.

<本実施形態の説明>
次に、図1〜図12を用いてコンパイラ5の動作について説明する。
<Description of this embodiment>
Next, the operation of the compiler 5 will be described with reference to FIGS.

図2は、前述したように、リスト構造データを含むループを有するC言語のソースプログラムである。コンパイラ5のループ解析部5−1は、このようなループを有するソースプログラム5−3を解析する。   FIG. 2 is a C language source program having a loop including list structure data as described above. The loop analysis unit 5-1 of the compiler 5 analyzes the source program 5-3 having such a loop.

まず、認識手段5−1−1は、ソースプログラム5−3中から図2のループ制御文2−2のような、ループ内にリスト構造データを持つループを検出する。   First, the recognition unit 5-1-1 detects a loop having list structure data in the loop, such as the loop control statement 2-2 in FIG. 2, from the source program 5-3.

次に、構造解析手段5−1−2は、検出されたループに含まれるリスト構造データを解析する。リスト構造データの解析では、リスト構造データ内の次のノードを指すポインタがリスト構造データ内のどの位置にあるかを解析する。図2に示したリスト構造データにおいて、double型データを8バイトとすると、x,y,zの後に位置するnextは、ノードの先頭アドレスから24バイト目に位置することとなる。つまり、図2に示すリスト構造データでは、次のノードを指すポインタの位置はノードの先頭から24バイト目となる。   Next, the structure analysis unit 5-1-2 analyzes the list structure data included in the detected loop. In the analysis of the list structure data, the position in the list structure data where the pointer pointing to the next node in the list structure data is analyzed is analyzed. In the list structure data shown in FIG. 2, when double type data is 8 bytes, the next located after x, y, z is located at the 24th byte from the head address of the node. That is, in the list structure data shown in FIG. 2, the position of the pointer pointing to the next node is the 24th byte from the head of the node.

次に、コンパイラ5のベクトル化判定手段5−1−3は、検出されたループがベクトル化できるか否かを判定する。ベクトル化できる条件としては、ループ内のリスト構造データ、配列、変数の定義・参照関係にベクトル化を阻害する依存関係がないことが挙げられる。   Next, the vectorization determination unit 5-1-3 of the compiler 5 determines whether or not the detected loop can be vectorized. As a condition that can be vectorized, the list structure data, the array, and the definition / reference relationship of the variables in the loop have no dependency that inhibits vectorization.

ループ解析部5−1の処理が終わると、ベクトル化実行部5−2による処理が行われる。ベクトル化実行部5−2は、ループ解析部5−1におってベクトル化できると判定されたリスト構造データを含むループを、以下のようにベクトル化する。   When the processing of the loop analysis unit 5-1 ends, the processing by the vectorization execution unit 5-2 is performed. The vectorization execution unit 5-2 vectorizes the loop including the list structure data determined to be vectorizable by the loop analysis unit 5-1, as follows.

まず、VLIST命令生成手段5−2−1は、ベクトル化するリスト構造データの各先頭アドレスのリストとリスト構造データのノードの個数をレジスタにロードするためのVLIST命令を生成する。このVLIST命令が実行されることによって、ベクトル化するリスト構造データの各先頭アドレスがベクトルレジスタに格納される。例えば、図3に示すfirstからlastまでの区間のリスト構造データに対してVLIST命令が実行されると、図3に示すように、リスト構造データの各先頭アドレスのリストがベクトルレジスタ3−1に格納される。また、VLIST命令によって、リスト構造データのノードの個数が図示しないスカラレジスタに格納される。VLIST命令の詳細については後述する。   First, the VLIST instruction generation means 5-2-1 generates a VLIST instruction for loading a list of each top address of the list structure data to be vectorized and the number of nodes of the list structure data into a register. By executing this VLIST instruction, each head address of the list structure data to be vectorized is stored in the vector register. For example, when the VLIST instruction is executed on the list structure data in the section from first to last shown in FIG. 3, a list of each head address of the list structure data is stored in the vector register 3-1, as shown in FIG. Stored. Further, the number of nodes of the list structure data is stored in a scalar register (not shown) by the VLIST instruction. Details of the VLIST instruction will be described later.

次に、ベクトル長ロード命令生成手段5−2−2は、VLIST命令により得られたノードの個数をベクトル長として設定する。   Next, the vector length load instruction generation unit 5-2-2 sets the number of nodes obtained by the VLIST instruction as the vector length.

次に、ベクトル収集命令生成手段5−2−3は、ベクトル収集命令を生成する。ベクトル収集命令は、ベクトルレジスタの各要素に格納されているアドレスのメモリデータを、別のベクトルレジスタの対応する要素に格納するように、メモリからデータをロードするものである。ベクトル収集命令生成手段5−2−3は、VLIST命令により得られたリスト構造データの先頭アドレスのリストを格納するベクトルレジスタ3−1を指定したベクトル収集命令を生成する。これによって、図3に示すように、ベクトルレジスタ3−1の各要素に格納されているアドレスのメモリデータを、メモリ3−2からベクトルレジスタ3−3へロードするベクトル収集命令が生成される。   Next, the vector collection command generation unit 5-2-3 generates a vector collection command. The vector collection instruction is to load data from the memory so that the memory data at the address stored in each element of the vector register is stored in the corresponding element of another vector register. The vector collection instruction generation unit 5-2-3 generates a vector collection instruction designating the vector register 3-1 for storing the list of the top addresses of the list structure data obtained by the VLIST instruction. As a result, as shown in FIG. 3, a vector collection instruction for loading the memory data at the address stored in each element of the vector register 3-1 from the memory 3-2 to the vector register 3-3 is generated.

次に、ベクトル演算命令生成手段5−2−4は、ベクトル収集命令によりベクトルレジスタ3−3へロードされたデータを指定してベクトル演算を実行し、結果を別のベクトルレジスタへ格納するベクトル演算命令を生成する。   Next, the vector operation instruction generation means 5-2-4 executes the vector operation by designating the data loaded to the vector register 3-3 by the vector collection instruction, and stores the result in another vector register. Generate instructions.

次に、ベクトル拡散命令生成手段5−2−5は、ベクトル拡散命令を生成する。ベクトル拡散命令は、ベクトルレジスタの各要素に格納されているアドレスのメモリ領域へ、別のベクトルレジスタの対応する要素のデータを格納するように、メモリにデータをストアするものである。ベクトル拡散命令生成手段5−2−5は、ベクトル演算命令により得られた演算結果を格納するベクトルレジスタおよびリスト構造データの先頭アドレスのリストを格納するベクトルレジスタを指定したベクトル拡散命令を生成する。これによって、図4に示すように、ベクトルレジスタ4−3に格納されているベクトル演算により得られた演算結果を、ベクトルレジスタ4−1に格納されているリスト構造データの先頭アドレスのメモリ4−2の領域へストアするベクトル拡散命令が生成される。   Next, the vector spread instruction generating unit 5-2-5 generates a vector spread instruction. The vector spread instruction stores data in the memory so that the data of the corresponding element of another vector register is stored in the memory area of the address stored in each element of the vector register. The vector diffusion instruction generating means 5-2-5 generates a vector diffusion instruction specifying a vector register for storing the operation result obtained by the vector operation instruction and a vector register for storing the list of the top addresses of the list structure data. As a result, as shown in FIG. 4, the operation result obtained by the vector operation stored in the vector register 4-3 is stored in the memory 4-4 at the head address of the list structure data stored in the vector register 4-1. A vector spread instruction to store in the two areas is generated.

次に、VLIST命令の例について詳述する。   Next, an example of the VLIST instruction will be described in detail.

<VLIST命令の例1>
一つ目の例のVLIST命令(以下、VLIST1命令と呼ぶ)は、以下のように、オペランドの所定のフィールドで、%v0,%s0,%s1,%s2,%s3の合計5個のレジスタを指定する構成とされている。
VLIST1命令 %v0,%s0,%s1,%s2,%s3
<Example 1 of VLIST instruction>
The VLIST instruction (hereinafter referred to as the VLIST1 instruction) of the first example has a total of five registers of% v0,% s0,% s1,% s2, and% s3 in a predetermined field of the operand as follows. It is configured to specify.
VLIST1 instruction% v0,% s0,% s1,% s2,% s3

%v0は、リスト構造データの各ノードの先頭アドレスを書込むベクトルレジスタである。%s0は、リスト構造データのノードの個数を書込むスカラレジスタである。%s1は、命令の対象となるリスト構造データの区間の先頭のアドレス(図1のfirst)を指すスカラレジスタである。%s2は、命令の対象となるリスト構造データの区間の末尾のアドレス(図1のlast)を指すスカラレジスタである。%s3は、命令の対象となるリスト構造データの構造解析手段5−1−2により取得したリスト構造内の次のデータのポインタの位置(図1のnext)を指すスカラレジスタである。   % V0 is a vector register for writing the head address of each node of the list structure data. % S0 is a scalar register for writing the number of nodes of list structure data. % S1 is a scalar register indicating the head address (first in FIG. 1) of the section of the list structure data that is the target of the instruction. % S2 is a scalar register that points to the last address (last in FIG. 1) of the section of the list structure data that is the target of the instruction. % S3 is a scalar register indicating the position of the pointer (next in FIG. 1) of the next data in the list structure acquired by the structure analysis unit 5-1-2 of the list structure data to be instructed.

VLIST1命令を命令セットに含むベクトル計算機では、VLIST1命令が発行されると、スカラレジスタ%s1、%s2、および%s3で指定されるfirst、last、nextによって特定されるリスト構造データの各ノードの先頭アドレスを取得してベクトルレジスタ%v0に格納する処理と、ノードの個数を計数してスカラレジスタ%s0に格納する処理とが、1命令に係る処理として行われる。   In the vector computer including the VLIST1 instruction in the instruction set, when the VLIST1 instruction is issued, each node of the list structure data specified by the first, last, and next specified by the scalar registers% s1,% s2, and% s3 The process of acquiring the start address and storing it in the vector register% v0 and the process of counting the number of nodes and storing it in the scalar register% s0 are performed as processes related to one instruction.

<VLIST命令の例2>
二つ目の例のVLIST命令(以下、VLIST2命令と呼ぶ)は、以下のように、オペランドの所定のフィールドで、%v0,%s0,%s1,%s2の合計4個のレジスタを指定する構成とされている。
VLIST2命令 %v0,%s0,%s1,%s2
<Example 2 of VLIST instruction>
The VLIST instruction (hereinafter referred to as the VLIST2 instruction) of the second example specifies a total of four registers of% v0,% s0,% s1, and% s2 in a predetermined field of the operand as follows: It is configured.
VLIST2 instruction% v0,% s0,% s1,% s2

%v0は、リスト構造データの各ノードの先頭アドレスを書込むベクトルレジスタである。%s0は、リスト構造データのノードの個数を書込むスカラレジスタである。%s1は、命令の対象となるリスク構造データの区間の先頭のアドレス(図1のfirst)を指すスカラレジスタである。%s2は、命令の対象となるリスト構造データの構造解析手段5−1−2により取得したリスト構造内の次のデータのポインタの位置(図1のnext)を指すスカラレジスタである。一つ目の例のVLIST1命令とは異なり、VLIST2命令は、命令の対象となるリスト構造データの区間の末尾のアドレス(図1のlast)を指すオペランドはない。その理由は、VLIST2命令は、図6の6−1のNULLに示すように、区間の最後はNULL(終端文字)と決めているためである。このように、VLIST2命令は、区間の末尾のアドレスを指すスカラレジスタを減らして、オペランド数を削減している。   % V0 is a vector register for writing the head address of each node of the list structure data. % S0 is a scalar register for writing the number of nodes of list structure data. % S1 is a scalar register indicating the head address (first in FIG. 1) of the section of the risk structure data that is the target of the instruction. % S2 is a scalar register indicating the position (next in FIG. 1) of the pointer of the next data in the list structure acquired by the structure analysis unit 5-1-2 of the list structure data to be instructed. Unlike the VLIST1 instruction in the first example, the VLIST2 instruction does not have an operand indicating the end address (last in FIG. 1) of the section of the list structure data that is the target of the instruction. The reason is that the VLIST2 instruction determines that the end of the section is NULL (terminal character) as indicated by NULL of 6-1 in FIG. As described above, the VLIST2 instruction reduces the number of operands by reducing the number of scalar registers indicating the end address of the section.

VLIST2命令を命令セットに含むベクトル計算機では、VLIST2命令が発行されると、スカラレジスタ%s1および%s2で指定されるfirst、nextによって特定されるリスト構造データの各ノードの先頭アドレスを取得してベクトルレジスタ%v0に格納する処理と、ノードの個数を計数してスカラレジスタ%s0に格納する処理とが、1命令に係る処理として行われる。   In a vector computer including the VLIST2 instruction in the instruction set, when the VLIST2 instruction is issued, the head address of each node of the list structure data specified by the first and next specified by the scalar registers% s1 and% s2 is obtained. Processing for storing in the vector register% v0 and processing for counting the number of nodes and storing in the scalar register% s0 are performed as processing related to one instruction.

<VLIST命令の例3>
三つ目の例のVLIST命令(以下、VLIST3命令と呼ぶ)は、以下のように、オペランドの所定のフィールドで、%v0,%s0,%s1,%s2の合計4個のレジスタを指定する構成とされている。
VLIST3命令 %v0,%s0,%s1,%s2
<Example 3 of VLIST instruction>
The VLIST instruction of the third example (hereinafter referred to as VLIST3 instruction) specifies a total of four registers of% v0,% s0,% s1, and% s2 in a predetermined field of the operand as follows: It is configured.
VLIST3 instruction% v0,% s0,% s1,% s2

%v0は、リスト構造データの各ノードの先頭アドレスを書込むベクトルレジスタである。%s0は、リスト構造データの区間の先頭のアドレス(図1のfirst)を指すスカラレジスタである。%s1は、リスト構造データの区間の末尾のアドレス(図1のlast)を指すスカラレジスタである。%s2は、リスト構造データの構造解析手段5−1−2により取得したリスト構造内の次のデータのポインタの位置(図1のnext)を指すスカラレジスタである。VLIST1,VLIST2とは異なり、VLIST3には、リスト構造データのノードの個数を書込むスカラレジスタを指定するオペランドは無い。   % V0 is a vector register for writing the head address of each node of the list structure data. % S0 is a scalar register indicating the head address (first in FIG. 1) of the section of the list structure data. % S1 is a scalar register indicating the end address (last in FIG. 1) of the section of the list structure data. % S2 is a scalar register indicating the position of the next data pointer (next in FIG. 1) in the list structure acquired by the structure analysis means 5-1-2 of the list structure data. Unlike VLIST1 and VLIST2, VLIST3 does not have an operand that specifies a scalar register for writing the number of nodes of list structure data.

VLIST3命令を命令セットに含むベクトル計算機では、VLIST3命令が発行されると、スカラレジスタ%s0、%s1、および%s2で指定されるfirst、last、nextによって特定されるリスト構造データの各ノードの先頭アドレスを取得して、図7に示すようにベクトルレジスタ%v0(7−1)に格納する処理と、末尾のアドレスの次の要素をNULL(終端文字)にする処理とが、1命令に係る処理として行われる。ここで、ベクトルレジスタ7−1の末尾のアドレスの次の要素をNULL(終端文字)にする理由は、ベクトルレジスタ7−1の何番目の要素までアドレスを格納したかを把握することができるようにするためである。ノードの個数の算出は、VLIST3命令に引き続く別の命令によって行われる(詳細は図10を参照して後述する)。   In the vector computer including the VLIST3 instruction in the instruction set, when the VLIST3 instruction is issued, each node of the list structure data specified by the first, last, and next specified by the scalar registers% s0,% s1, and% s2 The process of acquiring the start address and storing it in the vector register% v0 (7-1) as shown in FIG. 7 and the process of making the next element of the end address NULL (terminal character) are in one instruction. This process is performed. Here, the reason why the element next to the end address of the vector register 7-1 is NULL (termination character) is that it is possible to grasp up to which element of the vector register 7-1 the address has been stored. It is to make it. The calculation of the number of nodes is performed by another instruction subsequent to the VLIST3 instruction (details will be described later with reference to FIG. 10).

<VLIST命令の例4>
四つ目の例のVLIST命令(以下、VLIST4と呼ぶ)は、以下のように、オペランドの所定のフィールドで、%v0,%s0,%s1の合計3個のレジスタを指定する構成とされている。
VLIST4命令 %v0,%s0,%s1
<Example 4 of VLIST instruction>
The VLIST instruction of the fourth example (hereinafter referred to as VLIST4) is configured to specify a total of three registers of% v0,% s0, and% s1 in a predetermined field of the operand as follows. Yes.
VLIST4 instruction% v0,% s0,% s1

%v0は、リスト構造データの各先頭アドレスを書込むベクトルレジスタである。%s0は、リスト構造データの区間の先頭のアドレス(図1のfirst)を指すスカラレジスタである。%s1は、リスト構造データの構造解析手段5−1−2により取得したリスト構造内の次のデータのポインタの位置(図1のnext)を指すスカラレジスタである。VLIST4命令は、三つ目の例のVLIST3命令から区間の末尾のアドレス(図1のlast)を指すスカラレジスタのオペランドを無くした例である。VLIST4命令は、二つ目の例のVLIST2命令と同様に、区間の最後はNULL(終端文字)と決めてオペランド数を減らしている。   % V0 is a vector register for writing each head address of the list structure data. % S0 is a scalar register indicating the head address (first in FIG. 1) of the section of the list structure data. % S1 is a scalar register indicating the position of the next data pointer (next in FIG. 1) in the list structure acquired by the structure analysis unit 5-1-2 of the list structure data. The VLIST4 instruction is an example in which the operand of the scalar register indicating the last address of the section (last in FIG. 1) is eliminated from the VLIST3 instruction of the third example. Similarly to the VLIST2 instruction in the second example, the VLIST4 instruction determines the end of the section as NULL (terminal character) and reduces the number of operands.

VLIST4命令を命令セットに含むベクトル計算機では、VLIST4命令が発行されると、スカラレジスタ%s0および%s1で指定されるfirst、nextによって特定されるリスト構造データの各ノードの先頭アドレスを取得して、ベクトルレジスタ%v0に格納する処理と、末尾のアドレスの次の要素をNULL(終端文字)にする処理とが、1命令に係る処理として行われる。また、ノードの個数の算出は、VLIST3命令と同様に、VLIST4命令に引き続く別の命令によって行われる。   In a vector computer including the VLIST4 instruction in the instruction set, when the VLIST4 instruction is issued, the head address of each node of the list structure data specified by the first and next specified by the scalar registers% s0 and% s1 is obtained. The process of storing in the vector register% v0 and the process of setting the element next to the end address to NULL (termination character) are performed as processes related to one instruction. Further, the calculation of the number of nodes is performed by another instruction subsequent to the VLIST4 instruction, similarly to the VLIST3 instruction.

次に、図2に示したソースプログラムをコンパイルしたときに生成される命令列の例を図8〜図10、図12を参照して説明する。   Next, examples of instruction sequences generated when the source program shown in FIG. 2 is compiled will be described with reference to FIGS. 8 to 10 and FIG.

<命令列の例1>
図8は、VLIST1命令を用いた場合に生成される命令列である。最初のVLIST1命令は、リスト構造データの各ノードの先頭アドレスのリストをベクトルレジスタvreg1にロードし、そのノードの個数をスカラレジスタsreg1にロードする。次のLVL命令(ベクトル長ロード命令)は、スカラレジスタsreg1によりノードの個数を指定してベクトル長をロードする。次のVGT命令(ベクトル収集命令)は、ベクトルレジスタvreg1を指定してxのデータをメモリからベクトルレジスタvreg2にロードしている。次のVADD命令(ベクトル加算命令)は、yのアドレスのリストをベクトルレジスタvreg3に格納する。即ち、yのデータはxの次に位置するためdouble型を8バイトとすると、yはstruct Aの先頭から8バイト目に位置することになる。そのため、先頭アドレスのリスト(vreg1)にVADD命令で8を加算した演算結果をベクトルレジスタvreg3に格納している。次のVGT命令は、ベクトルレジスタvreg3を指定してyのデータをメモリからベクトルレジスタvreg4にロードする。次のVMUL命令(ベクトル乗算命令)は、ベクトルレジスタvreg2,vreg4にロードしたx,yを乗算し、演算結果をベクトルレジスタvreg5に格納する。つぎのVADD命令は、zのアドレスのリストをベクトルレジスタvreg6に格納する。即ち、zのデータはsruct Aの先頭から16バイト目に位置するので、先頭アドレスのリストに16を加算した演算結果をベクトルレジスタvreg6に格納している。次のVSC命令(ベクトル拡散命令)は、ベクトルレジスタvreg6を指定して、ベクトルレジスタvreg5の乗算結果を各ノードのzの位置へストアする。
<Example of instruction sequence 1>
FIG. 8 shows an instruction sequence generated when the VLIST1 instruction is used. The first VLIST1 instruction loads a list of head addresses of each node of the list structure data into the vector register vreg1, and loads the number of the nodes into the scalar register sreg1. The next LVL instruction (vector length load instruction) loads the vector length by specifying the number of nodes by the scalar register sreg1. The next VGT instruction (vector collection instruction) designates the vector register vreg1 and loads the data of x from the memory into the vector register vreg2. The next VADD instruction (vector addition instruction) stores a list of addresses of y in the vector register vreg3. That is, since the data of y is positioned next to x, assuming that the double type is 8 bytes, y is positioned at the 8th byte from the beginning of struct A. For this reason, the operation result obtained by adding 8 to the list (vreg1) of the top address by the VADD instruction is stored in the vector register vreg3. The next VGT instruction specifies the vector register vreg3 and loads y data from the memory into the vector register vreg4. The next VMUL instruction (vector multiplication instruction) multiplies x and y loaded in the vector registers vreg2 and vreg4, and stores the operation result in the vector register vreg5. The next VADD instruction stores a list of z addresses in the vector register vreg6. That is, since the data of z is located at the 16th byte from the head of struct A, the operation result obtained by adding 16 to the list of head addresses is stored in the vector register vreg6. The next VSC instruction (vector spread instruction) designates the vector register vreg6 and stores the multiplication result of the vector register vreg5 in the position of z of each node.

<命令列の例2>
図9は、VLIST2命令を用いた場合に生成される命令列である。リスト構造データの末尾をNULL(終端文字)と決めているため、VLIST2命令が使用される。それ以外は図8とは変わらない。
<Example 2 of instruction sequence>
FIG. 9 shows an instruction sequence generated when the VLIST2 instruction is used. Since the end of the list structure data is determined to be NULL (terminal character), the VLIST2 instruction is used. Other than that, it is not different from FIG.

<命令列の例3>
図10は、VLIST3命令を用いた場合に生成される命令列である。前述したように、VLIST3命令では、リスト構造データの先頭アドレスのリストをベクトルレジスタにロードするとき、末尾のアドレスの次の要素をNULL(終端文字)にする。即ち、VLIST3命令でリスト構造データの先頭アドレスをロードしたときのベクトルレジスタは、図11のベクトルレジスタ11−1のようになり、最後の要素がNULLとなる。そこで、図10の命令列では、VFMK.EQ命令(マスク生成命令)により、図11に示すように、ベクトルレジスタ11−2にマスクを生成する。VFMK.EQ命令ではオペランドの所定のフィールドで指定されたベクトルレジスタvreg1(11−1)の要素がNULLと等しい場合は1、それ以外は0の要素となるマスクをオペランドの所定のフィールドで指定されたマスクレジスタに生成する。そして、生成されたマスクを指定したLZVM命令(マスク先行ゼロカウント命令)を続ける。LZVM命令は、オペランドの所定のフィールドで指定されたベクトルレジスタ11−2のマスクの先頭から0がいくつ連続して続くかをカウントし、そのカウント結果であるノードの個数をオペランドの所定のフィールドで指定された図11のスカラレジスタ11−3(sreg1)に格納する。その後は図8、図9と同様である。
<Example 3 of instruction sequence>
FIG. 10 shows an instruction sequence generated when the VLIST3 instruction is used. As described above, in the VLIST3 instruction, when the list of the top address of the list structure data is loaded into the vector register, the element next to the end address is set to NULL (terminal character). That is, the vector register when the head address of the list structure data is loaded with the VLIST3 instruction is the vector register 11-1 in FIG. 11, and the last element is NULL. Therefore, in the instruction sequence of FIG. An EQ instruction (mask generation instruction) generates a mask in the vector register 11-2 as shown in FIG. VFMK. In the case of the EQ instruction, a mask that is 1 when the element of the vector register vreg1 (11-1) specified in the predetermined field of the operand is equal to NULL, and 0 that is otherwise, is specified by the predetermined field of the operand. Generate to register. Then, the LZVM instruction (mask leading zero count instruction) specifying the generated mask is continued. The LZVM instruction counts how many zeros continue from the beginning of the mask of the vector register 11-2 specified in the predetermined field of the operand, and the number of nodes as the count result is determined in the predetermined field of the operand. The data is stored in the designated scalar register 11-3 (sreg1) in FIG. The subsequent steps are the same as those shown in FIGS.

<命令列の例4>
図12は、VLIST4命令を用いた場合に生成される命令列である。リスト構造データの末尾をNULL(終端文字)と決めているためVLIST4命令が使用される。それ以外は図10とは変わらない。
<Example 4 of instruction sequence>
FIG. 12 shows an instruction sequence generated when the VLIST4 instruction is used. Since the end of the list structure data is determined to be NULL (terminal character), the VLIST4 instruction is used. Other than that, it is not different from FIG.

<本実施形態の効果>
このように本実施形態によれば、リスト構造データを含むループ制御文のベクトル化が可能となる。そして、ループのベクトル化によりプログラムの実行性能を向上させることができる。
<Effect of this embodiment>
As described above, according to the present embodiment, it is possible to vectorize a loop control statement including list structure data. The program execution performance can be improved by loop vectorization.

また、特許文献1では、図13の文13−3、13−4のように作業配列のメモリを確保してリスト構造データの各ノードの先頭アドレスをストアする。これに対して本実施形態では、リスト構造データの各ノードの先頭アドレスをベクトルレジスタに直接ロードする。そのためメモリの確保は不要である。また、作業配列であるメモリがベクトルレジスタに置き換わるためデータ転送も高速になる。   Further, in Patent Document 1, a work array memory is secured as in sentences 13-3 and 13-4 in FIG. 13, and the head address of each node of list structure data is stored. On the other hand, in the present embodiment, the head address of each node of the list structure data is directly loaded into the vector register. Therefore, it is not necessary to secure memory. Further, since the memory as the work array is replaced with a vector register, data transfer is also performed at high speed.

また、特許文献1においては、リスト構造データのノード数のカウントと先頭アドレスのストアのために図13の文13−2、13−4のように2回ループでリスト構造をたどっている。これに対して本実施形態では、VLIST命令により1回リスト構造をたどるだけでよく処理を減らせる。   In Patent Document 1, the list structure is traced in a loop twice as shown in sentences 13-2 and 13-4 in FIG. 13 for counting the number of nodes in the list structure data and storing the head address. On the other hand, in the present embodiment, the processing can be reduced only by following the list structure once by the VLIST instruction.

本実施形態は、以上の構成および動作を基本としつつ、各種の付加変更が可能である。例えば、ベクトル長が最大ベクトル長(ベクトルレジスタの要素数)を超える場合は、コンパイラ5は、最大ベクトル長のノード数を処理した後、リスト構造データの先頭アドレスがロードされたベクトルレジスタの最後尾のノードの次のノードから処理を再開することで、最大ベクトル長を超えるループを処理する。   In the present embodiment, various additions and changes can be made based on the above configuration and operation. For example, when the vector length exceeds the maximum vector length (the number of elements of the vector register), the compiler 5 processes the number of nodes of the maximum vector length, and then the tail end of the vector register loaded with the top address of the list structure data. A loop exceeding the maximum vector length is processed by resuming the processing from the node next to the current node.

[第2の実施形態]
図15を参照すると、本発明の第2の実施形態に係るコンピュータ15は、ソースプログラム15−3からベクトル計算機に対するオブジェクトプログラム15−4を生成するために、ループ解析部15−1とベクトル化実行部15−2とを含んで構成される。
[Second Embodiment]
Referring to FIG. 15, the computer 15 according to the second embodiment of the present invention performs vectorization execution with the loop analysis unit 15-1 in order to generate an object program 15-4 for the vector computer from the source program 15-3. Part 15-2.

ループ解析部15−1は、ソースプログラム15−3を解析してリスト構造データを繰り返し処理するループ制御文を認識する。ループ解析部15−1は、例えば図5のループ解析部5−1と同様に構成することができるが、それに限定されない。ベクトル化実行部15−2は、ループ解析部15−1で認識されたループ制御文をベクトル化する。ベクトル化実行部15−2は、例えば図5のベクトル化実行部5−2と同様に構成することができるが、それに限定されない。   The loop analysis unit 15-1 analyzes the source program 15-3 and recognizes a loop control statement that repeatedly processes the list structure data. The loop analysis unit 15-1 can be configured in the same manner as the loop analysis unit 5-1, for example, in FIG. 5, but is not limited thereto. The vectorization execution unit 15-2 vectorizes the loop control statement recognized by the loop analysis unit 15-1. The vectorization execution unit 15-2 can be configured, for example, in the same manner as the vectorization execution unit 5-2 in FIG. 5, but is not limited thereto.

ベクトル化実行部15−2は、オブジェクトプログラム15−4中に、第1のプログラム部分15−5と第2のプログラム部分15−6とを挿入するように構成されている。第1のプログラム部分15−5は、リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、リスト構造データのノード数をスカラレジスタに書き込む命令を含んでいる。第2のプログラム部分15−6は、ベクトルレジスタに書き込まれたリスト構造データの各ノードの先頭アドレスとスカラレジスタに書き込まれたリスト構造データのノード数とを使って、ループ制御文をベクトル化している。   The vectorization execution unit 15-2 is configured to insert a first program part 15-5 and a second program part 15-6 into the object program 15-4. The first program part 15-5 includes an instruction for writing the head address of each node of the list structure data into the vector register and writing the number of nodes of the list structure data into the scalar register. The second program portion 15-6 vectorizes the loop control statement using the head address of each node of the list structure data written in the vector register and the number of nodes of the list structure data written in the scalar register. Yes.

次に、本実施形態に係るコンピュータ15によるコード生成方法について説明する。   Next, a code generation method by the computer 15 according to the present embodiment will be described.

まず、ループ解析部15−1は、ソースプログラム15−3を解析してリスト構造データを繰り返し処理するループ制御文を認識する。次に、ベクトル化実行部15−2は、ループ制御文をベクトル化したオブジェクトプログラム15−4を生成する。上記ベクトル化では、オブジェクトプログラム15−4中に、第1のプログラム部分15−5と第2のプログラム部分15−6をと挿入する。   First, the loop analysis unit 15-1 analyzes the source program 15-3 and recognizes a loop control statement that repeatedly processes the list structure data. Next, the vectorization execution unit 15-2 generates an object program 15-4 in which the loop control statement is vectorized. In the vectorization, the first program part 15-5 and the second program part 15-6 are inserted into the object program 15-4.

このように本実施形態によれば、作業配列を使ってループ制御文をベクトル化するのに比べて、リスト構造データを繰り返し処理するループ制御文の実行速度の高速化が可能になる。   As described above, according to the present embodiment, it is possible to increase the execution speed of the loop control statement that repeatedly processes the list structure data, compared to vectorizing the loop control statement using the work array.

その理由は、オブジェクトプログラム15−4は、リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込む第1のプログラム部分15−5と、ベクトルレジスタに書き込まれたリスト構造データの各ノードの先頭アドレスを使ってループ制御文をベクトル化する第2のプログラム部分15−6とを含んで構成されているためである。   The reason is that the object program 15-4 has a first program part 15-5 for writing the start address of each node of the list structure data to the vector register, and the start address of each node of the list structure data written to the vector register. This is because it includes the second program portion 15-6 that vectorizes the loop control statement using.

本発明は、HPC(High−Performance−Computing)分野、ベクトルプロセッサを有する計算機に利用でき、特にリスト構造データを繰り返し処理するループ制御文を含むソースプログラムをコンパイルしてオブジェクトプログラムを生成する分野に利用できる。   The present invention can be used in the field of HPC (High-Performance-Computing), a computer having a vector processor, and particularly in the field of generating an object program by compiling a source program including a loop control statement for repeatedly processing list structure data. it can.

1−1…構造体(ノード)
2−1…リンク構造体のデータ宣言文
2−2…ループ制御文
3−1…ベクトルレジスタ
3−2…メモリ
3−3…ベクトルレジスタ
4−1…ベクトルレジスタ
4−2…メモリ
4−3…ベクトルレジスタ
5…コンパイラ
5−1…ループ解析部
5−1−1…リスト構造データを含むループの認識手段
5−1−2…リスト構造データの構造解析手段
5−1−3…ベクトル化判定手段
5−2…ベクトル化実行部
5−2−1…リスト構造先頭アドレス・リスト構造ノード数取得命令生成手段
5−2−2…ベクトル長ロード命令生成手段
5−2−3…ベクトル収集命令生成手段
5−2−4…ベクトル演算命令生成手段
5−2−5…ベクトル拡散命令生成手段
5−3…ソースプログラム
5−4…オブジェクトコード
6−1…NULL(終端文字)
7−1…ベクトルレジスタ
11−1…ベクトルレジスタ
11−2…マスクレジスタ
11−3…スカラレジスタ
13−1…ループ制御文
13−2〜13−5…文
14−1…情報処理装置
14−2…プログラム
14−1−1…操作入力部
14−1−2…画面表示部
14−1−3…通信インタフェース部
14−1−4…記憶部
14−1−5…演算処理部
15…コンピュータ
15−1…ループ解析部
15−2…ベクトル化実行部
15−3…ソースプログラム
15−4…オブジェクトプログラム
15−5…第1のプログラム部分
15−6…第2のプログラム部分
1-1 ... Structure (node)
2-1 ... link structure data declaration statement 2-2 ... loop control statement 3-1 ... vector register 3-2 ... memory 3-3 ... vector register 4-1 ... vector register 4-2 ... memory 4-3 ... Vector register 5... Compiler 5-1. Loop analysis section 5-1-1... Loop recognition means including list structure data 5-1-2. Structure analysis means for list structure data 5-1-3. 5-2 ... Vectorization execution unit 5-2-1 ... List structure start address / list structure node number acquisition instruction generation means 5-2-2 ... Vector length load instruction generation means 5-2-3 ... Vector collection instruction generation means 5-2-4 Vector calculation instruction generation means 5-2-5 Vector diffusion instruction generation means 5-3 Source program 5-4 Object code 6-1 NULL (Terminal character)
7-1 ... Vector register 11-1 ... Vector register 11-2 ... Mask register 11-3 ... Scalar register 13-1 ... Loop control statements 13-2 to 13-5 ... Statement 14-1 ... Information processing device 14-2 ... Program 14-1-1 ... Operation input unit 14-1-2 ... Screen display unit 14-1-3 ... Communication interface unit 14-1-4 ... Storage unit 14-1-5 ... Operation processing unit 15 ... Computer 15 -1 ... Loop analysis unit 15-2 ... Vectorization execution unit 15-3 ... Source program 15-4 ... Object program 15-5 ... First program part 15-6 ... Second program part

Claims (7)

ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータに、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識する処理と、
前記ループ制御文をベクトル化する処理を行わせ、
前記ベクトル化する処理では、
前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入する、
コンパイラ。
To a computer that generates an object program for a vector computer from a source program,
Processing for recognizing a loop control statement for repeatedly processing list structure data by analyzing the source program;
Let the loop control statement be vectorized,
In the process of vectorization,
During the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
insert,
compiler.
前記第1のプログラム部分は、第1のベクトル命令を含み、
前記第1のベクトル命令は、オペランドの所定のフィールドで、リスト構造データの各ノードの先頭アドレスを書込むベクトルレジスタ%v0、リスト構造データのノードの個数を書込むスカラレジスタ%s0,リスト構造データの区間の先頭のアドレスを指すスカラレジスタ%s1,リスト構造データの区間の末尾のアドレスを指すスカラレジスタ%s2,リスト構造内の次のデータのポインタの位置を指すスカラレジスタ%s3を指定する構成とされている、
請求項1に記載のコンパイラ。
The first program portion includes a first vector instruction;
The first vector instruction is a predetermined field of an operand, a vector register% v0 for writing the head address of each node of list structure data, a scalar register% s0 for writing the number of nodes of list structure data, and list structure data A structure for designating a scalar register% s1 that points to the start address of a section of data, a scalar register% s2 that points to the end address of the section of list structure data, and a scalar register% s3 that points to the position of the pointer of the next data in the list structure It is said that
The compiler according to claim 1.
前記第1のプログラム部分は、第2のベクトル命令を含み、
前記第2のベクトル命令は、オペランドの所定のフィールドで、リスト構造データの各ノードの先頭アドレスを書込むベクトルレジスタ%v0,リスト構造データのノードの個数を書込むスカラレジスタ%s0,リスク構造データの区間の先頭のアドレスを指すスカラレジスタ%s1,リスト構造内の次のデータのポインタの位置を指すスカラレジスタ%s2を指定する構成とされている、
請求項1に記載のコンパイラ。
The first program portion includes a second vector instruction;
The second vector instruction is a predetermined field of an operand, a vector register% v0 for writing the head address of each node of list structure data, a scalar register% s0 for writing the number of nodes of list structure data, and risk structure data A scalar register% s1 that points to the head address of the section of, and a scalar register% s2 that points to the position of the next data pointer in the list structure.
The compiler according to claim 1.
前記第1のプログラム部分は、第3のベクトル命令とマスク生成命令とマスク先行ゼロカウント命令を含み、
前記第3のベクトル命令は、オペランドの所定のフィールドで、リスト構造データの各ノードの先頭アドレスおよび終端を示す終端文字を書込むベクトルレジスタ%v0,リスト構造データの区間の先頭のアドレスを指すスカラレジスタ%s0,リスト構造データの区間の末尾のアドレスを指すスカラレジスタ%s1,リスト構造内の次のデータのポインタの位置を指すスカラレジスタ%s2を指定する構成とされ、
前記マスク生成命令は、オペランドの所定のフィールドで、前記ベクトルレジスタ%v0,マスクを生成するレジスタmreg1を指定する構成とされ、
前記マスク先行ゼロカウント命令は、オペランドの所定のフィールドで、前記レジスタmreg1,前記マスクの先頭から0が連続する数をノードの個数として格納するスカラレジスタを指定する構成とされている、
請求項1に記載のコンパイラ。
The first program part includes a third vector instruction, a mask generation instruction, and a mask leading zero count instruction;
The third vector instruction is a predetermined field of the operand, a vector register% v0 for writing the start address and end character indicating the end of each node of the list structure data, and a scalar indicating the start address of the section of the list structure data. The register% s0, the scalar register% s1 indicating the end address of the list structure data section, and the scalar register% s2 indicating the position of the pointer of the next data in the list structure are designated.
The mask generation instruction is configured to designate the vector register% v0 and a register mreg1 for generating a mask in a predetermined field of an operand.
The mask leading zero count instruction is configured to designate a scalar register that stores, as a number of nodes, the register mreg1, a number of consecutive zeros from the top of the mask, in a predetermined field of an operand.
The compiler according to claim 1.
前記第1のプログラム部分は、第4のベクトル命令とマスク生成命令とマスク先行ゼロカウント命令を含み、
前記第4のベクトル命令は、オペランドの所定のフィールドで、リスト構造データの各先頭アドレスおよび終端を示す終端文字を書込むベクトルレジスタ%v0,リスト構造データの区間の先頭のアドレスを指すスカラレジスタ%s0,リスト構造内の次のデータのポインタの位置(図1のnext)を指すスカラレジスタ%s1を指定する構成とされ、
前記マスク生成命令は、オペランドの所定のフィールドで、前記ベクトルレジスタ%v0,マスクを生成するレジスタmreg1を指定する構成とされ、
前記マスク先行ゼロカウント命令は、オペランドの所定のフィールドで、前記レジスタmreg1,前記マスクの先頭から0が連続する数をノードの個数として格納するスカラレジスタを指定する構成とされている、
請求項1に記載のコンパイラ。
The first program part includes a fourth vector instruction, a mask generation instruction, and a mask leading zero count instruction;
The fourth vector instruction is a predetermined field of the operand, a vector register% v0 for writing each head address of the list structure data and a terminal character indicating the end, and a scalar register% indicating the head address of the section of the list structure data s0, and is configured to designate a scalar register% s1 that points to the position of the next data pointer in the list structure (next in FIG. 1).
The mask generation instruction is configured to designate the vector register% v0 and a register mreg1 for generating a mask in a predetermined field of an operand.
The mask leading zero count instruction is configured to designate a scalar register that stores, as a number of nodes, the register mreg1, a number of consecutive zeros from the top of the mask, in a predetermined field of an operand.
The compiler according to claim 1.
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータであって、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識するループ解析部と、
前記ループ制御文をベクトル化するベクトル化実行部と、
を含み、
前記ベクトル化実行部は、前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入するように構成されている、
コンピュータ。
A computer that generates an object program for a vector computer from a source program,
A loop analysis unit that recognizes a loop control statement that analyzes the source program and repeatedly processes the list structure data;
A vectorization execution unit for vectorizing the loop control statement;
Including
The vectorization execution unit includes the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
Configured to insert,
Computer.
ソースプログラムからベクトル計算機に対するオブジェクトプログラムを生成するコンピュータが実行するコード生成方法であって、
前記ソースプログラムを解析してリスト構造データを繰り返し処理するループ制御文を認識し、
前記ループ制御文をベクトル化し、
前記ベクトル化では、
前記オブジェクトプログラム中に、
前記リスト構造データの各ノードの先頭アドレスをベクトルレジスタに書き込み、前記リスト構造データのノード数をスカラレジスタに書き込む第1のプログラム部分と、
前記ベクトルレジスタに書き込まれた前記リスト構造データの各ノードの先頭アドレスと前記スカラレジスタに書き込まれた前記リスト構造データのノード数とを使って、前記ループ制御文をベクトル化した第2のプログラム部分とを、
挿入する、
コンピュータのコード生成方法。
A code generation method executed by a computer that generates an object program for a vector computer from a source program,
Recognizing a loop control statement that repeatedly processes list structure data by analyzing the source program,
Vectorize the loop control statement;
In the vectorization,
During the object program,
A first program part for writing a head address of each node of the list structure data to a vector register, and writing a number of nodes of the list structure data to a scalar register;
A second program part in which the loop control statement is vectorized using the start address of each node of the list structure data written to the vector register and the number of nodes of the list structure data written to the scalar register And
insert,
Computer code generation method.
JP2017127370A 2017-06-29 2017-06-29 compiler Active JP6907761B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017127370A JP6907761B2 (en) 2017-06-29 2017-06-29 compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017127370A JP6907761B2 (en) 2017-06-29 2017-06-29 compiler

Publications (2)

Publication Number Publication Date
JP2019012324A true JP2019012324A (en) 2019-01-24
JP6907761B2 JP6907761B2 (en) 2021-07-21

Family

ID=65226372

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017127370A Active JP6907761B2 (en) 2017-06-29 2017-06-29 compiler

Country Status (1)

Country Link
JP (1) JP6907761B2 (en)

Also Published As

Publication number Publication date
JP6907761B2 (en) 2021-07-21

Similar Documents

Publication Publication Date Title
US7577936B2 (en) Optimization of conversion of a character coding system
US7917899B2 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
JP2001166949A (en) Method and device for compiling source code by using symbolic execution
US9182960B2 (en) Loop distribution detection program and loop distribution detection method
JP3318051B2 (en) Translation processing method
JP6907761B2 (en) compiler
JP4719415B2 (en) Information processing system and code generation method
JP2011129102A (en) Method and device for endian conversion
JP3887097B2 (en) COMPILING METHOD, COMPILING DEVICE, AND COMPUTER-READABLE STORAGE MEDIUM CONTAINING COMPILING PROGRAM
JP3196625B2 (en) Parallel compilation method
Tanaka et al. A code selection method for SIMD processors with PACK instructions
KR20040044655A (en) Method of generating bytecodes for loop in java virtual machine and processing the bytecodes
US10949181B1 (en) Computing performance for execution of functions called by function handles
JPH02176938A (en) Machine language instruction optimizing system
JPS61110240A (en) Optimization compiler
JPH0379741B2 (en)
JP2701246B2 (en) Compiler vectorization method
JPH11212807A (en) Program execution method
JP2001142719A (en) Compiler device and recording medium with recorded compiler program
JPH11195011A (en) Language translation processor, language translation processing method and record medium recording language translation processing program
JPH0514300B2 (en)
JP2005222262A (en) Loop merging method and program code generation method
JP2002140198A (en) Inline development method
JPH0497484A (en) Vectorization processing system for compiler
JP2004139369A (en) Analysis method for pointer pointing constant address domain

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20200512

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20210324

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20210413

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20210518

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: 20210601

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20210614

R150 Certificate of patent or registration of utility model

Ref document number: 6907761

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150