JPH05324346A - Vectorization system - Google Patents

Vectorization system

Info

Publication number
JPH05324346A
JPH05324346A JP15276192A JP15276192A JPH05324346A JP H05324346 A JPH05324346 A JP H05324346A JP 15276192 A JP15276192 A JP 15276192A JP 15276192 A JP15276192 A JP 15276192A JP H05324346 A JPH05324346 A JP H05324346A
Authority
JP
Japan
Prior art keywords
loop
loop structure
information table
intermediate text
generating
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
JP15276192A
Other languages
Japanese (ja)
Other versions
JP3057904B2 (en
Inventor
Yuji Yokoya
雄司 横谷
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 JP4152761A priority Critical patent/JP3057904B2/en
Publication of JPH05324346A publication Critical patent/JPH05324346A/en
Application granted granted Critical
Publication of JP3057904B2 publication Critical patent/JP3057904B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Abstract

PURPOSE:To generate an object program which can execute without a problem and without being affected by a loop length at the time of execution even when the loop length of a loop which needs operation arrangement at the time of vectorization is not identified at the time of compiling. CONSTITUTION:A loop structure selection means 5 selects loop structure where the loop length of the loop needing operation arrangement at the time of vectorization is not identified based on the results of the processing of a loop structure analyzation means 3 and a vectorization means 4. A loop structure deformation means 6 generates a third intermediate text 13 which likely processes by securing the operation arrangement of the number of elements for the loop length if the operation arrangement of such number of the elements can be secured at the time of execution and can likely process by the operation arrangement of the maximum number of the elements, which can be secured if the operation arrangement of such number of the elements can not be secured from a second intermediate text 11. An object program generation means 7 generates the object program 8 from the third intermediate program 13.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は高級言語で記述された原
始プログラムを入力してベクトル計算機に対する目的プ
ログラムを生成するコンパイラにおけるベクトル化方式
に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a vectorization method in a compiler which inputs a source program written in a high level language and generates an object program for a vector computer.

【0002】[0002]

【従来の技術】ベクトル演算命令を持つ計算機(ベクト
ル計算機)においては、複数の規則的に並んだデータ列
(ベクトルデータ)間の演算をベクトル命令により一度
に高速に実行できる。FORTRAN言語のような高級
言語で記述された原始プログラムを翻訳してベクトル計
算機に対する目的プログラムを生成するコンパイラにお
いては、原始プログラムを解析して可能な限りベクトル
命令を用いて処理するような命令列を生成する。これを
ベクトル化と呼ぶ。ベクトル化は通常ループ構造に対し
て行われる。
2. Description of the Related Art In a computer having a vector operation instruction (vector computer), an operation between a plurality of regularly arranged data strings (vector data) can be executed at a high speed by a vector instruction. In a compiler that translates a source program written in a high-level language such as FORTRAN language to generate an object program for a vector computer, an instruction sequence that analyzes the source program and processes it using vector instructions as much as possible is used. To generate. This is called vectorization. Vectorization is usually performed on the loop structure.

【0003】ところで、ベクトル化を行う場合、作業用
配列が必要となる場合がある。
By the way, when performing vectorization, a work array may be required.

【0004】例えば、ベクトル演算の結果を全てメモリ
上に格納する方式のベクトル計算機では、図2に示すF
ORTRAN言語で記述されたループをベクトル化する
場合、代入文の右辺の式 B(I)+C(I)*D(I) に対し、C(I)*D(I)の中間結果を格納するため
の作業用配列を用意する必要がある。
For example, in a vector computer of a system in which all results of vector operations are stored in a memory, F shown in FIG.
When vectorizing a loop written in the ORTRAN language, the intermediate result of C (I) * D (I) is stored for the expression B (I) + C (I) * D (I) on the right side of the assignment statement. It is necessary to prepare a working array for

【0005】一方、ベクトル演算の結果をベクトルレジ
スタに格納する方式のベクトル計算機においては、中間
結果はベクトルレジスタに保存できるので、上の例のよ
うな作業用配列を使う必要はない。しかし、ループ構造
中に、ベクトル処理可能な文とベクトル処理不可能な文
が混在しているため、ループ構造をベクトル処理可能な
部分と不可能な部分に分割して、ベクトル処理可能な部
分のみをベクトル化する方法をとる場合に作業用配列が
必要となることがある。
On the other hand, in a vector computer in which the result of vector operation is stored in a vector register, since the intermediate result can be stored in the vector register, it is not necessary to use the working array as in the above example. However, in the loop structure, statements that can be vector processed and statements that cannot be vector processed are mixed. Therefore, divide the loop structure into vector processable parts and vector processable parts, and only the vector processable parts. A work array may be required when the vectorization method is used.

【0006】例えば、FORTRAN言語で記述された
図3のようなループにおいて、変数Sはベクトル処理で
きる代入文で定義され、ベクトル処理できないWRI
TE文で参照されている。このままではループを分割
することはできないため、ループ全体がベクトル化でき
ない。しかし、変数Sに作業用の配列wを割り当てるこ
とにより図4のようにループの分割が行えるので、代入
文を含むループがベクトル化されるようになる。
For example, in a loop described in FORTRAN language as shown in FIG. 3, a variable S is defined by an assignment statement that can be vector processed, and a WRI that cannot be vector processed.
It is referenced in the TE statement. Since the loop cannot be divided as it is, the entire loop cannot be vectorized. However, by assigning the work array w to the variable S, the loop can be divided as shown in FIG. 4, so that the loop including the assignment statement is vectorized.

【0007】[0007]

【発明が解決しようとする課題】しかしながら、図2や
図3に示すFORTRAN言語で記述されたループで
は、ループの終値が変数Mであるため、作業用配列wの
大きさが実行時にならないとわからない。そのため、従
来技術では、実行時に必要になった場所で必要なだけの
作業領域を確保するような目的プログラムを生成する方
法や、コンパイル時に必要な作業用配列の大きさを仮定
し、その分だけ静的に領域を割り付ける方法がとられて
いた。
However, in the loop described in the FORTRAN language shown in FIGS. 2 and 3, since the loop end value is the variable M, the size of the work array w cannot be known until execution time. .. Therefore, in the conventional technology, a method of generating a target program that secures a necessary work area at a place needed at the time of execution, and the size of a work array required at the time of compilation are assumed, and The method of statically allocating the area was taken.

【0008】しかし、これらの方法で生成された目的プ
ログラムでは、実行時に必要な領域が確保できない場合
やコンパイル時に仮定した大きさより大きかった場合に
は、それ以上実行を続行することができないという問題
があった。
However, in the object program generated by these methods, if the necessary area cannot be secured at the time of execution or the size is larger than the size assumed at the time of compilation, there is a problem that the execution cannot be continued any more. there were.

【0009】本発明はこのような事情に鑑みて為された
ものであり、その目的は、ループ長が実行時にならない
とわからないようなループが作業用配列を必要とする場
合でも、実行時のループ長に制限されずに支障なく実行
を続けることができる目的プログラムを生成するベクト
ル化方式を提供することにある。
The present invention has been made in view of the above circumstances, and an object of the present invention is to execute a loop at the time of execution even if the loop needs a work array whose length is unknown at the time of execution. An object of the present invention is to provide a vectorization method for generating an object program which can be executed without any limitation without being limited in length.

【0010】[0010]

【課題を解決するための手段】本発明は上記の目的を達
成するために、高級言語で書かれた原始プログラムを入
力してベクトル計算機に対する目的プログラムを生成す
るコンパイラのベクトル化方式において、以下のような
手段を備えている。
In order to achieve the above object, the present invention provides a vectorizing method of a compiler for inputting a source program written in a high-level language to generate an object program for a vector computer. Equipped with such means.

【0011】(1)原始プログラム中のループ構造を認
識し、該ループ構造に対する第1中間テキストを生成す
るとともに、該ループ構造の初期値init,終値te
rm,増分値incr,ループ長mおよび指数変数を格
納したループ情報テーブルを生成するループ構造解析手
段 (2)該ループ構造解析手段で求められたループ構造の
第1中間テキストを入力し、ループ構造をベクトル処理
で実行する第2中間テキストに変換するとともに、ベク
トル処理で実行するために必要となる作業用配列の情報
を格納した作業用配列情報テーブルを生成するベクトル
化手段 (3)前記ループ構造解析手段で生成されたループ情報
テーブルと前記ベクトル化手段で生成された作業用配列
情報テーブルを入力し、必要となる作業用配列の大きさ
がコンパイル時には定まらないループ構造を選択するル
ープ構造選択手段 (4)該ループ構造選択手段で選択されたループ構造に
対し、前記ベクトル化手段で生成された第2中間テキス
トと作業用配列情報テーブルおよび前記ループ構造解析
手段で生成されたループ情報テーブルを入力し、ループ
構造の前にループ長m以下で確保可能な最大の要素数の
作業用配列を確保し且つ該確保した要素数を変数nに設
定する処理を行う中間テキストを挿入するとともに、ル
ープ構造を初期値0,終値term−incr,増分値
n×incrで指標変数iを持つ外側ループと初期値i
nit+i,終値min{init+i+(n−1)×
incr,term},増分値incrで指数変数Iの
内側ループからなる2重ループ構造に変形し、ループ中
に現れる作業用配列のI番目の要素の定義,参照を(I
−init−i)/incr+1番目の要素への定義,
参照に置換した第3中間テキストを生成するループ構造
変形手段と、 (5)該ループ構造変形手段で生成された第3中間テキ
ストを入力して目的プログラムを生成する目的プログラ
ム生成手段
(1) Recognizing the loop structure in the source program, generating a first intermediate text for the loop structure, and initializing the initial value init and the final value te of the loop structure.
rm, increment value incr, loop length m, and loop structure analysis means for generating a loop information table storing exponent variables (2) The first intermediate text of the loop structure obtained by the loop structure analysis means is input, and the loop structure is entered. Is converted into a second intermediate text to be executed by vector processing, and a work array information table storing work array information necessary for execution by vector processing is generated. (3) The loop structure Loop structure selecting means for inputting the loop information table generated by the analyzing means and the working array information table generated by the vectorizing means and selecting a loop structure in which the size of the required working array is not determined at compile time (4) For the loop structure selected by the loop structure selection means, the second structure generated by the vectorization means The interworking text, the work sequence information table, and the loop information table generated by the loop structure analysis means are input to secure the work sequence having the maximum number of elements that can be secured with the loop length m or less before the loop structure. An intermediate text for performing the process of setting the secured number of elements in the variable n is inserted, and the loop structure has an initial value 0, a final value term-incr, an increment value n × incr and an outer loop having an index variable i and an initial value i.
nit + i, final price min {init + i + (n-1) ×
incr, term}, with an increment value incr, it is transformed into a double loop structure consisting of an inner loop of the exponent variable I, and the definition and reference of the I-th element of the working array appearing in the loop (I
-Init-i) / incr + 1 definition to the 1st element,
A loop structure modifying means for generating a third intermediate text replaced with a reference, and (5) a target program generating means for generating a target program by inputting the third intermediate text generated by the loop structure modifying means

【0012】また、別の構成においては、上記(4)お
よび(5)のループ構造変形手段および目的プログラム
生成手段に代えて以下の手段を備えている。
Further, in another configuration, the following means is provided in place of the loop structure deforming means and the object program generating means of the above (4) and (5).

【0013】(4’)前記ベクトル化手段で生成された
第2中間テキストと作業用配列情報テーブルおよび前記
ループ構造解析手段で生成されたループ情報テーブルを
入力し、前記ループ構造選択手段で選択されたループ構
造を、コンパイラが適宜定める定数をLとすると、初期
値0,終値term−incr,増分値L×incrで
指標変数iを持つ外側ループと初期値init+i,終
値min{init+i+(L−1)×incr,te
rm},増分値incrで指数変数Iの内側ループから
なる2重ループ構造に変形し、更にループ中に現れる作
業用配列要素の定義,参照を(I−init−i)/i
ncr+1番目の要素への定義,参照に置換した第3中
間テキストを生成するループ構造変形手段 (5’)該ループ構造変形手段で生成された第3中間テ
キストと前記ベクトル化手段で生成された作業用配列情
報テーブルを入力し、大きさLで作業用配列を割り付け
た目的プログラムを生成する目的プログラム生成手段
(4 ') The second intermediate text generated by the vectorizing means, the work sequence information table, and the loop information table generated by the loop structure analyzing means are input and selected by the loop structure selecting means. In the loop structure, where L is a constant appropriately determined by the compiler, an outer loop having an index variable i with an initial value of 0, a final value of term-incr, and an increment value of L × incr, an initial value init + i, and a final value min {init + i + (L-1 ) × incr, te
rm} and the increment value incr are transformed into a double loop structure consisting of an inner loop of the exponent variable I, and the definition and reference of the working array element appearing in the loop are (I-init-i) / i.
Loop structure modification means for generating a third intermediate text, which is replaced with the definition and reference to the ncr + 1th element (5 ′) The third intermediate text generated by the loop structure modification means and the work generated by the vectorization means Program generating means for inputting a sequence information table for use and generating a target program in which a work sequence is allocated with a size L

【0014】[0014]

【作用】本発明のベクトル化方式においては、コンパイ
ラが高級言語で書かれた原始プログラムを入力してベク
トル計算機に対する目的プログラムを生成する際、ルー
プ構造解析手段が、原始プログラム中のループ構造を認
識し、そのループ構造に対する第1中間テキストを生成
するとともに、そのループ構造の初期値init,終値
term,増分値incr,ループ長mおよび指数変数
を格納したループ情報テーブルを生成し、次いでベクト
ル化手段が、ループ構造解析手段で求められたループ構
造の第1中間テキストを入力し、ループ構造をベクトル
処理で実行する第2中間テキストに変換するとともに、
ベクトル処理で実行するために必要となる作業用配列の
情報を格納した作業用配列情報テーブルを生成し、次い
でループ構造選択手段が、ループ構造解析手段で生成さ
れたループ情報テーブルとベクトル化手段で生成された
作業用配列情報テーブルを入力し、必要となる作業用配
列の大きさがコンパイル時には定まらないループ構造を
選択する。
In the vectorization method of the present invention, when the compiler inputs a source program written in a high-level language and generates an object program for a vector computer, the loop structure analysis means recognizes the loop structure in the source program. Then, the first intermediate text for the loop structure is generated, and the loop information table storing the initial value init, the final value term, the increment value incr, the loop length m, and the exponent variable of the loop structure is generated, and then the vectorization means. Inputs the first intermediate text of the loop structure obtained by the loop structure analysis means, converts the loop structure into the second intermediate text to be executed by vector processing, and
A work sequence information table storing work sequence information necessary for execution in vector processing is generated, and then the loop structure selection means uses the loop information table generated by the loop structure analysis means and the vectorization means. Input the generated work array information table and select a loop structure in which the size of the required work array is not determined at compile time.

【0015】そして、手段(4),(5)を備える構成
においては、実行時にループ長分の要素数の作業用配列
が確保できればそのような要素数の作業用配列を確保し
て処理を行うように、またそれだけの要素数の作業用配
列が確保できなければ確保可能な最大の要素数の作業用
配列を確保して処理が続行できるようにするために、ル
ープ構造変形手段が、ループ構造選択手段で選択された
ループ構造に対し、ベクトル化手段で生成された第2中
間テキストと作業用配列情報テーブルおよびループ構造
解析手段で生成されたループ情報テーブルを入力し、ル
ープ構造の前にループ長m以下で確保可能な最大の要素
数の作業用配列を確保し且つこの確保した要素数を変数
nに設定する処理を行う中間テキストを挿入するととも
に、ループ構造を初期値0,終値term−incr,
増分値n×incrで指標変数iを持つ外側ループと初
期値init+i,終値min{init+i+(n−
1)×incr,term},増分値incrで指数変
数Iの内側ループからなる2重ループ構造に変形し、ル
ープ中に現れる作業用配列のI番目の要素の定義,参照
を(I−init−i)/incr+1番目の要素への
定義,参照に置換した第3中間テキストを生成し、目的
プログラム生成手段が、ループ構造変形手段で生成され
た第3中間テキストを入力して目的プログラムを生成す
る。
In the configuration including the means (4) and (5), if the work array having the number of elements corresponding to the loop length can be secured at the time of execution, the work array having such a number of elements is secured to perform the processing. In order to ensure that a work array with such a number of elements cannot be secured and the work array with the maximum number of elements that can be secured is secured so that processing can continue, For the loop structure selected by the selecting means, the second intermediate text generated by the vectorizing means, the work sequence information table, and the loop information table generated by the loop structure analyzing means are input, and the loop is inserted before the loop structure. An intermediate text that secures a work array with the maximum number of elements that can be secured with a length of m or less and sets the secured number of elements in a variable n is inserted. Period value of 0, the closing price term-incr,
An outer loop having an index variable i with an increment value n × incr, an initial value init + i, and a final value min {init + i + (n-
1) × incr, term}, with an increment value incr, it is transformed into a double loop structure consisting of an inner loop of the exponent variable I, and the definition and reference of the I-th element of the working array appearing in the loop are defined as (I-init- i) / incr + 1 Generates a third intermediate text which is replaced with the definition and reference to the 1st element, and the target program generating means inputs the third intermediate text generated by the loop structure transforming means to generate a target program. ..

【0016】また、手段(4’),(5’)を備える構
成においては、コンパイラが適宜定める定数L分の要素
数の作業用配列を静的に確保し、それだけの要素数で処
理が続行できるようにするために、ループ構造変形手段
が、ベクトル化手段で生成された第2中間テキストと作
業用配列情報テーブルおよびループ構造解析手段で生成
されたループ情報テーブルを入力し、ループ構造選択手
段で選択されたループ構造を、初期値0,終値term
−incr,増分値L×incrで指標変数iを持つ外
側ループと初期値init+i,終値min{init
+i+(L−1)×incr,term},増分値in
crで指数変数Iの内側ループからなる2重ループ構造
に変形し、更にループ中に現れる作業用配列要素の定
義,参照を(I−init−i)/incr+1番目の
要素への定義,参照に置換した第3中間テキストを生成
し、目的プログラム生成手段が、ループ構造変形手段で
生成された第3中間テキストとベクトル化手段で生成さ
れた作業用配列情報テーブルを入力し、大きさLで作業
用配列を割り付けた目的プログラムを生成する。
Further, in the configuration provided with the means (4 ') and (5'), the work array having the number of elements corresponding to the constant L determined by the compiler is statically secured, and the processing is continued with that number of elements. In order to be able to do so, the loop structure modification means inputs the second intermediate text generated by the vectorization means, the work sequence information table and the loop information table generated by the loop structure analysis means, and the loop structure selection means. The loop structure selected in is set to the initial value 0 and the final value term.
-Incr, an outer loop having an index variable i with an increment value L x incr, an initial value init + i, and a final value min {init
+ I + (L-1) × incr, term}, increment value in
It is transformed into a double loop structure consisting of the inner loop of the exponent variable I with cr, and the definition and reference of the working array element appearing in the loop is further defined as the definition and reference to the (I-init-i) / incr + 1st element. The replaced third intermediate text is generated, and the object program generating means inputs the third intermediate text generated by the loop structure transforming means and the work array information table generated by the vectorizing means, and operates with the size L. Generates the target program with the allocated arrays.

【0017】[0017]

【実施例】次に本発明の実施例について図面を参照して
詳細に説明する。
Embodiments of the present invention will now be described in detail with reference to the drawings.

【0018】図1を参照すると、本発明のベクトル化方
式を適用したコンパイラ2の一実施例は、ループ構造解
析手段3と、ベクトル化手段4と、ループ構造選択手段
5と、ループ構造変形手段6と、目的プログラム生成手
段7とから構成され、原始プログラム1を入力し、目的
プログラム8を生成する。
Referring to FIG. 1, one embodiment of a compiler 2 to which the vectorization method of the present invention is applied is a loop structure analysis means 3, a vectorization means 4, a loop structure selection means 5, and a loop structure modification means. 6 and a target program generating means 7, which inputs the source program 1 and generates a target program 8.

【0019】なお、図1において、9,11,13,1
0,12は、それぞれコンパイラ2が処理の過程で生成
する第1,第2,第3中間テキスト,ループ情報テーブ
ル,作業用配列情報テーブルである。
In FIG. 1, 9, 11, 13, 1
Reference numerals 0 and 12 are the first, second, and third intermediate texts, the loop information table, and the work array information table, which are generated by the compiler 2 in the process of processing.

【0020】以下、各部の機能および動作を説明する。The function and operation of each unit will be described below.

【0021】コンパイラ2は、高級言語で記述された原
始プログラム1を入力し、目的プログラム8を生成す
る。
The compiler 2 inputs the source program 1 described in a high level language and generates a target program 8.

【0022】このとき、ループ構造解析手段3は、原始
プログラム1中に現れるループ構造を認識し、そのルー
プ構造に対する第1中間テキスト9を生成するととも
に、そのループ構造の初期値init,終値term,
増分値incrおよびこれらから求められるループ長
m,それにループ構造の指標変数j=Iを格納したルー
プ情報テーブル10を生成する。
At this time, the loop structure analyzing means 3 recognizes the loop structure appearing in the source program 1 and generates the first intermediate text 9 for the loop structure, and at the same time, the initial value init, the final value term of the loop structure,
The loop information table 10 storing the increment value incr, the loop length m obtained from them, and the index variable j = I of the loop structure is generated.

【0023】例えば図3のループ構造の場合、ループ構
造解析手段3は、初期値init=1,終値term=
M,増分値incr=1で、ループ長m=M,指標変数
j=Iというループ情報テーブル10を生成する。
For example, in the case of the loop structure shown in FIG. 3, the loop structure analyzing means 3 has an initial value init = 1 and a final value term =.
With M and the increment value incr = 1, the loop information table 10 with the loop length m = M and the index variable j = I is generated.

【0024】次に、ベクトル化手段4は、ループ構造の
第1中間テキスト9を入力し、ループ構造をベクトル処
理で実行する第2中間テキスト11に変形する。また、
ベクトル化するために必要となる作業用配列の大きさや
種類などの情報を格納した作業用配列情報テーブル12
を生成する。
Next, the vectorizing means 4 inputs the first intermediate text 9 of the loop structure and transforms the loop structure into the second intermediate text 11 which is executed by vector processing. Also,
Work array information table 12 that stores information such as size and type of work arrays required for vectorization
To generate.

【0025】例えば図3のループ構造の場合、ベクトル
化手段4は図4に示すように、変数Sを作業用配列wで
置換して2つのループ構造に分割し、代入文を含むルー
プ構造をベクトル処理するような第2中間テキスト11
を生成する。また、作業用配列wに対し、置換前の変数
がSで、型は実数型であるといった情報を格納した作業
用配列情報テーブル12を生成する。
For example, in the case of the loop structure shown in FIG. 3, the vectorization means 4 replaces the variable S with the working array w to divide the loop structure into two loop structures, as shown in FIG. Second intermediate text 11 like vector processing
To generate. Further, for the work array w, the work array information table 12 storing information that the variable before replacement is S and the type is a real number type is generated.

【0026】次に、ループ構造選択手段5は、ベクトル
化手段4で生成された作業用配列情報テーブル12およ
びループ構造解析手段3で生成されたループ情報テーブ
ル10を入力し、作業用配列が必要で、しかもループ長
が定数でないため実行時でないと作業用配列の大きさが
決定しないループ構造を変形処理を行う対象として選択
する。
Next, the loop structure selection means 5 inputs the work sequence information table 12 generated by the vectorization means 4 and the loop information table 10 generated by the loop structure analysis means 3, and a work sequence is required. In addition, since the loop length is not a constant, the size of the working array is not determined unless it is executed at the time of execution.

【0027】図3の例は、ループ長が変数Mでコンパイ
ル時にループ長が不明で、しかも変数Sを置換するため
の作業用配列が必要なループ構造であるため、ループ構
造選択手段5によって処理対象として選択される。
In the example of FIG. 3, since the loop length is the variable M, the loop length is unknown at the time of compilation, and a work array for replacing the variable S is required, the loop structure selecting means 5 processes the loop structure. Selected as a target.

【0028】次に、ループ構造変形手段6は、ループ構
造選択手段5で選択されたループ構造の中間テキストを
以下のように変形した第3中間テキスト13を生成す
る。
Next, the loop structure modification means 6 generates the third intermediate text 13 by modifying the intermediate text of the loop structure selected by the loop structure selection means 5 as follows.

【0029】先ず、ベクトル化手段4で生成された第2
中間テキスト11およびループ構造解析手段3で生成さ
れたループ情報テーブル10を入力し、ループ構造の直
前に、ループ長m以下で確保可能な最大の要素数の作業
用配列を確保し、確保した要素数を変数nに設定する処
理を行う中間テキストを挿入する。
First, the second generated by the vectorization means 4
The intermediate text 11 and the loop information table 10 generated by the loop structure analysis unit 3 are input, a work array having the maximum number of elements that can be ensured with a loop length m or less is secured immediately before the loop structure, and the secured elements are secured. Insert an intermediate text that performs the process of setting the number to the variable n.

【0030】次に、そのループ構造を、初期値0,終値
term−incr,増分値n×incrで、指標変数
がiの外側ループと、初期値init+i,終値min
{init+i+(n−1)×incr,term},
増分値incrで指数変数Iの内側ループとからなる2
重ループ構造に変形する。
Next, the loop structure is defined as an outer loop having an initial value 0, a final value term-incr, an increment value n × incr, and an index variable i, and an initial value init + i and a final value min.
{Init + i + (n-1) × incr, term},
2 with an inner loop of exponent variable I with increment value incr
It transforms into a heavy loop structure.

【0031】更に、ループ構造中に現れる作業用配列の
I番目の要素の定義,参照を(I−init−i)/i
ncr+1番目の要素への定義,参照に置換する。
Further, the definition and reference of the I-th element of the working array appearing in the loop structure is (I-init-i) / i.
Replace with the definition and reference to the ncr + 1 element.

【0032】従って、図3に示したループ構造の場合、
図5に示すように、外側ループの初期値が0,終値がM
−1,増分値がn,指標変数がiで、内側ループの初期
値が1+i,終値がMIN(i+n,M),増分値が
1,指標変数がIの2重ループ構造に変形され、また、
作業用配列要素w(I)の定義,参照がw{(I−1−
i)/1+1}=w(I−i)の定義,参照に置換さ
れ、更にループの前に、ループ長M以下で確保可能な最
大の要素数の作業用配列wを確保しその要素数をnに設
定するサブルーチンgetwork(M,w,n)が挿
入された、第3中間テキスト13が生成される。
Therefore, in the case of the loop structure shown in FIG.
As shown in FIG. 5, the outer loop has an initial value of 0 and a final value of M.
-1, the increment value is n, the index variable is i, the initial value of the inner loop is 1 + i, the final value is MIN (i + n, M), the increment value is 1, and the index variable is transformed into a double loop structure of I, and ,
The definition and reference of the work array element w (I) is w {(I-1-
i) / 1 + 1} = w (I-i) is replaced with the definition and reference, and before the loop, the working array w having the maximum number of elements that can be secured with the loop length M or less is secured and the number of elements is The third intermediate text 13 in which the subroutine getwork (M, w, n) to be set to n is inserted is generated.

【0033】最後に、目的プログラム生成手段7は、ル
ープ構造変形手段6で生成された第3中間テキスト13
を入力し、一連のベクトル命令およびスカラ命令を生成
して目的プログラム8を生成する。
Finally, the object program generating means 7 is the third intermediate text 13 generated by the loop structure transforming means 6.
To generate a series of vector instructions and scalar instructions to generate the object program 8.

【0034】以上のようにして生成された目的プログラ
ム8がベクトル計算機で実行されると、Mが決定する。
そして、決定されたM分の要素数の作業用配列wが確保
できれば、そのような作業用配列wを使用して処理が行
われる。また、Mより少ない要素数の作業用配列wしか
確保できなかった場合においても、多少処理の効率は低
下するが、確保できた要素数の作業用配列wを使用して
支障なく処理が続行される。
When the target program 8 generated as described above is executed by the vector computer, M is determined.
Then, if the work array w having the determined number of M elements can be secured, the processing is performed using such a work array w. Further, even if only the work array w having the number of elements smaller than M can be secured, the processing efficiency is somewhat lowered, but the processing is continued without any trouble by using the work array w having the secured number of elements. It

【0035】以上の実施例は作業用配列を実行時に動的
に確保するものであったが、予め静的に確保するように
しても良い。
Although the working array is dynamically secured at the time of execution in the above embodiment, it may be statically secured in advance.

【0036】図6はそのようなベクトル化方式を適用し
たコンパイラの構成図であり、図1と同一符号は同一部
分を示し、6’はループ構造変形手段、7’は目的プロ
グラム生成手段である。図6に示す実施例が図1に示す
実施例と相違するところは、ループ構造変形手段6’と
目的プログラム生成手段7’の点にあるので、以下その
点についてのみ説明する。
FIG. 6 is a block diagram of a compiler to which such a vectorization method is applied. The same reference numerals as those in FIG. 1 denote the same parts, 6'is a loop structure transforming means, and 7'is a target program generating means. .. The embodiment shown in FIG. 6 is different from the embodiment shown in FIG. 1 in the points of the loop structure modifying means 6'and the object program generating means 7 ', and therefore only those points will be described below.

【0037】ループ構造変形手段6’は、ベクトル化手
段3で生成された第2中間テキスト11と作業用配列情
報テーブル12およびループ構造解析手段3で生成され
たループ情報テーブル10を入力し、ループ構造を、初
期値0,終値term−incr,増分値L×inc
r,指標変数iの外側ループと、初期値init+i,
終値min{init+i+(L−1)×incr,t
erm},増分値incr,指数変数Iの内側ループと
からなる2重ループ構造に変形し、更にループ構造中に
現れる作業用配列要素の定義,参照を(I−init−
i)/incr+1番目の要素への定義,参照に置換す
る。
The loop structure transforming means 6 ′ inputs the second intermediate text 11 generated by the vectorizing means 3, the work sequence information table 12 and the loop information table 10 generated by the loop structure analyzing means 3 and loops. The structure has an initial value 0, a final value term-incr, and an increment value L × inc.
r, the outer loop of the index variable i, and the initial value init + i,
Final value min {init + i + (L-1) × incr, t
erm}, the increment value incr, and the inner loop of the exponent variable I, which is transformed into a double loop structure, and the definition and reference of the work array element appearing in the loop structure are (I-init-
i) / incr + 1 Replace with the definition and reference to the 1st element.

【0038】ここで、Lはコンパイラ2が適宜定める定
数であり、好ましくはベクトルレジスタ長の大きさと等
しい値が用いられる。
Here, L is a constant appropriately determined by the compiler 2, and a value equal to the size of the vector register length is preferably used.

【0039】また目的プログラム生成手段7’は、ルー
プ構造変形手段6’で生成された第3中間テキスト13
とベクトル化手段4で生成された作業用配列情報テーブ
ル12を入力し、大きさLで作業用配列を割り付けた目
的プログラムを生成する。
The object program generating means 7'is also the third intermediate text 13 generated by the loop structure transforming means 6 '.
Then, the working array information table 12 generated by the vectorizing means 4 is input, and a target program in which the working array is allocated with the size L is generated.

【0040】ベクトルレジスタを持つベクトル計算機に
おいては、1つのベクトル命令で処理できる要素数がベ
クトルレジスタの大きさに制限される。従って、作業用
配列の大きさもベクトルレジスタ長分だけ確保しておけ
ば充分である。そして、一般にベクトルレジスタ長は数
十〜数百程度なので、作業用配列の要素数もベクトルレ
ジスタ長で固定的に割り当てておいた方が実行時に領域
を確保するオーバヘッドもなくなる。
In a vector computer having a vector register, the number of elements that can be processed by one vector instruction is limited to the size of the vector register. Therefore, it is sufficient to secure the size of the working array by the length of the vector register. Further, since the vector register length is generally about several tens to several hundreds, it is possible to eliminate the overhead of securing an area at the time of execution when the number of elements of the working array is fixedly allocated by the vector register length.

【0041】図6の実施例はこのような点に着目したも
のであり、例えば図3に示したループ構造は、Lを10
とした場合、図7に示すように、外側ループの初期値が
0,終値がM−1,増分値が10,指標変数がiで、内
側ループの初期値が1+i,終値がMIN(i+10,
M),増分値が1,指標変数がIの2重ループ構造に変
形される。また、作業用配列要素w(I)の定義,参照
がw(I−i)の定義,参照に置換される。作業用配列
wはDIMENSION w(10)により大きさ10
で静的に割り当てられる。
The embodiment of FIG. 6 focuses on such a point. For example, in the loop structure shown in FIG.
7, the initial value of the outer loop is 0, the final value is M−1, the increment value is 10, the index variable is i, the initial value of the inner loop is 1 + i, and the final value is MIN (i + 10,
M), the increment value is 1, and the index variable is transformed into a double loop structure with I. Further, the definition and reference of the work array element w (I) are replaced with the definition and reference of w (Ii). The working array w has a size of 10 according to DIMENSION w (10).
Is statically assigned in.

【0042】[0042]

【発明の効果】以上説明したように、本発明は、実行時
にループ長以下で確保可能な最大の要素数の作業用配列
を確保して処理が続行できるような、または、予め静的
に確保した要素長Lの作業用配列で処理が続行できるよ
うな目的プログラムを生成するので、ループ長が実行時
にならないとわからないようなループが作業用配列を必
要とする場合でも、実行時のループ長に制限されずに支
障なく実行を続けることができる目的プログラムを作成
できるという効果がある。
As described above, according to the present invention, the work array having the maximum number of elements that can be secured within the loop length at the time of execution can be secured so that the processing can be continued, or statically secured in advance. Since a target program that can continue processing with a work array with the specified element length L is generated, even if a loop that needs to know the loop length at run time requires a work array, the loop length at run time is There is an effect that it is possible to create a target program that can be continuously executed without any limitation.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明のベクトル化方式の一実施例を適用した
コンパイラの構成図である。
FIG. 1 is a configuration diagram of a compiler to which an embodiment of a vectorization system of the present invention is applied.

【図2】FORTRAN言語で記述されたループ構造の
例を示す図である。
FIG. 2 is a diagram showing an example of a loop structure described in FORTRAN language.

【図3】FORTRAN言語で記述された別のループ構
造の例を示す図である。
FIG. 3 is a diagram showing an example of another loop structure described in FORTRAN language.

【図4】図3のループ構造を作業用配列wを用いて分割
したループ構造の例を示す図である。
FIG. 4 is a diagram showing an example of a loop structure obtained by dividing the loop structure of FIG. 3 using a work array w.

【図5】図3のループ構造を図1の実施例のベクトル化
方式で変形した例を示す図である。
5 is a diagram showing an example in which the loop structure of FIG. 3 is modified by the vectorization method of the embodiment of FIG.

【図6】本発明のベクトル化方式の別の実施例を適用し
たコンパイラの構成図である。
FIG. 6 is a configuration diagram of a compiler to which another embodiment of the vectorization method of the present invention is applied.

【図7】図3のループ構造を図6の実施例のベクトル化
方式で変形した例を示す図である。
7 is a diagram showing an example in which the loop structure of FIG. 3 is modified by the vectorization method of the embodiment of FIG.

【符号の説明】[Explanation of symbols]

1…原始プログラム 2…コンパイラ 3…ループ構造解析手段 4…ベクトル化手段 5…ループ構造選択手段 6,6’…ループ構造変形手段 7,7’…目的プログラム生成手段 8…目的プログラム 9…第1中間テキスト 10…ループ情報テーブル 11…第2中間テキスト 12…作業用配列情報テキスト 13…第3中間テキスト 1 ... Primitive program 2 ... Compiler 3 ... Loop structure analyzing means 4 ... Vectorizing means 5 ... Loop structure selecting means 6, 6 '... Loop structure modifying means 7, 7' ... Target program generating means 8 ... Target program 9 ... First Intermediate text 10 ... Loop information table 11 ... Second intermediate text 12 ... Work sequence information text 13 ... Third intermediate text

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】 高級言語で書かれた原始プログラムを入
力してベクトル計算機に対する目的プログラムを生成す
るコンパイラのベクトル化方式において、 原始プログラム中のループ構造を認識し、該ループ構造
に対する第1中間テキストを生成するとともに、該ルー
プ構造の初期値init,終値term,増分値inc
r,ループ長mおよび指数変数を格納したループ情報テ
ーブルを生成するループ構造解析手段と、 該ループ構造解析手段で求められたループ構造の第1中
間テキストを入力し、ループ構造をベクトル処理で実行
する第2中間テキストに変換するとともに、ベクトル処
理で実行するために必要となる作業用配列の情報を格納
した作業用配列情報テーブルを生成するベクトル化手段
と、 前記ループ構造解析手段で生成されたループ情報テーブ
ルと前記ベクトル化手段で生成された作業用配列情報テ
ーブルを入力し、必要となる作業用配列の大きさがコン
パイル時には定まらないループ構造を選択するループ構
造選択手段と、 該ループ構造選択手段で選択されたループ構造に対し、
前記ベクトル化手段で生成された第2中間テキストと作
業用配列情報テーブルおよび前記ループ構造解析手段で
生成されたループ情報テーブルを入力し、ループ構造の
前にループ長m以下で確保可能な最大の要素数の作業用
配列を確保し且つ該確保した要素数を変数nに設定する
処理を行う中間テキストを挿入するとともに、ループ構
造を初期値0,終値term−incr,増分値n×i
ncrで指標変数iを持つ外側ループと初期値init
+i,終値min{init+i+(n−1)×inc
r,term},増分値incrで指数変数Iの内側ル
ープからなる2重ループ構造に変形し、ループ中に現れ
る作業用配列のI番目の要素の定義,参照を(I−in
it−i)/incr+1番目の要素への定義,参照に
置換した第3中間テキストを生成するループ構造変形手
段と、 該ループ構造変形手段で生成された第3中間テキストを
入力して目的プログラムを生成する目的プログラム生成
手段とを具備したことを特徴とするベクトル化方式。
1. In a vectorization method of a compiler for inputting a source program written in a high-level language and generating an object program for a vector computer, a loop structure in the source program is recognized, and a first intermediate text for the loop structure. And the initial value init, the final value term, and the increment value inc of the loop structure.
Loop structure analysis means for generating a loop information table storing r, loop length m, and exponential variables, and a first intermediate text of the loop structure obtained by the loop structure analysis means are input, and the loop structure is executed by vector processing. And a vectorization means for generating a work sequence information table storing work sequence information necessary for execution in vector processing, as well as converting to a second intermediate text. Loop structure selecting means for inputting the loop information table and the working array information table generated by the vectorizing means, and selecting a loop structure in which the size of the required working array is not determined at compile time, and the loop structure selecting means For the loop structure selected by means,
The second intermediate text generated by the vectorizing means, the work sequence information table, and the loop information table generated by the loop structure analyzing means are input, and the maximum loop length m or less that can be secured before the loop structure is obtained. An intermediate text for securing a working array of the number of elements and setting the secured number of elements in a variable n is inserted, and a loop structure is set to an initial value 0, a final value term-incr, and an increment value n × i.
Outer loop with index variable i in ncr and initial value init
+ I, final price min {init + i + (n-1) × inc
r, term} and the increment value incr are transformed into a double loop structure consisting of an inner loop of the exponent variable I, and the definition and reference of the I-th element of the working array appearing in the loop are defined as (I-in
it-i) / incr + 1 definition of the first element, loop structure transformation means for generating a third intermediate text replaced with a reference, and the third intermediate text generated by the loop structure transformation means are input to execute the target program. A vectorization method comprising: a target program generating means for generating.
【請求項2】 高級言語で書かれた原始プログラムを入
力してベクトル計算機に対する目的プログラムを生成す
るコンパイラのベクトル化方式において、 原始プログラム中のループ構造を認識し、該ループ構造
に対する第1中間テキストを生成するとともに、該ルー
プ構造の初期値init,終値term,増分値inc
r,ループ長mおよび指数変数を格納したループ情報テ
ーブルを生成するループ構造解析手段と、 該ループ構造解析手段で求められたループ構造の第1中
間テキストを入力し、ループ構造をベクトル処理で実行
する第2中間テキストに変換するとともに、ベクトル処
理で実行するために必要となる作業用配列の情報を格納
した作業用配列情報テーブルを生成するベクトル化手段
と、 前記ループ構造解析手段で生成されたループ情報テーブ
ルと前記ベクトル化手段で生成された作業用配列情報テ
ーブルを入力し、必要となる作業用配列の大きさがコン
パイル時には定まらないループ構造を選択するループ構
造選択手段と、 前記ベクトル化手段で生成された第2中間テキストと作
業用配列情報テーブルおよび前記ループ構造解析手段で
生成されたループ情報テーブルを入力し、前記ループ構
造選択手段で選択されたループ構造を、コンパイラが適
宜定める定数をLとすると、初期値0,終値term−
incr,増分値L×incrで指標変数iを持つ外側
ループと初期値init+i,終値min{init+
i+(L−1)×incr,term},増分値inc
rで指数変数Iの内側ループからなる2重ループ構造に
変形し、更にループ中に現れる作業用配列要素の定義,
参照を(I−init−i)/incr+1番目の要素
への定義,参照に置換した第3中間テキストを生成する
ループ構造変形手段と、 該ループ構造変形手段で生成された第3中間テキストと
前記ベクトル化手段で生成された作業用配列情報テーブ
ルを入力し、大きさLで作業用配列を割り付けた目的プ
ログラムを生成する目的プログラム生成手段とを具備し
たことを特徴とするベクトル化方式。
2. In a vectorization method of a compiler for inputting a source program written in a high-level language and generating an object program for a vector computer, a loop structure in the source program is recognized, and a first intermediate text for the loop structure is recognized. And the initial value init, the final value term, and the increment value inc of the loop structure.
Loop structure analysis means for generating a loop information table storing r, loop length m, and exponential variables, and a first intermediate text of the loop structure obtained by the loop structure analysis means are input, and the loop structure is executed by vector processing. And a vectorization means for generating a work sequence information table storing work sequence information necessary for execution in vector processing, as well as converting to a second intermediate text. Loop structure selecting means for inputting the loop information table and the work array information table generated by the vectorizing means, and selecting a loop structure in which the size of the necessary work array is not determined at compile time, and the vectorizing means. Generated by the second intermediate text and the work sequence information table generated by Enter the loop information table, a loop structure, which is selected by the loop structure selection means, the compiler constants suitably determined as L, the initial value 0, the closing price term-
incr, an outer loop having an index variable i with an increment value L × incr, an initial value init + i, and a final value min {init +
i + (L-1) × incr, term}, increment value inc
The definition of the working array element which is transformed into a double loop structure consisting of the inner loop of the exponent variable I by r and appears in the loop,
A loop structure modification means for generating a third intermediate text in which a reference is replaced with a definition to the (I-init-i) / incr + 1th element and a reference, and a third intermediate text generated by the loop structure modification means and the above A vectorization method, comprising: a target program generation means for inputting a work array information table generated by the vectorization means and generating a target program in which a work array is allocated with a size L.
JP4152761A 1992-05-20 1992-05-20 Vectorization method Expired - Fee Related JP3057904B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4152761A JP3057904B2 (en) 1992-05-20 1992-05-20 Vectorization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4152761A JP3057904B2 (en) 1992-05-20 1992-05-20 Vectorization method

Publications (2)

Publication Number Publication Date
JPH05324346A true JPH05324346A (en) 1993-12-07
JP3057904B2 JP3057904B2 (en) 2000-07-04

Family

ID=15547576

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4152761A Expired - Fee Related JP3057904B2 (en) 1992-05-20 1992-05-20 Vectorization method

Country Status (1)

Country Link
JP (1) JP3057904B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009070070A (en) * 2007-09-12 2009-04-02 Nec Corp Compiler and compile method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009070070A (en) * 2007-09-12 2009-04-02 Nec Corp Compiler and compile method

Also Published As

Publication number Publication date
JP3057904B2 (en) 2000-07-04

Similar Documents

Publication Publication Date Title
US4833606A (en) Compiling method for vectorizing multiple do-loops in source program
EP0467629B1 (en) A loop compiler method & apparatus for a data processing system
US5790760A (en) Program generating apparatus and method thereof
US4821181A (en) Method for converting a source program of high level language statement into an object program for a vector processor
US5287510A (en) Method for improving the efficiency of arithmetic code generation in an optimizing compiler using machine independent update instruction generation
US6550059B1 (en) Method for generating optimized vector instructions from high level programming languages
US6117185A (en) Skip list data storage during compilation
US5522074A (en) Vectorization system for vectorizing loop containing condition induction variables
EP0947922B1 (en) Compiler
KR20080096306A (en) Compiling method and system for a rule-based optimal placement of scaling shifts
JPH05189472A (en) Vectorization processing system for compiler
JP3057904B2 (en) Vectorization method
JP3196625B2 (en) Parallel compilation method
JP3028821B2 (en) Parallel compilation method
US5437035A (en) Method and apparatus for compiling a program incending a do-statement
JPH0594470A (en) Vectrization system
JPH03135630A (en) Instruction scheduling system
JP3658771B2 (en) Compiler device
JPH02236638A (en) Register allocation managing system
JP2801193B2 (en) Vectorization processing device for induction variables
JPH0512033A (en) Parallel compiling system
JPH02109135A (en) Do form array input conversion system
JPS6365530A (en) Code optimizing system
JP2539070B2 (en) Compiler processor
JPH0713962A (en) Compiler device

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees