JP2012103923A - Compiler device, compiling method and compiler program - Google Patents
Compiler device, compiling method and compiler program Download PDFInfo
- Publication number
- JP2012103923A JP2012103923A JP2010252280A JP2010252280A JP2012103923A JP 2012103923 A JP2012103923 A JP 2012103923A JP 2010252280 A JP2010252280 A JP 2010252280A JP 2010252280 A JP2010252280 A JP 2010252280A JP 2012103923 A JP2012103923 A JP 2012103923A
- Authority
- JP
- Japan
- Prior art keywords
- function
- core
- global variable
- allocation target
- target function
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
本発明は、コンパイラ装置に関し、特にマルチコアプロセッサに対するオブジェクトプログラムを生成するコンパイラ装置に関する。 The present invention relates to a compiler apparatus, and more particularly to a compiler apparatus that generates an object program for a multi-core processor.
近年、半導体集積回路が多くの製品に搭載され、様々な製品において、複雑な制御が行われており、製品の処理能力を向上させるために、複数のコアをプロセッサに搭載したマルチコアプロセッサが利用されることが多くなってきた。そのため、複数のコアを搭載したプロセッサの特性を利用したオブジェクトプログラムを生成することができるコンパイラ装置の必要性が高まってきている。 In recent years, semiconductor integrated circuits have been mounted on many products, and complex control has been performed on various products. To improve the processing capability of products, multi-core processors with multiple cores mounted on processors have been used. There have been many things. Therefore, there is an increasing need for a compiler apparatus that can generate an object program that uses the characteristics of a processor having a plurality of cores.
特開2008−210027号公報(特許文献1)には、複数のCPUコアを有するマルチコアプロセッサにおいて、分岐命令を各CPUコアに割り当てることによって、分岐命令を並列処理させるオブジェクトプログラムを生成するコンパイラ装置が記載されている。このコンパイラ装置では、各CPUコアで所持している分岐命令の処理結果を、共有メモリに書き込む際に、分岐命令の条件判定を行っているメインスレッドの条件判定結果に基づいて、各CPUコアのストア制御機構の共有メモリ更新禁止フラグを利用して、共有メモリへの処理結果の反映を制御するオブジェクトプログラムを生成している。 Japanese Patent Laying-Open No. 2008-210027 (Patent Document 1) discloses a compiler device that generates an object program for parallel processing of branch instructions by assigning branch instructions to each CPU core in a multi-core processor having a plurality of CPU cores. Are listed. In this compiler apparatus, when the processing result of the branch instruction possessed by each CPU core is written to the shared memory, the condition of each CPU core is determined based on the condition determination result of the main thread that performs the condition determination of the branch instruction. Using the shared memory update prohibition flag of the store control mechanism, an object program for controlling the reflection of the processing result to the shared memory is generated.
従来技術では、各CPUコアにおいて、共有メモリ内の同一のグローバル変数を更新して、分岐命令の条件判定処理と、分岐命令の条件判定結果に基づいて実行する各命令を並列処理すると、共有メモリのグローバル変数の値の整合性がとれないという課題がある。例えば、メインスレッドの分岐命令の条件判定処理において、グローバル変数の更新処理を含み、その結果を分岐先の命令で参照・更新する場合である。 In the prior art, in each CPU core, when the same global variable in the shared memory is updated and the branch instruction condition determination process and each instruction executed based on the branch instruction condition determination result are processed in parallel, the shared memory There is a problem that the values of the global variables cannot be consistent. For example, the condition determination process of the branch instruction of the main thread includes a global variable update process, and the result is referred to and updated by the branch destination instruction.
図9は、コンパイルすると分岐命令を含むオブジェクトプログラムを生成するソースプログラムの例である。問題となるのは、図9において、条件判定処理に使用される変数Xが、グローバル変数の更新を含むf(a,b,c,d)の演算結果によって決定され、各CPUコアへの割り当てる対象となるg0(x0)、g1(x1)及びg2(x2)が、同一のグローバル変数の更新処理を含む場合である。各CPUコアによって並列処理が行われるため、各CPUコアに割り当てた分岐命令が参照するグローバル変数は、メインスレッドの分岐命令の条件判定処理後のグローバル変数を参照するという保障がない。そのため、分岐命令を投機的に並列処理させるCPUコアが、メインスレッドによる更新前のグローバル変数に基づいて、演算を行った場合は、共有メモリのグローバル変数の値の整合性がとれなくなる。 FIG. 9 is an example of a source program that generates an object program including a branch instruction when compiled. The problem is that in FIG. 9, the variable X used in the condition determination process is determined by the operation result of f (a, b, c, d) including the update of the global variable, and is assigned to each CPU core. This is a case where the target g0 (x0), g1 (x1), and g2 (x2) include the same global variable update processing. Since parallel processing is performed by each CPU core, there is no guarantee that the global variable referred to by the branch instruction assigned to each CPU core refers to the global variable after the condition determination processing of the branch instruction of the main thread. For this reason, when a CPU core that speculatively processes branch instructions in parallel performs an operation based on a global variable before being updated by the main thread, the consistency of the value of the global variable in the shared memory cannot be obtained.
本発明の目的は、条件分岐命令の条件判定処理と、分岐後の各命令がグローバル変数に依存している場合に、マルチコアプロセッサによって、投機的に条件分岐命令の条件判定処理と、分岐後の各命令が並列処理されても誤動作しないオブジェクトプログラムを生成するコンパイラ装置を提供することにある。 It is an object of the present invention to perform conditional branch instruction condition determination processing and conditional branch instruction condition determination processing speculatively by a multi-core processor when each instruction after branching depends on a global variable. An object of the present invention is to provide a compiler apparatus that generates an object program that does not malfunction even when instructions are processed in parallel.
本発明のコンパイラ装置は、ソースプログラムを読み込む読み込み部と、ソースプログラムの字句解析を行う字句解析部と、ソースプログラムの構文解析を行う構文解析部と、ソースプログラムに含まれる関数から、グローバル変数の値に基づいてグローバル変数の値を変更する処理を含む関数を、コア割り当て対象関数として抽出するコア割り当て対象関数抽出部と、コア割り当て対象関数が、条件分岐命令の条件判定処理による分岐後の呼出し関数となる場合には、マルチコアプロセッサの各CPUコアにコア割り当て対象関数を割り当て、条件分岐命令の条件判定処理と、コア割り当て対象関数の処理を並列処理させ、条件分岐命令の条件判定処理によって、グローバル変数が変更された場合には、グローバル変数の値に基づいてグローバル変数の値を変更する処理を、コア割り当て対象関数にリトライさせるようにソースプログラムを修正するソース修正部と、ソースプログラムをソース修正部により修正したソースプログラムから中間言語による中間語を作成する中間語作成部と、中間語を最適化する最適化部と、最適化された中間語からオブジェクトプログラムを生成するオブジェクト生成部とを備える。 A compiler apparatus according to the present invention includes a reading unit that reads a source program, a lexical analysis unit that performs lexical analysis of the source program, a syntax analysis unit that performs syntax analysis of the source program, and a function included in the source program. A core allocation target function extraction unit that extracts a function including processing for changing the value of a global variable based on a value as a core allocation target function; In the case of a function, a core allocation target function is allocated to each CPU core of the multi-core processor, the condition determination processing of the conditional branch instruction and the processing of the core allocation target function are processed in parallel, and by the condition determination processing of the conditional branch instruction, If a global variable is changed, it is based on the global variable value. A source modification part that modifies the source program so that the process that changes the value of the variable is retried to the core allocation target function, and an intermediate that creates an intermediate language in an intermediate language from the source program that is modified by the source modification part A word creation unit; an optimization unit that optimizes the intermediate language; and an object generation unit that generates an object program from the optimized intermediate language.
本発明のコンパイル方法は、読み込み部が、ソースプログラムを読み込むステップと、字句解析部が、ソースプログラムの字句解析を行うステップと、構文解析部が、ソースプログラムの構文解析を行うステップと、コア割り当て対象関数抽出部が、ソースプログラムに含まれる関数から、グローバル変数の値に基づいてグローバル変数の値を変更する処理を含む関数を、コア割り当て対象関数として抽出するステップと、ソース修正部が、コア割り当て対象関数が、条件分岐命令の条件判定処理による分岐後の呼出し関数となる場合には、マルチコアプロセッサの各CPUコアにコア割り当て対象関数を割り当て、条件分岐命令の条件判定処理と、コア割り当て対象関数の処理を並列処理させ、条件分岐命令の条件判定処理によって、グローバル変数が変更された場合には、グローバル変数の値に基づいてグローバル変数の値を変更する処理を、コア割り当て対象関数にリトライさせるようにソースプログラムを修正するステップと、中間語作成部が、ソースプログラムをソース修正部により修正したソースプログラムから中間言語による中間語を作成するステップと、最適化部が、中間語を最適化するステップと、オブジェクト生成部が、最適化された中間語からオブジェクトプログラムを生成するステップとを含む。 In the compiling method of the present invention, the reading unit reads the source program, the lexical analysis unit performs the lexical analysis of the source program, the syntax analysis unit performs the syntax analysis of the source program, and the core allocation. The target function extraction unit extracts a function including a process of changing the value of the global variable from the function included in the source program based on the value of the global variable as a core allocation target function, and the source correction unit includes the core When the assignment target function is a call function after branching by the conditional determination processing of the conditional branch instruction, the core allocation target function is allocated to each CPU core of the multi-core processor, the conditional determination processing of the conditional branch instruction, and the core allocation target Function processing is performed in parallel, and conditional branch instruction condition determination processing If the variable is changed, the step of modifying the source program so that the core allocation target function will retry the process of changing the value of the global variable based on the value of the global variable, and the intermediate language creating unit, A step of creating an intermediate language in an intermediate language from a source program obtained by correcting a source program by a source correction unit, a step of an optimization unit optimizing the intermediate language, and an object generation unit generating an object from the optimized intermediate language Generating a program.
本発明によれば、条件分岐命令の条件判定処理と、分岐後の各命令がグローバル変数に依存している場合に、マルチコアプロセッサによって、投機的に条件分岐命令の条件判定処理と、分岐後の各命令が並列処理されても誤動作しないオブジェクトプログラムを生成するコンパイラ装置を提供することができる。 According to the present invention, when a conditional branch instruction condition determination process and each instruction after branching depend on a global variable, the multi-core processor speculatively determines the conditional branch instruction condition determination process and It is possible to provide a compiler apparatus that generates an object program that does not malfunction even when instructions are processed in parallel.
添付図面を参照して、本発明の実施形態によるコンパイラ装置40を以下に説明する。
A
[構成の説明]
はじめに、本実施形態におけるコンパイラ装置40の構成の説明を行う。図1は、本発明の実施形態におけるコンパイラ装置40のブロック図である。本発明の実施形態におけるコンパイラ装置40は、読み込み部41、字句解析部42、構文解析部43、割り当て対象関数抽出部44、ソース修正部45、中間語作成部46、最適化部47、オブジェクト生成部48、変数名、定数等の各種情報のテーブル32、グローバル変数テーブル33及びコア割り当て対象関数テーブル34を備える。
[Description of configuration]
First, the configuration of the
読み込み部41は、コンパイルの対象となるソースプログラム30をコンパイラ装置40に読み込む。
The
字句解析部42は、従来技術の一般のコンパイラ装置と同様の方法で、ソースプログラム30の字句解析を行う。
The
構文解析部43は、従来技術の一般のコンパイラ装置と同様の方法で、ソースプログラム30の構文解析を行う。ただし、グローバル変数の管理について、ソースプログラム30に含まれるグローバル変数のread箇所及びwrite箇所の情報を、ソースプログラム30に含まれる関数ごとに所持するグローバル変数テーブル33を作成する。
The
コア割り当て対象関数抽出部44は、ソースプログラム30に含まれる関数の中から、マルチコアプロセッサにおける各CPUコアに対して、割り当てる対象となる関数を抽出する。
The core assignment target
ソース修正部45は、条件分岐命令の条件判定処理と、分岐後の各命令がグローバル変数に依存している場合に、マルチコアプロセッサによって、投機的に条件分岐命令の条件判定処理と、分岐後の各命令が並列処理されても誤動作しないオブジェクトプログラムを生成できるように、ソースプログラム30を修正する。
The
中間語作成部46は、従来技術の一般のコンパイラ装置と同様の方法で、ソースプログラム30から中間言語による中間語を作成する。
The intermediate
最適化部47は、従来技術の一般のコンパイラ装置と同様の方法で、中間語作成部46により作成された中間語を最適化する。
The
オブジェクト生成部48は、従来技術の一般のコンパイラ装置と同様の方法で、最適化部47により最適化された中間語からオブジェクトプログラムを生成する。
The
変数名、定数等の各種情報のテーブル32は、コンパイラ装置が、ソースプログラム30からオブジェクトプログラムを生成するために必要となる情報を保持するためのテーブルである。従来技術の一般のコンパイラ装置と同様の情報を、変数名、定数等の各種情報のテーブル32で保持している。
A table 32 of various information such as variable names and constants is a table for holding information necessary for the compiler apparatus to generate an object program from the
グローバル変数テーブル33は、ソースプログラム30に含まれるグローバル変数のread箇所及びwrite箇所の情報を、ソースプログラム30に含まれる関数ごとに所持するテーブルである。
The global variable table 33 is a table that holds information on read and write locations of global variables included in the
コア割り当て対象関数テーブル34は、ソースプログラム30に含まれる関数に対して、マルチコアプロセッサの各CPUコアに割り当てる対象となる関数であるかどうかを管理しているテーブルである。
The core assignment target function table 34 is a table that manages whether a function included in the
次に、本実施形態におけるコンパイラ装置40のハードウェア構成についての説明を行う。図10は、本発明の実施形態におけるコンパイラ装置40のハードウェア構成図である。
Next, the hardware configuration of the
コンパイラ装置40は、表示部20、入力部21、CPU22、補助記憶装置23、メモリ24及びシステムバス25を備える。
The
メモリ24は、コンパイラ装置40の主記憶装置である。コンパイラ装置40を利用する際には、本実施形態におけるコンパイラ装置40を実現するためのコンパイラプログラム10が、メモリ24上に展開される。表示部20は、コンパイラ装置40の実行結果が表示される。入力部21は、利用者がコンパイラ装置40を操作するためのインタフェースである。CPU22は、メモリ24上に展開されたコンピュータプログラムを実行する制御装置である。補助記憶装置23は、OS(Operating System)及びアプリケーションプログラムが記憶されている装置である。補助記憶装置23には、本実施形態におけるコンパイラ装置40を実現するためのコンパイラプログラム10が記憶されている。システムバス25は、表示部20、入力部21、CPU22、補助記憶装置23及びメモリ24とデータの送受信を行う通信路である。
The
次に、本発明の実施形態におけるコンパイラ装置40によって生成されたオブジェクトプログラムが実行されるマルチコアプロセッサについて説明する。図11は、本発明の実施形態におけるコンパイラ装置40によって生成されたオブジェクトプログラムが実行されるマルチコアプロセッサ7の例である。
Next, a multi-core processor that executes an object program generated by the
マルチコアプロセッサ7は、CPUコア0〜2、ローカルメモリ3〜5及び共有メモリ6を備える。CPUコア0〜2は、それぞれ独立に動作することができるマルチコアプロセッサ7のプロセッサコアである。ローカルメモリ3〜5は、CPUコア0〜2がそれぞれ独立に使用するメモリである。CPUコア0〜2は、共有メモリ6から演算に必要なデータを、対応するローカルメモリ3〜5にコピーし、それぞれのローカルメモリ3〜5を利用して演算を行い、演算結果をそれぞれのローカルメモリ3〜5で保持する。CPUコア0〜2は、それぞれのローカルメモリ3〜5で保持している演算結果を、必要に応じて共有メモリ6に反映する。共有メモリ6は、マルチコアプロセッサ7のそれぞれのCPUコア0〜2が共有することができるメモリである。
The
[動作方法の説明]
次に、本実施形態におけるコンパイラ装置40において、コンパイル方法の説明を行う。本実施形態のコンパイラ装置40において、コア割り当て対象関数抽出部44及びソース修正部45以外の機能ブロックについては、従来技術の一般のコンパイラ装置における処理と同様である。したがって、コア割り当て対象関数抽出部44及びソース修正部45についての動作方法について説明する。
[Description of operation method]
Next, the compiling method in the
まず、本発明の実施形態におけるコンパイラ装置のコア割り当て対象関数抽出部44についての動作方法について説明する。図2は、本発明の実施形態におけるコンパイラ装置のコア割り当て対象関数抽出部44において、コア割り当て対象関数の抽出方法のフローチャートである。
First, an operation method of the core assignment target
(ステップS101)
はじめに、コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数が、main関数であるかどうかを判断する。コア割り当て対象抽出部44は、main関数であれば、ステップS107に進み、main関数でなければ、ステップS102に進む。
(Step S101)
First, the core allocation
(ステップS102)
次に、コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数が、戻り値として値を返すかどうかを判断する。コア割り当て対象抽出部44は、戻り値として値を返す関数であれば、ステップS103に進み、戻り値として値を返す関数でなければ、ステップS104に進む。
(Step S102)
Next, the core allocation
(ステップS103)
次に、コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数が、戻り値を分岐命令の条件判定に利用しているかどうかを判断する。コア割り当て対象抽出部44は、戻り値を分岐命令の条件判定に利用していれば、ステップS107に進み、戻り値を分岐命令の条件判定に利用していなければ、ステップS104に進む。
(Step S103)
Next, the core allocation
(ステップS104)
次に、コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数が、関数内でグローバル変数にアクセスしているかどうかを判断する。コア割り当て対象抽出部44は、関数内でグローバル変数にアクセスしていれば、ステップS105に進み、関数内でグローバル変数にアクセスしていなければ、ステップS106に進む。
(Step S104)
Next, the core allocation
(ステップS105)
次に、コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数が、繰り返し文の中でグローバル変数にアクセスしているかどうかを判断する。コア割り当て対象抽出部44は、繰り返し文の中でグローバル変数にアクセスしていれば、ステップS107に進み、繰り返し文の中でグローバル変数にアクセスしていなければ、ステップS106に進む。
(Step S105)
Next, the core allocation
繰り返し文の中でグローバル変数にアクセスしている場合に、コア割り当て対象外の関数とする理由は、繰り返し文の中でグローバル変数にアクセスすると、グローバル変数のアクセスにオーバーヘッドがかかるためである。 When a global variable is accessed in a repetitive statement, the reason for making it a function that is not a core allocation target is that if a global variable is accessed in a repetitive statement, it takes overhead to access the global variable.
(ステップS106)
コア割り当て対象抽出部44は、コア割り当て対象となる条件を満たした関数を、コア割り当て対象としてコア割り当て対象関数テーブル34に記録する。
(Step S106)
The core allocation
(ステップS107)
コア割り当て対象抽出部44は、コア割り当て対象となる条件を満たさない関数を、コア割り当て対象外としてコア割り当て対象関数テーブル34に記録する。
(Step S107)
The core allocation
(ステップS108)
コア割り当て対象抽出部44は、コンパイル対象のソースプログラム30に含まれる関数で、まだコア割り当て対象となる条件を満たすかどうかをチェックしていない関数があるかどうかを判断する。コア割り当て対象抽出部44は、未チェックの関数がある場合には、ステップS101に進み、未チェックの関数がない場合には、コア割り当て対象関数抽出処理を終了する。
(Step S108)
The core allocation
次に、本発明の実施形態におけるコンパイラ装置のソース修正部45についての動作方法について説明する。図3A及び図3Bは、本発明の実施形態におけるコンパイラ装置のソース修正部45において、コア割り当て対象関数に対するソースプログラム修正方法のフローチャートである。
Next, an operation method for the
(ステップS201)
はじめに、ソース修正部45は、ソースプログラム30に含まれる関数が、コア割り当て対象の関数の呼び出し元の関数となっているかどうかを判断する。ソース修正部45は、コア割り当て対象の関数の呼び出し元の関数となっていれば、ステップS211に進み、コア割り当て対象の関数の呼び出し元の関数となっていなければ、ステップS202に進む。
(Step S201)
First, the
(ステップS202)
次に、ソース修正部45は、ソースプログラム30に含まれる関数が、コア割り当て対象の関数であるかどうかを判断する。ソース修正部45は、コア割り当て対象の関数であれば、ステップS203に進み、コア割り当て対象の関数でなければ、ソースプログラム修正処理を終了する。
(Step S202)
Next, the
(ステップS203)
次に、ソース修正部45は、コア割り当て対象の関数がグローバル変数をreadしているかどうかを判断する。ソース修正部45は、コア割り当て対象の関数にグローバル変数をreadしていれば、ステップS204に進み、コア割り当て対象の関数にグローバル変数をreadしていなければ、ステップS207に進む。
(Step S203)
Next, the
(ステップS204)
次に、ソース修正部45は、ソース修正処理中のコア割り当て対象関数の呼び出し元の関数において、ソース修正処理中のコア割り当て対象関数の呼び出し前に、他のコア割り当て対象関数が呼び出されているかどうかを判断する。ソース修正部45は、他のコア割り当て対象関数が呼び出されていれば、ステップS205に進み、他のコア割り当て対象関数が呼び出されていなければ、ステップS207に進む。
(Step S204)
Next, the
(ステップS205)
次に、ソース修正部45は、ステップS204の他のコア割り当て対象関数において、グローバル変数をwriteしているかどうかを判断する。ソース修正部45は、グローバル変数をwriteしていれば、ステップS206に進み、グローバル変数をwriteしていなければ、ステップS207に進む。
(Step S205)
Next, the
(ステップS206)
次に、ソース修正部45は、他のCPUコアで実行されている関数によって、グローバル変数の値が変更された場合には、他のCPUコアから通知されたグローバル変数の値を利用して、グローバル変数のreadをリトライするようにソースプログラム30を修正する。また、ソース修正部は、ソース修正処理中の関数を呼び出す関数に対して、ソース修正処理中の関数の終了を通知するようにソースプログラム30を修正する。ソース修正部45は、ステップS207に進む。
(Step S206)
Next, when the value of the global variable is changed by a function executed in another CPU core, the
(ステップS207)
次に、ソース修正部45は、コア割り当て対象の関数がグローバル変数をwriteしているかどうかを判断する。ソース修正部45は、コア割り当て対象の関数にグローバル変数をwriteしていれば、ステップS208に進み、コア割り当て対象の関数にグローバル変数をwriteしていなければ、ソースプログラム修正処理を終了する。
(Step S207)
Next, the
(ステップS208)
次に、ソース修正部45は、ソース修正処理中のコア割り当て対象関数の呼び出し元の関数において、ソース修正処理中のコア割り当て対象関数の呼び出し後に、他のコア割り当て対象関数が呼び出されているかどうかを判断する。ソース修正部45は、他のコア割り当て対象関数が呼び出されていれば、ステップS209に進み、他のコア割り当て対象関数が呼び出されていなければ、ソースプログラム修正処理を終了する。
(Step S208)
Next, the
(ステップS209)
次に、ソース修正部45は、ステップS208の他のコア割り当て対象関数において、グローバル変数をreadしているかどうかを判断する。ソース修正部45は、グローバル変数をreadしていれば、ステップS210に進み、グローバル変数をreadしていなければ、ソースプログラム修正処理を終了する。
(Step S209)
Next, the
(ステップS210)
次に、ソース修正部45は、他のCPUコアによって実行される、グローバル変数のreadを含む関数に、変更した後のグローバル変数の値を通知するようにソースプログラム30を修正する。ソース修正部45は、ソースプログラム修正処理を終了する。
(Step S210)
Next, the
(ステップS211)
ソース修正部45は、コア割り当て対象関数をCPUコアへ割り当てる関数をソースプログラム30に追加する。
(Step S211)
The
(ステップS212)
ソース修正部45は、他のCPUコアへ割り当てた関数の終了を待つ処理をソースプログラム30に追加する。
(Step S212)
The
(ステップS213)
ソース修正部45は、他のCPUコアへ割り当てた関数の処理結果を、対応するCPUコアのローカルメモリから、共有メモリ6へ反映するようにソースプログラム30を修正する。
(Step S213)
The
以上が、本発明の実施形態におけるコンパイラ装置40のコア割り当て対象関数抽出部44及びソース修正部45についての動作方法の説明である。
The above is the description of the operation method for the core assignment target
次に、C言語の具体的なソースプログラムの例に基づいて、本発明の実施例1におけるコンパイラ装置40を説明する。図4は、本発明の実施例1におけるコンパイラ装置を説明するためのコンパイル対象のC言語のソースプログラム30である。
Next, the
まず、図4のソースプログラム30について説明する。
First, the
まず、1行目には、整数型のグローバル変数g_nCountが定義され、0で初期化されている。 First, in the first line, an integer type global variable g_nCount is defined and initialized with zero.
2行目〜5行目には、グローバル変数g_nCountの値に1を加算する関数CountOneが記載されている。 The second to fifth lines describe a function CountOne that adds 1 to the value of the global variable g_nCount.
7行目〜10行目には、g_nCountの値にnAddを加算する関数ConutNが記載されている。ここで、nAddは、整数型の変数で、関数CountNの引数である。 The seventh line to the tenth line describe a function ContN that adds nAdd to the value of g_nCount. Here, nAdd is an integer type variable and is an argument of the function CountN.
12行目〜16行目には、グローバル変数g_nCountに1を代入し、nが0の場合には1、nが0以外の場合には0を戻り値として返却する関数condが記載されている。ここで、nは、整数型の変数で、関数condの引数である。 The 12th to 16th lines describe a function cond that assigns 1 to the global variable g_nCount, returns 1 when n is 0, and returns 0 when n is not 0. . Here, n is an integer type variable and is an argument of the function cond.
18行目〜24行目では、main関数が記載されている。main関数では、はじめにcond関数が呼び出される。次に、cond関数の戻り値が0でない場合には、CondOne関数が呼び出され、cond関数の戻り値が0の場合には、引数に10を設定したCoundNを呼び出す。最後に、戻り値として0を返却して処理を終了する。 In the 18th to 24th lines, the main function is described. In the main function, the cond function is first called. Next, if the return value of the cond function is not 0, the CondOne function is called, and if the return value of the cond function is 0, CallN with 10 set as an argument is called. Finally, 0 is returned as a return value and the process is terminated.
次に、図4のソースプログラム30に対応するグローバル変数テーブル33について説明する。図5は、本発明の実施例1におけるコンパイラ装置において、図4のソースプログラム30に対応するグローバル変数テーブル33の例である。図5のグローバル変数テーブル33は、グローバル変数名フィールド及び関数ごとのread箇所、write箇所を格納するフィールドを有する。図4のソースプログラム30では、グローバル変数g_nCountは、関数CountOneの4行目でread及びwriteされ、関数CountNの9行目でread及びwriteされ、関数condの14行目でwriteされ、main関数ではアクセスされていない。したがって、図4のソースプログラム30に対応するグローバル変数テーブル33の各フィールドの値は図5のようになる。グローバル変数テーブル33によって、グローバル変数g_nCountのread箇所及びwrite箇所を関数ごとに把握することができる。
Next, the global variable table 33 corresponding to the
次に、図4のソースプログラム30に対応するコア割り当て対象関数テーブル34について説明する。図6は、本発明の実施例1におけるコンパイラ装置において、図4のソースプログラム30に対応するコア割り当て対象関数テーブル34の例である。図6のコア割り当て対象関数テーブル34は、関数名フィールド、図2のフローチャートのコア割り当て対象となる条件に対応するフィールド、及びコア割り当て対象かどうかの情報を格納するフィールドを有する。図4のソースプログラム30に対して、図2のコア割り当て対象関数の抽出方法のフローチャートに基づいて、各関数について、フィールドの値が格納されている。図6では、main関数は、ステップS101により、コア割り当て対象外の関数として除外されている。cond関数は、15行目で戻り値を返し、main関数の21行目で、戻り値が条件判定に利用されているため、ステップS103により、コア割り当て対象外の関数として除外されている。CountOne関数及びCountN関数は、main関数ではなく、戻り値もなく、グローバル変数へのアクセスがあるが、繰り返し文内でアクセスしていないため、コア割り当て対象の関数となる。
Next, the core allocation target function table 34 corresponding to the
次に、図4のソースプログラム30が、本発明の実施例1におけるコンパイラ装置のソース修正部45によって、修正された後のソースプログラムについて説明する。図7は、本発明の実施例1におけるコンパイラ装置において、図4のソースプログラム30が、ソース修正部45によって修正された後のソースプログラムの例である。
Next, the source program after the
まず、ソースプログラム30に記載されている関数に対して、ソース修正部45が、関数内部に新規に追加しているSTART関数、WAIT関数、WRITEBACK関数、SEND_TO関数、RECV_FROM関数及びEND関数について説明する。
First, a START function, a WAIT function, a WRITEBACK function, a SEND_TO function, a RECV_FROM function, and an END function that are newly added by the
START関数は、引数に指定された関数をCPUコア0〜2のいずれかに割り当て、引数に指定された関数の処理に必要な変数を共有メモリ6から、CPU0〜2に対応するローカルメモリ3〜5にコピーし、CPUコア0〜2のいずれかで処理を開始させる。
The START function assigns a function designated as an argument to one of the
WAIT関数は、他のCPUコアに割り当てられた関数が終了するまで(他のCPUコアに割り当てられた関数内で呼ばれるEND関数が終了するまで)、WAIT関数を呼び出す関数の処理を停止させる。 The WAIT function stops the processing of the function that calls the WAIT function until the function assigned to the other CPU core ends (until the END function called in the function assigned to the other CPU core ends).
WRITEBACK関数は、CPUコア0〜2のいずれかで処理され、CPUコア0〜2に対応するローカルメモリ3〜5のいずれかで保持されている、引数で指定されている関数の演算結果を共有メモリ6に反映する。
The WRITEBACK function is processed by any of the
SEND_TO関数は、SEND_TO関数を呼び出す関数が実行されているCPUコアから、引数に指定された関数が実行されている他のCPUコアへ、引数に指定された変数の値を送信する。 The SEND_TO function transmits the value of the variable specified in the argument from the CPU core in which the function calling the SEND_TO function is executed to another CPU core in which the function specified in the argument is executed.
RECV_FROM関数は、SEND_TO関数に対応する関数であり、引数に指定された関数が実行されている他のCPUコアから、引数に指定された変数の値を受信する。 The RECV_FROM function is a function corresponding to the SEND_TO function, and receives the value of the variable specified in the argument from another CPU core in which the function specified in the argument is executed.
END関数は、WAIT関数に対応する関数であり、CPUコアに割り当てられた関数の終了処理を行い、WAIT関数を呼び出すことにより終了を待ち合わせている他のコアで実行されている関数に対して、処理が終了したことを通知する。 The END function is a function corresponding to the WAIT function, performs a termination process of the function assigned to the CPU core, and calls a WAIT function to call a WAIT function for a function executed in another core. Notify that the process has been completed.
次に、図4のソースプログラム30に含まれていた関数が、ソース修正部45によって、どのように修正されるかについて説明する。
Next, how the function included in the
まず、main関数について説明する。ソース修正部45は、main関数では、まず、図7の45、46行目において、START関数によってCountOne関数、CountN関数を呼び出す修正を行う。この修正によって、他のCPUコアにCountOne関数の処理とCountN関数の処理を実行させる。次に、図7の48行目において、WAIT関数の呼び出す処理を追加する。この修正によって、他のCPUコアに割り当てたCountOne関数、CountN関数の処理の終了を待ち合わせる。次に、図7の49行目、50行目において、WRITEBACK関数を使用する修正を行う。この修正により、図7の47行目の条件判定の結果に基づいて、他のCPUコアに割り当てたCountOne関数又はCountN関数の処理結果を、CPUコアのローカルメモリから、共有メモリ6に反映させる。
First, the main function will be described. In the main function, first, the
次に、cond関数について説明する。ソース修正部45は、cond関数では、図7の37、38行目において、SEND_TO関数により、CountOne関数及びCountN関数に対して、g_nCountの値を通知する。この修正により、main関数でCountOne関数及びCountN関数をSTART関数によって呼び出すことにより、他のCPUコアによって実行されているCountOne関数及びCountN関数に、cond関数で変更した後のg_nCountの値を通知することができる。
Next, the cond function will be described. In the cond function, the
次に、CountOne関数、CountN関数について説明する。ソース修正部45によるCountOne関数とCountN関数に対する修正は、同様であるため、CountOne関数についてのみ説明する。
Next, the CountOne function and the CountN function will be described. Since the correction to the CountOne function and the CountN function by the
CountOne関数がSTART関数によって呼び出される場合には、CountOne関数呼び出し時に共有メモリ6のg_nCountが、CountOne関数が実行されるCPUコアのローカルメモリへコピーされている。ソース修正部45は、図7の6〜14行目において、他のCPUコアによって実行されているcond関数によって、g_nCountの値が変更された場合には、通知されたg_nCountの値を利用して図7の8行目の処理をリトライする修正を行う。この修正により、cond関数によって、g_nCountの値が変更された場合には、CountOne関数によって、g_nCountの値を変更する処理がリトライされる。また、ソース修正部45は、図7の15行目において、END関数を呼び出す処理を追加する。この修正によって、main関数において、図7の48行目のWAIT関数によるCountOne関数の終了を待ち合わせることができる。
When the CountOne function is called by the START function, g_nCount of the shared
次に、本発明の実施例1におけるコンパイラ装置によって生成された、図7のソースプログラムに対応するオブジェクトプログラムが、マルチコアプロセッサ7で実行された場合の動作について説明する。図8は、本発明の実施例1におけるコンパイラ装置によって生成された、図7のソースプログラムに対応するオブジェクトプログラムを実行した場合の動作説明図である。
Next, an operation when the object program corresponding to the source program of FIG. 7 generated by the compiler apparatus according to the first embodiment of the present invention is executed by the
まず、main関数が実行されるCPUコア0の動作について説明する。
First, the operation of the
(ステップS301)
はじめに、CPUコア0でmain関数の実行が開始される。
(Step S301)
First, execution of the main function is started in the
(ステップS302)
次に、main関数が、CountOne関数及びCountN関数の処理を各CPUコアに割り当てる。
(Step S302)
Next, the main function assigns the processing of the CountOne function and the CountN function to each CPU core.
(ステップS303)
次に、CPUコア0で引数に1が設定されたCond関数が実行される。
(Step S303)
Next, the Cond function with 1 set as an argument is executed by the
(ステップS304)
次に、CPUコア0で実行されているmain関数は、他のCPUコアへ処理を割り当てたCountOne関数及びCountN関数の処理の終了を待つ。
(Step S304)
Next, the main function executed in the
(ステップS305)
次に、cond(1)の実行結果が代入されるcの値に基づいて、cが0以外の場合には、CountOne関数の処理結果を共有メモリ6に反映し、cが0の場合には、引数を10に設定したCountN関数の処理結果を共有メモリに反映する。
(Step S305)
Next, based on the value of c into which the execution result of cond (1) is substituted, if c is other than 0, the processing result of the CountOne function is reflected in the shared
(ステップS306)
CPUコア0のmain関数は、処理を終了する。
(Step S306)
The main function of the
次に、main関数によってCPUコア1に割り当てられるCountOne関数の動作について説明する。
Next, the operation of the CountOne function assigned to the
(ステップS307)
はじめに、CountOne関数は、CountOne関数読み出し時に、共有メモリ6からローカルメモリ4にコピーされたg_nCountの値を、CountOne関数内部のローカル変数で保持する。
(Step S307)
First, the CountOne function holds the value of g_nCount copied from the shared
(ステップS308)
次に、CountOne関数は、g_nCountの値を+1加算する処理を行う。
(Step S308)
Next, the CountOne function performs a process of adding +1 to the value of g_nCount.
(ステップS309)
次に、CountOne関数は、CPU0のcond関数が、g_nCountを1に書き換えた後の通知を待つ。
(Step S309)
Next, the CountOne function waits for a notification after the cond function of CPU0 rewrites g_nCount to 1.
(ステップS310)
次に、CountOne関数は、ステップS307で読み出したg_nCountの値と、CPU0のcond関数が書き換えた後のg_nCountの値が同一であるかどうかを判断する。g_nCountの値が同一であれば、ステップS308の演算結果をCPUコア1のローカルメモリ4で所持し、g_nCountの値が同一でなければ、ステップS307に戻って、処理をリトライする。
(Step S310)
Next, the CountOne function determines whether the value of g_nCount read in step S307 is the same as the value of g_nCount after the rewrite of the cond function of CPU0. If the value of g_nCount is the same, the calculation result of step S308 is held in the
(ステップS311)
CPUコア1のCountOne関数は、処理を終了する。
(Step S311)
The CountOne function of the
次に、main関数によってCPUコア2に割り当てられるCountN関数の動作について説明する。
Next, the operation of the CountN function assigned to the
(ステップS312)
はじめに、CountN関数は、CountN関数読み出し時に、共有メモリ6からローカルメモリ4にコピーされたg_nCountの値を、CountN関数内部のローカル変数で保持する。
(Step S312)
First, the CountN function holds the value of g_nCount copied from the shared
(ステップS313)
次に、CountN関数は、引数に10が設定されているため、g_nCountの値を+10加算する処理を行う。
(Step S313)
Next, the CountN function performs a process of adding +10 to the value of g_nCount because 10 is set as an argument.
(ステップS314)
次に、CountN関数は、CPU0のcond関数が、g_nCountを1に書き換えた後の通知を待つ。
(Step S314)
Next, the CountN function waits for a notification after the cond function of CPU0 rewrites g_nCount to 1.
(ステップS315)
次に、CountN関数は、ステップS312で読み出したg_nCountの値と、CPU0のcond関数が書き換えた後のg_nCountの値が同一であるかどうかを判断する。g_nCountの値が同一であれば、ステップS313の演算結果をローカルメモリ5で所持し、g_nCountの値が同一でなければ、ステップS312に戻って、処理をリトライする。
(Step S315)
Next, the CountN function determines whether the value of g_nCount read in step S312 is the same as the value of g_nCount after the rewrite of the cond function of CPU0. If the value of g_nCount is the same, the calculation result of step S313 is held in the
(ステップS316)
CPUコア2のCountN関数は、処理を終了する。
(Step S316)
The CountN function of the
本実施例1によれば、条件分岐命令の条件判定処理と、分岐後の各命令がグローバル変数に依存している場合に、マルチコアプロセッサによって、投機的に条件分岐命令の条件判定処理と、分岐後の各命令が並列処理されても誤動作しないオブジェクトプログラムを生成するコンパイラ装置を提供することができる。 According to the first embodiment, the conditional determination processing of the conditional branch instruction and the conditional determination processing of the conditional branch instruction speculatively by the multi-core processor when each instruction after branching depends on the global variable, It is possible to provide a compiler device that generates an object program that does not malfunction even if each subsequent instruction is processed in parallel.
また、本実施例1によれば、特許文献1の共有メモリ更新フラグを使用せずに、グローバル変数の更新を行うことができる。CPUコアに割り当てられた関数は、グローバル変数の更新情報を、CPUコア間のメッセージ送受信によって、知ることができるからである。
Further, according to the first embodiment, it is possible to update the global variable without using the shared memory update flag of
以上、本発明の実施の形態が添付の図面を参照することにより説明された。但し、本発明は、上述の実施の形態に限定されず、要旨を逸脱しない範囲で当業者により適宜変更され得る。 The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the above-described embodiments, and can be appropriately changed by those skilled in the art without departing from the scope of the invention.
0 CPUコア
1 CPUコア
2 CPUコア
3 ローカルメモリ
4 ローカルメモリ
5 ローカルメモリ
6 共有メモリ
7 マルチコアプロセッサ
10 コンパイラプログラム
20 表示部
21 入力部
22 CPU(Central Processing Unit)
23 補助記憶装置
24 メモリ
25 システムバス
30 原始プログラム(ソースプログラム)
31 目的プログラム(オブジェクトプログラム)
32 変数名、定数等の各種情報のテーブル
33 グローバル変数テーブル
34 コア割り当て対象関数テーブル
40 コンパイラ装置
41 読み込み部
42 字句解析部
43 構文解析部
44 コア割り当て対象関数抽出部
45 ソース修正部
46 中間語作成部
47 最適化部
48 オブジェクト生成部
0
23
31 Objective program (object program)
32 Table of various information such as variable names and
Claims (9)
前記ソースプログラムの字句解析を行う字句解析部と、
前記ソースプログラムの構文解析を行う構文解析部と、
前記ソースプログラムに含まれる関数から、グローバル変数の値に基づいて前記グローバル変数の値を変更する処理を含む関数を、コア割り当て対象関数として抽出するコア割り当て対象関数抽出部と、
前記コア割り当て対象関数が、条件分岐命令の条件判定処理による分岐後の呼出し関数となる場合には、前記コア割り当て対象関数を呼び出す関数が実行されるマルチコアプロセッサのコアとは、別のCPUコアに対して前記コア割り当て対象関数を1:1に割り当て、前記条件分岐命令の前記条件判定処理と、前記コア割り当て対象関数の処理を各前記CPUコアで並列処理させ、前記条件分岐命令の前記条件判定処理によって、前記グローバル変数が変更された場合には、前記グローバル変数の値に基づいて前記グローバル変数の値を変更する処理を、前記コア割り当て対象関数にリトライさせるように前記ソースプログラムを修正するソース修正部と、
前記ソースプログラムを前記ソース修正部により修正したソースプログラムから中間言語による中間語を作成する中間語作成部と、
前記中間語を最適化する最適化部と、
最適化された前記中間語からオブジェクトプログラムを生成するオブジェクト生成部と
を備えるコンパイラ装置。 A reading section for reading a source program;
A lexical analyzer for performing lexical analysis of the source program;
A parsing unit for parsing the source program;
A core allocation target function extraction unit that extracts a function including a process of changing the value of the global variable based on the value of the global variable from a function included in the source program as a core allocation target function;
When the core assignment target function is a call function after branching by the condition determination process of the conditional branch instruction, the CPU core assignment function is executed on a different CPU core from the core of the multicore processor on which the function calling the core assignment target function is executed. On the other hand, the core assignment target function is assigned 1: 1, the condition determination processing of the conditional branch instruction and the processing of the core assignment target function are processed in parallel in each CPU core, and the condition determination of the conditional branch instruction A source that modifies the source program so that when the global variable is changed by the processing, the function to change the value of the global variable based on the value of the global variable is caused to retry the function to be allocated to the core Correction part,
An intermediate language creating unit for creating an intermediate language in an intermediate language from a source program obtained by modifying the source program by the source modifying unit;
An optimization unit for optimizing the intermediate language;
A compiler apparatus comprising: an object generation unit that generates an object program from the optimized intermediate language.
請求項1に記載のコンパイラ装置。 In the core allocation target function extraction unit, the function included in the source program is not a main function, and the return value of the function is not used for the condition determination processing of the conditional branch instruction, and When there is access to a global variable from a function, and access to the global variable from the function is not accessed from the iterative process in the function, or there is no access to the global variable from the function The compiler apparatus according to claim 1, wherein the function is a core allocation target function of a multi-core processor.
前記条件分岐命令の前記条件判定処理に使用されている関数に対しては、前記コア割り当て対象関数に、変更後の前記グローバル変数の値を通知する処理を追加する修正を行い、
前記コア割り当て対象関数に対しては、前記グローバル変数を変更する前の値を保持する処理と、前記通知する処理による通知を受信するまで待ち合わせる処理と、前記通知する処理による前記通知を受信するまで待ち合わせる処理の後に、前記保持する処理で保持したグローバル変数の値と、前記グローバル変数の値を比較し、前記グローバル変数の値が同一でない場合には、前記コア割り当て対象関数による前記グローバル変数の値を変更する処理をリトライする処理を追加する修正を行う
請求項1又は2に記載のコンパイラ装置。 For the function that calls the core allocation target function, the source modification unit allocates the core allocation target function to the multi-core processor, waits for the end of the processing of the core allocation target function, and the core allocation Modify to add the processing to validate the processing result of the target function,
For the function used in the condition determination process of the conditional branch instruction, the core allocation target function is modified to add a process for notifying the changed value of the global variable,
For the core allocation target function, a process of holding a value before changing the global variable, a process of waiting until a notification by the notification process is received, and a process of receiving the notification by the notification process After the waiting process, the value of the global variable held in the holding process is compared with the value of the global variable, and if the value of the global variable is not the same, the value of the global variable by the core allocation target function The compiler apparatus according to claim 1, wherein correction is performed to add a process of retrying the process of changing the process.
前記コア割り当て対象関数抽出部は、前記ソースプログラムに含まれる関数に対して、前記マルチコアプロセッサの各CPUコアに割り当てる対象となる関数であるかどうかの情報を記憶するコア割り当て対象関数テーブルを作成し、
前記ソース修正部は、前記グローバル変数テーブル及び前記コア割り当て対象関数テーブルに基づいて前記ソースプログラムを修正する
請求項1乃至3いずれか1項に記載のコンパイラ装置。 The syntax analysis unit creates a global variable table that holds information on read locations and write locations of global variables included in the source program for each function included in the source program,
The core allocation target function extraction unit creates a core allocation target function table for storing information on whether or not the function included in the source program is a function to be allocated to each CPU core of the multi-core processor. ,
The compiler apparatus according to any one of claims 1 to 3, wherein the source correction unit corrects the source program based on the global variable table and the core allocation target function table.
字句解析部が、前記ソースプログラムの字句解析を行うステップと、
構文解析部が、前記ソースプログラムの構文解析を行うステップと、
コア割り当て対象関数抽出部が、前記ソースプログラムに含まれる関数から、グローバル変数の値に基づいて前記グローバル変数の値を変更する処理を含む関数を、コア割り当て対象関数として抽出するステップと、
ソース修正部が、前記コア割り当て対象関数が、条件分岐命令の条件判定処理による分岐後の呼出し関数となる場合には、前記コア割り当て対象関数を呼び出す関数が実行されるマルチコアプロセッサのコアとは、別のCPUコアに対して前記コア割り当て対象関数を1:1に割り当て、前記条件分岐命令の前記条件判定処理と、前記コア割り当て対象関数の処理を各前記CPUコアで並列処理させ、前記条件分岐命令の前記条件判定処理によって、前記グローバル変数が変更された場合には、前記グローバル変数の値に基づいて前記グローバル変数の値を変更する処理を、前記コア割り当て対象関数にリトライさせるように前記ソースプログラムを修正するステップと、
中間語作成部が、前記ソースプログラムを前記ソース修正部により修正したソースプログラムから中間言語による中間語を作成するステップと、
最適化部が、前記中間語を最適化するステップと、
オブジェクト生成部が、最適化された前記中間語からオブジェクトプログラムを生成するステップと
を含むコンパイル方法。 The reading unit reads the source program; and
A lexical analyzer performing lexical analysis of the source program;
A step in which a syntax analysis unit parses the source program;
A step of extracting a function including a process of changing a value of the global variable from a function included in the source program as a core allocation target function from a function included in the source program;
When the core allocation target function is a call function after branching by the condition determination process of the conditional branch instruction, the source correction unit, the core of the multicore processor on which the function that calls the core allocation target function is executed, The core assignment target function is assigned 1: 1 to another CPU core, the condition determination processing of the conditional branch instruction and the processing of the core assignment target function are processed in parallel in each CPU core, and the conditional branch When the global variable is changed by the condition determination process of the instruction, the source to cause the core allocation target function to retry the process of changing the value of the global variable based on the value of the global variable Steps to modify the program;
An intermediate language creating unit creating an intermediate language in an intermediate language from a source program obtained by modifying the source program by the source modifying unit;
An optimization unit optimizing the intermediate language;
A compiling method, comprising: an object generating unit generating an object program from the optimized intermediate language.
前記コア割り当て対象関数抽出部が、前記ソースプログラムに含まれる関数が、main関数ではなく、かつ、前記関数の戻り値が前記条件分岐命令の前記条件判定処理に利用されておらず、かつ、前記関数からグローバル変数へのアクセスがあり、かつ、前記関数から前記グローバル変数へのアクセスが前記関数内の繰り返し処理の中からアクセスされておらず、又は、前記関数からグローバル変数へのアクセスがない場合に、マルチコアプロセッサの前記コア割り当て対象関数とするステップ
を含む請求項5に記載のコンパイル方法。 The step of extracting as the core allocation target function includes:
The core allocation target function extraction unit is configured such that the function included in the source program is not a main function, and the return value of the function is not used for the condition determination process of the conditional branch instruction, and When there is access to a global variable from a function, and access to the global variable from the function is not accessed from the iterative process in the function, or there is no access to the global variable from the function The compiling method according to claim 5, further comprising the step of setting the core allocation target function of a multi-core processor.
前記ソース修正部が、前記条件分岐命令の前記条件判定処理に使用されている関数に対しては、前記コア割り当て対象関数に、変更後の前記グローバル変数の値を通知する処理を追加する修正を行うステップと、
前記ソース修正部が、前記コア割り当て対象関数に対しては、前記グローバル変数を変更する前の値を保持する処理と、前記通知する処理による通知を受信するまで待ち合わせる処理と、前記通知する処理による前記通知を受信するまで待ち合わせる処理の後に、前記保持する処理で保持したグローバル変数の値と、前記グローバル変数の値を比較し、前記グローバル変数の値が同一でない場合には、前記コア割り当て対象関数による前記グローバル変数の値を変更する処理をリトライする処理を追加する修正を行うステップと
を含む請求項5又は6に記載のコンパイル方法。 The step of modifying the source program includes: a process in which the source modification unit allocates the core allocation target function to the multi-core processor for a function that calls the core allocation target function; A process of waiting for completion, a step of correcting to add a process of enabling the processing result of the core allocation target function, and
For the function used in the condition determination process of the conditional branch instruction, the source correction unit adds a process of notifying the core allocation target function of the value of the changed global variable. Steps to do,
For the core allocation target function, the source modification unit holds the value before changing the global variable, waits until receiving a notification by the notifying process, and by the notifying process After waiting for the notification to be received, the global variable value held in the holding process is compared with the global variable value. If the global variable values are not the same, the core allocation target function The compile method according to claim 5, further comprising a step of adding a process of retrying a process of changing the value of the global variable according to.
前記コア割り当て対象関数として抽出するステップは、前記コア割り当て対象関数抽出部が、前記ソースプログラムに含まれる関数に対して、前記マルチコアプロセッサの各CPUコアに割り当てる対象となる関数であるかどうかの情報を記憶するコア割り当て対象関数テーブルを作成するステップと、
前記ソース修正部が、前記グローバル変数テーブル及び前記コア割り当て対象関数テーブルに基づいて前記ソースプログラムを修正するステップと
を含む請求項1乃至3いずれか1項に記載のコンパイル方法。 The step of performing the syntax analysis includes the step of creating a global variable table in which the syntax analysis unit possesses information on a read location and a write location of the global variable included in the source program for each function included in the source program. When,
The step of extracting as the core allocation target function is information regarding whether the core allocation target function extraction unit is a function to be allocated to each CPU core of the multi-core processor with respect to the function included in the source program. Creating a core allocation target function table for storing
The compile method according to claim 1, wherein the source correction unit includes a step of correcting the source program based on the global variable table and the core allocation target function table.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010252280A JP2012103923A (en) | 2010-11-10 | 2010-11-10 | Compiler device, compiling method and compiler program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010252280A JP2012103923A (en) | 2010-11-10 | 2010-11-10 | Compiler device, compiling method and compiler program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2012103923A true JP2012103923A (en) | 2012-05-31 |
Family
ID=46394237
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2010252280A Withdrawn JP2012103923A (en) | 2010-11-10 | 2010-11-10 | Compiler device, compiling method and compiler program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2012103923A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2014115613A1 (en) * | 2013-01-23 | 2014-07-31 | 学校法人 早稲田大学 | Parallelism extraction method and method for making program |
WO2016032234A1 (en) * | 2014-08-27 | 2016-03-03 | 주식회사 파수닷컴 | Source code analysis device, computer program for same, and recording medium thereof |
JP2018073054A (en) * | 2016-10-27 | 2018-05-10 | 株式会社Dtsインサイト | Object analyzing device, object analyzing method, and program |
US10496516B2 (en) | 2014-08-27 | 2019-12-03 | Sparrow Co., Ltd. | Source code analysis device, computer program for same, and recording medium thereof |
-
2010
- 2010-11-10 JP JP2010252280A patent/JP2012103923A/en not_active Withdrawn
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2014115613A1 (en) * | 2013-01-23 | 2014-07-31 | 学校法人 早稲田大学 | Parallelism extraction method and method for making program |
WO2016032234A1 (en) * | 2014-08-27 | 2016-03-03 | 주식회사 파수닷컴 | Source code analysis device, computer program for same, and recording medium thereof |
US10496516B2 (en) | 2014-08-27 | 2019-12-03 | Sparrow Co., Ltd. | Source code analysis device, computer program for same, and recording medium thereof |
JP2018073054A (en) * | 2016-10-27 | 2018-05-10 | 株式会社Dtsインサイト | Object analyzing device, object analyzing method, and program |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7730463B2 (en) | Efficient generation of SIMD code in presence of multi-threading and other false sharing conditions and in machines having memory protection support | |
US8832672B2 (en) | Ensuring register availability for dynamic binary optimization | |
US11900113B2 (en) | Data flow processing method and related device | |
US9015690B2 (en) | Proactive loop fusion of non-adjacent loops with intervening control flow instructions | |
JPH01166141A (en) | Debugging system | |
EP3066560B1 (en) | A data processing apparatus and method for scheduling sets of threads on parallel processing lanes | |
US20100095286A1 (en) | Register reduction and liveness analysis techniques for program code | |
US20110219204A1 (en) | Gpu support for garbage collection | |
JP2011070256A (en) | Debugger and program | |
JP2005332387A (en) | Method and system for grouping and managing memory instruction | |
US9513886B2 (en) | Heap data management for limited local memory(LLM) multi-core processors | |
US7480768B2 (en) | Apparatus, systems and methods to reduce access to shared data storage | |
JP2019049843A (en) | Execution node selection program and execution node selection method and information processor | |
JP2010009495A (en) | Information processor, program processing method, and computer program | |
US11226798B2 (en) | Information processing device and information processing method | |
JP2012103923A (en) | Compiler device, compiling method and compiler program | |
KR20220016993A (en) | How to manipulate the mask of an explicit independent mask register in the Graphics Processing Unit (GPU) | |
US8949777B2 (en) | Methods and systems for mapping a function pointer to the device code | |
US20200371827A1 (en) | Method, Apparatus, Device and Medium for Processing Data | |
US10496433B2 (en) | Modification of context saving functions | |
JP5293609B2 (en) | Multiprocessor and cache synchronization control method and program thereof | |
US20140223419A1 (en) | Compiler, object code generation method, information processing apparatus, and information processing method | |
JP6217386B2 (en) | Program generation method for multiprocessor | |
US20050251795A1 (en) | Method, system, and program for optimizing code | |
US20200409746A1 (en) | Information processing apparatus and recording medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A300 | Withdrawal of application because of no request for examination |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 20140204 |