JP5477206B2 - Compiling device and compiling program - Google Patents
Compiling device and compiling program Download PDFInfo
- Publication number
- JP5477206B2 JP5477206B2 JP2010153528A JP2010153528A JP5477206B2 JP 5477206 B2 JP5477206 B2 JP 5477206B2 JP 2010153528 A JP2010153528 A JP 2010153528A JP 2010153528 A JP2010153528 A JP 2010153528A JP 5477206 B2 JP5477206 B2 JP 5477206B2
- Authority
- JP
- Japan
- Prior art keywords
- program
- range
- information
- line
- loop
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Description
本願は、コンパイル装置およびコンパイルプログラムに関する。 The present application relates to a compiling device and a compiling program.
プログラムの実行性能のボトルネックとなっている箇所の特定や改善方法を短期間で見つけ出すための技術として「プロファイラ」と呼ばれる技術が存在する。このプロファイラは、プログラム実行時に、関数の呼び出し回数、サイクル数、キャッシュミスの数など、プログラム実行時の挙動を表わすPA(Profile Analysis)情報(性能解析情報、ハードウエア情報)を取得する技術である。このプロファイラには、大別して以下の2種類が存在する。 There is a technique called “profiler” as a technique for quickly identifying a part that is a bottleneck of the execution performance of a program and finding a method for improvement. This profiler is a technique for acquiring PA (Profile Analysis) information (performance analysis information, hardware information) representing behavior during program execution, such as the number of function calls, the number of cycles, and the number of cache misses, during program execution. . This profiler is roughly divided into the following two types.
・実行時に、一定間隔の割込みにより、全体の大まかなPA情報を取得する。 -At the time of execution, the general PA information is acquired by interruption at regular intervals.
・ソースプログラムに、PA情報取得のための関数呼び出しを手作業で加え、そのソースプログラムの中の一部分について詳細なPA情報を取得する。 A function call for acquiring PA information is manually added to the source program, and detailed PA information is acquired for a part of the source program.
詳細なPA情報を取得するためには後者の方法が選択されるが、コンパイルの際の最適化処理によってソースプログラムには表現されないループや処理ブロックが生成されることがある。この場合、PA情報取得関数をソースプログラム上に書き加えておいてもコンパイルの際に生成される新たなループや処理ブロックにおける詳細なPA情報を取得することができないおそれがある。 The latter method is selected to acquire detailed PA information, but a loop or processing block that is not expressed in the source program may be generated by optimization processing at the time of compilation. In this case, even if a PA information acquisition function is added to the source program, there is a possibility that detailed PA information in a new loop or processing block generated at the time of compilation cannot be acquired.
1つの側面では、本発明は、コンパイルの際に新たに生成されたループや処理ブロックについてもPA情報を取得できるオブジェクトプログラムを生成することにある。 In one aspect, the present invention is to generate an object program that can acquire PA information for a loop or a processing block that is newly generated during compilation.
本件開示のコンパイル装置は、取得手段と、第1変換手段と、第1設定手段と、最適化手段と、第2設定手段と、関数埋込手段と、第2変換手段とを有する。 The compiling device of the present disclosure includes an acquisition unit, a first conversion unit, a first setting unit, an optimization unit, a second setting unit, a function embedding unit, and a second conversion unit.
ここで、取得手段は、PA位置ファイルとソースプログラムとを取得する。PA位置ファイルは、プログラム実行時の挙動を表わすPA情報を取得する、そのプログラム上の範囲を表わすPAレンジが記述されたファイルである。また、ソースプログラムは、プログラム言語を用いて作成されたプログラムである。 Here, the acquisition unit acquires the PA position file and the source program. The PA position file is a file in which a PA range representing a range on the program is described, which acquires PA information representing a behavior at the time of program execution. The source program is a program created using a program language.
また、第1変換手段は、取得手段で取得したソースプログラムを中間言語で記述された第1のプログラムに変換する。 The first conversion means converts the source program acquired by the acquisition means into a first program described in an intermediate language.
第1設定手段は、取得手段が取得したPA位置ファイルからPAレンジを読み出して、そのPAレンジを上記の第1のプログラム上に設定する。 The first setting means reads the PA range from the PA position file acquired by the acquisition means, and sets the PA range on the first program.
最適化手段は、第1設定手段でPAレンジが設定された第1のプログラムに最適化処理を施して、その第1のプログラム上に設定されたPAレンジを引き継いだ第2のプログラムを生成する。 The optimization unit performs an optimization process on the first program in which the PA range is set by the first setting unit, and generates a second program that takes over the PA range set on the first program. .
第2設定手段は、第1のプログラム上のPAレンジ内のループ又は処理ブロックの数と比べたときの第2のプログラム上のPAレンジ内のループ又は処理ブロックの数の増加の有無を調べる。そして、第2のプログラム上のPAレンジ内のループ又は処理ブロックの数が増加していた場合に、この第2設定手段は、その第2のプログラム上のPAレンジ内の各ループ又は各処理ブロックに新たなPAレンジを設定する。 The second setting means checks whether or not the number of loops or processing blocks in the PA range on the second program has increased as compared with the number of loops or processing blocks in the PA range on the first program. Then, when the number of loops or processing blocks in the PA range on the second program has increased, the second setting means sets each loop or processing block in the PA range on the second program. Set a new PA range.
関数埋込手段は、上記の第2のプログラムに、PA情報取得のためのPA情報取得関数を、その第2のプログラムに設定されたPAレンジ毎に埋め込む。 The function embedding means embeds a PA information acquisition function for acquiring PA information in the second program for each PA range set in the second program.
さらに、第2変換手段は、PA情報取得関数が埋め込まれた状態の第2のプログラムを、コンピュータ上で実行可能なオブジェクトプログラムに変換する。 Further, the second conversion means converts the second program in which the PA information acquisition function is embedded into an object program executable on the computer.
また、本件開示のコンパイルプログラムは、プログラムをコンパイルする演算処理装置内で実行され、その演算処理装置内に、本件のコンパイル装置を構築するプログラムである。 Further, the compile program disclosed herein is a program that is executed in an arithmetic processing device that compiles a program and constructs the compiling device of the present subject in the arithmetic processing device.
本件開示のコンパイル装置およびコンパイルプログラムによれば、コンパイルの際に生成された新たなループや処理ブロックについても詳細なPA情報を取得することができる。したがってプログラムの実行性能の詳細な分析が可能となる。 According to the compiling apparatus and the compiling program of the present disclosure, it is possible to acquire detailed PA information for a new loop or processing block generated at the time of compiling. Therefore, detailed analysis of program execution performance becomes possible.
以下、コンパイル時の最適化処理によってループや処理ブロックが増加する場合を例示し、その後、実施形態を説明する。 Hereinafter, a case where the number of loops and processing blocks increases due to optimization processing at the time of compilation will be exemplified, and then the embodiment will be described.
図1は、最適化処理においてSIMD化が行なわれ、その結果、複数のループが生成される例を示した図である。最適化処理はコンパイル装置内で取り扱うのに適した中間言語上で行なわれるが、この図1では、分かり易さのため、ソースプログラムであるか中間言語を用いたプログラムであるかを問わず、ソースプログラムの形式で示している。 FIG. 1 is a diagram illustrating an example in which SIMD processing is performed in the optimization process, and as a result, a plurality of loops are generated. The optimization process is performed on an intermediate language suitable for handling in the compiling apparatus. In FIG. 1, for the sake of simplicity, regardless of whether the program is a source program or a program using the intermediate language. Shown in source program format.
図1(A)のソースプログラム中の(1)行目の「do i=1,100」は、以下の処理を行なうことを意味している。 “Do i = 1,100” on line (1) in the source program of FIG. 1A means that the following processing is performed.
・先ずi=1と置いて、(3)行目の「end do」までの間の処理を実行する。 First, i = 1 is set, and the process up to “end do” on the (3) line is executed.
・その後iを1ずつインクリメントしながらi=100になるまで「end do」までの間の処理を繰り返す。 After that, i is incremented by 1 and the process until “end do” is repeated until i = 100.
また、(2)行目の「a(i)=3」は、配列aの中のa(i)に3を代入することを意味している。 In addition, “a (i) = 3” in the (2) th line means that 3 is assigned to a (i) in the array a.
さらに、(3)行目の「end do」は、(1)行目の「do i=1,100」を開始位置とするループの終了位置であることを意味している。 Furthermore, “end do” in the (3) line means that the loop is at the end position of “do i = 1,100” in the (1) line.
ここでは、この図1(A)に示す単純なループを例に挙げて説明する。 Here, a simple loop shown in FIG. 1A will be described as an example.
図1(B)は、図1(A)のプログラムを元にコンパイルにおける最適化処理により作成されたプログラムを示している。 FIG. 1B shows a program created by optimization processing in compilation based on the program of FIG.
図1(B)の(1)行目の「if」文は、配列aが8バイトの境界上にある場合に、(5)行目の「else」よりも手前((4)行目まで)の処理を実行し、そうでない場合には、(5)行目の「else」以降の処理を実行することを意味している。 In FIG. 1B, the “if” statement on the (1) line is the line before the “else” on the (5) line (up to the (4) line) when the array a is on the 8-byte boundary. ) Is executed. Otherwise, the process after “else” on the (5) line is executed.
ここでは、メモリのアクセスが8バイト単位であって、かつアクセスの境界がハードウェア的に決まっていることを想定している。ただし、ここでは、この条件自体に大きな意味はなく、詳細説明は省略する。 Here, it is assumed that the memory access is in units of 8 bytes and the access boundary is determined by hardware. However, this condition itself has no significant meaning here, and detailed description thereof is omitted.
また、(2)行目の「do i=1,99,2」は、先ずi=1と置いて(4)行目の「end do」までの処理を実行し、その後iを2ずつインクリメントしながら(4)行目「end do」までの処理をi=99まで繰り返すことを意味している。 In (2) line “do i = 1,99,2”, i = 1 is set first and the process up to (4) line “end do” is executed, and then i is incremented by two. On the other hand, (4) the process up to the line “end do” is repeated until i = 99.
また、(3)行目の「a(i:i+1)=3」は、a(i)とa(i+1)の双方に3を代入することを意味している。 Also, “a (i: i + 1) = 3” in the (3) th line means that 3 is substituted for both a (i) and a (i + 1).
この(3)行目の処理のように1つの命令で複数のデータを処理(ここではa(i)=3の処理とa(i+1)=3の処理)を実行することをSIMD(Single Instruction Multiple Data)と呼ぶ。このSIMDによれば高速処理が期待できる。 It is SIMD (Single Instruction) that a plurality of data is processed by one instruction (here, a (i) = 3 processing and a (i + 1) = 3 processing) as in the processing of the (3) line. This is called “Multiple Data”. According to this SIMD, high-speed processing can be expected.
(4)行目の「end do」は、(2)行目の「do i=1,99,2」を開始位置とするループの終了位置であることを意味している。 (4) “end do” in the line means that the end position of the loop starts with “do i = 1,99,2” in line (2).
(5)行目は、(1)行目の「if」文での実例(ここでは「配列aが8バイトの境界上にある」という条件)を満たさない場合に、この「else」文以下の処理を行なうことを意味している。 (5) If the line does not satisfy the example in the “if” statement on line (1) (here, the condition that “array a is on an 8-byte boundary”), this “else” statement This means that the process is performed.
(6)行目の「do i=1,100,1」は、先ずi=1と置いて(8)行目の「end do」までの間の処理を実行し、その後iを1ずつインクリメントしながら(8)行目までの間の処理をi=100まで繰り返すことを意味している。 (6) For “do i = 1,100,1” in the row, first, i = 1 is set, and the processing until “end do” in the (8) row is executed, and then i is incremented by 1 However, (8) means that the process up to the line is repeated until i = 100.
(7)行目の「a(i)=3」は、配列aの中のa(i)に3を代入することを意味している。 (7) “a (i) = 3” in the line means that 3 is assigned to a (i) in the array a.
(8)行目の「end do」は、(6)行目の「do i=1,100,1」を開始位置とするループの終了位置であることを意味している。 (8) “end do” in the line means the end position of the loop starting from “do i = 1,100,1” in the (6) line.
(9)行目の「end if」は、(1)行目の「if」文を開始位置とする処理の終了位置であることを意味している。 (9) “end if” on the line means that the end position of the process starts with the “if” statement on the (1) line.
すなわち、この図1(B)は、配列aが8バイトの境界上にある場合は、(3)行目のSIMDにより処理の高速化を図り、そうでない場合は、単純な逐次処理が行なわれるプログラムを表わしている。 That is, in FIG. 1B, when the array a is on the 8-byte boundary, the processing speed is increased by SIMD in the (3) th row, otherwise simple sequential processing is performed. Represents a program.
この図1(B)のプログラムの場合、図1(B)に示した(c)のifとendifとに囲まれたブロックが図1(A)のループに相当する。図1(A)の場合は単純な1つのループで構成されているが、図1(B)の場合はif−else文のif配下とelse配下それぞれにループが生成されている。すなわちこの図1(B)には、(c)のブロック内に(a)と(b)の2つのループが存在する。 In the case of the program shown in FIG. 1B, the block surrounded by if and endif shown in FIG. 1B corresponds to the loop shown in FIG. In the case of FIG. 1A, a simple loop is formed, but in the case of FIG. 1B, loops are generated under the if and else subordinates of the if-else statement. That is, in FIG. 1B, there are two loops (a) and (b) in the block (c).
図1(A)のループに関しPA情報を取得するための関数を図1(A)のソースプログラムに埋め込んだ場合、単純には、図1(B)の(c)のブロック全体についてのPA情報が得られ、(a)や(b)のループ単独でのPA情報を得ることはできない。(c)のブロックのPA情報を取得しても(a)のループと(b)のループのどちらが実行されたのか不明ともなりかねず、プログラムの実行性能の分析が不十分となるおそれがある。 When a function for acquiring PA information related to the loop of FIG. 1A is embedded in the source program of FIG. 1A, simply, PA information for the entire block of FIG. Thus, PA information cannot be obtained for the loops (a) and (b) alone. Even if the PA information of the block (c) is acquired, it may be unclear whether the loop (a) or the loop (b) was executed, and the analysis of the program execution performance may be insufficient. .
後述する実施形態の場合、(a)のループや(b)のループのそれぞれについて分離したPA情報を取得することが可能であり、プログラムの実行性能の詳細な分析を行なうことが可能となる。 In the case of an embodiment to be described later, it is possible to acquire separate PA information for each of the loops (a) and (b), and a detailed analysis of the program execution performance can be performed.
ここでは、最適化処理によりif−else文のif配下とelse配下それぞれにループが生成される例について説明したが、そのプログラムの記述によっては、処理ブロックが生成されることもある。実際のプログラムは通常はもっと複雑な記述となっているが、図1の例で処理ブロックを説明すると、例えば以下のように説明される。すなわち、図2(B)に示す(b)のループに代わり、「a(1)=3」,「a(2)=3」,「a(3)=3」の3つの処理が逐次的に行なわれるように記述されたプログラムが生成される可能性がある。このような場合、「a(1)=3」,「a(2)=3」,「a(3)=3」の3つの処理の連続を1つの処理ブロックとして捉え、後述する実施形態ではそのような処理ブロックについても、ループと同様、その処理ブロックについての独立したPA情報を取得することが可能である。 Here, an example has been described in which loops are generated under the if and else subordinates of an if-else statement by optimization processing, but depending on the description of the program, a processing block may be generated. The actual program is usually a more complicated description, but the processing block will be explained as follows, for example, in the example of FIG. That is, instead of the loop of (b) shown in FIG. 2B, three processes “a (1) = 3”, “a (2) = 3”, and “a (3) = 3” are sequentially performed. There is a possibility that a program written to be executed at the same time is generated. In such a case, a series of three processes “a (1) = 3”, “a (2) = 3”, and “a (3) = 3” is regarded as one processing block. For such a processing block, it is possible to acquire independent PA information for the processing block as in the case of the loop.
図2は、最適化処理によりループ分配が行なわれた例を示した図である。 FIG. 2 is a diagram illustrating an example in which loop distribution is performed by optimization processing.
図2(A)はソースプログラムであって、その(1)行目の「do i=1,n」は、以下の処理を行なうことを意味している。 FIG. 2A shows a source program, and “do i = 1, n” in the (1) line means that the following processing is performed.
・先ずi=1を置いて(4)行目の「end do」までの間の処理を実行する。 First, i = 1 is set, and the processing up to (end do) in the (4) th line is executed.
・その後iを1つずつインクリメントしながらi=nに達するまで、(4)行目の「end do」までの間の処理を繰り返す。 Thereafter, i is incremented by 1 until i = n is reached, and the process until “end do” in the (4) th line is repeated.
また、図2(A)の(2)行目のa(i)=iは、配列aのうちのa(i)にiを代入することを意味している。 Further, a (i) = i in the (2) th row in FIG. 2A means that i is substituted for a (i) in the array a.
また、3行目のb(i)=b(i−1)+a(i)は、配列bのうちのb(i−1)の値とa(i)の値とを足し算して、b(i)に代入することを意味している。 B (i) = b (i−1) + a (i) in the third row is obtained by adding the value of b (i−1) and the value of a (i) in the array b to b This means that it is assigned to (i).
さらに、(4)行目の「end do」は、(1)行目の「do i=1,n」を開始位置とするループの終了位置であることを意味している。 Furthermore, “end do” in the (4) th line means the end position of the loop starting from “do i = 1, n” in the (1) th line.
図2(B)は、最適化処理により図2(A)のソースプログラムを元にして作成されたプログラムを示している。 FIG. 2B shows a program created based on the source program of FIG. 2A by the optimization process.
この図2(B)の(1)行目の「do i=1,n」は、図2(A)の1行目と同様である。 “Do i = 1, n” in the (1) line in FIG. 2B is the same as in the first line in FIG.
図2(B)の(2)行目の「a(i)=i」は、図2(A)の(2)行目と同じである。 “A (i) = i” in the (2) line in FIG. 2B is the same as the (2) line in FIG.
また、図2(B)の(4)行目の「do i=1,n」は、(1)行目の「do i=1,n」と同様である。ただし、この(4)行目を開始位置とするループの終了位置は(6)行目の「end do」である。 Further, “do i = 1, n” in the (4) line in FIG. 2B is the same as “do i = 1, n” in the (1) line. However, the end position of the loop starting from the (4) th line is “end do” on the (6) th line.
また、図2(B)の(5)行目の「b(i)=b(i−1)+a(i)」は、図2(A)の(3)行目と同じである。ずなわち、この図2の場合、図2(A)の(1)行目〜(4)行目の全域からなるループは、図2(B)の(c)で示す範囲の全域に相当する。図2(A)の場合は単純な1つのループで構成されているが、図2(B)の場合ループ分配が行なわれ、(c)で示す範囲の中に(a)と(b)の2つのループが存在する。 Further, “b (i) = b (i−1) + a (i)” in the (5) line in FIG. 2B is the same as the (3) line in FIG. In other words, in the case of FIG. 2, the loop composed of the entire area from line (1) to line (4) in FIG. 2A corresponds to the entire area indicated by (c) in FIG. To do. In the case of FIG. 2 (A), it is composed of a simple loop, but in the case of FIG. 2 (B), loop distribution is performed, and (a) and (b) are included in the range shown in (c). There are two loops.
ここでは、簡単なソースプログラムを用いて例示しているが、例えば演算のためのレジスタが不足するような複雑な演算処理を行なうループの場合、図2(B)にようにループを複数に分離した方が効率の良い演算処理を行なうことができる場合がある。最適化処理によりループ分配した方が効率的と判断されると図2(B)のようなループ分配が行なわれることがある。 Here, a simple source program is used as an example. For example, in the case of a loop that performs complicated arithmetic processing in which a register for arithmetic is insufficient, the loop is separated into a plurality as shown in FIG. In some cases, efficient calculation processing can be performed. If it is determined that the loop distribution by the optimization process is more efficient, the loop distribution as shown in FIG. 2B may be performed.
この図2の場合も図1の場合と同様であり、PA情報取得のための関数を図2(A)のソースプログラムに埋め込んだ場合、単純には、図2(B)の(c)の範囲全体についてのPA情報の取得が行なわれることになる。この場合、(a)や(b)のループ単独でのPA情報を得ることはできない。したがって、(c)の範囲での実行性能が悪い場合、(a)のループに問題があるのか(b)のループに問題があるのか詳細な分析が不充分となるおそれがある。 The case of FIG. 2 is the same as the case of FIG. 1, and when a function for obtaining PA information is embedded in the source program of FIG. 2A, it is simply shown in FIG. 2B (c). The PA information for the entire range is acquired. In this case, it is not possible to obtain PA information for the loops (a) and (b) alone. Therefore, when the execution performance in the range of (c) is poor, there is a possibility that detailed analysis will be insufficient to determine whether there is a problem in the loop of (a) or a problem in the loop of (b).
そこで以下では、図1(B)や図2(B)の(a)や(b)のループについても独立したPA情報を取得できるようにした実施形態を説明する。 Therefore, in the following, an embodiment in which independent PA information can be acquired also for the loops (a) and (b) in FIG. 1 (B) and FIG. 2 (B) will be described.
図3は、コンパイル装置の一実施形態として動作するコンピュータの外観図、図4は、図3に外観を示すコンピュータのハードウエア構成図である。 FIG. 3 is an external view of a computer that operates as an embodiment of the compiling device, and FIG. 4 is a hardware configuration diagram of the computer whose external appearance is shown in FIG.
図3に示すコンピュータ100は、後述するCPU(Control Processing Unit)、メモリ、ハードディスク装置等を内蔵した本体部110を有する。またこのコンピュータ100は、その本体部110からの指示により表示画面121上に画像を表示する画像表示部120を有する。さらに、このコンピュータ100は、ユーザによるキー操作に応じてこのコンピュータ100内に指示や文字情報等を入力するキーボード130を有する。さらに、このコンピュータ100は、ユーザ操作により、表示画面121上に表示されたカーソルの移動や、表示画面121上に表示されたアイコン等の指定による指示入力等を行なうマウス140を有する。
A
本体部110は、CD(Compact Disk)やDVD(Digital Versatile Disk)(以下では、CDとDVDを区別せずにCD/DVDと称する)が装填されるCD/DVD装填口111を有する。その本体部110の内部には、そのCD/DVD装填口111から装填されたCD/DVDをドライブする、CD/DVDドライブが内蔵されている。
The
本体部110には、さらに、図4に示すように、CPU(Control Processing Unit)112、メモリ113、ハードディスク装置114およびネットワークインタフェイス115を有する。また、この図5には、CD/DVD117をドライブする上述のCD/DVDドライブ116も示されている。
The
これらの各要素の相互間、さらに、これらの各要素と、図4に外観を示した画像表示部120、キーボード130およびマウス140との相互間は、バス150で接続されている。
A
ここで、ハードディスク装置114には、各種プログラムやデータ等が保存されている。このハードディスク装置114に保存されているプログラムが読み出されてメモリ113に展開され、そのメモリ113上に展開されたプログラムがCPU112で実行される。また、ネットワークインタフェイス115は、LAN(Local Area Network)やインタネット等を介して外部と通信する要素である。
Here, the
ここでハードディスク装置114には、ソースプログラム(例えば図1(A),図2(A)参照)を元にオブジェクトプログラムを作成するコンパイルプログラムが保存されている。
Here, the
ソースプログラムは、CD/DVD117に格納されてCD/DVDドライブ116で読み込まれる。あるいは、ネットワークインタフェース115を介して受信してもよい。ハードディスク装置114に保存されているコンパイルプログラムがメモリ113に展開されCPU112で実行されると、このコンピュータ100はコンパイル装置の一例として動作する。このコンピュータ100がコンパイル装置として動作すると、上記のようにして取得したソースプログラムを元にオブジェクトプログラムが作成される。作成されたオブジェクトプログラムは一旦はハードディスク装置114内に保存された後、CD/DVDドライブ116によりCD/DVDに書き込まれたり、あるいは、ネットワークインタフェース115を介して送信される。このようにして、そのオブジェクトプログラムが実行先のコンピュータ(図示せず)に渡され、そのコンピュータで実行される。
The source program is stored in the CD /
図5は、実施形態としてのコンパイル装置の機能説明図である。 FIG. 5 is a functional explanatory diagram of the compiling device as the embodiment.
この図5のコンパイル装置10は、図3,図4に示すコンピュータ内でのコンパイルプログラムの実行によりそのコンピュータ内に実現する機能を表わしたものである。
The compile
この図5のコンパイル装置10は、プログラム言語で作成されたソースプログラム1を取り込み、そのソースプログラム1を、実行予定のコンピュータ上で実行可能なオブジェクトプログラム2に変換するコンパイルを実行する装置である。ここで、このオブジェクトプログラム2が実行されるコンピュータは、このコンパイル装置10の機能実現に用いるコンピュータと同一のコンピュータであることを妨げるものではないが、別のコンピュータであってもよい。
The compiling
ここで、本実施形態の場合、コンパイル装置10にはソースプログラム1のほかPA位置ファイル3も取り込まれ、そのPA位置ファイル3の記述を元にPA情報取得のための関数が埋め込まれたオブジェクトプログラム2が生成される。本実施形態ではPA情報として、PAレンジで指定された区間内での「サイクル数」、「命令数」、「キャッシュミス」などを取得する関数が埋め込まれる。
Here, in the case of the present embodiment, the compiling
このコンパイル装置10は、ソースプログラム/PA位置ファイル取得部11と、構文解析部12と、PA位置ファイル解析部13と、最適化部14と、PA取得関数挿入部15と、コード生成部16とを有する。また、このうちのPA取得関数挿入部15は、PAレンジ設定部151と、関数埋込部152とを有する。
The compiling
ソースプログラム/PA位置ファイル取得部11は、取得手段の一例であり、このコンパイル装置10にソースプログラム1とPA位置ファイル2とを取り込む。ソースプログラム1は、フォートラン言語やC言語、C++言語などのプログラム言語で作成されたプログラムである。また、PA位置ファイル3は、プログラム実行時の挙動を表わすPA情報を取得する、プログラム上の範囲を表わすPAレンジが記述されたファイルである。また、このPA位置ファイル3には、そのPAレンジとともに、後述するPAレンジ設定部151で新たなPAレンジを設定する場合の、その新たなPAレンジ設定箇所を指定するPAレンジ設定箇所指定情報も記述されている。
The source program / PA location
図6は、本実施形態におけるPA位置ファイルの記述内容を示す図である。1行目には、「*」印に続き、「PAレンジ設定箇所指定情報」のいずれかが記述されている。このPAレンジ設定箇所指定情報には、
「all」
「entirety−loop−only」
「main−loop−only」
「mod−loop−only」
の4種類が存在する。
FIG. 6 is a diagram showing the description contents of the PA location file in the present embodiment. On the first line, “PA range setting location designation information” is described after the “*” mark. This PA range setting location designation information includes
"All"
"Entity-loop-only"
“Main-loop-only”
"Mod-loop-only"
There are four types.
これらについて、図1(B),図2(B)を参照しながら説明する。 These will be described with reference to FIGS. 1B and 2B.
「all」は、図1(B),図2(B)の(a),(b),(c)の全てのループについてPA情報を取得することを意味している。 “All” means that PA information is acquired for all the loops of (a), (b), and (c) of FIG. 1 (B) and FIG. 2 (B).
また、「entirety−only」は、(c)のループについてのみPA情報を取得し、(a),(b)の個々のループについての独立したPA情報の取得は不要であることを意味している。 “Entity-only” means that PA information is acquired only for the loop of (c), and it is not necessary to acquire independent PA information for the individual loops of (a) and (b). Yes.
また、「main−loop−only」は、子ループのうちの最初のループ、すなわち(a)のループについてのみPA情報を取得し、(b),(c)のループについてのPA情報の取得は不要であることを意味している。 “Main-loop-only” acquires PA information only for the first loop of child loops, that is, the loop of (a), and acquisition of PA information for the loops of (b) and (c) It means that it is unnecessary.
さらに、「mod−loop−only」は、子ループのうちの最初のループを除く各ループ(図1(B),図2(B)の場合は(b)のループ)についてのPA情報を取得し、(a),(c)のループについてのPA情報の取得は不要であることを意味している。 Furthermore, “mod-loop-only” obtains PA information for each loop (the loop of (b) in the case of FIG. 1B and FIG. 2B) except the first loop among the child loops. This means that it is not necessary to acquire PA information for the loops (a) and (c).
また、PA位置ファイル内の記述内容のうちの2行目は以下のことを意味している。 The second line of the description contents in the PA position file means the following.
「ソースファイル名」はPA情報取得対象のソースプログラムが記述されたソースファイルの名前、「モジュール名」は、そのソースファイル中の、PA情報を取得するモジュールの名前である。さらに、「始点行番号,終点行番号」は、そのモジュール中のPA取得範囲の、それぞれ開始位置,終了位置を表わす始点行番号,終点行番号である。これら開始位置と終了位置とに挟まれる範囲を、ここでは「PAレンジ」と称している。 “Source file name” is the name of the source file in which the source program for which PA information is to be acquired is described, and “module name” is the name of the module for acquiring PA information in the source file. Further, the “starting line number and ending line number” are a starting line number and an ending line number representing the start position and the end position, respectively, of the PA acquisition range in the module. A range between the start position and the end position is referred to as “PA range” here.
図6では、PA位置ファイルは2行で記述されているが、3行目以降にも2行目と同様の記述を行ない、1つのPA位置ファイルで複数のPAレンジを指定することも可能である。 In FIG. 6, the PA position file is described in two lines. However, the same description as the second line can be made in the third and subsequent lines, and a plurality of PA ranges can be specified in one PA position file. is there.
図5に戻って説明を続ける。 Returning to FIG.
図5に示すコンパイル装置10の構文解析部12は、第1変換手段の一例であり、ソースプログラム/PA位置ファイル取得部11で取得したソースプログラムを、このコンパイル装置10での取扱いに適した中間言語で記述された第1のプログラムに変換する。
The
また、PA位置ファイル解析部13は、第1設定手段の一例である。すなわち、このPA位置ファイル解析部13は、PA位置ファイルから、PA取得範囲の開始位置を終了位置とで規定されるPAレンジを読み出して、そのPAレンジ(開始位置と終了位置)を上記の第1のプログラム上に設定する。
The PA position
また最適化部14は、最適化手段の一例であり、PAレンジが設定された第1のプログラムに最適化処理を施して、その第1のプログラム上に設されたPAレンジを引き継いだ第2のプログラムを生成する。ここでの最適化処理は、例えば図1,図2に示すSIMD化やループ分配など、第1のプログラムに、そのプログラムがより効率的に実行されるように変更を加える処理をいう。
The
この最適化部14による最適化処理内容は、最適化情報141として書き残される。
The contents of the optimization process by the
図7は最適化情報を示す図である。 FIG. 7 is a diagram showing optimization information.
ここでは、「ソースファイル名」と「モジュール名」と「対象行番号」とにより、最適化処理によるプログラムの変更が加えられた位置が特定される。また、「最適化種別」により、最適化処理によって行なわれたプログラムの変更の種別が特定される。「最適化種別」には、例えば、「SIMD化」(図1参照)や「ループ分配」(図2参照)などが含まれる。 Here, the position where the program is changed by the optimization process is specified by the “source file name”, “module name”, and “target line number”. The “optimization type” identifies the type of program change performed by the optimization process. The “optimization type” includes, for example, “SIMD” (see FIG. 1), “loop distribution” (see FIG. 2), and the like.
また図5に示すPA取得関数挿入部15を構成するPAレンジ設定部151は、第2設定手段の一例であり、第1のプログラムと比べたときの、第2のプログラム上のPAレンジ内のループ又は処理ブロックの数の増加の有無を調べる。そして増加していた場合に、第2のプログラム上のPAレンジ内の各ループ又は処理ブロックに新たなPAレンジを設定する。この新たなPAレンジを設定するにあたっては、PA位置ファイル3に記述された「PAレンジ設定箇所指定情報」に基づいて新たなPAレンジが設定される。
The PA
また、PA取得関数挿入部15を構成する関数埋込部152は、関数埋込手段の一例であって、第2のプログラムに、PA情報取得のためのPA情報取得関数を、第2のプログラムに設定されたPAレンジごとに埋め込む。
The
さらに、コード生成部16は、第2の変換手段の一例であり、PA情報取得関数が埋め込まれた第2のプログラムを、コンピュータ上で実行可能なオブジェクトプログラム2に変換する。ソースプログラム1が、メインルーチンとサブルーチンなど複数のプログラムに分かれている場合もある。このとき、コード生成部16は、それら複数のプログラムについてオブジェクトプログラムを作成する。その後、リンカ17によって、複数のオブジェクトプログラムを統合し、最終的に実行可能なオブジェクトプログラムを作成する。
Furthermore, the
以下、ソースプログラムおよびPA位置ファイルの例を挙げながら、図5に示すコンパイル装置11の各部の動作についてさらに記述する。
Hereinafter, the operation of each part of the compiling
図8は、ソースプログラムを取得して中間言語による第1のプログラムに変換する処理のイメージを示した図である。 FIG. 8 is a diagram showing an image of processing for acquiring a source program and converting it into a first program in an intermediate language.
図8(A)はソースプログラムの一例、図8(B)はPA位置ファイルの一例、図8(C)は、中間言語による第1プログラムの一例を示している。 FIG. 8A shows an example of a source program, FIG. 8B shows an example of a PA position file, and FIG. 8C shows an example of a first program in an intermediate language.
図8(A)に記載されている「ソースプログラム(a.f90)」は、このソースプログラムが記述されているソースファイルの名前が「a.f90」であることを意味している。 “Source program (a.f90)” described in FIG. 8A means that the name of the source file in which the source program is described is “a.f90”.
また、このソースプログラムの(1)行目の「subroutine sub1(a,b,n)」は、この(1)行目以降が、「sub1」と名づけられa,b,nを引数とするサブルーチンであることを表わしている。 In addition, “subroutine sub1 (a, b, n)” on the (1) line of this source program is a subroutine that is named “sub1” on and after the (1) line and has a, b, n as arguments. It represents that.
また、(2)行目の「integer::n」は、nが整数であることを表わしている。 Also, “integer :: n” on the (2) line represents that n is an integer.
また、(3)行目の「real,dimension(1000)::a,b」は、a,bのそれぞれが実数であって、かつそれぞれが1000個の要素を持つ配列であることを表わしている。 In addition, “real, dimension (1000) :: a, b” on the (3) line indicates that each of a and b is a real number and each is an array having 1000 elements. Yes.
また、(4)〜(7)行目については、図2(A)の(1)〜(4)行目とそれぞれ同一であり、ここでの重複説明は省略する。 Further, the (4) to (7) lines are the same as the (1) to (4) lines in FIG. 2A, respectively, and a duplicate description is omitted here.
さらに(8)行目の「end subroutine sub1」は、「sub1」と名づけられたサブルーチンの終了位置であることを表わしている。 Furthermore, “end subroutine sub1” on line (8) represents the end position of the subroutine named “sub1”.
また、図8(B)の「PA位置ファイル(parange.txt)」は、このPA位置ファイルのファイル名が「parange.txt」であることを意味している。 In addition, “PA location file (page.txt)” in FIG. 8B means that the file name of this PA location file is “page.txt”.
また、図8(B)のPA位置ファイル中の1行目の「*all」は、図6を参照して説明した「PAレンジ設定箇所指定情報」が「all」であることを表わしている。 Also, “* all” on the first line in the PA position file in FIG. 8B indicates that “PA range setting location designation information” described with reference to FIG. 6 is “all”. .
また、図8(B)のPA位置ファイル中の2行目の「a.f90」,「sub1」,「4」,「7」は、ソースファイル名が「a.f90」(図8(A)参照)、モジュール名が「sub1」、PAレンジが4行目から7行目までであることを表わしている。 Further, “a.f90”, “sub1”, “4”, and “7” in the second line in the PA position file of FIG. 8B have source file names “a.f90” (FIG. 8A )), The module name is “sub1”, and the PA range is from the fourth line to the seventh line.
ここでは、図5に示すコンパイル装置10のソースプログラム/PA位置ファイル取得部11で、図8(A)のソースプログラムおよび図8(B)のPA位置ファイルが取得されたものとする。
Here, it is assumed that the source program / PA location
このとき、図5の構文解析部12では、図8(A)に示すソースプログラムを元にして、図8(C)にイメージを示す、中間言語で記述された第1のプログラムが作成される。
At this time, the
図8(C)の、「基本処理ブロック(Line1)」,「基本処理ブロック(Line2),「基本処理ブロック(Line3),および「基本処理ブロック(Line8)は、図8(A)のソースプログラムの、それぞれ(1)行目、(2)行目、(3)行目、および(8)行目の命令が中間言語に変換された部分である。また、図8(C)の「ループ(line4−7)」は、図8(A)の(4)行目から(7)行目までのループが中間言語で記述された部分である。その「ループ(line4−7)」は、Line4のブロック、Line5,6のブロック、Line5,6を指定回数繰り返すためのカウンタのブロック、およびLine7のブロックからなる。Line4のブロックは、図8(A)の(4)行目に対応し、Line5,6のブロックは、図8(A)の(5),(6)行目に対応する。カウンタのブロックは、iを1からnまでカウントしながらLine5,6の処理を繰り返させるためのブロックである。Line7のブロックは、図8(A)の(7)行目に対応するブロックである。カウンタのブロックからLine5,6のブロックに向かう矢印は処理の繰り返しを表わしている。また、Line4のブロックからLine7のブロックに向かう矢印は、例えばn=0又はn<0など、図8(A)の(4)行目から(7)行目の間のループ処理の条件を満足しない場合に、(4)行目から(7)行目にスキップすることを表わしている。図8(C)の「ループ(line4−7)」は、1つのまとまった処理を実行する複数の基本処理ブロックからなる「処理ブロック」の1つである。
The “basic processing block (Line1)”, “basic processing block (Line2)”, “basic processing block (Line3), and“ basic processing block (Line8) ”in FIG. 8C are the source programs of FIG. Are the parts in which the instructions on the (1) line, (2) line, (3) line, and (8) line are converted into an intermediate language, respectively, and the “loop” in FIG. “(Line4-7)” is a portion in which a loop from the (4) line to the (7) line in FIG. 8A is described in an intermediate language. The “loop (line 4-7)” includes a
図9は、図5のPA位置ファイル解析部13での処理を示すフローチャートである。
FIG. 9 is a flowchart showing processing in the PA position
また図10は、PA位置ファイル解析部13での処理のイメージを示す図である。
FIG. 10 is a diagram showing an image of processing in the PA position
PA位置ファイル解析部13では、図9に示すように、先ずPA位置ファイル(図8(B)参照)から、そこに記述された、「ソースファイル名」「モジュール名」「PAレンジ(開始位置と終了位置)」が読み取られる(ステップS11)。そして、中間言語で記述された第1のプログラム(図8(C)参照)を辿り、PAレンジの開始位置、終了位置として指定された行番号を探索する(ステップS12)。この探索により見つけた行番号に対応づけて開始位置、終了位置を表わす属性値を設定する(ステップS13)。またここでは、その開始位置から終了位置までの間に存在する処理ブロックやループの数も計数して設定しておく。
In the PA position
この処理を、図8に示す例の続きで説明すると、図10に示すように、Line4のブロックに「PA(1)start/all/blockNum:1」なる属性値が設定され、Line7のブロックに「PA(1)end/all」なる属性値が設定される。 This process will be described in the continuation of the example shown in FIG. 8. As shown in FIG. 10, the attribute value “PA (1) start / all / blockNum: 1” is set in the Line4 block, and the Line7 block is set. An attribute value “PA (1) end / all” is set.
Line4のブロックに設定された属性値のうちの「PA(1)start」は、通し番号(1)のPAレンジの開始位置であることを表わしている。また、「all」は、図6を参照して説明した「PAレンジ設定箇所指定情報」が「all」であることを表わしている。さらに、「blockNum:1」は、このPAレンジ内にある処理ブロック又はループの数が1であることを表わしている。
“PA (1) start” among the attribute values set in the block of
Line7のブロックに設定された属性値のうちの「PA(1)end」は、通し番号(1)のPAレンジの終了位置であることを表わしている。「all」は、Line4のブロックの属性値のうちの「all」が繰り返されている。
“PA (1) end” among the attribute values set in the block of
図9のステップS14では、PA位置ファイルから全てのPAレンジについての設定が終了したか否かが判定され、未設定のPAレンジが存在するときはステップS11に戻ってその未設定のPAレンジについての処理が繰り返される。 In step S14 of FIG. 9, it is determined whether or not the settings for all the PA ranges have been completed from the PA position file. If there is an unset PA range, the process returns to step S11 to determine the unset PA range. The process is repeated.
ここで、図8(B)に示すPA位置ファイルは2行で構成されており、PAレンジはその2行目に記載された1つのみである。ただし、前述した通り2行目と同様の記述を3行目以降に記載することにより、1つのPA位置ファイルで複数のPAレンジを設定することもできる。図9のステップS14は、複数のPAレンジが設定されている場合があることを考慮したステップである。 Here, the PA position file shown in FIG. 8B is composed of two lines, and the PA range is only one described in the second line. However, as described above, by describing the same description as the second line in the third and subsequent lines, a plurality of PA ranges can be set with one PA position file. Step S14 in FIG. 9 is a step that takes into consideration that a plurality of PA ranges may be set.
全てのPAレンジについて属性値の設定が終了すると(図9のステップS14)、それらの属性値が設定された第1のプログラム(図10参照)が図5に示す最適化部14に渡される(ステップS15)。
When setting of attribute values for all PA ranges is completed (step S14 in FIG. 9), the first program (see FIG. 10) in which those attribute values are set is passed to the
図5の最適化部14では、PA位置ファイル解析部13から受け取った第1のプログラムに最適化処理が施される。ここでは、最適化処理の結果、ループ分配(図2参照)が行なわれたものとする。
In the
このとき、最適化部14は、ソースファイル名「a.f90」、モジュール名「sub1」、対象行番号「4,7」、および最適化種別「ループ分配」なる最適化情報141を生成する(図5,図7参照)。
At this time, the
図11は、最適化処理により生成された第2のプログラムを示すイメージ図である。 FIG. 11 is an image diagram showing a second program generated by the optimization process.
ここには、「ループ(line4−7)」が2つ存在する。上側のループは、図8(A)の(5)行目の処理を担当するループ、下側のループは図8(A)の(6)行目の処理を担当するループである。また、上側のループ、下側のループのいずれにも「L−dst」が記載されている。この「L−dst」は、そのループに関する最適化情報141(図5参照)を示している。また、この第2のプログラムは、最適化前の第1のプログラム(図10参照)のPAレンジに関する属性値を引き継いでいる。PAレンジの開始位置に関する属性値は、2つのループのうちの上側のループのLine4のブロックに対応づけられている。また、PAレンジの終了位置に関する属性値は2つのループのうちの下側のループのLine7のブロックに対応づけられている。
There are two “loops (lines 4-7)”. The upper loop is a loop in charge of the processing of the (5) line in FIG. 8A, and the lower loop is a loop in charge of the processing of the (6) line in FIG. 8A. In addition, “L-dst” is described in both the upper loop and the lower loop. This “L-dst” indicates optimization information 141 (see FIG. 5) regarding the loop. In addition, the second program takes over the attribute value related to the PA range of the first program (see FIG. 10) before optimization. The attribute value related to the start position of the PA range is associated with the
この段階では、PAレンジは、上側のループの先頭から下側のループの最終までが1つのPAレンジ(ここでは、「PAレンジ<1>」と称する)が設定されていることになる。 At this stage, one PA range (herein referred to as “PA range <1>”) is set from the beginning of the upper loop to the end of the lower loop.
図12,図13は、図5のPA取得関数挿入部15の処理を示すフローチャートの、それぞれ前半部分、後半部分を示す図である。
FIGS. 12 and 13 are diagrams showing the first half and the second half of the flowchart showing the processing of the PA acquisition
PA取得関数挿入部15では、最適化処理の行なわれた第2のプログラムに関し、図12,図13の処理を行なう。
The PA acquisition
ここでは先ず、最適化情報141(図5参照)が調べられて、ループに関する最適化処理が行なわれたか否かが判定される(ステップS21)。そしてループに関する最適化処理が行なわれた場合、その最適化処理が行なわれたループがPAレンジに含まれるループであるか否かが判定される(ステップS22)。ループに関する最適化処理が行なわれていない場合(ステップS21)、あるいは、ループに関する最適化処理が行なわれていてもPAレンジ内のループに関して最適化処理が行なわれていない場合(ステップS22)は、図13のステップS33に進む。ステップS33については後述する。 Here, first, the optimization information 141 (see FIG. 5) is examined to determine whether or not the optimization processing related to the loop has been performed (step S21). When the optimization process related to the loop is performed, it is determined whether or not the loop subjected to the optimization process is a loop included in the PA range (step S22). When the optimization process related to the loop is not performed (step S21), or when the optimization process related to the loop is performed, the optimization process is not performed regarding the loop in the PA range (step S22). Proceed to step S33 of FIG. Step S33 will be described later.
PAレンジ内のループに関し最適化処理が行なわれている場合(ステップS22)は、ステップS23に進み、そのPAレンジ内の処理フローを辿り、処理ブロックやループの数が数えられる。その数が増加していないときは(ステップS24)、ステップS33に進む。 If the optimization process is being performed for the loop in the PA range (step S22), the process proceeds to step S23, the process flow in the PA range is followed, and the number of processing blocks and loops is counted. When the number has not increased (step S24), the process proceeds to step S33.
図14は、ループ数の増加が認識された段階の第2のプログラムのイメージ図である。 FIG. 14 is an image diagram of the second program at the stage where the increase in the number of loops is recognized.
ここでは、元々は1つが存在していなかったループが2つに増加しており、PAレンジ<1>を親のPAレンジとしたときに、その親のPAレンジ<1>の下に2つの子のPAレンジ<1.1>,<1.2>が存在することが認識される。 Here, the number of loops that originally did not exist has increased to two, and when PA range <1> is set as the parent PA range, two loops are placed under the parent PA range <1>. It is recognized that there are child PA ranges <1.1> and <1.2>.
ループ又は処理ブロックの数が増加したことが認識されると(図12,ステップS24)、ステップS25に進み、第2のプログラム上に新たなPAレンジが設定される。 When it is recognized that the number of loops or processing blocks has increased (FIG. 12, step S24), the process proceeds to step S25, and a new PA range is set on the second program.
図15は、第2のプログラム上に新たなPAレンジが設定された状態を示すイメージ図である。 FIG. 15 is an image diagram showing a state in which a new PA range is set on the second program.
ここには、上下2つのループのうちの上側のループのLine4のブロックには、PAレンジに関する属性値として「PA(1,1.1)start/all」が設定されている。また、上側のループのLine7のブロックには、「PA(1.1)end/all」、下側のループのLine4のブロックには「PA(1.2)start/all」、下側のループのLine7のブロックには「PA(1,1.2)end/all」の属性値が設定されている。
Here, “PA (1, 1.1) start / all” is set as an attribute value related to the PA range in the block of
上側のループのLine4のブロックに設定されている属性値のうちの、「PA(1,1.1)start」は、親のPAレンジ<1>と子のPAレンジ<1.1>の双方のPAレンジの開始位置であることを表わしている。「all」については説明済であり、ここでの説明は省略する。
Among the attribute values set in the
上側のループのLine7のブロックに設定されている属性値のうちの「PA(1.1)end」は、子のPAレンジ<1.1>の終了位置であることを表わしている。
“PA (1.1) end” among the attribute values set in the
また、下側のループのLine4のブロックに設定されている属性値のうちの「PA(1.2)start」は子のPAレンジ<1.2>の開始位置であることを表わしている。
Of the attribute values set in the
さらに、下側のループのLine7のブロックに設定されている属性値のうちの「PA(1,1.2)end」は、親のPAレンジ<1>および子のPAレンジ<1.2>の双方のPAレンジの終了位置であることを表わしている。
Further, “PA (1, 1.2) end” among the attribute values set in the
ここでは、このように、親のPAレンジ<1>、および2つの子のPAレンジ<1.1>,<1.2>が、互いの親子関係が分かるように設定されている。 Here, in this way, the parent PA range <1> and the two child PA ranges <1.1> and <1.2> are set so that the parent-child relationship can be understood.
図12のステップS26では、PA位置ファイルから「PAレンジ設定箇所指定情報」が読み込まれる。前述の通り、この「PAレンジ設定箇所指定情報」には、ここで例示している「all」のほか、「entirety−only」、「main−loop−only」、および「mod−loop−only」の合計4種類存在する。 In step S26 of FIG. 12, “PA range setting location designation information” is read from the PA position file. As described above, the “PA range setting location designation information” includes “all-only”, “main-loop-only”, and “mod-loop-only” in addition to “all” illustrated here. There are a total of four types.
ステップS27では、その読み込んだ「PAレンジ設定箇所指定情報」が「entirety−only」であるか否かが判定され、「entirety−only」であったときは子のPAレンジに関する属性値が削除される(ステップS28)。 In step S27, it is determined whether or not the read “PA range setting location designation information” is “entry-only”, and if it is “entry-only”, the attribute value related to the child PA range is deleted. (Step S28).
「entirety−only」は、子のPAレンジについての個別のPA情報は不要であって、親のPAレンジについて一括してPA情報を取得することを指示する情報だからである。 This is because “entity-only” does not require individual PA information for the child PA range, and is information for instructing to collectively acquire PA information for the parent PA range.
また、その「PAレンジ設定箇所指定情報」が「main−loop−only」のときは、子のPAレンジのうちの2番目以降の子のPAレンジに関する属性値が削除される(ステップS30)。ここで、2番目以降と表現しているのは、親のPAレンジ内に3つ以上のループ又は処理ブロックが存在することもあるからである。 If the “PA range setting location designation information” is “main-loop-only”, the attribute values related to the second and subsequent child PA ranges of the child PA ranges are deleted (step S30). Here, the reason for expressing the second or later is that there may be three or more loops or processing blocks in the parent PA range.
さらに、その「PAレンジ設定箇所指定情報」が「mod−loop−only」のときは(ステップS31)、子のPAレンジのうちの1番目の子のPAレンジに関する属性値が削除される(ステップS32)。 Furthermore, when the “PA range setting location designation information” is “mod-loop-only” (step S31), the attribute value related to the PA range of the first child of the child PA ranges is deleted (step S31). S32).
尚、ここで示している具体例(図15参照)では「all」が指定されているため、ステップS27,S29,S31のいずれも「no」であり、子のPAレンジの属性値はいずれも削除されることなく残される。 In the specific example shown here (see FIG. 15), since “all” is designated, all of steps S27, S29, and S31 are “no”, and the attribute values of the child PA range are all. It remains without being deleted.
図12,図13に示す処理のうち、ステップS32までの処理が、図5のPAレンジ設定部151の処理に相当し、以下のステップS33以降の処理が図5の関数埋込部152の処理に相当する。
Of the processes shown in FIGS. 12 and 13, the process up to step S32 corresponds to the process of the PA
ステップS33では、PA情報取得関数挿入処理が行なわれる。ここでは、PAレンジに関する属性値が参照されて、各PAレンジについて第2のプログラム内にPA情報取得のための関数が埋め込まれる。 In step S33, PA information acquisition function insertion processing is performed. Here, an attribute value related to the PA range is referred to, and a function for acquiring PA information is embedded in the second program for each PA range.
図16は、第2のプログラムにPA情報取得関数が埋め込まれた状態を示すイメージ図である。 FIG. 16 is an image diagram showing a state in which the PA information acquisition function is embedded in the second program.
上下2つのループのうちの上側のループのLine4のブロックには、「Call PA_start(1.1)」が埋め込まれ、上側のループのLine7のブロックには「Call PA_end(1.1)」が埋め込まれている。
Of the two upper and lower loops, “Call PA_start (1.1)” is embedded in the
また、下側のループのLine4のブロックには、「Call PA_start(1.2)」が埋め込まれ、下側のループのLine7のブロックには「Call PA_end(1.2)」が埋め込まれている。
Also, “Call PA_start (1.2)” is embedded in the
上側のループのLine4のブロックに埋め込まれている「Call PA_start(1.1)」は、PA情報の取得の開始を実行する関数を呼び出す命令である。また、上側のループのLine7のブロックに埋め込まれている「Call PA_end(1.1)」は、「Call PA_start(1.1)」で開始したPA情報の取得の停止を実行する関数を呼び出す命令である。
“Call PA_start (1.1)” embedded in the block of
又、これと同じく、下側のループのLine4のブロックに埋め込まれている「Call PA_start(1.2)」、およびLine7のブロックに埋め込まれている「Call PA_end(1.2)」は、それぞれ、PA情報の取得の開始、PA情報の取得の終了を実行する各関数を呼び出す命令である。2つのPAレンジに<1.1>、<1.2>という番号を付すことにより、それら2つのPAレンジを合算したPAレンジが親のPAレンジ<1>であることが分かるように関連づけている。
Similarly, “Call PA_start (1.2)” embedded in the
図13のステップS33で、例えば図16に示すようにPA情報取得関数の埋込みが行なわれると、PA取得関数が埋め込まれた第2のプログラムがコード生成部16(図5参照)に渡される。 In step S33 of FIG. 13, for example, when the PA information acquisition function is embedded as shown in FIG. 16, the second program in which the PA acquisition function is embedded is passed to the code generation unit 16 (see FIG. 5).
コード生成部16は、PA取得情報が埋め込まれた第2のプログラムを受け取り、コンピュータで実行可能なオブジェクトプログラムを生成する。また、メインルーチンとサブルーチンなど複数のプログラムが存在するときは、コード生成部16、リンカ17によって、それら複数のプログラムの結合も行なわれて、最終的に実行可能なオブジェクトプログラムが生成される。
The
図17は、ソースプログラム上に、図16の中間言語イメージ上のPA取得関数と同じ内容を書き下したときのイメージ図である。 FIG. 17 is an image diagram when the same content as the PA acquisition function on the intermediate language image of FIG. 16 is written on the source program.
ここでは、(3)行目〜(5)行目のループと(8)行目〜(10)行目のループとの2つのループにループ分配されている。ここで、(1)行目に親のPAレンジ(1)のPA情報取得開始を実行する関数を呼び出す命令が記述されている。また、(2)行目には子のPAレンジ(1.1)のPA情報取得開始を実行する関数を呼び出す命令が記述されている。さらに、(6)行目には子のPAレンジ(1.1)のPA情報の取得の停止を実行する関数を呼び出す命令が記述されている。さらに、(7)行目には子のPAレンジ(1.2)のPA情報の取得を開始する関数を呼び出す命令が記述されている。さらに、(11)行目には子のPAレンジ(1.2)のPA情報の取得を停止する関数を呼び出す命令が記述され、(12)行目には親のPAレンジ(1)のPA情報の取得を停止する関数を呼び出す命令が記述されている。 Here, the loop is distributed to two loops, that is, the loop of the (3) line to the (5) line and the loop of the (8) line to the (10) line. Here, an instruction for calling a function for executing the PA information acquisition start of the parent PA range (1) is described in the (1) line. Further, in the (2) line, an instruction for calling a function for executing the PA information acquisition start of the child PA range (1.1) is described. Further, the (6) line describes an instruction for calling a function for stopping the acquisition of the PA information of the child PA range (1.1). Further, the (7) line describes an instruction for calling a function for starting the acquisition of PA information of the child PA range (1.2). Further, an instruction for calling a function for stopping acquisition of PA information of the child PA range (1.2) is described in the (11) line, and a PA in the parent PA range (1) is described in the (12) line. An instruction for calling a function for stopping the acquisition of information is described.
ここで、図16では、親のPAレンジに関するPA情報取得関数は明示的には埋め込まれていない。上述の通り、親子関係が分かっており、親のPA情報は2つの子のPA情報の和として自動的に求められる。 Here, in FIG. 16, the PA information acquisition function related to the parent PA range is not explicitly embedded. As described above, the parent-child relationship is known, and the parent PA information is automatically obtained as the sum of the PA information of the two children.
これに対し、図17の場合、プログラマが書き下すことが想定されており、プログラマが自分でループ分配を行ない、PA取得関数も自分で埋め込んでいる。 On the other hand, in the case of FIG. 17, it is assumed that the programmer writes down, the programmer performs the loop distribution by himself, and also embeds the PA acquisition function by himself.
このように、従来はPAレンジの親子関係が自動認識されることもなく、PAレンジ<1>と、PAレンジ<1.1>と、PAレンジ<1.2>はそれぞれ別々のPAレンジとして認識される。したがってプログラマが全てのPAレンジについてPA情報取得関数を記述しておく必要がある。 Thus, conventionally, the parent-child relationship of the PA range is not automatically recognized, and the PA range <1>, PA range <1.1>, and PA range <1.2> are set as separate PA ranges, respectively. Be recognized. Therefore, it is necessary for the programmer to describe PA information acquisition functions for all PA ranges.
図18は、「all」以外の「PAレンジ設定箇所指定情報」が指定された場合の、ソースコードイメージを示した図である。 FIG. 18 is a diagram showing a source code image when “PA range setting location designation information” other than “all” is designated.
図18(A)は、「entirety−only」が指定された場合であり、複数のループ全体を含むようにPA情報取得関数が埋め込まれている。 FIG. 18A shows a case where “entry-only” is designated, and a PA information acquisition function is embedded so as to include the entire plurality of loops.
図18(B)は、「main−loop−only」が指定された場合であり、PA情報取得関数が1番目のループのみ含むように埋め込まれている。 FIG. 18B shows a case where “main-loop-only” is designated, and the PA information acquisition function is embedded so as to include only the first loop.
図18(C)は、「mod−loop−only」が指定された場合であり、PA情報取得関数が2番目のループのみ含むように埋め込まれている。尚、ここには、ループ2つのみの場合が示されているが、3つ以上のループが存在する場合、「mod−loop−only」では2番目以降の各ループそれぞれについて独立してPA情報が得られるように、PA情報取得関数が埋め込まれる。 FIG. 18C shows a case where “mod-loop-only” is designated, and the PA information acquisition function is embedded so as to include only the second loop. Although only two loops are shown here, when there are three or more loops, in the “mod-loop-only”, the PA information is independently set for each of the second and subsequent loops. PA information acquisition function is embedded.
図19は、コンパイル実行時の表示画面例を示す図である。 FIG. 19 is a diagram showing an example of a display screen at the time of compiling.
1行目の「frt a.f90 −pa_range“parange.txt” −o a.exe」は、オペレータによるキーボード130(図3参照)等の操作により入力される。ここで、「frt」は、フォートラン(Fortran)言語で記述されたソースプログラムをコンパイルするためのコマンドである。また、「a.f90」はソースプログラムが記述されたソースファイルの名前である(図8(A)参照)。また、−pa_range“parange.txt”は、そのソースファイル「a.f90」と結びつけるべきPA位置ファイルのファイル名が「parange.txt」であることを表わしている(図8(B)参照)。さらに、「−o a.exe」は、最終的なオブジェクトプログラムが格納される実行ファイルの名称が「a.exe」であることを表わしている。 In the first line, “frt a.f90 -pa_range“ parrange. “txt” -o a.exe ”is input by an operation of the keyboard 130 (see FIG. 3) by the operator. Here, “frt” is a command for compiling a source program described in the Fortran language. “A.f90” is the name of the source file in which the source program is described (see FIG. 8A). Further, -pa_range “place.txt” indicates that the file name of the PA location file to be associated with the source file “a.f90” is “place.txt” (see FIG. 8B). Further, “-o a.exe” indicates that the name of the execution file in which the final object program is stored is “a.exe”.
すなわち、この1行目は、フォートラン言語で記述された、「a.f90」のファイルに格納されているソースプログラムに、PA位置ファイル「parange.txt」を参照しながらPA情報取得関数を埋め込んでオブジェクトプログラムを生成することを指示するオペレータの命令を表わしている。また、この1行目はさらに、その生成したオブジェクトプログラムを「a.exe」のファイルに格納することを指示している。 In other words, the first line embeds a PA information acquisition function in the source program stored in the file “a.f90” described in the Fortran language while referring to the PA location file “parrange.txt”. It represents an operator command instructing generation of an object program. The first line further instructs to store the generated object program in the file “a.exe”.
2行目以降は、コンパイル装置でのコンパイルの実行の進度に応じて順次表示される情報である。最終行の「実行ファイル完成(a.exe)」まで表示されることで、コンパイルが完了したことが分かる。 The second and subsequent lines are information that is sequentially displayed according to the progress of execution of compilation by the compiling device. By displaying up to “execution file completion (a.exe)” on the last line, it is understood that the compilation is completed.
図20は、実行ファイルに格納された、PA情報取得関数が埋め込まれたオブジェクトプログラムの実行により得られるPA情報の表示イメージを示した図である。 FIG. 20 is a diagram showing a display image of PA information obtained by executing an object program embedded with a PA information acquisition function, stored in an execution file.
1行目は、親のPAレンジ<1>に関するPA情報である。この親のPAレンジ<1>のPA情報は2行目の子のPAレンジ<1.1>のPA情報と3行目の子のPAレンジ<1.2>のPA情報との和となっている。 The first line is PA information related to the parent PA range <1>. The PA information of the parent PA range <1> is the sum of the PA information of the child PA range <1.1> of the second row and the PA information of the child PA range <1.2> of the third row.
「interval」はPAレンジを示している。1行目の「4−7/block1(a.f90−sub1)」は、a.f90/sub1の4行目から7行目までの処理ブロックに関するPA情報であることを意味している。2行目、3行目についても同様である。「cycle」、「instructions」「cachemiss」は、各処理ブロック実行時における、それぞれ、サイクル数、命令数、およびキャッシュミスの数を表わしている。 “Interval” indicates the PA range. “4-7 / block1 (a.f90-sub1)” on the first line is a. This means that the PA information is related to the processing blocks from the fourth line to the seventh line of f90 / sub1. The same applies to the second and third lines. “Cycle”, “instructions”, and “cachemiss” represent the number of cycles, the number of instructions, and the number of cache misses when each processing block is executed.
このように、本実施形態では、最適化処理によりループ又は処理ブロックが増えた場合であっても、各ループ又は各処理ブロックについての詳細なPA情報を取得することができる。したがってプログラムの実行性能の詳細な分析が可能となる。 As described above, in this embodiment, even when the number of loops or processing blocks is increased by the optimization processing, detailed PA information about each loop or each processing block can be acquired. Therefore, detailed analysis of program execution performance becomes possible.
1 ソースプログラム
2 オブジェクトプログラム
3 PA位置ファイル
10 コンパイル装置
11 ソースプログラム/PA位置ファイル取得部
12 構文解析部
13 PA位置ファイル解析部
14 最適化部
15 PA取得関数挿入部
16 コード生成部
17 リンカ
100 コンピュータ
110 本体部
111 CD/DVD装填口
112 CPU
113 メモリ
114 ハードディスク装置
115 ネットワークインタフェイス
116 CD/DVDドライブ
117 CD/DVD
120 画像表示部
130 キーボード
121 表示画面
140 マウス
141 最適化情報
150 バス
151 PAレンジ設定部
152 関数埋込部
DESCRIPTION OF
113
DESCRIPTION OF
Claims (4)
前記取得手段で取得したソースプログラムを中間言語で記述された第1のプログラムに変換する第1変換手段と、
前記PA位置ファイルから前記PAレンジを読み出して、該PAレンジを前記第1のプログラム上に設定する第1設定手段と、
前記第1設定手段で前記PAレンジが設定された前記第1のプログラムに最適化処理を施して、該第1のプログラム上に設定された前記PAレンジを引き継いだ第2のプログラムを生成する最適化手段と、
前記第1のプログラム上の前記PAレンジ内のループ又は処理ブロックの数と比べたときの前記第2のプログラム上の前記PAレンジ内のループ又は処理ブロックの数の増加の有無を調べ、該第2のプログラム上の該PAレンジ内のループ又は処理ブロックの数が増加していた場合に、該第2のプログラム上の前記PAレンジ内の各ループ又は各処理ブロックに新たなPAレンジを設定する第2設定手段と、
前記第2のプログラムに、前記PA情報取得のためのPA情報取得関数を、該第2のプログラムに設定された前記PAレンジ毎に埋め込む関数埋込手段と、
前記PA情報取得関数が埋め込まれた状態の前記第2のプログラムを、コンピュータ上で実行可能なオブジェクトプログラムに変換する第2変換手段とを有することを特徴とするコンパイル装置。 An acquisition means for acquiring a PA position file describing a PA range representing a range on the program for obtaining PA information representing a behavior at the time of program execution, and a source program created using a program language;
First conversion means for converting the source program acquired by the acquisition means into a first program described in an intermediate language;
First setting means for reading the PA range from the PA position file and setting the PA range on the first program;
Optimizing the first program in which the PA range is set by the first setting means to generate a second program that takes over the PA range set on the first program And
Check if there is an increase in the number of loops or processing blocks in the PA range on the second program as compared to the number of loops or processing blocks in the PA range on the first program; When the number of loops or processing blocks in the PA range on the second program has increased, a new PA range is set for each loop or processing block in the PA range on the second program A second setting means;
Function embedding means for embedding a PA information acquisition function for acquiring the PA information in the second program for each PA range set in the second program;
A compiling apparatus comprising: a second conversion unit configured to convert the second program in which the PA information acquisition function is embedded into an object program executable on a computer.
前記第2設定手段は、前記第2のプログラム上に、前記新たなPAレンジを、前記PAレンジ設定箇所指定情報に基づいて設定するものであることを特徴とする請求項1記載のコンパイル装置。 The PA position file describes PA range setting location designation information for designating the new PA range setting location when the new PA range is set by the second setting means together with the PA range. ,
The compiling apparatus according to claim 1, wherein the second setting means sets the new PA range on the second program based on the PA range setting location designation information.
プログラム実行時の挙動を表わすPA情報を取得する該プログラム上の範囲を表わすPAレンジが記述されたPA位置ファイルと、プログラム言語を用いて作成されたソースプログラムとを取得する取得手段と、
前記取得手段で取得したソースプログラムを中間言語で記述された第1のプログラムに変換する第1変換手段と、
前記PA位置ファイルから前記PAレンジを読み出して、該PAレンジを前記第1のプログラム上に設定する第1設定手段と、
前記第1設定手段で前記PAレンジが設定された前記第1のプログラムに最適化処理を施して、該第1のプログラム上に設定された前記PAレンジを引き継いだ第2のプログラムを生成する最適化手段と、
前記第1のプログラム上の前記PAレンジ内のループ又は処理ブロックの数と比べたときの前記第2のプログラム上の前記PAレンジ内のループ又は処理ブロックの数の増加の有無を調べ、該第2のプログラム上の該PAレンジ内のループ又は処理ブロックの数が増加していた場合に、該第2のプログラム上の前記PAレンジ内の各ループ又は各処理ブロックに新たなPAレンジを設定する第2設定手段と、
前記第2のプログラムに、前記PA情報取得のためのPA情報取得関数を、該第2のプログラムに設定された前記PAレンジ毎に埋め込む関数埋込手段と、
前記PA情報取得関数が埋め込まれた状態の前記第2のプログラムを、コンピュータ上で実行可能なオブジェクトプログラムに変換する第2変換手段とを有するコンパイル装置を構築することを特徴とするコンパイルプログラム。 It is executed in an arithmetic processing unit that executes a program or compiles, and in the arithmetic processing unit,
An acquisition means for acquiring a PA position file describing a PA range representing a range on the program for obtaining PA information representing a behavior at the time of program execution, and a source program created using a program language;
First conversion means for converting the source program acquired by the acquisition means into a first program described in an intermediate language;
First setting means for reading the PA range from the PA position file and setting the PA range on the first program;
Optimizing the first program in which the PA range is set by the first setting means to generate a second program that takes over the PA range set on the first program And
Check if there is an increase in the number of loops or processing blocks in the PA range on the second program as compared to the number of loops or processing blocks in the PA range on the first program; When the number of loops or processing blocks in the PA range on the second program has increased, a new PA range is set for each loop or processing block in the PA range on the second program A second setting means;
Function embedding means for embedding a PA information acquisition function for acquiring the PA information in the second program for each PA range set in the second program;
A compiling program comprising: a compiling device having second converting means for converting the second program in which the PA information acquisition function is embedded into an object program executable on a computer.
前記第2設定手段は、前記第2のプログラム上に、前記新たなPAレンジを、前記PAレンジ設定箇所指定情報に基づいて設定するものであることを特徴とする請求項3記載のコンパイルプログラム。 The PA position file describes PA range setting location designation information for designating the new PA range location when the second setting means sets a new PA range together with the PA range,
4. The compiled program according to claim 3, wherein the second setting means sets the new PA range on the second program based on the PA range setting location designation information.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2010153528A JP5477206B2 (en) | 2010-07-06 | 2010-07-06 | Compiling device and compiling program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2010153528A JP5477206B2 (en) | 2010-07-06 | 2010-07-06 | Compiling device and compiling program |
Publications (3)
| Publication Number | Publication Date |
|---|---|
| JP2012018434A JP2012018434A (en) | 2012-01-26 |
| JP2012018434A5 JP2012018434A5 (en) | 2013-06-13 |
| JP5477206B2 true JP5477206B2 (en) | 2014-04-23 |
Family
ID=45603664
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2010153528A Active JP5477206B2 (en) | 2010-07-06 | 2010-07-06 | Compiling device and compiling program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP5477206B2 (en) |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2636665B2 (en) * | 1993-02-26 | 1997-07-30 | 日本電気株式会社 | Execution information collection device |
| JP3290567B2 (en) * | 1995-08-24 | 2002-06-10 | 富士通株式会社 | Profile instrumentation method |
-
2010
- 2010-07-06 JP JP2010153528A patent/JP5477206B2/en active Active
Also Published As
| Publication number | Publication date |
|---|---|
| JP2012018434A (en) | 2012-01-26 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20050223363A1 (en) | Evaluation of a code segment | |
| US7904892B2 (en) | Systems and methods for identifying and displaying dependencies | |
| US8423982B2 (en) | Speculative compilation | |
| US20060064677A1 (en) | Debugger and method for debugging computer programs across multiple programming languages | |
| JP5583514B2 (en) | Compiling method for optimizing binary code, compiler system thereof, and computer program | |
| García Frey et al. | UsiComp: an extensible model-driven composer | |
| US20120110560A1 (en) | Data type provider for a web semantic store | |
| US20070220496A1 (en) | Multiple operating device version software generating device and multiple operating device version software generation support program and method | |
| JP2012510661A (en) | Method and system for parallel processing of sequential computer program code | |
| US11989537B2 (en) | Dataflow-based computer program visualization and refactoring | |
| JP2018156133A (en) | Compiler program, information processing apparatus and compilation method | |
| JP2013008277A (en) | Coverage measuring apparatus and method and program | |
| JP5421228B2 (en) | Program, apparatus, and method for visualizing relationships using virtual tasks | |
| JP5849592B2 (en) | Programmable controller system, programming device thereof, programmable controller, program, and debugging method | |
| JP5481571B2 (en) | How to improve understanding of time complexity and flow in code | |
| CN110554861B (en) | Software development environment with compile and read-evaluate-print-loop operations | |
| JP4867864B2 (en) | Performance data collection / display system, performance data display device, and program thereof | |
| JP6500626B2 (en) | Computer, compiler program, link program and compilation method | |
| KR20070038637A (en) | How to identify call relationship of monitored data when monitoring data of Java byte code | |
| JP2011070533A (en) | Code editing program and code editing apparatus | |
| JP4328328B2 (en) | Software development tool program | |
| JP5477206B2 (en) | Compiling device and compiling program | |
| KR100417655B1 (en) | Regulating information generator and program development system composed of regulator | |
| JP2003241967A (en) | Program execution device and method, and program executed therein | |
| JP2017204080A (en) | Information processing apparatus, compilation method, and compiler program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20130425 |
|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20130425 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20131118 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20131210 |
|
| A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20131219 |
|
| 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: 20140114 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140127 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 5477206 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |