JP2011103026A - Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system - Google Patents

Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system Download PDF

Info

Publication number
JP2011103026A
JP2011103026A JP2009257047A JP2009257047A JP2011103026A JP 2011103026 A JP2011103026 A JP 2011103026A JP 2009257047 A JP2009257047 A JP 2009257047A JP 2009257047 A JP2009257047 A JP 2009257047A JP 2011103026 A JP2011103026 A JP 2011103026A
Authority
JP
Japan
Prior art keywords
instruction
basic block
object code
program
instructions
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.)
Pending
Application number
JP2009257047A
Other languages
Japanese (ja)
Inventor
Shinichi Okusako
伸一 奥迫
Kazushi Enomoto
和史 榎本
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.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2009257047A priority Critical patent/JP2011103026A/en
Priority to PCT/JP2010/069833 priority patent/WO2011058946A1/en
Publication of JP2011103026A publication Critical patent/JP2011103026A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To accurately measure the number of dynamic steps of machine instruction level of a program without extremely increasing an execution load or being affected by optimization. <P>SOLUTION: When an executable program 114 is generated by compiling a source code 113, an instruction to add the number of instructions included in a basic block as the minimum unit of optimization to a dynamic step counter is generated with a pseudo object code as an internal expression of an object code, and then executable program 114 generated by the compiler 104 is executed by using the compiler 104 equipped with a function of embedding the generated instruction in the basic block, and the number of dynamic steps corresponding to conditions during execution is measured, and the measured value is output to an auxiliary storage device as dynamic step information, and displayed on an output device 116 by a dynamic step display part 111. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、計算機システムにおいて、プログラムの実行時にどれだけのマシン命令数が実行されたかを表すダイナミックステップ数を計測する技術に関するものである。   The present invention relates to a technique for measuring the number of dynamic steps representing how many machine instructions are executed when a program is executed in a computer system.

計算機システムにおけるプログラムの性能を評価する指標としてダイナミックステップ数がある。ダイナミックステップ数とは、プログラムの実行時にどれだけの処理(マシン命令数)が実行されたかを示す値である。なお、ダイナミックステップ数とは対照的に、前記指標としてスタティックなステップ数という値も存在する。   There is a dynamic step number as an index for evaluating the performance of a program in a computer system. The number of dynamic steps is a value indicating how much processing (the number of machine instructions) has been executed when the program is executed. In contrast to the number of dynamic steps, there is a value called a static number of steps as the index.

プログラムの総ステップ数を表すスタティックなステップ数はプログラムの実行前に決定する値であるため、ソースコードやコンパイル後のプログラムを静的に解析することで容易に取得できる。これに対し、ダイナミックステップ数はプログラムの実行時の条件により変化する実行パスのステップ数を計測する必要があるため、スタティックなステップ数を得ることに比べると困難である。   Since the static step number indicating the total number of steps of the program is a value determined before the execution of the program, it can be easily obtained by statically analyzing the source code or the compiled program. On the other hand, since the number of dynamic steps needs to measure the number of steps in the execution path that changes depending on the conditions during program execution, it is more difficult than obtaining a static number of steps.

従来から、ダイナミックステップ数を計測するときには、主に、ソースコードレベルで計測する方法と、マシン命令レベルで計測する方法とが存在する。
例えば、高級言語のソースコードレベルでダイナミックステップ数を計測するために、デバッガやテストツールを用いて各行が実行されたかを調べる方法がある。この方法では、読み込んだソースコードの各行に対してその行が何回実行されたかを示すカウンタを割り当てておき、その状態でプログラムを実行することで、ダイナミックステップ数の計測が可能となる。
Conventionally, when measuring the number of dynamic steps, there are mainly a method of measuring at the source code level and a method of measuring at the machine instruction level.
For example, in order to measure the number of dynamic steps at the source code level of a high-level language, there is a method of examining whether each line has been executed using a debugger or a test tool. In this method, a counter indicating how many times the line has been executed is assigned to each line of the read source code, and the number of dynamic steps can be measured by executing the program in that state.

また、マシン命令レベルのダイナミックステップ数を計測する方法としては、OS(Operating System)の割り込み機能を利用して、オブジェクトプログラムのマシン命令1つ1つが実行されるたびにカウンタを加算する方法がある。この方法では、生成される命令1つ1つが実行されるたびに、OSによる割り込みを発生させ、発生した割り込みを処理する割り込みハンドラによりダイナミックステップ数のカウンタを加算する。これにより、プログラムの実行終了時にダイナミックステップ数が得られる。   Further, as a method of measuring the number of dynamic steps at the machine instruction level, there is a method of adding a counter each time each machine instruction of an object program is executed using an interrupt function of an OS (Operating System). . In this method, each time a generated instruction is executed, an interrupt is generated by the OS, and a dynamic step number counter is added by an interrupt handler that processes the generated interrupt. As a result, the number of dynamic steps is obtained at the end of program execution.

なお、特許文献1には、ソースコード対実行ステップ数対応データベースを保持することで、入力ソースコードに対応するプロセッサの実行ステップ数を計測する技術が開示されている。   Patent Document 1 discloses a technique for measuring the number of execution steps of a processor corresponding to an input source code by holding a source code pair execution step correspondence database.

特開2001−273174号公報JP 2001-273174 A

例えば高級言語のソースコードレベルのダイナミックステップ数をデバッガやテストツールによる方法で計測したとしても、実際にどれだけの命令がCPU(Central Processing Unit)により実行されたか否かはアーキテクチャに依存して異なるため、正確な性能値を求めることができない。特許文献1の方法でもマシン命令レベルの測定はできるが、予測値のため誤差があったり、最適化の影響を受ける可能性があったりという問題がある。
また、ソースコードに対応した計測では、コンパイラが最適化を行なった際にマシン命令の順序を入れ替える可能性があるため、例えば繰り返し処理内の命令が最適化により繰り返し処理の外へ移動された場合、誤ったステップ数が計測されてしまうという問題がある。
For example, even if the number of dynamic steps at the source code level of a high-level language is measured by a method using a debugger or a test tool, how many instructions are actually executed by the CPU (Central Processing Unit) depends on the architecture. Therefore, an accurate performance value cannot be obtained. Although the method of Patent Document 1 can also measure the machine instruction level, there is a problem that there is an error due to a predicted value and there is a possibility of being influenced by optimization.
In the measurement corresponding to the source code, there is a possibility that the order of the machine instructions is changed when the compiler performs optimization. For example, when an instruction in the iterative process is moved out of the iterative process due to optimization There is a problem that the wrong number of steps is measured.

一方、マシン命令レベルのダイナミックステップ数を計測する際に、OSの割り込み機能を利用する方法では、1つ1つのマシン命令に対してダイナミックステップ数が計測されるため、コンパイラによる最適化の影響を受けずにマシン命令レベルの計測値を得ることができる。
しかしながら、この方法ではマシン命令毎に加算処理が生じてしまい、ダイナミックステップ数計測時の実行負荷が大きくなるため、実運用環境で計測するのには適さない。
On the other hand, when measuring the number of dynamic steps at the machine instruction level, the method using the interrupt function of the OS measures the number of dynamic steps for each machine instruction. Measurement values at the machine instruction level can be obtained without receiving them.
However, in this method, addition processing occurs for each machine instruction, and the execution load at the time of measuring the number of dynamic steps increases. Therefore, this method is not suitable for measurement in an actual operation environment.

本発明は前記事情を鑑みて、プログラムの実行負荷を抑えつつも、プログラムのマシン命令レベルのダイナミックステップ数を正確に計測することを目的とする。   In view of the above circumstances, an object of the present invention is to accurately measure the number of dynamic steps at the machine instruction level of a program while suppressing the execution load of the program.

前記目的を達成するために、本発明の計算機システムは、
ソースコードをコンパイルして実行可能プログラムを生成する手段として、
ソースコードを入力し、字句解析、構文解析、及び意味解析の処理を行う機能を備え、
ソースコードの解析結果から、コンパイラにおけるオブジェクトコードの内部表現である擬似オブジェクトコードを生成する機能を備え、
擬似オブジェクトコードを解析することでプログラムの実行効率を向上する最適化処理を行なった後で、基本ブロック毎の擬似オブジェクトコードに含まれる命令数をダイナミックステップ数計測用のカウンタに加算する命令を生成し、基本ブロックの擬似オブジェクトコードの中に生成した命令を埋め込む機能を備え、
擬似オブジェクトコードから、実行可能プログラムを生成する機能を備える。
In order to achieve the above object, the computer system of the present invention provides:
As a means of compiling source code and generating an executable program,
It has a function to input source code and perform lexical analysis, syntax analysis, and semantic analysis.
From the analysis result of source code, it has a function to generate pseudo object code that is the internal representation of object code in the compiler,
Generates instructions that add the number of instructions included in the pseudo object code for each basic block to the counter for measuring the number of dynamic steps after performing optimization processing to improve the execution efficiency of the program by analyzing the pseudo object code And the function to embed the generated instruction in the pseudo object code of the basic block,
A function of generating an executable program from the pseudo object code is provided.

また、前記コンパイラを用い、ソースコードをコンパイルして生成された実行可能プログラムを実行することでプログラムのダイナミックステップ数を計測し、
計測したダイナミックステップ数をダイナミックステップ情報として、例えば実行可能プログラムが利用するランタイムライブラリが備えるダイナミックステップ情報出力機能により補助記憶装置へ出力する。
補助記憶装置へ出力されたダイナミックステップ情報は、ダイナミックステップ情報表示装置により出力装置へ表示する。
詳細は後記する。
In addition, using the compiler, by measuring the number of dynamic steps of the program by executing the executable program generated by compiling the source code,
The measured number of dynamic steps is output to the auxiliary storage device as dynamic step information by, for example, a dynamic step information output function provided in a runtime library used by the executable program.
The dynamic step information output to the auxiliary storage device is displayed on the output device by the dynamic step information display device.
Details will be described later.

本発明によれば、プログラムの実行負荷を抑えつつも、プログラムのマシン命令レベルのダイナミックステップ数を正確に計測することができる。   According to the present invention, the number of dynamic steps at the machine instruction level of a program can be accurately measured while suppressing the execution load of the program.

本実施形態におけるハードウェア構成を示す図である。It is a figure which shows the hardware constitutions in this embodiment. 本実施形態における全体のデータの流れを表すシステムの構成の概要図である。It is a schematic diagram of the composition of the system showing the whole data flow in this embodiment. 本実施形態におけるコンパイル時のデータの流れを表すシステム構成図である。It is a system configuration figure showing the flow of data at the time of compilation in this embodiment. 本実施形態における実行時のデータの流れを表すシステム構成図である。It is a system configuration figure showing the flow of data at the time of execution in this embodiment. 基本ブロック抽出処理のフロー図である。It is a flowchart of a basic block extraction process. ダイナミックステップ数をカウントする命令の埋込み処理のフロー図である。It is a flowchart of the embedding process of the instruction | indication which counts the number of dynamic steps. 基本ブロック内の命令をCPUが実行するために要するクロック数の推定フロー図である。It is an estimation flow figure of the number of clocks required in order for a CPU to execute the command in a basic block. コンパイラの入力データとなるソースコードの例である。It is an example of the source code used as the input data of the compiler. コンパイラが内部で生成する擬似オブジェクトコードの例である。It is an example of pseudo object code generated internally by a compiler. コンパイラが内部で生成する基本ブロック管理テーブルの例である。It is an example of a basic block management table generated internally by a compiler. ダイナミックステップ数のカウント命令が埋込まれた後の擬似オブジェクトコードの例である。It is an example of the pseudo object code after the count instruction of the number of dynamic steps is embedded. 各命令の実行に必要なクロック数を表したテーブルである。It is a table showing the number of clocks required for execution of each instruction. スケジューリング前のある基本ブロック内の命令列の例を表した図である。It is a figure showing the example of the command sequence in a certain basic block before scheduling. スケジューリング後の基本ブロック内の命令列の例を表した図である。It is a figure showing the example of the command sequence in the basic block after scheduling. 関数単位のダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。It is a figure showing the example of a display which output the dynamic step information of the function unit on the screen of the output device by the dynamic step display device. 基本ブロック単位のダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。It is a figure showing the example of a display which output the dynamic step information of the basic block unit on the screen of the output device by the dynamic step display device. ソースコードに関連付けたダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。It is the figure showing the example of a display which output the dynamic step information linked | related with the source code on the screen of the output device by the dynamic step display device.

以下、本発明の実施の形態(以下、「実施形態」という)を、図面を用いて説明する。
図1は、本実施形態におけるハードウェア構成を示す図である。
本実施形態のハードウェア構成は、主にCPU(制御部)102と主記憶装置(記憶部)103からなる計算機システム101と、データ(ソースコード113、実行可能プログラム114、ダイナミックステップ情報115を含む。)を保存しておく補助記憶装置(記憶部)112、CPU102による実行結果を例えば画面に表示する出力装置(表示部)116を含む。
Hereinafter, embodiments of the present invention (hereinafter referred to as “embodiments”) will be described with reference to the drawings.
FIG. 1 is a diagram illustrating a hardware configuration according to the present embodiment.
The hardware configuration of this embodiment includes a computer system 101 mainly including a CPU (control unit) 102 and a main storage device (storage unit) 103, and data (source code 113, executable program 114, and dynamic step information 115). .) Is stored, and an output device (display unit) 116 that displays the execution result of the CPU 102 on a screen, for example.

図1に示すように、主記憶装置103には、コンパイラ104やダイナミックステップ表示部111、またコンパイラ104がコンパイル処理をするなかで参照及び書込みを行う擬似オブジェクトコード109や基本ブロック管理テーブル110、といったソフトウェアが読み込まれている。CPU102は、前記した又は後記するソフトウェアを読み出し、計算機システム102が備える記憶領域(不図示)に所定の演算処理を実行することにより、ソフトウェアとハードウェアとの協働関係が実現される。コンパイラ104は、字句/構文/意味解析部105、擬似オブジェクト生成部106、命令レベル最適化部107及びオブジェクトプログラム生成部108といったソフトウェア(処理部)を含む。   As shown in FIG. 1, the main storage device 103 includes a compiler 104, a dynamic step display unit 111, a pseudo object code 109 that is referred to and written while the compiler 104 performs compilation processing, and a basic block management table 110. The software is loaded. The CPU 102 reads the software described above or described later, and executes predetermined arithmetic processing on a storage area (not shown) provided in the computer system 102, thereby realizing a cooperative relationship between the software and hardware. The compiler 104 includes software (processing unit) such as a lexical / syntax / semantic analysis unit 105, a pseudo object generation unit 106, an instruction level optimization unit 107, and an object program generation unit 108.

また、補助記憶装置112には、コンパイラ104に入力されるソースコード113や、コンパイラ104によるコンパイルの結果生成される実行可能プログラム114、実行可能プログラム114を実行することにより出力されたダイナミックステップ情報115が記憶されている。   The auxiliary storage device 112 also includes source code 113 input to the compiler 104, an executable program 114 generated as a result of compilation by the compiler 104, and dynamic step information 115 output by executing the executable program 114. Is remembered.

図2は、本実施形態における全体のデータの流れを表すシステム構成の概要図である。
まず、コンパイラ104がソースコード113をコンパイルする。コンパイルすることにより、実行可能生成プログラム114が生成される。
FIG. 2 is a schematic diagram of a system configuration representing the overall data flow in the present embodiment.
First, the compiler 104 compiles the source code 113. By compiling, an executable generation program 114 is generated.

コンパイルにより生成された実行可能プログラム114は、ソースコード113に記述された処理を実行するユーザプログラム処理部201と、マシン命令レベルのダイナミックステップ数(マシン命令レベルの実行命令数)を計測するダイナミックステップ計測部202を備える。
実行可能プログラム114は主記憶装置103に読み込まれ、OSから実行に必要な資源を割り当てられることで、プログラムの実行単位である実行プロセス203となり、プログラムの実行がなされる。
The executable program 114 generated by the compilation includes a user program processing unit 201 that executes processing described in the source code 113, and a dynamic step that measures the number of dynamic steps at the machine instruction level (the number of execution instructions at the machine instruction level). A measurement unit 202 is provided.
The executable program 114 is read into the main storage device 103, and resources necessary for execution are allocated from the OS, whereby the execution process 203, which is a program execution unit, is executed, and the program is executed.

実行プロセス203内には、前記ユーザプログラム処理部201と、ダイナミックステップ計測部202とが実行状態となっているため、ソースコード113に書かれた処理に加え、実行時の条件に応じたダイナミックステップ数の計測の処理を適切に実行することができる。計測したダイナミックステップ数は、ダイナミックステップ情報115として補助記憶装置112へ出力される。   In the execution process 203, since the user program processing unit 201 and the dynamic step measurement unit 202 are in an execution state, in addition to the processing written in the source code 113, dynamic steps corresponding to conditions at the time of execution The number measurement process can be appropriately executed. The measured number of dynamic steps is output as dynamic step information 115 to the auxiliary storage device 112.

ダイナミックステップ情報115は、例えば画面表示用のプログラムであるダイナミックステップ表示部111により出力装置116にて表示される。このダイナミックステップ情報115は、計測したダイナミックステップ数を含んでいるが、加えて出力装置116の表示態様に応じた値を含んでいる。例えば、図2を参照すると、出力装置116は、後記する基本ブロック単位で前記ダイナミックステップ数を表示しているが、この場合は、ダイナミックステップ情報115は、基本ブロックの識別値(例:BB0001)を含んでいる。このような表示の表示態様についても後記する。
以降、コンパイル時と実行時に分けて、データの流れの詳細を説明する。
The dynamic step information 115 is displayed on the output device 116 by the dynamic step display unit 111 which is a program for screen display, for example. The dynamic step information 115 includes the measured number of dynamic steps, but additionally includes a value corresponding to the display mode of the output device 116. For example, referring to FIG. 2, the output device 116 displays the number of dynamic steps in units of basic blocks to be described later. In this case, the dynamic step information 115 is an identification value of a basic block (eg, BB0001). Is included. The display mode of such display will also be described later.
Hereinafter, the details of the data flow will be described separately for compilation and execution.

図3は、本実施形態におけるコンパイル時のデータの流れを表すシステム構成図である。コンパイラ104はソースコード113を入力とし、コンパイルを行うことで実行可能プログラム114を出力する。コンパイラ104の内部はいくつかの処理部に分かれており、各処理部が段階的にコンパイル処理を行う。コンパイラ104は、字句/構文/意味解析部105、擬似オブジェクト生成部106、命令レベル最適化部107、オブジェクトプログラム生成部108を備えている。   FIG. 3 is a system configuration diagram showing the flow of data at the time of compilation in the present embodiment. The compiler 104 receives the source code 113 and outputs an executable program 114 by compiling. The inside of the compiler 104 is divided into several processing units, and each processing unit performs compilation processing step by step. The compiler 104 includes a lexical / syntax / semantic analysis unit 105, a pseudo object generation unit 106, an instruction level optimization unit 107, and an object program generation unit 108.

字句/構文/意味解析部105では、入力されたソースコード113から字句を切り出し(字句解析)、切り出した字句集合の文法的な妥当性の解析(構文解析)及び意味的な妥当性の解析(意味解析)を行う。   The lexical / syntax / semantic analysis unit 105 cuts out a lexical phrase from the input source code 113 (lexical analysis), analyzes the grammatical validity (syntax analysis) of the extracted lexical set, and analyzes the semantic validity ( Semantic analysis).

擬似オブジェクト生成部106では、字句/構文/意味解析部105によるソースコード113の解析結果から、コンパイラ104におけるオブジェクトコードの内部表現である擬似オブジェクトコード109を生成する。   The pseudo object generation unit 106 generates a pseudo object code 109 that is an internal representation of the object code in the compiler 104 from the analysis result of the source code 113 by the lexical / syntax / semantic analysis unit 105.

命令レベル最適化部107では、擬似オブジェクトコード109を解析することでプログラムの実行効率を向上するための最適化処理を行う。この命令レベル最適化部107は、基本ブロック抽出部301、フロー解析部302、最適化処理部303、ダイナミックステップカウント命令埋込部304により構成されている。   The instruction level optimizing unit 107 performs an optimization process for improving the execution efficiency of the program by analyzing the pseudo object code 109. The instruction level optimization unit 107 includes a basic block extraction unit 301, a flow analysis unit 302, an optimization processing unit 303, and a dynamic step count instruction embedding unit 304.

基本ブロック抽出部301は、擬似オブジェクトコード109において最適化を行う上での最小単位となる基本ブロックを抽出し、基本ブロック管理テーブル110にその基本ブロックの情報を格納する。   The basic block extraction unit 301 extracts a basic block which is a minimum unit for optimization in the pseudo object code 109 and stores information on the basic block in the basic block management table 110.

フロー解析部302は、擬似オブジェクトコード109と基本ブロック管理テーブル110を基に、プログラムがどのような経路を通り得るか(制御フロー解析)、データがどのように伝播するか(データフロー解析)、といった解析を行う。   Based on the pseudo object code 109 and the basic block management table 110, the flow analysis unit 302 determines what route the program can take (control flow analysis), how the data propagates (data flow analysis), Analysis is performed.

最適化処理部303は、フロー解析部302により収集した情報、つまり制御フロー解析及びデータフロー解析の解析結果を基に、プログラムの実行効率を良くするための、定数伝播、レジスタリマッピング、不要命令削除など、といった最適化処理を行う。   The optimization processing unit 303 uses constant propagation, register remapping, and unnecessary instructions to improve program execution efficiency based on information collected by the flow analysis unit 302, that is, analysis results of control flow analysis and data flow analysis. Perform optimization such as deletion.

ダイナミックステップカウント命令埋込部304は、前記最適化処理で解析した情報(最適化後の擬似オブジェクトコードに含まれる命令の命令列)を基に、ダイナミックステップ数をカウントする命令を生成し、生成した命令を擬似オブジェクトコード109の所定の箇所の中に埋め込むカウント命令埋め込み処理を行う。   The dynamic step count instruction embedding unit 304 generates and generates an instruction for counting the number of dynamic steps based on the information analyzed in the optimization process (instruction sequence of instructions included in the pseudo object code after optimization). The count instruction embedding process for embedding the executed instruction in a predetermined portion of the pseudo object code 109 is performed.

オブジェクトプログラム生成部108では、前記最適化処理及びダイナミックステップ数のカウント命令埋め込み処理が施された擬似オブジェクトコード109から、実行可能プログラム114の生成処理を行う。   The object program generation unit 108 generates an executable program 114 from the pseudo object code 109 that has been subjected to the optimization process and the count instruction embedding process of the number of dynamic steps.

実行可能プログラム114内には、ユーザプログラム処理部306(基本ブロックが定められたときのユーザプログラム処理部201(図2参照)に相当)とダイナミックステップ計測部307(基本ブロックが定められたときのダイナミックステップ計測部202(図2参照)に相当)が基本ブロック群305のそれぞれに存在している。   The executable program 114 includes a user program processing unit 306 (corresponding to the user program processing unit 201 (see FIG. 2) when the basic block is determined) and a dynamic step measurement unit 307 (when the basic block is determined). A dynamic step measurement unit 202 (corresponding to FIG. 2) is present in each of the basic block groups 305.

なお、コンパイラ104は前記のような構成に限るものではなく、例えばダイナミックステップカウント命令埋込部304を命令レベル最適化部107の内部にではなく独立した処理部にする、といった構成であっても良い。   The compiler 104 is not limited to the above-described configuration. For example, the dynamic step count instruction embedding unit 304 may be an independent processing unit instead of the instruction level optimization unit 107. good.

ここで、図3に示す構成のうち、擬似オブジェクトコード109、基本ブロック抽出部301、基本ブロック管理テーブル110及びダイナミックステップカウント命令埋込部304について詳しく説明する。   3, the pseudo object code 109, the basic block extraction unit 301, the basic block management table 110, and the dynamic step count instruction embedding unit 304 will be described in detail.

前記のように、コンパイラ104に入力されたソースコード113は、字句/構文/意味解析部105により解析され、擬似オブジェクト生成部106により生成される擬似オブジェクトコード109として表現される。例えば、図8のソースコード801を入力してコンパイルしたときに生成される擬似オブジェクトコードの例を図9に示す。   As described above, the source code 113 input to the compiler 104 is analyzed by the lexical / syntax / semantic analysis unit 105 and expressed as the pseudo object code 109 generated by the pseudo object generation unit 106. For example, FIG. 9 shows an example of pseudo object code generated when the source code 801 in FIG. 8 is input and compiled.

擬似オブジェクトコードの各命令は、命令の内容を示す値が格納される命令902と、それぞれの命令を識別する値が格納される命令ID901により構成されており、場合によっては、命令同士は命令ID901をリンクすることにより繋がれている。擬似オブジェクトコードの段階では便宜上、分岐先を示すラベル(例:THENラベル、ELSEラベル)も1つの命令として表現される。
なお、図9はあくまでも説明上の例であり、擬似オブジェクトコードの内容及び表現方法は図9の形態に限るものではない。例えば、命令同士を繋ぐリンクを示す値(例:リンク先の命令の内容、リンク元の命令の内容)が格納されるフィールドを備えるように擬似オブジェクトコードを構成しても良い。
Each instruction of the pseudo object code includes an instruction 902 in which a value indicating the content of the instruction is stored and an instruction ID 901 in which a value for identifying each instruction is stored. It is connected by linking. At the pseudo object code stage, labels indicating branch destinations (eg, THEN label, ELSE label) are also expressed as one instruction for convenience.
Note that FIG. 9 is merely an illustrative example, and the content and expression method of the pseudo object code are not limited to the form of FIG. For example, the pseudo object code may be configured to include a field for storing a value indicating a link connecting the instructions (for example, the contents of the instruction at the link destination and the contents of the instruction at the link source).

ダイナミックステップカウント命令埋込部304の処理は、基本ブロックを単位として行なわれる。基本ブロックとは、分岐も合流も含まない逐次的な命令列(命令が1つである場合も含む)のことであり、オブジェクトコードにおいては、ある基本ブロックの先頭行が実行されるとその基本ブロック内の命令がすべて実行される処理単位である。制御フローグラフ(CFG:Control Flow Graph)でいえば、ノードや頂点に相当する。一般的に、プログラムの制御の流れを解析して行う最適化では、基本ブロックの単位で処理が行われる。基本ブロックは、基本ブロック抽出部301により擬似オブジェクトコード109から抽出される。   The processing of the dynamic step count instruction embedding unit 304 is performed in units of basic blocks. A basic block is a sequential instruction sequence (including a case where there is only one instruction) that does not include branching or merging. In object code, when the first line of a certain basic block is executed, the basic block is executed. A processing unit in which all instructions in a block are executed. In the case of a control flow graph (CFG), it corresponds to a node or a vertex. In general, in the optimization performed by analyzing the control flow of a program, processing is performed in units of basic blocks. The basic block is extracted from the pseudo object code 109 by the basic block extraction unit 301.

図5は、基本ブロック抽出部301による基本ブロックの抽出処理を示すフロー図である。また抽出した結果は、図10で示す基本ブロック管理テーブル110として主記憶装置103に格納される。ここで、基本ブロックの抽出とは、擬似オブジェクトコード109から全ての基本ブロックを取り出す(抽出する)処理であり、擬似オブジェクトコード109を基本ブロックに分割する処理であるとも言える。
以下、図5を参照しながら本実施形態における基本ブロックの抽出方法について説明する。
FIG. 5 is a flowchart showing basic block extraction processing by the basic block extraction unit 301. The extracted result is stored in the main storage device 103 as the basic block management table 110 shown in FIG. Here, the extraction of the basic block is a process of extracting (extracting) all the basic blocks from the pseudo object code 109, and can be said to be a process of dividing the pseudo object code 109 into basic blocks.
Hereinafter, a basic block extraction method according to the present embodiment will be described with reference to FIG.

まず、擬似オブジェクトコード109から最初の命令を取り出す(ステップ501)。
次に、基本ブロックの情報を管理する基本ブロック管理テーブル110のエントリを作成し、そのエントリの開始位置に取り出した命令の命令IDを入れる(ステップ502)。具体的には、取り出した命令の命令ID901に格納された値を、前記エントリに含まれる開始位置フィールド1002に格納する。
First, the first instruction is extracted from the pseudo object code 109 (step 501).
Next, an entry of the basic block management table 110 that manages basic block information is created, and the instruction ID of the extracted instruction is entered at the start position of the entry (step 502). Specifically, the value stored in the instruction ID 901 of the extracted instruction is stored in the start position field 1002 included in the entry.

次に、取り出した命令がラベル以外かどうかを判定し(ステップ503)、もしラベルでなければ(ステップ503でYes)、その取り出した命令は、真に何らかの命令であるので、その命令をカウントすべく、基本ブロック管理テーブル110のエントリに含まれる命令数フィールド1003の値(命令数)を1加算する(ステップ504)。一方、ラベルであった場合は(ステップ503でNo)、命令数フィールド1003の値は加算せずに、ステップ504をスキップする。   Next, it is determined whether or not the fetched instruction is other than a label (step 503). If it is not a label (Yes in step 503), the fetched instruction is truly some instruction, so that instruction is counted. Therefore, 1 is added to the value (instruction number) in the instruction number field 1003 included in the entry of the basic block management table 110 (step 504). On the other hand, if it is a label (No in step 503), the value in the instruction number field 1003 is not added and step 504 is skipped.

次に、擬似オブジェクトコード109に次の命令があるかどうかの判定を行い(ステップ505)、次の命令がある場合は(ステップ505でYes)その命令を取り出し(ステップ506)、もしなければ(ステップ505でNo)抽出フローの処理を終了する。   Next, it is determined whether or not there is a next instruction in the pseudo object code 109 (step 505). If there is a next instruction (Yes in step 505), the instruction is taken out (step 506). In step 505, No) the extraction flow process is terminated.

次の命令が存在する場合は(ステップ505でYes)、次の命令が新しい基本ブロックの始まりかどうかを判定する(ステップ507)。取り出した命令がラベルであれば、いずれかの分岐命令から合流してくる可能性があるため、このラベルから新しい基本ブロックの始まりとなる。また、1つ前の命令が分岐命令(条件分岐命令又は無条件分岐命令)であった場合、1つ前の命令から別の命令へ分岐する可能性があるため、それまでの基本ブロックは1つ前の命令で終了となり、新しい基本ブロックの始まりと判定できる。   If the next instruction exists (Yes in step 505), it is determined whether the next instruction is the start of a new basic block (step 507). If the fetched instruction is a label, there is a possibility of joining from any of the branch instructions, so that a new basic block starts from this label. If the previous instruction is a branch instruction (conditional branch instruction or unconditional branch instruction), there is a possibility of branching from the previous instruction to another instruction. It ends with the previous instruction and can be determined as the start of a new basic block.

ステップ507の判定で真となった場合(ステップ507でYes)、ステップ506で取り出した命令以降が新しい基本ブロックとなるため、ステップ502に戻って新しい基本ブロック管理テーブル110のエントリを作成し、以降の処理を同様に繰り返す。ステップ507の判定で偽となった場合は(ステップ507でNo)、基本ブロックが継続するため、ステップ504に戻り、以降の処理を繰り返す。   If the determination in step 507 is true (Yes in step 507), the instruction taken out in step 506 and subsequent instructions become new basic blocks, so the process returns to step 502 to create a new basic block management table 110 entry. The above process is repeated in the same manner. If the determination in step 507 is false (No in step 507), the basic block continues, so the process returns to step 504 and the subsequent processing is repeated.

以上のフローにより抽出された基本ブロックの情報は、図10で示す基本ブロック管理テーブルのブロックIDフィールド1001、命令ID901の値のうち基本ブロックの開始位置を示す値が格納される開始位置フィールド1002及び基本ブロックに含まれる命令数を格納する命令数フィールド1003に格納される。なお、ブロックID1001に格納される値は各基本ブロックを識別する値であり、基本ブロック管理テーブル110の新たなエントリが作成されるたびに一意に割り当てられるものとする。推定クロック数フィールド1004については後述する別の実施形態において説明する。   The basic block information extracted by the above flow includes a block ID field 1001 of the basic block management table shown in FIG. 10, a start position field 1002 in which a value indicating the start position of the basic block among the values of the instruction ID 901 is stored, The number of instructions included in the basic block is stored in an instruction number field 1003. The value stored in the block ID 1001 is a value for identifying each basic block, and is uniquely assigned every time a new entry in the basic block management table 110 is created. The estimated clock number field 1004 will be described in another embodiment to be described later.

図3に戻り、ダイナミックステップカウント命令埋込部304は、擬似オブジェクトコード109と基本ブロック管理テーブル110からダイナミックステップ数をカウントする命令を生成し、生成した命令を擬似オブジェクトコード109の中に埋め込む処理を実行する。   Returning to FIG. 3, the dynamic step count instruction embedding unit 304 generates an instruction for counting the number of dynamic steps from the pseudo object code 109 and the basic block management table 110, and embeds the generated instruction in the pseudo object code 109. Execute.

図6は、ダイナミックステップカウント命令埋込部304による、ダイナミックステップ数をカウントする命令の埋込み処理のフロー図である。
まず、基本ブロック管理テーブル110から、最初の基本ブロックの情報が格納されているエントリを取り出す(ステップ601)。
FIG. 6 is a flowchart of an instruction embedding process for counting the number of dynamic steps by the dynamic step count instruction embedding unit 304.
First, an entry storing information on the first basic block is extracted from the basic block management table 110 (step 601).

次に、取り出した基本管理テーブル110のエントリから、開始位置フィールド1002と命令数フィールド1003の情報(開始位置、命令数)を取得し(ステップ602)、取得した情報から基本ブロック内の命令数をダイナミックステップカウンタに加算する命令を生成する(ステップ603)。   Next, information (start position, number of instructions) in the start position field 1002 and instruction number field 1003 is acquired from the extracted entry of the basic management table 110 (step 602), and the number of instructions in the basic block is obtained from the acquired information. An instruction to be added to the dynamic step counter is generated (step 603).

ステップ603で生成した命令は、基本ブロックの開始位置の命令がラベルであるかどうかを判定し(ステップ604)、以下に示すように基本ブロックの中へ埋め込まれる。つまり、基本ブロックの開始位置がラベルであった場合(ステップ604でYes)、他の分岐命令からラベルに合流してくる可能性があるため、ラベルの次の位置に前記生成した命令を埋込む(ステップ605)。もし基本ブロックの開始位置がラベルでなかった場合は(ステップ604でNo)、処理の先頭となるように基本ブロック開始位置の命令の前に前記生成した命令を埋込む(ステップ606)。ステップ605及びステップ606を経た後は、ステップ607に処理が進む。   The instruction generated in step 603 determines whether the instruction at the start position of the basic block is a label (step 604) and is embedded in the basic block as shown below. That is, if the start position of the basic block is a label (Yes in step 604), there is a possibility that another branch instruction may join the label, so the generated instruction is embedded at the next position of the label. (Step 605). If the start position of the basic block is not a label (No in step 604), the generated instruction is embedded before the instruction of the basic block start position so as to be the head of the process (step 606). After step 605 and step 606, the process proceeds to step 607.

その後、基本ブロック管理テーブルの次のエントリがあるかどうかを判定し(ステップ607)、もしなければ(ステップ607でNo)ダイナミックステップ数をカウントする命令の埋め込み処理を終了する。もしあれば(ステップ607でYes)、基本ブロック管理テーブルの次のエントリを取り出し(ステップ608)、ステップ602の処理に戻り、以降の処理を同様に繰り返す。
以上のフローにより、基本ブロック単位でダイナミックステップ数のカウント命令埋め込み処理を行うことができる。
Thereafter, it is determined whether or not there is a next entry in the basic block management table (step 607). If not (No in step 607), the instruction embedding process for counting the number of dynamic steps is terminated. If there is (Yes in Step 607), the next entry in the basic block management table is extracted (Step 608), the process returns to Step 602, and the subsequent processes are repeated in the same manner.
With the above flow, the count instruction embedding process for the number of dynamic steps can be performed in units of basic blocks.

図11は、図9の擬似オブジェクトコードと図10の基本ブロック管理テーブルからダイナミックステップ数のカウント命令が埋め込まれた後の擬似オブジェクトコードの例を示す図である。命令ID1101及び命令1102は、それぞれ図9の命令ID901及び命令902と同等である。   FIG. 11 is a diagram illustrating an example of the pseudo object code after the count instruction of the number of dynamic steps is embedded from the pseudo object code of FIG. 9 and the basic block management table of FIG. The instruction ID 1101 and the instruction 1102 are equivalent to the instruction ID 901 and the instruction 902 in FIG. 9, respectively.

最初の基本ブロックの開始位置に配置されているFUNCラベル1103の後ろには、最初の基本ブロックの命令数をカウントする処理がadd命令(加算命令)1104として埋め込まれている(図6のステップ605の処理を参照)。
また、次の基本ブロックの始まりであった無条件分岐命令1106の前には、次の基本ブロックの命令数をカウントするadd命令1105が埋め込まれている(図6のステップ606の処理を参照)。
同様に、add命令1107、1108、1109が、図6のステップ604の判定に従って、それぞれの基本ブロックの命令数をカウントする処理として埋め込まれている。このようにして、1つの基本ブロックに1つのadd命令が埋め込まれるようにして擬似オブジェクトコードが生成される。
A process of counting the number of instructions of the first basic block is embedded as an add instruction (addition instruction) 1104 behind the FUNC label 1103 arranged at the start position of the first basic block (step 605 in FIG. 6). See processing).
Further, an add instruction 1105 for counting the number of instructions in the next basic block is embedded in front of the unconditional branch instruction 1106 which is the start of the next basic block (see the process in step 606 in FIG. 6). .
Similarly, add instructions 1107, 1108, and 1109 are embedded as processing for counting the number of instructions in each basic block in accordance with the determination in step 604 of FIG. In this way, pseudo object code is generated such that one add instruction is embedded in one basic block.

以上、擬似オブジェクトコード109、基本ブロック抽出部301、基本ブロック管理テーブル110及びダイナミックステップカウント命令埋込部304についての詳細な説明を終える。   The detailed description of the pseudo object code 109, the basic block extraction unit 301, the basic block management table 110, and the dynamic step count instruction embedding unit 304 is finished.

以上を踏まえた上で、改めて図3の流れを説明する。
本実施形態では、コンパイラ104がソースコード113をコンパイルする過程において、まず字句/構文/意味解析部105及び擬似オブジェクト生成部106がオブジェクトコードの内部表現である擬似オブジェクトコード109を生成する。この擬似オブジェクトコード109を基に、命令レベル最適化部107がプログラムの実行効率を上げるための最適化処理を行う。
Based on the above, the flow of FIG. 3 will be described again.
In this embodiment, in the process in which the compiler 104 compiles the source code 113, the lexical / syntax / semantic analysis unit 105 and the pseudo object generation unit 106 first generate the pseudo object code 109 that is an internal representation of the object code. Based on the pseudo object code 109, the instruction level optimization unit 107 performs an optimization process for increasing the execution efficiency of the program.

最適化処理では、分岐と合流が含まれない基本ブロックを処理単位にして解析が行われる。基本ブロック抽出部301により擬似オブジェクトコード109から基本ブロックが抽出され、抽出した基本ブロックの情報は基本ブロック管理テーブル110に格納される。
さらに、フロー解析部302により擬似オブジェクトコード109と基本ブロック管理テーブル110を基に、制御フローやデータフローの解析が行なわれた後で、最適化処理部303により実行効率向上のための最適化処理が施される。
In the optimization process, analysis is performed with a basic block that does not include branching and merging as a processing unit. A basic block is extracted from the pseudo object code 109 by the basic block extraction unit 301, and information on the extracted basic block is stored in the basic block management table 110.
Further, after the flow analysis unit 302 analyzes the control flow and the data flow based on the pseudo object code 109 and the basic block management table 110, the optimization processing unit 303 performs optimization processing for improving execution efficiency. Is given.

最適化処理の後、ダイナミックステップカウント命令埋込部304により、ダイナミックステップ数のカウント命令埋込み処理が行われる。ダイナミックステップカウント命令埋込部304では、最適化の際に抽出及び解析した擬似オブジェクトコード109と基本ブロック管理テーブル110の情報を用いて基本ブロックを単位にカウント用の命令の埋込み処理が行われる。擬似オブジェクトコード109内の各基本ブロックに対し、それぞれに含まれる命令数をカウンタに加算する命令が生成され、基本ブロック中に埋め込まれる。   After the optimization process, the dynamic step count instruction embedding unit 304 performs a count instruction embedding process for the number of dynamic steps. The dynamic step count instruction embedding unit 304 embeds a count instruction in units of basic blocks using the pseudo object code 109 extracted and analyzed at the time of optimization and information in the basic block management table 110. For each basic block in the pseudo object code 109, an instruction for adding the number of instructions included in the counter to the counter is generated and embedded in the basic block.

以上の処理を経て、オブジェクトプログラム生成部108により生成される実行可能プログラム114には、ソースコード113に記述された処理を実行するユーザプログラム処理部306と、基本ブロック内の命令数をカウントするダイナミックステップ計測部307が基本ブロック群305のそれぞれに備えられている。   Through the above processing, the executable program 114 generated by the object program generation unit 108 includes a user program processing unit 306 that executes the processing described in the source code 113, and a dynamic that counts the number of instructions in the basic block. A step measurement unit 307 is provided in each of the basic block groups 305.

本実施形態では、コンパイルの過程でプログラムにおける基本ブロックの情報、例えば前記のように命令数を計測する命令を生成し、基本ブロックの中に、生成した命令を埋め込むことで、実行時の動的な条件に対応して基本ブロックの情報を計測する機能を備えた実行可能プログラムを生成することができる。
また、計測の対象となる基本ブロックの情報は、マシン命令レベルの情報であるため、実際にプログラムを動作させるマシン環境での性能値を正確に得ることができる。
また、基本ブロックを単位に加算命令を埋め込むため、コンパイル時の最適化処理の影響を受けることなく計測することが可能である。
以上、本実施形態におけるコンパイル時の特徴を説明した。続いて、実行時の特徴を、図4を参照しながら説明する。
In the present embodiment, information on basic blocks in a program, for example, instructions for measuring the number of instructions as described above are generated in the process of compilation, and the generated instructions are embedded in the basic blocks, so that It is possible to generate an executable program having a function of measuring basic block information corresponding to various conditions.
Further, since the basic block information to be measured is machine instruction level information, the performance value in the machine environment in which the program is actually operated can be obtained accurately.
In addition, since the addition instruction is embedded in units of basic blocks, measurement can be performed without being affected by optimization processing at the time of compilation.
In the above, the feature at the time of compilation in this embodiment was explained. Next, features at the time of execution will be described with reference to FIG.

図4は、本実施形態における実行時のデータの流れを表すシステム構成図である。
ソースコード113をコンパイルして生成された実行可能プログラム114は、主記憶装置103へ読み込まれ、OSから必要な資源を割り当てられることで実行プロセス203として実行状態になる。
FIG. 4 is a system configuration diagram illustrating a data flow at the time of execution in the present embodiment.
The executable program 114 generated by compiling the source code 113 is read into the main storage device 103, and is put into an execution state as an execution process 203 when necessary resources are allocated from the OS.

実行プロセス203には、基本ブロック群401(実行プロセス203として定められたときの基本ブロック群305に相当)の処理とダイナミックステップ情報出力部402が読み込まれている。ダイナミックステップ情報出力部402は、例えばプログラムが実行時に利用する実行時ライブラリ(ランタイムライブラリ)により提供される。   In the execution process 203, the processing of the basic block group 401 (corresponding to the basic block group 305 when determined as the execution process 203) and the dynamic step information output unit 402 are read. The dynamic step information output unit 402 is provided by, for example, a runtime library (runtime library) used by a program at the time of execution.

基本ブロック群401の、ダイナミックステップ計測部307により計測した情報は、ダイナミックステップ情報出力部402によりダイナミックステップ情報115として補助記憶装置112(図1参照)へ出力される。そして、ダイナミックステップ情報115は、ダイナミックステップ表示部111により、出力装置116へ表示される。   Information measured by the dynamic step measurement unit 307 in the basic block group 401 is output as dynamic step information 115 by the dynamic step information output unit 402 to the auxiliary storage device 112 (see FIG. 1). The dynamic step information 115 is displayed on the output device 116 by the dynamic step display unit 111.

プログラムの実行時において、どのようなパスで処理が実行されるかは、ユーザの要求や連携プログラム、環境の条件などにより異なり、実行時になってみないとわからない。そのため、プログラム中のどの基本ブロックが実行されるかという点も実行時になってみないとわからない。
本実施形態では、前記のように基本ブロックを単位としてダイナミックステップ数を計測する機能が備えられているため、分岐や繰り返しによる制御がどのような条件で行なわれても、漏れなくダイナミックステップ数をカウントすることができる。
The path through which processing is executed during program execution differs depending on user requests, linked programs, environmental conditions, and the like, and cannot be understood until it is executed. For this reason, it is impossible to know which basic block in the program is executed at the time of execution.
In this embodiment, since the function of measuring the number of dynamic steps in units of basic blocks as described above is provided, the number of dynamic steps can be set without omission regardless of the conditions under which control by branching or repetition is performed. Can be counted.

なお、基本ブロック単位で計測した情報は、擬似オブジェクトコード109全体におけるダイナミックステップ数の合計を求めたり、高級言語における関数単位や手続き単位で集計したりすることにより、プログラムの性能解析に役立てることができる。
また、ダイナミックステップ数の計測は基本ブロック毎にまとめて行われるため、実行時の負担を大幅に高めることなく計測することが可能である。
Information measured in units of basic blocks can be used for program performance analysis by calculating the total number of dynamic steps in the entire pseudo object code 109 or by summing up in units of functions or procedures in a high-level language. it can.
In addition, since the number of dynamic steps is collectively measured for each basic block, it is possible to measure without greatly increasing the execution load.

図15、図16、図17を参照して、出力装置116へ表示されたダイナミックステップ情報の例を示す。図15は、関数単位のダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。図16は、基本ブロック単位のダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。図17は、ソースコードに関連付けたダイナミックステップ情報をダイナミックステップ表示装置によって出力装置の画面に出力した表示例を表した図である。   An example of dynamic step information displayed on the output device 116 will be described with reference to FIGS. 15, 16, and 17. FIG. 15 is a diagram illustrating a display example in which dynamic step information in units of functions is output to the screen of the output device by the dynamic step display device. FIG. 16 is a diagram showing a display example in which dynamic step information in units of basic blocks is output to the screen of the output device by the dynamic step display device. FIG. 17 is a diagram illustrating a display example in which the dynamic step information associated with the source code is output to the screen of the output device by the dynamic step display device.

図15を参照すると、[関数名]及び[ステップ数]という項目を設けて、ソースコードに使用されている関数ごとのダイナミックステップ数が表示されている。さらに、表示するダイナミックステップ情報として、ソースコード全体におけるダイナミックステップ数、つまり、前記関数に対応するダイナミックステップ数の合計も表示される。このような表示態様で表示を行う場合、ダイナミックステップ情報115は、ソースコードに使用される関数の関数名、その関数が実行されたときのダイナミックステップ数を含んでいる。このように関数単位で表示することも可能であり、又手続き単位で表示することも可能である。   Referring to FIG. 15, items [function name] and [number of steps] are provided, and the number of dynamic steps for each function used in the source code is displayed. Further, as the dynamic step information to be displayed, the number of dynamic steps in the entire source code, that is, the total number of dynamic steps corresponding to the function is also displayed. When displaying in such a display mode, the dynamic step information 115 includes the function name of the function used in the source code and the number of dynamic steps when the function is executed. In this way, it is possible to display in units of functions, and it is also possible to display in units of procedures.

図16を参照すると、[ブロックID]、[関数名]、[行情報]及び[ステップ数]という項目を設けて、擬似オブジェクトコードに対し設定した基本ブロックごとのダイナミックステップ数が表示されている。[関数名]の欄には、各基本ブロックが含まれる関数が表示される。また、[行情報]の欄には、基本ブロックの開始位置を示すソースコードの行番号が表示される。このような表示態様で表示を行う場合、ダイナミックステップ情報115は、基本ブロックの識別値、ソースコードに使用される関数の関数名、ソースコードの行情報、その基本ブロック内の関数が実行されたときのダイナミックステップ数を含んでいる。   Referring to FIG. 16, items [block ID], [function name], [line information], and [number of steps] are provided, and the number of dynamic steps for each basic block set for the pseudo object code is displayed. . In the [Function Name] field, a function including each basic block is displayed. In the [Line Information] field, the line number of the source code indicating the start position of the basic block is displayed. When displaying in such a display mode, the dynamic step information 115 includes the identification value of the basic block, the function name of the function used in the source code, the line information of the source code, and the function in the basic block. Includes the number of dynamic steps.

図17を参照すると、行番号付きのソースコードと、基本ブロックの範囲をソースコードに対応付けたダイナミックステップ数とが表示されている。このような表示態様で表示を行う場合、ダイナミックステップ情報115は、ソースコードの行情報、ソースコードそのもの、そのソースコードの各行にある関数や手続きが実行されたときのダイナミックステップ数を含んでいる。なお、関数や手続きが記載されていない行については、ダイナミックステップ数は表示しない。図17のようにソースコードの行ごとにダイナミックステップ数を表示すれば、どの命令が実行されたか容易に把握できる。   Referring to FIG. 17, the source code with line numbers and the number of dynamic steps in which the basic block range is associated with the source code are displayed. When displaying in such a display mode, the dynamic step information 115 includes source code line information, source code itself, and the number of dynamic steps when a function or procedure in each line of the source code is executed. . Note that the number of dynamic steps is not displayed for lines that do not contain functions or procedures. If the number of dynamic steps is displayed for each line of the source code as shown in FIG. 17, it is possible to easily grasp which instruction has been executed.

≪この実施形態のまとめ≫
本実施形態によれば、コンパイラで生成された実行可能プログラムは、基本ブロック単位でダイナミックステップ数を計測する機能及び計測したダイナミックステップ数を出力する機能を有するため、このプログラムを実行することで、実行時の条件に応じたマシン命令レベルのダイナミックステップ数を正確に計測することが可能となる。
また、ダイナミックステップ数をカウントする命令の埋め込み処理は、最適化における最小単位である基本ブロックを処理の対象とするため、最適化処理による命令順序の入れ替えの影響を受けることなく、性能値を正しく計測することが可能となる。
また、ダイナミックステップ数の計測処理は基本ブロック単位でまとめて行なわれるため、マシン命令毎に加算処理を行う従来技術のように実行負荷が極端に大きくなることはなく、効率良く計測することが可能となる。
<< Summary of this embodiment >>
According to the present embodiment, the executable program generated by the compiler has a function of measuring the number of dynamic steps in units of basic blocks and a function of outputting the measured number of dynamic steps. Therefore, by executing this program, It becomes possible to accurately measure the number of dynamic steps at the machine instruction level according to the conditions at the time of execution.
In addition, the instruction embedding process that counts the number of dynamic steps targets the basic block, which is the smallest unit in optimization, so that the performance value is correct without being affected by the change of instruction order by the optimization process. It becomes possible to measure.
In addition, since the dynamic step count measurement processing is performed in units of basic blocks, the execution load does not become extremely large as in the prior art in which addition processing is performed for each machine instruction, and measurement can be performed efficiently. It becomes.

以上、本発明の好適な実施形態の例を説明したが、本発明の実施形態は前記説明に限るものではない。以降、別の実施形態について説明する。   As mentioned above, although the example of the suitable embodiment of the present invention was explained, the embodiment of the present invention is not restricted to the above-mentioned explanation. Hereinafter, another embodiment will be described.

≪別の実施形態≫
図6のフローでは、基本ブロックに命令数をカウントする処理の埋め込み方法を示しているが、基本ブロックに埋め込む命令はこの限りではなく、基本ブロックの推定クロック数(マシン命令レベルの実行クロック数)をカウントする命令(加算命令)を埋め込む形態が可能である。ここで、基本ブロックの推定クロック数とは、CPUがその基本ブロックを何クロックで処理することができるかを推定した値である。この値は最適化の命令スケジューリングを行う過程で推定しているため、その値を使用する。以下、ある基本ブロックを処理するために必要なクロック数を推定する処理について説明する。
<< Another Embodiment >>
The flow in FIG. 6 shows a method of embedding processing for counting the number of instructions in the basic block. However, the instruction embedded in the basic block is not limited to this, and the estimated number of clocks of the basic block (the number of execution clocks at the machine instruction level) It is possible to embed an instruction for counting (addition instruction). Here, the estimated number of clocks of the basic block is a value obtained by estimating how many clocks the CPU can process the basic block. Since this value is estimated in the process of optimizing instruction scheduling, that value is used. Hereinafter, processing for estimating the number of clocks necessary for processing a certain basic block will be described.

図7は、基本ブロック内の命令をCPUが実行するために要するクロック数の推定フロー図である。
まず、基本ブロック管理テーブル110のエントリから基本ブロック内の最初の命令を取り出す(ステップ701)。
FIG. 7 is an estimation flowchart of the number of clocks required for the CPU to execute the instructions in the basic block.
First, the first instruction in the basic block is extracted from the entry in the basic block management table 110 (step 701).

次に、取り出した命令の使用しているレジスタ(使用レジスタ)と、その前後の命令との使用レジスタの依存関係を調べる(ステップ702)。レジスタの依存関係とは、同一のレジスタを使用する命令が2以上存在し、それらの命令において、ある命令を実行するまでは他の命令の実行を待機する関係、という意味を少なくとも含む。
次に、レジスタの依存関係から、待ち時間がより小さくなるように命令をスケジューリングする(ステップ703)。スケジューリングの詳細は、図12、図13、図14を参照して後記する。
Next, the dependency relationship between the used register of the fetched instruction (used register) and the used register between the preceding and subsequent instructions is checked (step 702). The register dependency includes at least the meaning of a relationship in which two or more instructions using the same register exist, and these instructions wait for execution of another instruction until a certain instruction is executed.
Next, instructions are scheduled so as to reduce the waiting time from the dependency of the registers (step 703). Details of the scheduling will be described later with reference to FIGS. 12, 13, and 14.

ステップ703の後、次の命令があるかどうかを判定し(ステップ704)、もしあれば(ステップ704でYes)、次の命令を取り出して(ステップ705)、ステップ702に戻り、以降の処理を同様に繰り返す。次の命令がなければ(ステップ704でNo)、基本ブロック内の命令が全てスケジューリングされたことになり、スケジューリングによるスケジューリング結果から基本ブロック単位の推定クロック数を求める(ステップ706)。なお、求めた推定クロック数は、最適化後のものであっても良いし、最適化前のものであっても良い。
以上で、クロック数を推定するフローに関する説明を終了する。
After step 703, it is determined whether there is a next instruction (step 704). If there is (Yes in step 704), the next instruction is taken out (step 705), and the process returns to step 702 to perform the subsequent processing. Repeat in the same way. If there is no next instruction (No in step 704), all instructions in the basic block have been scheduled, and the estimated number of clocks for each basic block is obtained from the scheduling result by scheduling (step 706). Note that the obtained estimated number of clocks may be one after optimization or one before optimization.
This is the end of the description of the flow for estimating the number of clocks.

前記フローによるクロック数推定の例を、図12、図13、図14を参照して説明する。
図13は、スケジューリング前のある基本ブロック内に含まれる命令列の例を表した図である。この図では、命令の種類と、その命令を実行するときに使用するレジスタの識別値(「r2」等で表記)とが命令ごとに格納されている。クロック数の推定処理(図7参照)では、この命令列からレジスタの依存関係を調べて、スケジューリングを行う。
An example of estimating the number of clocks according to the flow will be described with reference to FIG. 12, FIG. 13, and FIG.
FIG. 13 is a diagram illustrating an example of an instruction sequence included in a certain basic block before scheduling. In this figure, the type of instruction and the identification value of a register (indicated by “r2” or the like) used when executing the instruction are stored for each instruction. In the process of estimating the number of clocks (see FIG. 7), the register dependency is examined from this instruction sequence and scheduling is performed.

図13の命令列の場合、例えば最初のLD命令1303と、次のMOV命令1304との間でレジスタr2の使用に依存関係がある。そのため、MOV命令1304の実行を開始するためには、最初のLD命令1303の実行が終わるまで待つ必要がある。   In the case of the instruction sequence of FIG. 13, for example, there is a dependency relationship between the first LD instruction 1303 and the next MOV instruction 1304 in the use of the register r2. Therefore, in order to start the execution of the MOV instruction 1304, it is necessary to wait until the execution of the first LD instruction 1303 is completed.

レジスタ使用の依存による待ち時間は、図12に示す、各命令の実行に必要なクロック数のテーブルを参照することで得られる。テーブル中の値は、CPUが各命令1201を実行するのに必要なクロック数1202の例を示している。一連の命令列において使用するレジスタに依存関係があった場合、前記したようにレジスタが使用可能になるまで処理に待ち時間が生じる。待ち時間は依存する命令に応じて異なり、図12のテーブル中の値で示される各命令のクロック数1202で示される。
図13のLD命令1303の場合、実行を終えるまで2クロック必要となるため、最初のLD命令1303と次のMOV命令1304の間に2クロックの待ち時間を考慮してスケジューリングする。
The waiting time due to the dependence on register use is obtained by referring to the table of the number of clocks necessary for executing each instruction shown in FIG. The values in the table show an example of the number of clocks 1202 necessary for the CPU to execute each instruction 1201. When there is a dependency relationship between registers used in a series of instruction sequences, as described above, there is a waiting time for processing until the registers can be used. The waiting time varies depending on the dependent instruction, and is indicated by the clock number 1202 of each instruction indicated by the value in the table of FIG.
In the case of the LD instruction 1303 in FIG. 13, two clocks are required until the execution is completed. Therefore, scheduling is performed in consideration of a waiting time of two clocks between the first LD instruction 1303 and the next MOV instruction 1304.

前記した手順により図13の命令列をスケジューリングした例、つまりスケジューリング後の基本ブロック内の命令列の例を図14((a)最適化前、(b)最適化後)に示す。なお、図12、図13及び図14に示すテーブルは、例えば、主記憶装置103に記憶されている。
前記したように、最初のLD命令1404(図13の符号1303に相当)と次のMOV命令1405(図13の符号1304に相当)との間に2クロックの待ち時間がある。同様に、ADD命令1406(図13の符号1306に相当)とMOV命令1407(図13の符号1303に相当)の間にもレジスタの依存関係により1クロックの待ち時間が生じている。
FIG. 14 ((a) before optimization, (b) after optimization) shows an example in which the instruction sequence of FIG. 13 is scheduled by the above-described procedure, that is, an example of the instruction sequence in the basic block after scheduling. Note that the tables shown in FIGS. 12, 13, and 14 are stored in the main storage device 103, for example.
As described above, there is a waiting time of 2 clocks between the first LD instruction 1404 (corresponding to reference numeral 1303 in FIG. 13) and the next MOV instruction 1405 (corresponding to reference numeral 1304 in FIG. 13). Similarly, a waiting time of one clock is generated between the ADD instruction 1406 (corresponding to reference numeral 1306 in FIG. 13) and the MOV instruction 1407 (corresponding to reference numeral 1303 in FIG. 13) due to the dependency of registers.

この待ち時間を小さくするために、スケジューリングでは命令順序の入れ替えによる最適化を行う。例えば図14のスケジューリング例の場合、MOV命令1407とST命令1408(図13の符号1307に相当)の間にはレジスタの依存関係がないため、(b)に示すように、ST命令1408を先に実行するように順番を入れ替えることができる。
また、ST命令1408はADD命令1406ともレジスタに依存関係がないため、ADD命令1406とMOV命令1407の間の待ちクロック中にST命令1408を実行することができ、順番入れ替え前に比べると、入れ替え後では(b)最適化後の例1409で示すように推定クロック数が1クロック分減少する。
In order to reduce this waiting time, optimization is performed by changing the order of instructions in scheduling. For example, in the scheduling example of FIG. 14, there is no register dependency between the MOV instruction 1407 and the ST instruction 1408 (corresponding to reference numeral 1307 in FIG. 13). The order can be changed so that
Since the ST instruction 1408 has no register dependency with the ADD instruction 1406, the ST instruction 1408 can be executed during the waiting clock between the ADD instruction 1406 and the MOV instruction 1407. Later, as shown in (b) Example 1409 after optimization, the estimated number of clocks decreases by one clock.

このようにスケジューリングするため、この基本ブロック内の最後の命令が実行を開始するまでのクロック数として7クロックという推定値を得ることができる。よって、推定した基本ブロックの推定クロック数をカウントする命令を生成し、生成した命令をその基本ブロックに埋込むことで、実行時の推定クロック数を計測することが可能となる。なお、推定クロック数をカウントする命令の埋込みに関する処理は、例えば図6に示した処理に準拠する。また、基本ブロック管理テーブル(図10参照)には、この推定クロック数が基本ブロックごとに、推定クロック数フィールド1004に格納される。計測したクロック数は、例えば図15、図16、図17に示した表示態様に準じて表示することができる。   Since scheduling is performed in this manner, an estimated value of 7 clocks can be obtained as the number of clocks until the last instruction in the basic block starts execution. Therefore, by generating an instruction for counting the estimated number of clocks of the estimated basic block and embedding the generated instruction in the basic block, the estimated number of clocks at the time of execution can be measured. Note that the processing related to embedding an instruction for counting the estimated number of clocks is based on the processing shown in FIG. 6, for example. In the basic block management table (see FIG. 10), this estimated clock number is stored in the estimated clock number field 1004 for each basic block. The measured number of clocks can be displayed in accordance with the display mode shown in FIGS. 15, 16, and 17, for example.

