JP2005293080A - Information processing apparatus, program processing method, and compile processing program - Google Patents
Information processing apparatus, program processing method, and compile processing program Download PDFInfo
- Publication number
- JP2005293080A JP2005293080A JP2004105437A JP2004105437A JP2005293080A JP 2005293080 A JP2005293080 A JP 2005293080A JP 2004105437 A JP2004105437 A JP 2004105437A JP 2004105437 A JP2004105437 A JP 2004105437A JP 2005293080 A JP2005293080 A JP 2005293080A
- Authority
- JP
- Japan
- Prior art keywords
- loop control
- loop
- program
- control statement
- statement
- 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.)
- Withdrawn
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
【課題】 ループの継続条件式に非等値演算子を使用したループ制御文が示すループのベクトル演算を迅速に実行する方法を提供する。
【解決手段】 情報処理装置(100)は、ソースプログラム(20)に対するコンパイル処理によりベクトル命令を含む目的プログラム(30)を生成するためのコンパイル処理手段(10)を備える。コンパイル処理手段は、入力されたソースプログラムから、制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文(6-1)を検出する検出処理部(11)と、検出されたループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する変形処理部(12)とを有する。
【選択図】 図1
PROBLEM TO BE SOLVED: To provide a method for quickly executing a loop vector operation indicated by a loop control statement using an inequality operator in a loop continuation conditional expression.
An information processing apparatus (100) includes compile processing means (10) for generating a target program (30) including a vector instruction by compile processing for a source program (20). The compile processing means detects a loop control statement (6-1) having a continuation conditional expression in which a control variable and a loop invariant closing price are related by an inequality operator from the input source program ( 11) and a transformation processing unit (12) that transforms the detected loop control statement into a plurality of loop control statements for executing a loop that is equivalent to the loop control statement and that is based on the closing price. Have
[Selection] Figure 1
Description
本発明は、C言語あるいはC++言語のようなプログラミング言語にて記述されたソースプログラムからベクトル命令を含む目的プログラムを生成するコンパイル処理に関し、特に、繰り返し回数が指定されていないループ制御文が含まれるソースプログラムに前記コンパイル処理を施すための手法に関する。 The present invention relates to a compile process for generating a target program including a vector instruction from a source program described in a programming language such as C language or C ++ language, and particularly includes a loop control statement in which the number of repetitions is not specified. The present invention relates to a technique for performing the compile processing on a source program.
従来、ソースプログラムにコンパイル処理を施すにあたり、例えば図5の5−1式ように、繰り返し回数が指定されているループ制御文に対しては、ベクトル命令を適用することにより演算処理の効率化を図ることが知られている。図示の5−1式は、ループ制御文の一例として示したC言語のfor文であり、文中の継続条件式5aにより、ループの繰り返し回数が規定される。 Conventionally, when compiling a source program, for example, as shown in equation 5-1, FIG. 5, for loop control statements in which the number of iterations is specified, a vector instruction is applied to improve the efficiency of the arithmetic processing. It is known to plan. The expression 5-1 shown in the figure is a C for sentence shown as an example of a loop control sentence, and the number of loop iterations is defined by the continuation conditional expression 5a in the sentence.
ところで、図6の6−1式のようなループ制御文によれば、上記5−1式による演算結果と同様な結果が得られると考えられるが、図示の6−1式は、その継続条件式6aに「!=」なる非等値演算子が使用されていることから、ループ外への飛び出しを伴うアルゴリズムとなる。 By the way, according to the loop control statement like the expression 6-1 in FIG. 6, it is considered that the same result as the calculation result according to the expression 5-1 is obtained. However, the expression 6-1 shown in FIG. Since the inequality operator “! =” Is used in the expression 6a, the algorithm involves jumping out of the loop.
図6のようなループ制御文は、繰り返し回数が不明であることから、これをベクトル化すると、演算処理が長期化するか、あるいは無限ループに陥る可能性が高い。そのため、一般的には、この種のループ制御文はベクトル化しないよう予めコンパイラ側に設定を行うが、例えば、後述の特許文献1及び2の手法を用いれば、コンパイル処理にマスク演算やループ後の処理を付加することにより、上記のような繰り返し回数が不明のループ制御文であっても適正なベクトル演算が可能となる。
しかしながら、上記の特許文献1及び2の手法を用いた場合、マスク演算やループ後の処理といった付加的な処理を必要とされることから、その分、プログラムの実行時間が長引くという不都合がある。
However, when the methods of
本発明は、上記課題に鑑みてなされたものであり、継続条件式に非等値演算子が用いられるループ制御文が示す演算内容をベクトル命令に沿って迅速に実行し得る情報処理装置、及び、該装置のためのプログラム処理方法、並びに、コンパイル処理プログラムを提供することを目的とする。 The present invention has been made in view of the above problems, and is an information processing apparatus that can quickly execute an operation content indicated by a loop control statement in which an inequality operator is used in a continuation conditional expression along a vector instruction, and Another object of the present invention is to provide a program processing method and a compile processing program for the apparatus.
本発明に係る情報処理装置は、ソースプログラムに対するコンパイル処理によりベクトル命令を含む目的プログラムを生成するためのコンパイル処理手段を備え、前記コンパイル処理手段は、入力されたソースプログラムから、制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出する検出処理部と、前記検出処理部により検出されたループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する変形処理部とを有する。 An information processing apparatus according to the present invention includes compile processing means for generating a target program including a vector instruction by compile processing for a source program, and the compile processing means receives control variables and loop invariants from the input source program. A detection processing unit for detecting a loop control statement having a continuation conditional expression associated with an unequal operator and a loop control statement detected by the detection processing unit is equivalent to the loop control statement. And a transformation processing unit that transforms into a plurality of loop control statements for executing a loop based on the closing price.
本発明に係るプログラム処理方法は、ソースプログラムに対するコンパイル処理によりベクトル命令を含む目的プログラムを生成する情報処理装置が、ソースプログラムを入力されたとき、該ソースプログラムから制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出し、該検出したループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形するという方法である。 According to the program processing method of the present invention, when an information processing apparatus that generates a target program including a vector instruction by compiling a source program receives a source program, a control variable and a loop-invariant closing price are obtained from the source program. A loop control statement having a continuation conditional expression related by an unequal operator is detected, and the detected loop control statement is equivalent to the loop control statement, and each executes a loop based on the closing price. It is a method of transforming into a plurality of loop control statements.
本発明に係るコンパイル処理プログラムは、ソースプログラムに対するコンパイル処理によりベクトル命令を含む目的プログラムを生成するコンパイル処理ステップをコンピュータに実行させるコンパイル処理プログラムであって、ソースプログラムを入力されたとき、前記コンパイル処理ステップに先立ち、前記入力されたソースプログラムから、制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出する検出処理ステップと、前記検出処理ステップにおいて検出されたループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する変形処理ステップとを前記コンピュータに実行させる。
The compile processing program according to the present invention is a compile processing program for causing a computer to execute a compile processing step for generating a target program including a vector instruction by compile processing for a source program, and when the source program is input, the compile processing program Prior to the step, a detection processing step of detecting a loop control statement having a continuation conditional expression in which a control variable and a loop invariant closing price are related by an inequality operator from the input source program, and the detection processing step Causing the computer to execute a transformation processing step that transforms the loop control statement detected in
本発明によれば、継続条件式に非等値演算子を使用したループ制御文を、終値を基点とした等価なループ制御文に変形することから、コンパイル処理により生成される当該ベクトル命令を単純化することができる。これにより、ループのベクトル演算を高速に実行することが可能となる。 According to the present invention, since the loop control statement using the inequality operator in the continuation conditional expression is transformed into an equivalent loop control statement based on the closing price, the vector instruction generated by the compilation process is simplified. Can be This makes it possible to execute loop vector operations at high speed.
[実施例]
以下、本発明の実施例について図面を用いて詳細に説明する。図1は、本発明による実施例の情報処理装置の構成を示すブロック図である。実施例の情報処理装置100は、本発明に係るコンパイル処理手段に対応するコンパイラ10を備える。コンパイラ10は、C言語あるいはC++言語などにより記述されたソースプログラム20に対するコンパイル処理により、ベクトル命令を含む目的プログラム30を生成することを情報処理装置100に実行させるコンパイル処理プログラムである。
[Example]
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. FIG. 1 is a block diagram showing a configuration of an information processing apparatus according to an embodiment of the present invention. The
コンパイラ10は、本発明の情報処理装置における検出処理部の機能を果たすループ終了条件検出部11と、変形処理部の機能を果たすループ変形部12とを有する。ループ終了条件検出部11は、コンパイラ10に入力されたソースプログラム20から、制御変数とループ不変の終値とが「!=」なる非等値演算子により関連付けられた継続条件式を有するループ制御文を検出する。ループ変形部12は、ループ終了条件検出部11が検出したループ制御文を、このループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する。
The
図2に示すフローチャートに沿って、情報処理装置100のコンパイル処理手順を説明する。ここでは、説明のため、処理対象となるソースプログラム20に図6に示す6−1式のfor文が含まれており、また、「(初期値)<(終値)」及び「(増分値)>0」であることと、「(終値)」はループ演算中に値が変化しないループ不変のオペランドであることとが成り立っているとする。
The compile processing procedure of the
まず、コンパイラ10にソースプログラム20が入力されると(ステップS1)、ループ終了条件検出部11は、上記説明した検出条件に対応するループ制御文として図6の6−1式を検出する(ステップS2)。6−1式のfor文は、その継続条件式6aとして、制御変数である「i」と、ループ不変のオペランドの「(終値)」との関係が非等値演算子の「!=」により定義されたものである。ここでは、制御変数「i」の値が、「(終値)」を除き、「(初期値)」から「(増分値)」の間隔で順次増加するよう制御される。
First, when the
ループ変形部12は、ループ終了条件検出部11が検出した6−1式を、これに等価なループ制御文に変換する(ステップS3)。図3に、ループ変形部12による変換結果を示す。図示の3−1式は、大小比較演算子を使用した「i<(終値)」が継続条件式3aとして設定されたfor文であり、また、他方の3−2式は、「(初期値)」の設定が空値であり、継続条件式3bとして「i!=(終値)」が設定されたfor文である。
The
図3に示す変換後のループ制御文に、上記の「(初期値)<(終値)」及び「(増分値)>0」なる前提を加味すると、3−1式は、制御変数「i」に与える値の遷移に関し、「(初期値)」から「(終値)」の直前までの漸増を制御し、また、他方の3−2式は、「(終値)」を含まない、それ以降の漸増を制御する。すなわち、3−1式及び3−2式の組み合わせは、「(終値)」を基点として、変換前の6−1式の制御変数「i」が取り得る値の範囲を2分割したものに相当する。よって、変換前の6−1式と、変換後の3−1式及び3−2式の組み合わせとは等価の関係にある。 3 is added to the loop control statement after conversion shown in FIG. 3 by adding the above assumptions “(initial value) <(final value)” and “(increment value)> 0”. The transition from “(initial value)” to “(close price)” is controlled with respect to the transition of the value given to, and the other expression 3-2 does not include “(close price)”. Control the gradual increase. That is, the combination of Formula 3-1 and Formula 3-2 is equivalent to dividing the range of values that can be taken by the control variable “i” of Formula 6-1 before conversion, with “(final value)” as a base point. To do. Therefore, the expression 6-1 before conversion is equivalent to the combination of expression 3-1 and expression 3-2 after conversion.
ループ変形部12により変換された図3のループ制御文は、ベクトル処理が可能な従来のコンパイラと同様な処理によりベクトル命令に変換され(ステップS4)、コンパイル処理された他の命令列と共に、目的プログラム30として出力される(ステップS5)。
The loop control statement of FIG. 3 converted by the
なお、図3に示す変換後のループ制御文のうち、「(終値)」より以降の漸増を担う3−2式は、継続条件式3bに「!=」を使用していることから、無限ループの発生や演算処理の長期化といった問題が生じ易い。よって、この3−2式は、ベクトル化する前に削除する、あるいは従来と同様に、ベクトル化されても演算を実行しないような設定を、予めコンパイラ10に行うことが望ましい。
In the loop control statement after conversion shown in FIG. 3, the expression 3-2 responsible for the gradual increase after “(final price)” uses “! =” In the continuation conditional expression 3b, so that it is infinite. Problems such as the occurrence of loops and prolonged processing are likely to occur. Therefore, it is desirable to delete the expression 3-2 before vectorization or to the
以上説明した実施例によれば、ソースプログラム20のコンパイル処理に先立ち、継続条件式に「!=」を使用したループ制御文を、「<」のような大小比較演算子を用いた等価なループ制御文に変換することから、コンパイル処理により生成されるベクトル命令列を単純化することができる。これにより、ベクトル演算を高速に実行することが可能となる。
According to the embodiment described above, prior to compiling the
上記実施例で説明した図3に示すループ制御文は、制御変数「i」の値を「(初期値)」から「(終値)」に向けて漸増させることを前提として、図6の6−1式を変形したものであるが、本発明を実施するにあたっては、このような前提に依存しない汎用的なループ制御文を設定することもできる。 The loop control statement shown in FIG. 3 described in the above embodiment assumes that the value of the control variable “i” is gradually increased from “(initial value)” to “(final value)”. Although one set is modified, in implementing the present invention, a general-purpose loop control statement that does not depend on such a premise can be set.
図4は、6−1式をループ変形部12により汎用的なものに変換した結果であり、そのアルゴリズムは、上記説明した等価なループ制御文を、「i」の増減条件に応じて生成するための判断処理を行うものとなっている。図4において、4−1式は、図3の3−1式及び3−2式と同様である。すなわち、4−1式は、6−1式のオペランドが、上記実施例にて説明した「(初期値)<(終値)」及び「(増分値)>0」の場合に適用されるループ制御文である。
FIG. 4 shows the result of converting equation 6-1 into a general-purpose one by the
また、4−2式は、6−1式のオペランドが「(初期値)>(終値)」及び「(増分値)<0」の場合、すなわち、制御変数「i」の値を「(初期値)」から「(終値)」に向けて漸減させる場合に適用するループ制御文である。 Further, in the expression 4-2, when the operands of the expression 6-1 are “(initial value)> (final value)” and “(increment value) <0”, that is, the value of the control variable “i” is “(initial This is a loop control statement that is applied when the value is gradually decreased from “value)” to “(close price)”.
4−3式は、例えば、「(初期値)=(終値)」、又は「(増分値)=0」、又は「(初期値)<(終値)」及び「(増分値)<0」、又は「(初期値)>(終値)」及び「(増分値)>0」のように、実質的にループが形成されない場合には、制御変数「i」の値が変化せず、ベクトル化の必要はないことから、ループ制御文は6−1式のままの形状とする。また、明示的なループからの飛び出しがない限り無限ループになる場合にも、4−3式が適用される。 The expression 4-3 is, for example, “(initial value) = (final value)” or “(increment value) = 0” or “(initial value) <(final value)” and “(increment value) <0”. Or, when the loop is not substantially formed as in “(initial value)> (final value)” and “(increment value)> 0”, the value of the control variable “i” does not change, and the vectorization Since there is no need, the loop control statement has the shape of 6-1. The expression 4-3 is also applied to an infinite loop unless there is an explicit jump out of the loop.
このように、図4に示すような汎用的なループ制御文を用いることにより、コンパイラ10は、ループ終了条件検出部11が検出するループ制御文のオペランド内容を事前に把握することなく、上記説明した実施例により生成されるベクトル命令と同様なものを生成することができる。
As described above, by using a general-purpose loop control statement as shown in FIG. 4, the
上記実施例では、本発明に係るループ制御文としてfor文を用いたが、for文に限らず、例えば、while文や、goto文を使用したループに適用することも可能である。また、C++言語のSTL(Standard Template Library)を利用した際は、従来知られているように、ループの継続条件式に「!=」が使用されるが、本発明は、C++言語のソースプログラムのうち、STLのvectorやvalarrayのようなメモリに対し連続的なアクセスを実行するアルゴリズムを含むものに好適である。 In the above embodiment, the for statement is used as the loop control statement according to the present invention. However, the for statement is not limited to the for statement, and can be applied to a loop using a while statement or a goto statement, for example. In addition, when a C ++ language STL (Standard Template Library) is used, “! =” Is used as a loop continuation conditional expression as is conventionally known, but the present invention is a C ++ language source program. Among them, it is suitable for an algorithm including an algorithm for executing continuous access to a memory such as an STL vector or valarray.
100 情報処理装置
10 コンパイラ
11 ループ終了条件検出部
12 ループ変形部
20 ソースプログラム
30 目的プログラム
DESCRIPTION OF
Claims (9)
前記コンパイル処理手段は、
入力されたソースプログラムから、制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出する検出処理部と、
前記検出処理部により検出されたループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する変形処理部とを有することを特徴とする情報処理装置。 Compiling processing means for generating a target program including vector instructions by compiling processing for a source program,
The compile processing means includes
A detection processing unit that detects, from the input source program, a loop control statement having a continuation conditional expression in which a control variable and a loop invariant closing price are related by an inequality operator;
A transformation processing unit that transforms the loop control statement detected by the detection processing unit into a plurality of loop control statements that are equivalent to the loop control statement and that each execute a loop based on the closing price. An information processing apparatus characterized by that.
ソースプログラムを入力されたとき、該ソースプログラムから制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出し、該検出したループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形することを特徴とするプログラム処理方法。 An information processing apparatus that generates a target program including vector instructions by compiling a source program,
When a source program is input, a loop control statement having a continuation conditional expression in which a control variable and a loop invariant closing price are related by an inequality operator is detected from the source program, and the detected loop control statement is A program processing method, wherein the program processing method is transformed into a plurality of loop control statements for executing a loop that is equivalent to the loop control statement and each has a base point based on the closing price.
ソースプログラムを入力されたとき、前記コンパイル処理ステップに先立ち、
前記入力されたソースプログラムから、制御変数とループ不変の終値とが非等値演算子により関連付けられた継続条件式を有するループ制御文を検出する検出処理ステップと、
前記検出処理ステップにおいて検出されたループ制御文を、該ループ制御文に等価であり且つそれぞれが前記終値を基点とするループを実行するための複数のループ制御文に変形する変形処理ステップとを前記コンピュータに実行させることを特徴とするコンパイル処理プログラム。 A compile processing program for causing a computer to execute a compile processing step for generating a target program including a vector instruction by compile processing for a source program,
When a source program is input, prior to the compilation step,
A detection processing step of detecting a loop control statement having a continuation conditional expression in which a control variable and a loop invariant closing price are related by an inequality operator from the input source program;
A transformation processing step for transforming the loop control statement detected in the detection processing step into a plurality of loop control statements for executing a loop that is equivalent to the loop control statement and each of which is based on the closing price. A compile processing program to be executed by a computer.
9. The compilation according to claim 8, wherein in the conversion processing step, the computer is caused to generate the first loop control statement and the second loop control statement corresponding to the increase / decrease condition of the control variable. Processing program.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2004105437A JP2005293080A (en) | 2004-03-31 | 2004-03-31 | Information processing apparatus, program processing method, and compile processing program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2004105437A JP2005293080A (en) | 2004-03-31 | 2004-03-31 | Information processing apparatus, program processing method, and compile processing program |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2005293080A true JP2005293080A (en) | 2005-10-20 |
Family
ID=35325959
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2004105437A Withdrawn JP2005293080A (en) | 2004-03-31 | 2004-03-31 | Information processing apparatus, program processing method, and compile processing program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2005293080A (en) |
-
2004
- 2004-03-31 JP JP2004105437A patent/JP2005293080A/en not_active Withdrawn
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US9645803B2 (en) | Methods and systems for forming an adjusted perform range | |
| US5522074A (en) | Vectorization system for vectorizing loop containing condition induction variables | |
| US20010020294A1 (en) | Optimization apparatus that decreases delays in pipeline processing of loop and computer-readable storage medium storing optimization program | |
| JP2005293080A (en) | Information processing apparatus, program processing method, and compile processing program | |
| US20070204260A1 (en) | Program transformation system | |
| JP6810380B2 (en) | Source program conversion system, source program conversion method, and source program conversion program | |
| JP5215813B2 (en) | Program conversion method and program conversion apparatus | |
| Yuki et al. | Derivation of efficient FSM from loop nests | |
| JP2674489B2 (en) | Vectorization processor | |
| JPH0440742B2 (en) | ||
| JP3034582B2 (en) | Compile processing method | |
| JPH0269867A (en) | Vectorizing system | |
| JPH04332044A (en) | Vectorization processing system for compiler | |
| JP2853604B2 (en) | Vectorization processing method of infinite loop | |
| JP2010049315A (en) | Optimizing compiler and optimization compile method | |
| JPH0795272B2 (en) | Compile method | |
| JPH03110670A (en) | Vector computer | |
| CN121560331A (en) | Parameterized compiling optimization method and system based on multi-stage intermediate representation | |
| JP3922699B2 (en) | Optimization method and program for moving invariant expressions in loop | |
| JP3734658B2 (en) | COMPILER DEVICE AND COMPUTER-READABLE RECORDING MEDIUM RECORDING COMPILER PROGRAM | |
| JPH0377141A (en) | Division processing system for vector operation train | |
| JP2008015665A (en) | Program analysis method and program analysis apparatus | |
| JP2007233805A (en) | Program conversion system | |
| JPH0497484A (en) | Vectorization processing system for compiler | |
| JPH06222928A (en) | Loop optimizing method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A300 | Application deemed to be withdrawn because no request for examination was validly filed |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 20070605 |