本実施形態のクロック数の推定処理は前記実施形式に限るものではない。例えば、命令のスケジューリングとは切り離して推定することも可能である。
本実施形態では、基本ブロックに埋め込む命令として最適化効果をカウントする命令を埋め込む形態も可能である。
The processing for estimating the number of clocks in this embodiment is not limited to the above-described embodiment. For example, estimation can be performed separately from instruction scheduling.
In the present embodiment, it is possible to embed an instruction for counting an optimization effect as an instruction to be embedded in a basic block.

図14の例では最適化前後で推定クロック数が1クロック減少していることがわかる。そこで、命令スケジューリングを含む最適化前後の推定クロック数の差分(マシン命令レベルの実行クロック数)をカウンタに加算する命令(クロック数差分加算命令)を生成し、生成した命令を基本ブロックの中に埋め込む。これにより、最適化による実行効率向上の効果を計測することが可能となる。なお、推定クロック数の差分をカウントする命令の埋込みに関する処理は、例えば図6に示した処理に準拠する。   In the example of FIG. 14, it can be seen that the estimated number of clocks is reduced by one clock before and after optimization. Therefore, it generates an instruction (clock number difference addition instruction) that adds the difference of the estimated clock number before and after optimization including the instruction scheduling (execution clock number of machine instruction level) to the counter, and put the generated instruction in the basic block Embed. Thereby, it is possible to measure the effect of improving the execution efficiency by the optimization. Note that the processing related to the embedding of the instruction for counting the difference in the estimated number of clocks is based on the processing shown in FIG. 6, for example.

また、推定クロック数の差分を求める処理は、例えば図7に示した処理に準拠する。この場合、ステップ706において、最適化前後を示したスケジューリング結果(図14の(a)(b)参照)を比較して前記差分を求める。また、基本ブロック管理テーブル(図10参照)には、この推定クロック数の差分が基本ブロックごとに、所定のフィールドに(例えば、推定クロック数フィールド1004の代用として)格納される。計測したクロック数の差分は、例えば図15、図16、図17に示した表示態様に準じて表示することができる。   Further, the process for obtaining the difference in the estimated number of clocks is based on the process shown in FIG. 7, for example. In this case, in Step 706, the difference is obtained by comparing the scheduling results (see FIGS. 14A and 14B) showing before and after optimization. Also, in the basic block management table (see FIG. 10), the difference in the estimated clock number is stored in a predetermined field for each basic block (for example, as a substitute for the estimated clock number field 1004). The measured difference in the number of clocks can be displayed in accordance with the display modes shown in FIGS. 15, 16, and 17, for example.

なお、本実施形態では、図2や図4に示すように、ダイナミックステップ数を表示するための方法として、ダイナミックステップ情報115を補助記憶装置112へ出力し、ダイナミックステップ表示部111により出力装置116へ表示しているが、表示のための形態はこの限りではない。例えば、ダイナミックステップ表示部111の機能を実行可能プログラム114や、実行時ライブラリに持たせることで、ダイナミックステップ情報115を補助記憶装置112へ出力することなく、直接出力装置116へ表示する形態が可能である。プログラムの開発の便宜を考慮して、これらの表示の形態のいずれかを採用するように設計変更することが好ましい。   In this embodiment, as shown in FIGS. 2 and 4, as a method for displaying the number of dynamic steps, the dynamic step information 115 is output to the auxiliary storage device 112, and the output device 116 is output by the dynamic step display unit 111. However, the display form is not limited to this. For example, by providing the function of the dynamic step display unit 111 in the executable program 114 or the runtime library, the dynamic step information 115 can be directly displayed on the output device 116 without being output to the auxiliary storage device 112. It is. In consideration of the convenience of program development, it is preferable to change the design so that one of these display forms is adopted.

≪その他≫
例えば、add命令が埋め込まれた基本ブロックの実行プロセスが実行されるときには、add命令自身はカウントしないようにして基本ブロックの命令数をカウントしないように設計すると良い。そのカウントをするように設計したときには、埋込んだadd命令の数をダイナミックステップ数等から減算することが好ましい。
≪Others≫
For example, when an execution process of a basic block in which an add instruction is embedded is executed, the add instruction itself may not be counted, and the number of instructions in the basic block may not be counted. When it is designed to count, it is preferable to subtract the number of embedded add instructions from the number of dynamic steps.

基本ブロック管理テーブル(図10参照)を構成するエントリにおいて、開始位置フィールド1002を用いて基本ブロックの開始位置にある命令の命令IDを用いる代わりに、基本ブロックの終了位置にある命令の命令IDを用いるようにしても良い。または、開始位置及び終了位置の両方の命令IDを用いるようにしても良い。
基本ブロックの開始位置の命令としては、例えば、手続きや関数のエントリーポイント 、ジャンプや分岐の対象、条件分岐命令の後の、分岐しなかった場合のコード、例外を発生させる命令の後のコード、例外ハンドラがあり、これらの命令IDを用いるようにしても良い。
また、基本ブロックの終了位置の命令としては、例えば、無条件あるいは条件分岐命令(直接分岐も間接分岐も含む)、呼び出し元の手続きへのReturn、例外処理を発生させうる命令、復帰しない関数(例:exit関数)があり、これらの命令IDを用いるようにしても良い。ただし、制御フローが基本ブロックの最後を通過することは基本的にはないため、基本ブロックの境界は、基本ブロックを見つけた後に修正しなければならない場合もある。そのための擬似オブジェクトコード等の設計変更を行うようにすると良い。
In the entry constituting the basic block management table (see FIG. 10), instead of using the instruction ID of the instruction at the start position of the basic block using the start position field 1002, the instruction ID of the instruction at the end position of the basic block is used. It may be used. Alternatively, the command IDs at both the start position and the end position may be used.
Instructions at the start position of the basic block include, for example, procedure and function entry points, jump and branch targets, code after a conditional branch instruction, code after an instruction that causes an exception, There are exception handlers, and these instruction IDs may be used.
The instruction at the end position of the basic block includes, for example, an unconditional or conditional branch instruction (including a direct branch and an indirect branch), a return to the calling procedure, an instruction that can cause exception processing, and a function that does not return ( Example: exit function), and these instruction IDs may be used. However, since the control flow does not basically pass through the end of the basic block, the boundary of the basic block may have to be corrected after finding the basic block. Therefore, it is preferable to change the design of the pseudo object code or the like.

前記した各実施形態において説明した技術事項の一部又は全部を組み合わせた発明を実現することできるのは勿論である。
その他、ハードウェア、ソフトウェア、フローチャート、テーブル等の具体的な構成について、本発明の趣旨を逸脱しない範囲で適宜変更が可能である。
Of course, it is possible to realize an invention in which some or all of the technical matters described in the above embodiments are combined.
In addition, specific configurations of hardware, software, flowcharts, tables, and the like can be appropriately changed without departing from the spirit of the present invention.

101 計算機システム
102 CPU(制御部)
103 主記憶装置(記憶部)
104 コンパイラ
105 字句/構文/意味解析部
106 擬似オブジェクトコ生成部
107 命令レベル最適化部
108 オブジェクトプログラム生成部
109 擬似オブジェクトコード
110 基本ブロック管理テーブル
111 ダイナミックステップ表示部
112 補助記憶装置(記憶部)
113 ソースコード
114 実行可能プログラム
115 ダイナミックステップ情報
116 出力装置(表示部)
201 ユーザプログラム処理部
202 ダイナミックステップ計測部
203 実行プロセス
301 基本ブロック抽出部
302 フロー解析部
303 最適化処理部
304 ダイナミックステップカウント命令埋込部
402 ダイナミックステップ情報出力部
101 computer system 102 CPU (control unit)
103 Main storage device (storage unit)
104 Compiler 105 Lexical / Syntax / Semantic Analysis Unit 106 Pseudo Object Co Generation Unit 107 Instruction Level Optimization Unit 108 Object Program Generation Unit 109 Pseudo Object Code 110 Basic Block Management Table 111 Dynamic Step Display Unit 112 Auxiliary Storage Device (Storage Unit)
113 Source code 114 Executable program 115 Dynamic step information 116 Output device (display unit)
201 User Program Processing Unit 202 Dynamic Step Measurement Unit 203 Execution Process 301 Basic Block Extraction Unit 302 Flow Analysis Unit 303 Optimization Processing Unit 304 Dynamic Step Count Instruction Embedding Unit 402 Dynamic Step Information Output Unit

Claims (6)

ソースコードをコンパイルして生成するプログラムを実行するときにマシン命令レベルの実行命令数を計測する計算機システムにおける実行命令数計測方法において、
前記計算機システムの記憶部は、前記ソースコードと、前記コンパイルを行うコンパイラとを記憶しており、
前記計算機システムの制御部は、
前記コンパイラにより前記ソースコードをコンパイルしてオブジェクトコードの内部表現である擬似オブジェクトコードを生成するステップと、
前記擬似オブジェクトコードに含まれる命令を参照し、分岐も合流も含まない逐次的な命令列である基本ブロックに前記擬似オブジェクトコードを分割するステップと、
プログラムを実行する際に、前記基本ブロックに含まれる命令が実行されるときの命令数をカウンタに加算する加算命令を、前記基本ブロックに埋込むステップと、
プログラムを実行して前記加算命令が実行されたことにより、前記基本ブロックの前記命令数に基づいて前記実行命令数を表示部に表示させるステップと、を実行する
ことを特徴とする実行命令数計測方法。
In a method for measuring the number of execution instructions in a computer system that measures the number of execution instructions at the machine instruction level when executing a program generated by compiling source code,
The storage unit of the computer system stores the source code and a compiler that performs the compilation,
The control unit of the computer system is
Compiling the source code with the compiler to generate pseudo object code that is an internal representation of the object code;
Dividing the pseudo object code into basic blocks that are sequential instruction sequences that refer to instructions included in the pseudo object code and do not include branching or merging;
Embedding in the basic block an addition instruction for adding to the counter the number of instructions when the instruction included in the basic block is executed when executing the program;
Displaying the number of instructions to be executed on a display unit based on the number of instructions in the basic block when the program is executed and the addition instruction is executed. Method.
前記制御部は、
前記実行命令数としてのダイナミックステップ数を、(1)前記ソースコードに使用される関数若しくは手続き単位、(2)前記基本ブロック単位又は(3)前記ソースコードの行単位、のいずれかで前記表示部に表示させる
ことを特徴とする請求項1に記載の実行命令数計測方法。
The controller is
The number of dynamic steps as the number of execution instructions is indicated by either (1) a function or procedure unit used in the source code, (2) the basic block unit or (3) a line unit of the source code. The method according to claim 1, wherein the number of executed instructions is displayed.
ソースコードをコンパイルして生成するプログラムを実行するときにマシン命令レベルの実行クロック数を計測する計算機システムにおける実行クロック数計測方法において、
前記計算機システムの記憶部は、前記ソースコードと、前記コンパイルを行うコンパイラとを記憶しており、
前記計算機システムの制御部は、
前記コンパイラにより前記ソースコードをコンパイルしてオブジェクトコードの内部表現である擬似オブジェクトコードを生成するステップと、
前記擬似オブジェクトコードに含まれる命令を参照し、分岐も合流も含まない逐次的な命令列である基本ブロックに前記擬似オブジェクトコードを分割するステップと、
プログラムを実行する際に、前記基本ブロックに含まれる命令を実行するのに必要となるクロック数をレジスタの依存関係に基づいて推定するステップと、
該推定した推定クロック数をカウンタに加算する加算命令を前記基本ブロックに埋込むステップと、
プログラムを実行して前記加算命令が実行されたことにより、前記基本ブロックの前記推定クロック数に基づいて前記実行クロック数を表示部に表示させるステップと、
を実行することを特徴とする実行クロック数計測方法。
In a method for measuring the number of execution clocks in a computer system that measures the number of execution clocks at the machine instruction level when executing a program generated by compiling source code,
The storage unit of the computer system stores the source code and a compiler that performs the compilation,
The control unit of the computer system is
Compiling the source code with the compiler to generate pseudo object code that is an internal representation of the object code;
Dividing the pseudo object code into basic blocks that are sequential instruction sequences that refer to instructions included in the pseudo object code and do not include branching or merging;
Estimating the number of clocks required to execute an instruction included in the basic block when executing a program based on the dependency of a register;
Embedding in the basic block an addition instruction for adding the estimated number of estimated clocks to a counter;
Displaying the execution clock number on a display unit based on the estimated clock number of the basic block by executing the program and executing the addition instruction;
The execution clock number measuring method characterized by performing this.
前記制御部は、
前記コンパイラによる最適化を行う前の前記推定クロック数と、前記最適化を行った後の前記推定クロック数との差分を前記カウンタに加算するクロック数差分加算命令を、前記基本ブロックに埋込むステップと、
プログラムを実行して前記クロック数差分加算命令が実行されたことにより、前記基本ブロックの前記差分に基づいて前記実行クロック数を前記表示部に表示させるステップと、を実行する
ことを特徴とする請求項3に記載の実行クロック数計測方法。
The controller is
Embedding in the basic block a clock number difference addition instruction for adding the difference between the estimated clock number before optimization by the compiler and the estimated clock number after the optimization to the counter When,
The step of displaying the number of execution clocks on the display unit based on the difference of the basic block by executing a program and executing the clock number difference addition instruction is executed. Item 4. The method of measuring the number of execution clocks according to Item 3.
ソースコードをコンパイルして生成するプログラムを実行するときにマシン命令レベルの実行命令数を計測する計算機システムにおいて、
前記ソースコードと、前記コンパイルを行うコンパイラとを記憶する記憶部を備え、
前記コンパイラにより前記ソースコードをコンパイルしてオブジェクトコードの内部表現である擬似オブジェクトコードを生成する制御と、
前記擬似オブジェクトコードに含まれる命令を参照し、分岐も合流も含まない逐次的な命令列である基本ブロックに前記擬似オブジェクトコードを分割する制御と、
プログラムを実行する際に、前記基本ブロックに含まれる命令が実行されるときの命令数をカウンタに加算する加算命令を、前記基本ブロックに埋込む制御と、
プログラムを実行して前記加算命令が実行されたことにより、前記基本ブロックの前記命令数に基づいて前記実行命令数を表示部に表示させる制御と、を実行する制御部を備える
ことを特徴とする計算機システム。
In a computer system that measures the number of execution instructions at the machine instruction level when executing a program generated by compiling source code,
A storage unit that stores the source code and a compiler that performs the compilation;
Control to compile the source code by the compiler to generate pseudo object code that is an internal representation of the object code;
Control for referring to the instructions included in the pseudo object code and dividing the pseudo object code into basic blocks that are sequential instruction sequences including neither branch nor merge;
A control for embedding in the basic block an addition instruction for adding to the counter the number of instructions when the instruction included in the basic block is executed when executing the program;
And a control unit that executes a control to display the number of execution instructions on a display unit based on the number of instructions in the basic block when the addition instruction is executed by executing a program. Computer system.
ソースコードをコンパイルして生成するプログラムを実行するときにマシン命令レベルの実行クロック数を計測する計算機システムにおいて、
前記ソースコードと、前記コンパイルを行うコンパイラとを記憶する記憶部を備え、
前記計算機システムの制御部は、
前記コンパイラにより前記ソースコードをコンパイルしてオブジェクトコードの内部表現である擬似オブジェクトコードを生成する制御と、
前記擬似オブジェクトコードに含まれる命令を参照して、分岐も合流も含まない逐次的な命令列である基本ブロックに前記擬似オブジェクトコードを分割する制御と、
プログラムを実行する際に、前記基本ブロックに含まれる命令を実行するのに必要となるクロック数をレジスタの依存関係に基づいて推定する制御と、
該推定した推定クロック数をカウンタに加算する加算命令を前記基本ブロックに埋込む制御と、
プログラムを実行して前記加算命令が実行されたことにより、前記基本ブロックの前記推定クロック数に基づいて前記実行クロック数を表示部に表示させる制御と、を実行する制御部を備える
ことを特徴とする計算機システム。
In a computer system that measures the number of execution clocks at the machine instruction level when executing a program generated by compiling source code,
A storage unit that stores the source code and a compiler that performs the compilation;
The control unit of the computer system is
Control to compile the source code by the compiler to generate pseudo object code that is an internal representation of the object code;
Control to divide the pseudo object code into basic blocks that are sequential instruction sequences that do not include branching or merging with reference to instructions included in the pseudo object code;
Control for estimating the number of clocks required to execute the instructions included in the basic block based on the dependency of the register when executing the program;
A control for embedding an addition instruction for adding the estimated number of clocks to the counter in the basic block;
A control unit for executing a program and executing a control to display the execution clock number on a display unit based on the estimated clock number of the basic block when the addition instruction is executed. Computer system to do.
JP2009257047A 2009-11-10 2009-11-10 Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system Pending JP2011103026A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2009257047A JP2011103026A (en) 2009-11-10 2009-11-10 Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system
PCT/JP2010/069833 WO2011058946A1 (en) 2009-11-10 2010-11-08 Method for counting number of executed instructions, method for counting number of execution clocks, and computer system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009257047A JP2011103026A (en) 2009-11-10 2009-11-10 Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system

Publications (1)

Publication Number Publication Date
JP2011103026A true JP2011103026A (en) 2011-05-26

Family

ID=43991605

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009257047A Pending JP2011103026A (en) 2009-11-10 2009-11-10 Method for measuring number of dynamic steps, method for measuring number of clocks, and computer system

Country Status (2)

Country Link
JP (1) JP2011103026A (en)
WO (1) WO2011058946A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015210574A (en) * 2014-04-24 2015-11-24 富士通株式会社 Information processor, processing method and processing program

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0520135A (en) * 1991-07-15 1993-01-29 Nec Corp Execution time performance measuring system for target program
JP2000242529A (en) * 1999-02-23 2000-09-08 Matsushita Electric Ind Co Ltd Device and system for assisting program development and recording medium
JP2004030514A (en) * 2002-06-28 2004-01-29 Ip Flex Kk Method for analyzing performance
JP2005215830A (en) * 2004-01-28 2005-08-11 Internatl Business Mach Corp <Ibm> Compiler, compile method, compile program, and recording medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0520135A (en) * 1991-07-15 1993-01-29 Nec Corp Execution time performance measuring system for target program
JP2000242529A (en) * 1999-02-23 2000-09-08 Matsushita Electric Ind Co Ltd Device and system for assisting program development and recording medium
JP2004030514A (en) * 2002-06-28 2004-01-29 Ip Flex Kk Method for analyzing performance
JP2005215830A (en) * 2004-01-28 2005-08-11 Internatl Business Mach Corp <Ibm> Compiler, compile method, compile program, and recording medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015210574A (en) * 2014-04-24 2015-11-24 富士通株式会社 Information processor, processing method and processing program

Also Published As

Publication number Publication date
WO2011058946A1 (en) 2011-05-19

Similar Documents

Publication Publication Date Title
US7168060B2 (en) Method of generating development environment for developing system LSI and medium which stores program therefor using VLIW designating description
US10031842B2 (en) Method for adjusting the precision of a computer program manipulating at least one number with a decimal point
WO2001035223A1 (en) Method and system for simulating execution of a target program in a simulated target system
Li et al. Practical symbolic race checking of GPU programs
JP6342129B2 (en) Source code error position detection apparatus and method for mixed mode program
JP2009524866A (en) System and method for parallel execution of programs
KR20080052308A (en) A software development apparatus for providing performance prediction and a method thereof
JP2005141410A (en) Compiler apparatus and compile method
Malburg et al. Property mining using dynamic dependency graphs
JP2008176453A (en) Simulation device
US20120331448A1 (en) Coverage measurement apparatus and method and medium
Carlsson et al. Worst-case execution time analysis of disable interrupt regions in a commercial real-time operating system
WO2011058946A1 (en) Method for counting number of executed instructions, method for counting number of execution clocks, and computer system
Tan The worst-case execution time tool challenge 2006
JP4860564B2 (en) Program profiling apparatus, program profiling method, and program
Malburg et al. Tuning dynamic data flow analysis to support design understanding
Kirner Integration of static runtime analysis and program compilation
CN114153750B (en) Code checking method and device, code compiling method and electronic equipment
Garcia et al. HybridVerifier: a cross-platform verification framework for instruction set simulators
Parravicini et al. The Cost of Speculation: Revisiting Overheads in the V8 JavaScript Engine
JP2013080406A (en) Compilation device, information processing system, compilation method, compilation program, and storage medium
Mason et al. Lampview: A loop-aware toolset for facilitating parallelization
JP5116624B2 (en) Simulation apparatus and simulation method
Österberg Calculation of WCET with symbolic execution
Omar et al. Binary-level data dependence analysis of hot execution regions using abstract interpretation at runtime

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20121009

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20130305