JP2019215804A - Multicore microcomputer and parallelizing method - Google Patents
Multicore microcomputer and parallelizing method Download PDFInfo
- Publication number
- JP2019215804A JP2019215804A JP2018113736A JP2018113736A JP2019215804A JP 2019215804 A JP2019215804 A JP 2019215804A JP 2018113736 A JP2018113736 A JP 2018113736A JP 2018113736 A JP2018113736 A JP 2018113736A JP 2019215804 A JP2019215804 A JP 2019215804A
- Authority
- JP
- Japan
- Prior art keywords
- processing unit
- data
- instruction
- core
- unit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/45—Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
- G06F8/453—Data distribution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/45—Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
- G06F8/456—Parallelism detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/45—Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
- G06F8/458—Synchronisation, e.g. post-wait, barriers, locks
Abstract
Description
本発明は、シングルプログラムから生成された並列プログラムを実行するマルチコアマイコン、及びシングルコアマイコン用のシングルプログラムからマルチコアマイコン用の並列プログラムを生成する並列化方法に関する。 The present invention relates to a multicore microcomputer that executes a parallel program generated from a single program, and a parallelization method that generates a parallel program for a multicore microcomputer from a single program for a single core microcomputer.
従来、シングルコアマイコン用のシングルプログラムから、マルチコアマイコン用の並列プログラムを生成する並列化方法の一例として、特許文献1に開示された並列化コンパイル方法が知られている。
2. Description of the Related Art Conventionally, as an example of a parallelization method for generating a parallel program for a multi-core microcomputer from a single program for a single-core microcomputer, a parallelization compile method disclosed in
この並列化コンパイル方法では、シングルプログラムのソースコードの字句解析や構文解析を行って中間言語に展開し、この中間言語を用いて、複数のマクロタスク(処理単位)の依存関係の解析や最適化等を行う。また、従来の並列化コンパイル方法では、各マクロタスクの依存関係やマクロタスク毎の実行時間を基にコアへの割り付けやスケジューリングを行って並列プログラムを生成する。 In this parallel compilation method, lexical analysis and syntax analysis of the source code of a single program are performed to develop into an intermediate language, and this intermediate language is used to analyze and optimize the dependencies of a plurality of macro tasks (processing units). And so on. In the conventional parallelizing compilation method, a parallel program is generated by allocating to cores and scheduling based on the dependency of each macro task and the execution time of each macro task.
しかしながら、シングルプログラムから生成された並列プログラムの並列度が低い場合、すなわち、並列プログラムにおいて複数のコアにて並列実行できる処理単位が少ない場合には、マルチコアマイコンの処理能力を十分に活かすことができない。 However, when the degree of parallelism of a parallel program generated from a single program is low, that is, when the number of processing units that can be executed in parallel by a plurality of cores in the parallel program is small, the processing capability of the multi-core microcomputer cannot be fully utilized. .
本発明は、上述した点に鑑みてなされたものであり、生成される並列プログラムの並列度が低くても、相互干渉を防止しつつ複数のコアでの処理単位の並列実行頻度を高めることが可能なマルチコアマイコン及び並列化方法を提供することを目的とする。 The present invention has been made in view of the above points, and it is possible to increase the frequency of parallel execution of a processing unit in a plurality of cores while preventing mutual interference even if the degree of parallelism of a generated parallel program is low. It is an object of the present invention to provide a possible multi-core microcomputer and a parallelization method.
上記目的を達成するために、本発明によるマルチコアマイコンは、コアが一つであるシングルコアマイコン用のシングルプログラムから生成された、複数のコア(31c、31d)を有するマルチコアマイコン用の並列プログラム(31a1’)を実行するものであって、
並列プログラムは、シングルプログラムに含まれる、複数の処理単位からなるタスク毎に、複数の処理単位の依存関係に基づき、複数の処理単位の複数のコアへの割り付けと実行順序とが決定されたものであり、
マルチコアマイコンの複数のコアは、それぞれ、自コアに割り付けられた、複数のタスクに属するそれぞれの処理単位から、実行すべき処理単位を選択する選択部(S110〜S200、S310〜S400、510〜S610、S670)を有し、
選択部は、
各タスクの処理単位を対象として、当該処理単位の実行時に利用予定のデータにアクセス可能であるか否かを判定する判定部(S140、S340、S540)と、
判定部によって利用予定のデータにアクセス可能と判定された処理単位を実行すべき処理単位として決定するとともに、他コアにおいて実行される処理単位による該当データへのアクセスを禁止するための禁止処理(S150、S350、S550、S670)を実行する決定時処理部(S150〜S160、S350〜S360、S550〜S560、S670)と、を備え、
複数のコアは、それぞれ、決定時処理部によって決定された処理単位に含まれる命令を実行するように構成される。
In order to achieve the above object, a multi-core microcomputer according to the present invention provides a parallel program for a multi-core microcomputer having a plurality of cores (31c, 31d) generated from a single program for a single-core microcomputer having one core. 31a1 ′), and
A parallel program is one in which the assignment of multiple processing units to multiple cores and the execution order are determined based on the dependencies of multiple processing units for each task consisting of multiple processing units included in a single program And
Each of the plurality of cores of the multi-core microcomputer selects a processing unit to be executed from among the processing units belonging to the plurality of tasks allocated to the own core (S110 to S200, S310 to S400, 510 to S610). , S670),
The selection unit is
A determination unit (S140, S340, S540) that determines whether or not the data to be used can be accessed when the processing unit is executed, with respect to the processing unit of each task;
Prohibition processing for determining the processing unit determined to be accessible to the data to be used by the determination unit as the processing unit to be executed, and prohibiting the processing unit executed in another core from accessing the corresponding data (S150) , S350, S550, S670) at the time of determination (S150-S160, S350-S360, S550-S560, S670).
Each of the plurality of cores is configured to execute an instruction included in the processing unit determined by the determination-time processing unit.
このように、本発明によるマルチコアマイコンによれば、各コアにおいて、割り付けられた各タスクの複数の処理単位の中で、その処理単位の実行時に利用予定のデータにアクセス可能である処理単位が、実行すべき処理単位として決定される。さらに、その利用予定のデータが他コアにおいて実行される処理単位によってアクセスされることを禁止するための禁止処理が実行される。これにより、複数のコアにおいて実行される処理単位同士が相互干渉することを防止することができる。 As described above, according to the multi-core microcomputer according to the present invention, in each core, among a plurality of processing units of each assigned task, a processing unit capable of accessing data to be used when the processing unit is executed, It is determined as a processing unit to be executed. Further, a prohibition process is executed to prohibit the data to be used from being accessed by a processing unit executed in another core. Thereby, it is possible to prevent the processing units executed in the plurality of cores from interfering with each other.
そして、あるコアにおける上記禁止処理の実行の結果、他コアの処理単位について、利用予定のデータにアクセス不可と判定された場合には、他コアにおいて利用予定データにアクセス可能である別の処理単位が、実行すべき処理単位として決定される。従って、他コアでの処理単位の実行により相互干渉を引き起こす虞がある場合には、当該他コアにおいて、そのような相互干渉を引き起こす虞のない別の処理単位が実行される。このため、生成される並列プログラムの並列度が低くても、複数のコアでの処理単位の並列実行頻度を高めることが可能となる。 Then, as a result of the execution of the above-described prohibition process in one core, if it is determined that the data to be used is inaccessible for the processing unit of another core, another processing unit that can access the data to be used in another core Is determined as a processing unit to be executed. Therefore, when there is a possibility that mutual interference may be caused by execution of a processing unit in another core, another processing unit which is not likely to cause such mutual interference is executed in the other core. For this reason, even if the degree of parallelism of the generated parallel program is low, it is possible to increase the parallel execution frequency of the processing unit in a plurality of cores.
また、本発明の並列化方法は、 コアが一つであるシングルコアマイコン用のシングルプログラムから、複数のコア(31c,31b)を有するマルチコアマイコン用の並列プログラム(31a1)を生成するものであって、
シングルプログラムに含まれる、複数の処理単位からなるタスク毎に、複数の処理単位の依存関係に基づき、複数の処理単位の複数のコアへの割り付けと実行順序とを決定するコア割付及び実行順序決定手順(10a〜10d)と、
実行順序決定手順にて決定された複数のコアへの割り付け及び実行順序に従って複数の処理単位がマルチコアマイコンの複数のコアで実行されるように並列プログラムを生成するとともに、並列プログラムの各々の処理単位の開始ポイントに開始ポイント命令を追加し、終了ポイントに終了ポイント命令を追加する並列プログラム生成手順(10e、10f)と、を備え、
開始ポイント命令と終了ポイント命令とは、マルチコアマイコンにおいて、複数のコアで同時期に実行される処理単位に含まれる命令によって同じデータへアクセスしないようにデータアクセスの調停を行なわせるとともに、データアクセスが禁止されたコアにおいて、該当するタスクの処理単位以外の別のタスクの処理単位を実行させるものである。
Further, the parallelization method of the present invention generates a parallel program (31a1) for a multi-core microcomputer having a plurality of cores (31c, 31b) from a single program for a single-core microcomputer having one core. hand,
Core assignment and execution order determination for determining the assignment of a plurality of processing units to a plurality of cores and the execution order based on the dependency of the plurality of processing units for each task including a plurality of processing units included in a single program Procedures (10a to 10d),
A parallel program is generated such that a plurality of processing units are executed by a plurality of cores of the multi-core microcomputer in accordance with the assignment to the plurality of cores determined in the execution order determination procedure and the execution order, and each processing unit of the parallel program And a parallel program generation procedure (10e, 10f) for adding a start point instruction to the start point of the above and an end point instruction to the end point.
The start point instruction and the end point instruction allow the multi-core microcomputer to perform data access arbitration so that the same data is not accessed by an instruction included in a processing unit executed by a plurality of cores at the same time. In the prohibited core, a processing unit of another task other than the processing unit of the corresponding task is executed.
従って、本発明の並列化方法は、マルチコアマイコンにおいて、複数のコアで実行される処理単位同士の相互干渉を防止しつつ、複数のコアでの処理単位の並列実行頻度を高めることが可能な並列プログラムを生成することができる。 Therefore, the parallelization method according to the present invention provides a multi-core microcomputer capable of increasing the frequency of parallel execution of processing units in a plurality of cores while preventing mutual interference between processing units executed in the plurality of cores. A program can be generated.
上記括弧内の参照番号は、本開示の理解を容易にすべく、後述する実施形態における具体的な構成との対応関係の一例を示すものにすぎず、なんら発明の範囲を制限することを意図したものではない。 The reference numbers in parentheses above are merely one example of a correspondence relationship with a specific configuration in the embodiment described later in order to facilitate understanding of the present disclosure, and are intended to limit the scope of the invention. It was not done.
また、上述した特徴以外の、特許請求の範囲の各請求項に記載した技術的特徴に関しては、後述する実施形態の説明及び添付図面から明らかになる。 Further, technical features described in each claim of the claims other than the above-described features will be apparent from the description of the embodiments and the accompanying drawings described later.
(第1実施形態)
以下において、図面を参照しながら、発明を実施するための第1実施形態を説明する。本実施形態では、並列化ツールとしてのコンピュータ10が、コアが一つであるシングルコアマイコン用のシングルプログラムから、2個以上のコア31c、31dを有するマルチコアマイコン31用に並列化した並列プログラム31a1を生成する例について説明する。なお、マルチコアマイコン31のコアの数は、3個以上であっても良い。
(First embodiment)
Hereinafter, a first embodiment for carrying out the invention will be described with reference to the drawings. In the present embodiment, the
このように、シングルプログラムから並列プログラム31a1を生成する背景として、制御の高度化によりプログラム量は年々増加する傾向にあるのに対し、シングルコアマイコンの性能向上には限界があることが挙げられる。つまり、例えばシングルコアマイコンの動作周波数を高めて処理能力を向上しようとしても、動作周波数を高めるにも限界があり、また動作周波数を高めることにより発熱量の増大や消費電力の増加を招いてしまう。このため、コア数の増加により処理能力向上を図るマルチコアマイコン31を適用することが有効と考えられている。
As described above, the background of generating the parallel program 31a1 from the single program is that the amount of the program tends to increase year by year due to the sophistication of the control, but the performance improvement of the single core microcomputer is limited. That is, for example, even if an attempt is made to increase the operating frequency by increasing the operating frequency of a single-core microcomputer, there is a limit in increasing the operating frequency, and increasing the operating frequency causes an increase in heat generation and an increase in power consumption. . For this reason, it is considered effective to apply the
この際、プログラムの開発者が、マルチコアの能力を最大限に発揮させられるように、各コアに適切に処理を割り振ったり、そのスケジューリングも行ったりしなければならないとすると、プログラムの開発負荷が増加してしまう。このようなプログラムの開発負荷を低減するために、シングルプログラムから並列プログラム31a1を自動生成することは技術的意義がある。さらに、シングルプログラムから並列プログラム31a1を自動生成することにより、シングルプロセッサ用に開発した既存のソフトウエア資産を有効に活用することも可能となる。 At this time, if the program developers must properly allocate processing to each core and schedule it so that the multi-core capability can be maximized, the program development load will increase Resulting in. It is of technical significance to automatically generate the parallel program 31a1 from a single program in order to reduce the development load of such a program. Further, by automatically generating the parallel program 31a1 from the single program, it is possible to effectively use the existing software resources developed for the single processor.
まず、図1を参照して、コンピュータ10の構成に関して説明する。コンピュータ10は、並列化方法を実行する並列化ツールに相当し、シングルプログラムから並列プログラム31a1を生成するものである。なお、本実施形態では、コンピュータ10は、C言語で記述されたシングルプログラムに基づき、C言語で記述された並列プログラム31a1を生成するように構成される。このため、後述するマルチコアマイコン31のROM(コードROM)31aに記憶され、マルチコアマイコン31によって実行される並列プログラム31a1’は、例えば図2に示すように、さらにコンパイラ20によりコンパイルされて、バイナリコードに翻訳されたものとなる。
First, the configuration of the
しかしながら、本発明は、これに限定されない。シングルプログラムは、C言語とは異なるプログラミング言語で記述されていてもよい。また、並列プログラム31a1は、例えば、シングルプログラムの解析時に使用する中間言語で記述されていてもよい。あるいは、コンピュータ10は、C言語で記述された並列プログラムと中間言語で記述された並列プログラムとをともに生成してもよい。さらに、コンピュータ10が、コンパイラ20としての機能も取り込み、直接、バイナリコードの並列プログラム31a1’を生成してもよい。
However, the present invention is not limited to this. The single program may be described in a programming language different from the C language. The parallel program 31a1 may be described in, for example, an intermediate language used when analyzing a single program. Alternatively, the
コンピュータ10は、図1に示すように、ディスプレイ11、HDD12、CPU13、ROM14、RAM15、入力装置16、読取部17などを備えて構成されている。コンピュータ10は、読取部17により、記憶媒体18に記憶された記憶内容を読み取ることができる。図1に示すように、記憶媒体18には、例えば、自動並列化コンパイラ1が記憶される。なお、コンピュータ10及び記憶媒体18は、特開2015−1807号公報に記載されたパーソナルコンピュータ100及び記憶媒体180と同様であるため、詳細は、特開2015−1807号公報を参照されたい。
As shown in FIG. 1, the
自動並列化コンパイラ1は、並列プログラム31a1を生成するための手順をコンピュータ10に実行させるソフトウエアである。よって、自動並列化コンパイラ1により、コンピュータ10は並列化方法を実行可能となる。換言すれば、自動並列化コンパイラ1は、並列化方法を含むプログラムである。コンピュータ10は、自動並列化コンパイラ1を実行することで、並列化ツールとして、並列プログラム31a1を生成する。
The
次に、図2を参照して、並列化ツールとしてのコンピュータ10が有する、シングルプログラムから並列プログラム31a1を生成するための各機能及び処理手順について説明する。図2は、コンピュータ10の各機能及び処理手順を機能ブロックとして表した図である。図2に示すように、コンピュータ10は、字句解析部10a、構文・意味解析部10b、依存関係解析部10c、コア割付及びスケジューリング部10d、同期ポイント命令追加部10e、及びコード生成部10fとしての機能を有している。
Next, with reference to FIG. 2, functions and processing procedures of the
本実施形態では、図2に示すように、コンピュータ10には、制御対象機器を制御するためのシングルプログラム全体を一度に解析して並列プログラム31a1を生成するのではなく、独立した処理機能(タスク)毎に分割されたシングルプログラムを対象として、その並列プログラム31a1を生成する。なお、本実施形態により生成される並列プログラム31a1は、マルチコアマイコン31において実行されるときの実行速度を早めることができるので、制御対象機器として、例えば、素早い処理速度が求められる、車両に搭載されたエンジンや電動モータとすることが好適である。この場合、図4に示すように、マルチコアマイコン31は、車両に搭載されるエンジン制御装置、モータ制御装置、ハイブリッド制御装置などの車載装置30として具現化される。
In the present embodiment, as shown in FIG. 2, the
タスク毎に分割されたシングルプログラムは複数の処理単位を含み、その複数の処理単位が実行されることにより、タスク毎の目的とする処理機能を実現することができる。このように複数の処理単位は、目的とする処理機能を実現するために協働するものであり、例えば先の処理単位で処理された変数データを参照する後の処理単位や、先の処理単位の条件分岐によって実行される後の処理単位などを含む。 The single program divided for each task includes a plurality of processing units, and by executing the plurality of processing units, a target processing function for each task can be realized. As described above, the plurality of processing units cooperate to realize a target processing function. For example, the processing unit after referring to the variable data processed in the previous processing unit, the previous processing unit And the subsequent processing unit executed by the conditional branch.
ここで、処理単位とは、各コアに割り振る際の最小単位であるコア配置単位や、関数をいう。コア配置単位は、処理ブロック、マクロタスク、あるいは単なる処理単位などと言い換えることができる。コア配置単位と関数との関係は、コア配置単位≧関数である。つまり、関数は、コア配置単位自体である場合や、コア配置単位に含まれる親関数やサブ関数の場合がある。 Here, the processing unit refers to a core arrangement unit which is a minimum unit when allocating to each core, or a function. The core arrangement unit can be rephrased as a processing block, a macro task, or a simple processing unit. The relationship between the core arrangement unit and the function is such that core arrangement unit ≧ function. That is, the function may be the core arrangement unit itself, or may be a parent function or subfunction included in the core arrangement unit.
字句解析部10a及び構文・意味解析部10bは、C言語で記述されたシングルプログラムのソースコードを対象として、字句解析や、構文と意味の解析を行い、中間言語に展開する。字句解析部10a及び構文・意味解析部10bによって展開された中間言語は、汎用的な命令を含んでいる。なお、字句解析部10a及び構文・意味解析部10bは、特開2015−1807号公報のFE3に相当するため、詳細は、特開2015−1807号公報を参照されたい。
The
依存関係解析部10cは、中間言語に展開されたシングルプログラムに含まれる処理単位の依存関係を解析し、並列実行可能な処理単位を抽出する。依存関係には、後に実行される処理単位が先に実行される処理単位で更新された変数データを参照するなどのデータ依存関係と、後に実行される処理単位が先に実行される処理単位の条件分岐先となるなどの制御依存関係とが含まれる。このような依存関係がある複数の処理単位は、依存関係に従う処理順序で実行される必要がある。なお、本実施形態では、上述したようにタスク毎に分割されたシングルプログラムが並列化の対象である。タスク毎に分割されたシングルプログラムに含まれる複数の処理単位は、データ依存関係や制御依存関係を有している。
The
コア割付及びスケジューリング部10dは、依存関係解析部10cで解析した解析結果に基づき、複数の処理単位を2個以上のコア31c、31dに割り付ける(割り振る)。この際、コア割付及びスケジューリング部10dは、例えば、並列実行可能な処理単位が2個以上のコア31c、31dで並行して実行されるように、複数の処理単位の割り付けを行う。
The core allocation and
図3に、各タスクが、それぞれ複数の処理単位からなり、それら複数の処理単位の各コア31c、31dへの割り付けの一例を示す。図3に示す例では、シングルプログラムには、タスクA、タスクB、及びタスクCの3つのタスクが含まれている。なお、図3では、説明のため、3つのタスクしか示していないが、実際には、シングルプログラムには、より多くのタスクが含まれる場合がある。
FIG. 3 shows an example of the assignment of each of the plurality of processing units to each of the
コア割付及びスケジューリング部10dは、図3に示すように、タスクAの処理単位A1〜A3に関して、処理単位A1、A2を第1コア31cに割り付け、処理単位A2と並列に実行可能な処理単位A3を第2コア31dに割り付ける。また、タスクBの処理単位B1、B2に関して、処理単位B1、B2を第2コア31dに割り付ける。そして、タスクCの処理単位C1〜C4については、処理単位C1、C2を第1コア31cに割り付け、それらと並列に実行可能な処理単位C3、C4を第2コア31dに割り付ける。
As shown in FIG. 3, the core allocation and
そして、コア割付及びスケジューリング部10dは、第1コア31c及び第2コア31dに割り振られた複数の処理単位A1〜A3、B1〜B2、C1〜C4のスケジューリングを行う。具体的には、コア割付及びスケジューリング部10dは、各タスク毎に、各タスクの処理単位A1〜A3、B1〜B2、C1〜C4の依存関係に基づいて、第1コア31c及び第2コア31dに割り振られた各処理単位A1〜A3、B1〜B2、C1〜C4の実行スケジュール(実行順序)を決定する。なお、依存関係解析部10c、及びコア割付及びスケジューリング部10dは、特開2015−1807号公報のMP5に相当するため、詳細は、特開2015−1807号公報を参照されたい。
Then, the core allocation and
同期ポイント命令追加部10eは、コア割付及びスケジューリング部10dによってスケジューリングされた、並列プログラムを構成する各タスクの複数の処理単位の各々の開始ポイントに開始ポイント命令を追加し、終了ポイントに終了ポイント命令を追加するものである。同期ポイント命令追加部10eは、追加すべき開始ポイント命令、及び終了ポイント命令としてのプログラムを保有しており、各々の処理単位に対応しつつ、それぞれの開始ポイント及び終了ポイントに、開始ポイント命令及び終了ポイント命令を追加する。
The synchronization point
開始ポイント命令は、対応する処理単位の開始ポイントを示すものであることに加え、以下に説明する情報や命令も含む。まず、開始ポイント命令は、対応する処理単位に含まれる命令によってメモリ(RAM31bやレジスタなど)に保存されたデータへのアクセス(データの読み取り、更新など)が行われる場合、そのアクセス対象となるデータを示すアクセスデータ情報を含む。同期ポイント命令追加部10eは、アクセス対象となるデータに関する情報を、構文・意味解析部10bから取得することができる。
The start point instruction indicates the start point of the corresponding processing unit, and also includes information and instructions described below. First, a start point instruction is a data to be accessed when an instruction included in a corresponding processing unit accesses (reads, updates, etc.) data stored in a memory (
これにより、マルチコアマイコン31にて、並列プログラム31a1’に含まれる各処理単位の実行開始時(実質的な処理の開始前)に、開始ポイント命令に基づき、その処理単位がいずれのデータにアクセスする予定であるかを事前に把握することができる。このアクセスデータ情報は、後述するように、各コア31c、31dに設けられたアクセスデータ制御ユニット43内のアクセスデータテーブル43a、43bに一時的に保存される。なお、処理単位がメモリに保存されたデータにアクセスするものではない場合、開始ポイント命令は、アクセスデータ情報を含まないか、あるいは、アクセスするデータが無いことを示すアクセスデータ情報を含む。
Thus, at the start of execution of each processing unit included in the parallel program 31a1 '(before the start of substantial processing), the
また、開始ポイント命令は、アクセスデータ情報が示すデータにアクセス可能か否かを判定するための命令を含む。この命令に基づき、各コア31c、31dのアクセスデータ制御ユニット43は、アクセスデータ情報が示すデータにアクセス可能か否かの判定を行う。より詳細には、アクセスデータ制御ユニット43は、上記命令により、アクセス予定のデータに対応する禁止フラグの状態を確認する。禁止フラグは、並列プログラム31a1’の各タスクのそれぞれの処理単位によりアクセスされるデータの各々に個別に対応するように設定され、各コア31c,31dが読み書き可能なメモリの所定の記憶領域に保存される。例えば、禁止フラグの状態がセット状態である場合、アクセスデータ制御ユニット43は、対応するデータにアクセス不可であると判定する。一方、禁止フラグの状態がリセット状態である場合、アクセスデータ制御ユニット43は、対応するデータにアクセス可能であると判定する。
Further, the start point instruction includes an instruction for determining whether or not the data indicated by the access data information can be accessed. Based on this instruction, the access
また、開始ポイント命令は、アクセスデータ制御ユニット43にてアクセスデータ情報が示すデータにアクセス可能と判定された場合に、アクセスデータ制御ユニット43が、該当データのロックを行うための命令を含む。このロック命令に基づき、アクセスデータ制御ユニット43は、禁止フラグがリセット状態であり、対応するデータにアクセス可能と判定した場合、参照した禁止フラグをセット状態に変化させて、データをロックする。これにより、開始ポイント命令以降の処理単位の命令が開始された場合、その処理単位の命令を実行中に、他のコアで実行される処理単位による該当データへのアクセスを禁止することが可能となる。
The start point instruction includes an instruction for the access
また、開始ポイント命令は、アクセスデータ制御ユニット43にてアクセスデータ情報が示すデータにアクセス不可と判定された場合、別のタスクの処理単位への切り替えを指示するための命令を含む。この命令に基づいて、プロセス切替ユニット44は、アクセスデータ制御ユニット43にてアクセスデータ情報が示すデータにアクセス不可と判定された場合に、実行対象となる処理単位を、別のタスクの処理単位に切り替える。その結果、データへのアクセス不可と判定されたコア31c、31dにおいて、該当データが解放されるまで、処理単位の実行が待機されるのではなく、切り替えられた処理単位が実行されえる。このため、各コア31c、31dでの処理単位の実行頻度を高めることが可能となる。なお、実行対象となった処理単位は、あらためて、アクセスデータ制御ユニット43において、アクセス予定のデータへのアクセスが可能であるかどうかにより、その実行可否が判定される。
Further, the start point instruction includes an instruction for instructing switching to a processing unit of another task when the access
より詳細に説明すると、各コア31c,31dに、いずれかの処理単位が割り振られた各タスクは、それぞれ処理優先度が定められている。プロセス切替ユニット44は、初期的に、実行対象となる処理単位を、最も高い処理優先度を持つタスクの処理単位に定める。その処理単位に関して、アクセスデータ制御ユニット43において、アクセス予定のデータへのアクセス不可と判定されると、プロセス切替ユニット44は、実行対象となる処理単位を、次に処理優先度の高いタスクに属する処理単位に切り替える。
Describing in more detail, each task to which one of the processing units is assigned to each of the
各タスクの処理優先度に関しては、開始ポイント命令が、各タスクの処理優先度を示す情報を含んでいても良い。その場合、開始ポイント命令に含まれる処理優先度情報が、プロセス切替ユニット44のプライオリティテーブル44cに展開される。プロセス切替ユニット44は、プライオリティテーブル44cに展開された各タスクの処理優先度情報に基づき、いずれのタスクが最も高い処理優先度を持つか、次に処理優先度が高いタスクはいずれであるか等を判定することができる。あるいは、各タスクの処理単位に含まれる命令を保存する命令キュー42a、42bについて、予め、各タスクと1対1に対応するように、各タスクとの対応関係を定めるとともに、プライオリティテーブル44cには、各命令キュー42a、42bの処理優先度を定めても良い。
Regarding the processing priority of each task, the start point instruction may include information indicating the processing priority of each task. In that case, the processing priority information included in the start point instruction is developed in the priority table 44c of the
そして、終了ポイント命令は、対応する処理単位の終了ポイントを示すものであることに加え、以下に説明する命令も含む。すなわち、終了ポイント命令は、開始ポイント命令に含まれるデータのロック命令に基づき、データがロックされた場合、アクセスデータ制御ユニット43が、そのデータのロックを解除するための命令を含む。処理単位の命令がすべて終了すれば、もはや、他のコアで実行される処理単位による該当データへのアクセスを禁止する必要は無いためである。終了ポイント命令に含まれるロック解除命令に基づいて、アクセスデータ制御ユニット43は、禁止フラグの状態をセット状態からリセット状態に変化させる。
The end point instruction includes an instruction described below, in addition to indicating the end point of the corresponding processing unit. That is, the end point instruction includes an instruction for the access
コード生成部10fは、コア割付及びスケジューリング部10dによって決定された各コア31c、31dへの割り付け及び実行順序に従って該当するタスクの複数の処理単位が実行され、かつ各処理単位の開始ポイント及び終了ポイントでは、上述した開始ポイント命令及び終了ポイント命令が実行されるように、並列プログラム31a1に相当するプログラムコードを生成する。コンピュータ10は、コード生成部10fによって生成されたプログラムコードを並列プログラム31a1として出力する。
The
次に、車載装置30の構成に関して説明する。車載装置30は、図4に示すように、マルチコアマイコン31、通信部32、センサ部33、及び入出力ポート34などを備えて構成される。また、マルチコアマイコン31は、ROM31a、RAM31b、第1コア31c、及び第2コア31dなどを備えて構成されている。車載装置30は、例えば、自動車に搭載されたエンジン制御装置やハイブリッド制御装置などに適用され得る。以下、車載装置30がエンジン制御装置として適用された例について説明する。
Next, the configuration of the vehicle-mounted
第1コア31cと第2コア31dは、コードROMとしてのROM31aに保存された並列プログラム31a1’を実行することで、例えばエンジン制御を実行する。具体的には、制御対象機器としての各アクチュエータを駆動することにより燃料噴射量、点火時期、吸入空気量などを制御する。なお、ROM31aには、エンジン制御で使用される定数データなども保存されている。RAM31bは、変数データなどを一時的に格納するものであり、マルチコアマイコン31が並列プログラム31a1’を実行するときに、各コア31c、31dにより適宜アクセスされる。通信部32は、車内LAN等を介して接続された他のECUと通信を行う。センサ部33は、エンジンの状態を検出するための各種のセンサを含む。入出力ポート34は、エンジンを制御するための各種信号の送受信を行う。
The
図5は、各コア31c、31d内の構成を概念的に示したブロック図である。なお、各コア31c、31dは同一の構成を有するため、図5には、第1コア31cについてのみ、内部構成を示している。また、図5では、説明を簡単にするため、相対的に高い処理優先度を持つタスク_Hと、相対的に低い処理優先度を持つタスク_Lの2つのタスクを、実行の有無を判定する対象となる実行タスク候補とした例について説明する。
FIG. 5 is a block diagram conceptually showing a configuration in each of the
図5に示すように、各コア31c、31dは、ROM31aから読み出した各タスクの処理単位(タスク_H、タスク_L)に含まれる命令コードを格納する命令キャッシュメモリ40a、40bを有している。命令キャッシュメモリ40a、40bに格納された各処理単位の命令コードは、命令フェッチ・デコード部41によって読み出され、デコードされて、それぞれの命令キュー42a、42bに転送される。
As shown in FIG. 5, each of the
なお、図5において、タスク_H及びタスク_Lの処理単位の命令コードが分離したコードROM31aに記憶されるように描かれているが、コードROM31aが物理的に分離していることは必ずしも必要ではない。例えば、複数のタスクが共通のコードROM31aに記憶されても良い。この場合、各コア31c、31dが、実行タスク候補とする各タスクに対応する数のプログラムカウンタを備えることで、共通のROM31aから各タスクの処理単位の命令コードを読み出すことができる。一方、命令キュー42a、42bに関しては、実行タスク候補の数に応じた複数の命令キューを備えることが好ましい。これにより、処理単位の切り替えを即座に行うことができるようになるためである。
Although FIG. 5 illustrates that the instruction codes of the processing units of task_H and task_L are stored in the separated
ただし、各コア31c、31dは、それぞれのコア31c、31dに割り付けられたすべてのタスクに対応する数の命令キューを有していなくともよい。実行タスク候補となる複数のタスクの処理単位の命令が複数の命令キューに蓄積されていれば、ほとんどの場合、処理単位の切り替えを支障なく行うことができ、各コア31c、31dが待機状態となることを回避できるためである。例えば、実行タスク候補とする複数のタスクは、タスク間で処理順序が規定されていないタスクの内、処理優先度の高いタスクから必要数のタスクを選択することができる。そして、実行タスク候補の1つのタスクについて、すべての処理単位の実行が終了した場合、未処理のタスクの中で、最も高い処理優先度のタスクで置き換えれば良い。
However, each of the
各コア31c、31dは、図5に示すように、アクセスデータ制御ユニット43を有する。このアクセスデータ制御ユニット43は、実行タスク候補毎に、アクセスデータテーブル43a、43bを有する。アクセスデータテーブル43a、43bには、上述したように、開始ポイント命令に含まれるアクセスデータ情報が格納される。これにより、アクセスデータ制御ユニット43は、実行タスク候補となっているタスクの処理単位が実行された場合に、アクセスすることになるデータを、その処理単位の実行前に把握することができる。そして、アクセスデータ制御ユニット43は、アクセスデータ情報が示すデータに対応する禁止フラグの状態を参照することにより、アクセスデータ情報が示すデータにアクセス可能か否かの判定を行う。この判定において、アクセスデータ情報が示すデータにアクセス可能と判定すると、アクセスデータ制御ユニット43は、該当データに対応する禁止フラグをセット状態に変化させて、そのデータをロックする。これにより、処理単位の命令を実行する準備が完了する。一方、アクセスデータ情報が示すデータにアクセス不可と判定すると、アクセスデータ制御ユニット43は、その判定結果を、プロセス切替ユニット44に与える。
Each of the
プロセス切替ユニット44は、上述したように、実行タスク候補の各々のタスクの処理優先度を示す情報を格納するプライオリティテーブル44cを備える。プロセス切替ユニット44は、プライオリティテーブル44cの各々のタスクの処理優先度を示す情報に基づき、初期的に、最も高い処理優先度を持つタスクの処理単位を実行対象の処理単位として定める。具体的には、プロセス切替ユニット44は、実行タスク候補となっている各タスクの処理単位の命令をそれぞれ格納しているレジスタ44a、44bの中で、最も高い処理優先度を持つタスクに対応するレジスタに格納されている命令を演算部45へ転送する。ただし、プロセス切替ユニット44は、最も高い処理優先度を有するタスクの処理単位がデータへのアクセス不可であるとの判定結果をアクセスデータ制御ユニット43から得た場合、プロセス切替ユニット44は、プライオリティテーブル44cを参照して、次に処理優先度が高いタスクの処理単位を実行対象の処理単位とする。換言すれば、プロセス切替ユニット44は、実行対象とする処理単位を、最も高い処理優先度を持つタスクの処理単位から、次に高い処理優先度を持つタスクの処理単位へと切り替える。このとき、プロセス切替ユニット44は、実行タスク候補となっている各タスクの処理単位の命令をそれぞれ格納しているレジスタ44a、44bの中で、次に高い処理優先度を持つタスクに対応するレジスタに格納されている命令を演算部45へ転送する。
As described above, the
演算部45は、演算ユニット45aとレジスタ45bとを有する。プロセス切替ユニット44から転送された命令は、レジスタ45bに一旦格納される。そして、レジスタ45bに格納された命令に応じた処理が、演算ユニット45aにて実行される。このように、各コア31c、31dでは、処理単位によってデータへのアクセス不可である場合、実行対象となる処理単位の切り替えが行われるので、各コア31c、31dでの処理単位の実行頻度を高めることができるようになる。
The
データキャッシュメモリ46は、実行対象となる処理単位によってアクセスされるデータを、予めメモリから読み出して保存しておくものである。処理単位の実行によって、そのデータが更新される場合には、その更新データがデータキャッシュメモリ46に一旦保存され、その後、メモリ内のデータが更新データによって書換えられる。
The
ここで、上述した車載装置30などの組み込みシステムのためのシングルプログラムでは、各タスク間で処理順序が規定されないことも多い。このため、各コア31c、31dでデータアクセス待ちのために処理単位の実行処理が中断される状況が生じた場合、処理順序が規定されていないタスクの処理単位を代わりに実行することにより、各コア31c、31dにおける並列実行頻度を高めることができる。その結果、生成された並列プログラム31a1’の実行速度を早めることが可能となる。
Here, in a single program for an embedded system such as the in-
そのため、本実施形態では、並列プログラム31a1’及びマルチコアマイコン31を、上述したように構成することで、各コア31c、31dで実行される処理単位同士の相互干渉を防止しつつ、各コア31c、31dでの処理単位の並列実行頻度を高めることを可能とした。
Therefore, in the present embodiment, by configuring the parallel program 31a1 ′ and the
以下に、並列プログラム31a1’を実行する際のマルチコアマイコン31の動作を、図6のフローチャートを参照して説明することにより、各コア31c、31dで実行される処理単位同士の相互干渉を防止しつつ、各コア31c、31dでの処理単位の並列実行頻度を高めることができるかについてより詳しく説明する。なお、図6のフローチャートは、第1コア31cにて実行される処理を示しているが、他のコアでも同様の処理が実行される。
Hereinafter, the operation of the
図6のステップS100では、実行タスク候補毎にそれぞれの処理単位に含まれる命令をロードし、対応する命令キュー42a、42bにエンキューする。ステップS110では、実行タスク候補の中で最も高い処理優先度を持つタスクを選択し、その選択したタスクに対応する命令キュー42a、42bの命令を参照する。ステップS120では、参照した命令が開始ポイント命令であるか否かを判定する。ステップS120にて開始ポイント命令であると判定した場合、ステップS130の処理に進んで、開始ポイント命令に含まれるアクセスデータ情報を取得し、アクセスデータテーブル43aに格納する。そして、ステップS140において、アクセスデータ情報が示すデータにアクセス可能であるか、つまり、そのデータに対応する禁止フラグがリセット状態となっているかどうかを判定する。なお、処理単位が、メモリに保存されたデータにアクセスするものではない場合には、ステップS140の判定結果は、常に“Yes”となる。
In step S100 of FIG. 6, the instructions included in each processing unit are loaded for each execution task candidate, and enqueued in the
ステップS140にて、アクセスデータ情報が示すデータにアクセス可能と判定した場合、ステップS150の処理に進む。ステップS150では、アクセス可能と判定したデータに対応する禁止フラグの状態をセット状態に変化させる。これにより、開始ポイント命令以降の処理単位の命令を実行する準備が整う。そのため、ステップS160では、同タスクの処理単位の次の命令を参照した上で、ステップS120の処理に戻る。この場合、ステップS120では、開始ポイント命令では無いと判定され、ステップS210の処理に進む。さらに、参照している命令は、処理単位の実体的処理に係る命令であるため、ステップS210においても、終了ポイント命令ではないと判定され、ステップS250の処理に進む。 If it is determined in step S140 that the data indicated by the access data information can be accessed, the process proceeds to step S150. In step S150, the state of the prohibition flag corresponding to the data determined to be accessible is changed to the set state. As a result, a preparation for executing the instruction in the processing unit after the start point instruction is completed. Therefore, in step S160, the process returns to step S120 after referring to the next instruction in the processing unit of the task. In this case, in step S120, it is determined that the instruction is not a start point instruction, and the process proceeds to step S210. Further, since the referred command is a command related to the substantive processing of the processing unit, it is also determined in step S210 that the command is not an end point command, and the process proceeds to step S250.
ステップS250では、参照している命令を実行する。すなわち、プロセス切替ユニット44から該当する命令が演算部45に転送され、その転送された命令に応じた処理が演算ユニット45aにおいて実行される。その後、ステップS260において、同タスクの処理単位の次の命令を参照した上で、ステップS120の処理に戻る。このような処理が、参照される命令が終了ポイント命令となるまで、すなわち、処理単位の終了ポイントに達するまで繰り返される。参照される命令が終了ポイント命令となると、ステップS210における判定結果が“Yes”となる。この場合、ステップS220の処理に進んで、演算部45における演算出力データにより、メモリ内のデータを更新する。ただし、実行している処理単位がメモリ内のデータを書き換えるものではない場合には、この処理はスキップされる。
In step S250, the referred instruction is executed. That is, the corresponding instruction is transferred from the
続くステップS230では、アクセス対象となっていたデータに対応する禁止フラグの状態をセット状態からリセット状態に変化させる。これにより、データのロックが解除され、他コア31dにおいて実行される処理単位によって、該当データへのアクセスが可能となる。そして、ステップS240にて、同タスクの次の処理単位の命令を参照した上で、ステップS120の処理に戻る。このように、データへのアクセスが可能である限り、最も高い処理優先度を持つタスクの処理単位が順番に実行されていく。
In subsequent step S230, the state of the prohibition flag corresponding to the data to be accessed is changed from the set state to the reset state. As a result, the lock of the data is released, and the data can be accessed by the processing unit executed in the
処理単位の実行中に利用するデータへのアクセスが不可である場合、ステップS140における判定結果が“No”となる。この場合、ステップS170の処理に進み、実行対象となっているタスクは、実行タスク候補の中で最も低い処理優先度を持っているタスクであるか否かが判定される。このステップS170の判定結果が“No”である場合、実行タスク候補の中に、実行対象となっているタスクよりも低い処理優先度を有するタスクがあることになる。そのため、ステップS180の処理に進んで、次に処理優先度が高いタスクを実行対象とし、そのタスクに対応する命令キュー42bに蓄積されている命令を参照した上で、ステップS120の処理に戻る。このようなタスクの切り替えが行われた場合、参照した命令は、次に処理優先度が高いタスクの処理単位の開始ポイント命令となる。従って、ステップS120における判定結果が“Yes”となり、上述したように、実行対象となった処理単位は、あらためて、アクセス予定のデータへのアクセスが可能であるかどうかにより、その実行可否が判定される。
If access to the data used during execution of the processing unit is not possible, the result of the determination in step S140 is “No”. In this case, the process proceeds to step S170, and it is determined whether the task to be executed is the task having the lowest processing priority among the execution task candidates. If the determination result in step S170 is “No”, it means that among the execution task candidates, there is a task having a lower processing priority than the task to be executed. Therefore, the process proceeds to step S180, where the task having the next highest processing priority is set as an execution target, the command stored in the
一方、ステップS170において、実行対象となっているタスクは、実行タスク候補の中で最も低い処理優先度を持っているタスクと判定された場合、実行タスク候補の中に、よい低い処理優先度を持っているタスクは存在しない。このため、ステップS170の判定結果が“Yes”となった場合には、ステップS190の処理に進んで、一定時間待機する。そして、ステップS200の処理で、実行タスク候補の中で最も高い処理優先度を持つタスクの処理単位の命令を参照する。つまり、最も低い処理優先度を持つタスクが実行対象となっているときに、処理単位の切り替えを行う必要が生じた場合には、一定時間待機した後、最も高い処理優先度を持つタスクの処理単位に切り替えるのである。これにより、再び、最も高い処理優先度を持つタスクの処理単位から順に、アクセス予定のデータへのアクセスが可能であるかどうかにより、その実行可否を判定した上で、実行可能な処理単位の命令を実行させることが可能となる。 On the other hand, in step S170, if it is determined that the task to be executed has the lowest processing priority among the execution task candidates, a good low processing priority is assigned to the execution task candidates. There are no tasks to have. Therefore, when the result of the determination in step S170 is “Yes”, the process proceeds to step S190 and waits for a certain time. Then, in the processing of step S200, the instruction of the processing unit of the task having the highest processing priority among the execution task candidates is referred to. In other words, if it is necessary to switch the processing unit when the task with the lowest processing priority is the execution target, after waiting for a certain time, the processing of the task with the highest processing priority Switch to units. This makes it possible to determine again whether or not the data to be accessed can be accessed in order from the processing unit of the task having the highest processing priority, and then determine the instruction of the executable processing unit. Can be executed.
以上説明したように、本発明の第1実施形態によれば、並列プログラム31a1’の各タスクのそれぞれの処理単位によりアクセスされるデータの各々に個別に対応するように設定される禁止フラグを用いることにより、各コア31c、31dにて実行しようとするタスクの処理単位が、その実行時に利用するデータにアクセス可能であるか否かを判定することが可能となる。従って、データへのアクセス不可と判定された場合には、そのデータへのアクセスが可能となるまで待機するのではなく、実行可能な処理単位への切り替えを行うことができるようになる。このため、生成された並列プログラム31a1‘の並列度が低くても、複数のコア31c、31dでの処理単位の並列実行頻度を高めることが可能となる。
As described above, according to the first embodiment of the present invention, a prohibition flag set to individually correspond to data accessed by each processing unit of each task of the parallel program 31a1 'is used. This makes it possible to determine whether or not the processing unit of the task to be executed by each of the
(第2実施形態)
次に、本発明の第2実施形態について説明する。上述した第1実施形態では、並列プログラム31a1’の各タスクのそれぞれの処理単位によりアクセスされるデータの各々に個別に対応するように設定される禁止フラグを用いて、各コア31c,31dにて実行される処理単位の相互干渉を防止するものであった、しかしながら、1つのコアで実行中の処理単位によってアクセスされるデータへの、他のコアで実行される処理単位によるアクセスを禁止する手法は、上述した第1実施形態の手法に限られない。本第2実施形態では、第1実施形態とは異なる手法の一例について説明する。
(Second Embodiment)
Next, a second embodiment of the present invention will be described. In the above-described first embodiment, the
第2実施形態におけるマルチコアマイコン31の構成を図7に示す。図7に示されるように、本実施形態のマルチコアマイコン31は、メモリへのアクセスを管理するメモリプロテクションユニット(MPU)47を備える。MPU47は、同一データに対するアクセスを単一のコア31c、31dのみに許可するように作動する。すなわち、MPU47は、いずれのコア31c、31dからもアクセスされていないデータに対して、いずれかのコア31c、31dからのアクセス要求があった場合には、そのアクセス要求を許可する。しかし、MPU47は、いずれかのコア31c、31dによってアクセスされているデータに対して、別のコア31c、31dからのアクセス要求があっても、そのアクセス要求を拒否する。
FIG. 7 shows the configuration of the
MPU47に対するデータのアクセス要求は、図7に示すように、各コア31c、31dのアクセスデータ制御ユニット43から出力される。このアクセス要求に対し、MPU47は、アクセスを許可する許可通知もしくはアクセスを拒否する拒否通知を、アクセスデータ制御ユニット43に返送する。各コア31c、31dのアクセスデータ制御ユニット43は、図8のステップS340において、MPU47からの許可通知もしくは拒否通知に基づき、メモリに保存されたデータへのアクセスの可否を判定する。
A data access request to the
アクセスデータ制御ユニット43がMPU47から許可通知を受領すると、そのコアは、処理単位の実行のために該当データを読み出して、データキャッシュメモリ46に保存する。さらに、図8のフローチャートのステップS350において、そのコアのアクセスデータ制御ユニット43が、MPU47に対して、読み出したデータをロックするよう要求する。このロック要求に応じて、MPU47は該当データへの他コアからのアクセスを禁止するようになる。
When the access
そして、処理単位の実体的処理に係るすべての命令が終了し、その処理単位の終了ポイントに達すると、図8のフローチャートのステップS410における判定結果が“Yes”となり、ステップS420〜S440の処理が実行される。この内、ステップS430の処理では、アクセスデータ制御ユニット43が、MPU47に対して、ロックしているデータをアンロックするよう要求する。このアンロック要求に応じて、MPU47は該当データを他コアからのアクセスにも開放するようになる。
Then, when all the instructions related to the substantive processing of the processing unit are completed and the end point of the processing unit is reached, the determination result in step S410 of the flowchart of FIG. 8 becomes “Yes”, and the processing of steps S420 to S440 is performed. Be executed. In the process of step S430, the access
その他のマルチコアマイコン31の構成や、図8のフローチャートにおける処理は、上述した第1実施形態と同様であるため、説明を省略する。
The other configuration of the
以上の第2実施形態によっても、第1実施形態と同様に、各コア31c、31dにて実行しようとするタスクの処理単位が、その実行時に利用するデータにアクセス可能であるか否かを判定することができる。従って、データへのアクセス不可と判定された場合には、そのデータへのアクセスが可能となるまで待機するのではなく、実行可能な処理単位への切り替えを行うことができるようになる。このため、生成された並列プログラム31a1‘の並列度が低くても、複数のコア31c、31dでの処理単位の並列実行頻度を高めることが可能となる。
According to the above-described second embodiment, similarly to the first embodiment, it is determined whether or not the processing unit of the task to be executed by each of the
(第3実施形態)
次に、本発明の第3実施形態について説明する。上述した第1実施形態及び第2実施形態では、1つのコアがアクセスしているデータへの他コアによるアクセスを禁止することにより、複数のコアで実行される処理単位による相互干渉を防止するものであった。
(Third embodiment)
Next, a third embodiment of the present invention will be described. In the first and second embodiments described above, mutual interference by processing units executed by a plurality of cores is prevented by prohibiting another core from accessing data accessed by one core. Met.
本実施形態では、上述した第1実施形態又は第2実施形態の構成に加えて、例えば、1つのコアが、制御上、特に重要なデータへのアクセスを行って、そのデータの更新などを行う場合に、他コアにおいて別タスクの処理単位への切り替えを禁止するものである。これにより、他コアにおける切り替え後の別タスクの処理単位によって、誤って、その重要なデータが影響を受けることを確実に防止することができる。加えて、同じタスク内の処理単位の間では、従来の並列化コンパイル方法により、依存関係に従って、例えば、同期ポイント命令追加部によって待合せ処理を追加することが可能である。これにより同じタスク内の処理単位同士で、誤って、その重要なデータが影響を受けることを確実に防止することができる。詳細は、特開2015−1807号公報を参照されたい。 In the present embodiment, in addition to the configuration of the first embodiment or the second embodiment described above, for example, one core accesses data that is particularly important for control and updates the data. In this case, the switching of the other core to the processing unit of another task is prohibited. Thus, it is possible to reliably prevent the important data from being erroneously affected by the processing unit of another task after switching in another core. In addition, between processing units in the same task, it is possible to add a queuing process according to the dependency by, for example, a synchronization point instruction adding unit by the conventional parallelizing compilation method. As a result, it is possible to reliably prevent the important data from being erroneously affected by the processing units in the same task. For details, refer to JP-A-2015-1807.
本実施形態によるマルチコアマイコン31は、図9に示すように、各コア31c、31dのアクセスデータ制御ユニット43同士が通信可能に構成されている。そして、各コア31c、31dのアクセスデータ制御ユニット43は、開始ポイント命令に続いて、他コアにおいて別タスクの処理単位への切り替えを禁止する排他区間の開始命令が設定されている場合(図10のフローチャートのステップS660:Yes)、他コアのアクセスデータ制御ユニットへ、別タスクの制御単位への切り換えの禁止要求であるプリエンプション禁止要求を出力する(図10のフローチャートのステップS670)。なお、図10のフローチャートは、第1実施形態の構成による作動を前提としたものであるが、第2実施形態の構成に対して、本実施形態の構成を追加しても良い。
As shown in FIG. 9, the
このプリエンプション禁止要求を受信した他コアのアクセスデータ制御ユニットは、実行対象となっているタスクの制御処理がアクセス予定のデータにアクセス不可であっても(図10のフローチャートのステップS540:No)、図10のフローチャートのステップS570に示すように、プリエンプション禁止要求に応じて、そのままステップS120の処理に戻ることにより、別タスクの処理単位への切り換えを禁止する。 The access data control unit of the other core that has received the preemption prohibition request, even if the control process of the task to be executed cannot access the data to be accessed (step S540 in the flowchart of FIG. 10: No). As shown in step S570 of the flowchart of FIG. 10, in response to the preemption prohibition request, the process returns to the process of step S120, thereby prohibiting the switching to the processing unit of another task.
排他区間開始命令と対をなすように、終了ポイント命令の直前に、排他区間終了命令が設定される。処理単位の実体的処理が終了して、排他区間終了命令が参照されると、図10のフローチャートの判定結果が“Yes”となる。この場合、ステップS720の処理に進んで、他コアに対して出力しているプリエンプション禁止要求を停止する。 An exclusive section end command is set immediately before the end point command so as to form a pair with the exclusive section start command. When the substantive processing of the processing unit ends and the exclusive section end instruction is referred to, the determination result in the flowchart of FIG. 10 becomes “Yes”. In this case, the process proceeds to step S720 to stop the preemption prohibition request output to the other core.
その他のマルチコアマイコン31の構成や、図8のフローチャートにおける処理は、上述した第1実施形態と同様であるため、説明を省略する。
The other configuration of the
以上、本発明の好ましい実施形態について説明した。しかしながら、本発明は、上記実施形態に何ら制限されることはなく、本発明の趣旨を逸脱しない範囲において、種々の変形が可能である。 The preferred embodiment of the present invention has been described above. However, the present invention is not limited to the above embodiment, and various modifications are possible without departing from the gist of the present invention.
例えば、上述した第1及び第2実施形態では、最初に最も高い処理優先度を持つタスクの処理単位に関して、その処理単位の命令によってアクセス予定のデータがアクセス可能であるかどうかを判定し、アクセス不可である場合に、実行対象となる処理単位を、次に高い処理優先度を持つタスクの処理単位に切り替えるものであった。しかしながら、例えば、最初に、実行タスク候補の各タスクの処理単位の命令によってアクセス予定のデータにアクセス可能であるかどうかを判定し、アクセス可能であるタスクの中で、最も処理優先度の高いタスクの処理単位を実行対象として決定しても良い。 For example, in the above-described first and second embodiments, regarding the processing unit of the task having the highest processing priority, it is determined whether or not the data to be accessed is accessible by the instruction of the processing unit. If it is impossible, the processing unit to be executed is switched to the processing unit of the task having the next highest processing priority. However, for example, first, it is determined whether or not the data to be accessed is accessible by the instruction of the processing unit of each task of the execution task candidate, and the task having the highest processing priority among the accessible tasks is determined. May be determined as an execution target.
また、上述した実施形態では、マルチコアマイコン31を車載装置30として適用する例について説明したが、マルチコアマイコン31の適用対象はこれに限られない。
Further, in the above-described embodiment, an example in which the
1:自動並列化コンパイラ、10:コンピュータ、10a:字句解析部、10b:意味解析部、10c:依存関係解析部、10d:コア割付及びスケジューリング部、10e:同期ポイント命令追加部、10f:コード生成部、11:ディスプレイ、12:HDD、13:CPU、14:ROM、15:RAM、16:入力装置、17:読取部、18:記憶媒体、20:コンパイラ、30:車載装置、31:マルチコアマイコン、31a:ROM31a1:並列プログラム、31b:RAM、31c:第1コア、31d:第2コア、32:通信部、33:センサ部、34:入出力ポート、40a、40b:命令キャッシュメモリ、41:命令フェッチ・デコード部、42a、42b:命令キュー、43:アクセスデータ制御ユニット、43a、43b:アクセスデータテーブル、44:プロセス切替ユニット、44a、44b:レジスタ、44c:プライオリティテーブル、45:演算部、45a:演算ユニット、45b:レジスタ、46:データキャッシュメモリ、47:MPU
1: Automatic parallelizing compiler, 10: Computer, 10a: Lexical analysis section, 10b: Semantic analysis section, 10c: Dependency analysis section, 10d: Core allocation and scheduling section, 10e: Synchronization point instruction addition section, 10f: Code generation , 11: display, 12: HDD, 13: CPU, 14: ROM, 15: RAM, 16: input device, 17: reading unit, 18: storage medium, 20: compiler, 30: in-vehicle device, 31:
Claims (20)
前記並列プログラムは、前記シングルプログラムに含まれる、複数の処理単位からなるタスク毎に、前記複数の処理単位の依存関係に基づき、前記複数の処理単位の前記複数のコアへの割り付けと実行順序とが決定されたものであり、
前記マルチコアマイコンの前記複数のコアは、それぞれ、自コアに割り付けられた、複数のタスクに属するそれぞれの処理単位から、実行すべき処理単位を選択する選択部(S110〜S200、S310〜S400、510〜S610、S670)を有し、
前記選択部は、
各タスクの処理単位を対象として、当該処理単位の実行時に利用予定のデータにアクセス可能であるか否かを判定する判定部(S140、S340、S540)と、
前記判定部によって利用予定のデータにアクセス可能と判定された処理単位を実行すべき処理単位として決定するとともに、他コアにおいて実行される処理単位による該当データへのアクセスを禁止するための禁止処理(S150、S350、S550、S670)を実行する決定時処理部(S150〜S160、S350〜S360、S550〜S560、S670)と、を備え、
前記複数のコアは、それぞれ、前記決定時処理部によって決定された処理単位に含まれる命令を実行するマルチコアマイコン。 A multi-core microcomputer (31) for executing a parallel program (31a1 ′) for a multi-core microcomputer having a plurality of cores (31c, 31d) generated from a single program for a single-core microcomputer having one core,
The parallel program is included in the single program, for each task consisting of a plurality of processing units, based on the dependency of the plurality of processing units, the allocation of the plurality of processing units to the plurality of cores and the execution order Has been determined,
Each of the plurality of cores of the multi-core microcomputer selects a processing unit to be executed from among processing units belonging to a plurality of tasks allocated to its own core (S110 to S200, S310 to S400, 510). ~ S610, S670),
The selection unit includes:
A determination unit (S140, S340, S540) that determines whether or not data to be used can be accessed at the time of execution of the processing unit, with respect to the processing unit of each task;
Prohibition processing for determining the processing unit determined to be accessible to the data to be used by the determination unit as the processing unit to be executed, and prohibiting access to the data by the processing unit executed in another core ( Determination processing units (S150 to S160, S350 to S360, S550 to S560, and S670) for executing S150, S350, S550, and S670);
A multi-core microcomputer, wherein each of the plurality of cores executes an instruction included in a processing unit determined by the determination-time processing unit.
前記判定部は、前記特定部により特定された処理単位を対象として、利用予定のデータにアクセス可能であるか否かを判定し、
前記選択部は、さらに、前記判定部によって利用予定のデータにアクセス不可と判定されると、前記判定部の判定対象となる処理単位を、次に処理優先度の高いタスクに属する処理単位に切り替える切替部(S170〜S200、S370〜S400、S580〜S610)を有する請求項1に記載のマルチコアマイコン。 The selecting unit includes a specifying unit (S110, S310, S510) for specifying a processing unit belonging to a task having a relatively highest processing priority based on the processing priority of each of the plurality of tasks.
The determining unit, for the processing unit specified by the specifying unit, determines whether or not the data to be used is accessible,
When the determining unit determines that the data to be used is inaccessible, the selecting unit switches the processing unit to be determined by the determining unit to a processing unit belonging to a task having the next highest processing priority. The multi-core microcomputer according to claim 1, further comprising a switching unit (S170 to S200, S370 to S400, S580 to S610).
前記命令キューから与えたれた命令に応じた演算処理を実行する演算処理部(45)と、を有し、
前記複数の命令キューに、前記複数のタスクに属するそれぞれの処理単位に含まれる命令が保存され、
前記切替部は、前記演算処理部への命令の供給元となる命令キューを切り替える請求項2乃至4のいずれかに記載のマルチコアマイコン。 A plurality of instruction queues (42a, 42b) for storing at least instructions included in each processing unit of the plurality of tasks allocated to the own core;
An arithmetic processing unit (45) for executing arithmetic processing according to the instruction given from the instruction queue;
Instructions included in each processing unit belonging to the plurality of tasks are stored in the plurality of instruction queues,
The multi-core microcomputer according to claim 2, wherein the switching unit switches an instruction queue serving as a source of instructions to the arithmetic processing unit.
前記開始ポイント命令は、対応する処理単位に含まれる命令によって前記データへのアクセスが行われる場合、利用予定のデータを示すアクセスデータ情報を含む請求項1乃至5のいずれかに記載のマルチコアマイコン。 Each processing unit of the parallel program includes a start point instruction indicating a start point thereof,
6. The multi-core microcomputer according to claim 1, wherein the start point instruction includes access data information indicating data to be used when the data is accessed by an instruction included in a corresponding processing unit.
前記決定時処理部による前記禁止処理は、前記終了ポイント命令に応じて解除される請求項6又7に記載のマルチコアマイコン。 Each processing unit of the parallel program includes an end point instruction indicating its end point,
8. The multi-core microcomputer according to claim 6, wherein the prohibition processing by the determination-time processing unit is released in response to the end point instruction. 9.
前記判定部は、利用予定の前記データに対応するフラグが立てられてロックされているか否かにより、当該データにアクセス可能であるか否かを判定する請求項1乃至8のいずれかに記載のマルチコアマイコン。 The determination-time processing unit performs a process of setting a flag indicating that the data to be used is in use as the prohibition process (S150, S550), locks the data,
9. The device according to claim 1, wherein the determination unit determines whether the data is accessible based on whether a flag corresponding to the data to be used is set and locked. 9. Multi-core microcomputer.
前記メモリに対するアクセスを管理するメモリ管理部(47)と、を備え、
前記複数のコアが、割り付けられた前記複数のタスクのそれぞれの処理単位を実行する際に利用する前記データは、前記メモリに記憶され、
前記決定時処理部は、前記禁止処理(S350)として、前記メモリ管理部へ利用予定の前記データのロックを指示する処理を実施し、
前記判定部は、前記メモリ管理部によって利用予定の前記データがロックされているか否かにより、当該データにアクセス可能であるか否かを判定する請求項1乃至8のいずれかに記載のマルチコアマイコン。 A memory accessible by the plurality of cores;
A memory management unit (47) for managing access to the memory;
The data used by the plurality of cores when executing the respective processing units of the assigned tasks is stored in the memory,
The determination-time processing unit performs, as the prohibition process (S350), a process of instructing the memory management unit to lock the data to be used,
9. The multi-core microcomputer according to claim 1, wherein the determination unit determines whether the data to be used is accessible by the memory management unit based on whether the data is locked. .
前記シングルプログラムに含まれる、複数の処理単位からなるタスク毎に、前記複数の処理単位の依存関係に基づき、前記複数の処理単位の前記複数のコアへの割り付けと実行順序とを決定するコア割付及び実行順序決定手順(10a〜10d)と、
前記実行順序決定手順にて決定された前記複数のコアへの割り付け及び実行順序に従って前記複数の処理単位が前記マルチコアマイコンの前記複数のコアで実行されるように前記並列プログラムを生成するとともに、前記並列プログラムの各々の処理単位の開始ポイントに開始ポイント命令を追加し、終了ポイントに終了ポイント命令を追加する並列プログラム生成手順(10e、10f)と、を備え、
前記開始ポイント命令と前記終了ポイント命令とは、前記マルチコアマイコンにおいて、前記複数のコアで同時期に実行される処理単位に含まれる命令によって同じデータへアクセスしないようにデータアクセスの調停を行なわせるとともに、データアクセスが禁止されたコアにおいて、該当するタスクの処理単位以外の別のタスクの処理単位を実行させるものである並列化方法。 A parallelization method for generating a parallel program (31a1) for a multi-core microcomputer having a plurality of cores (31c, 31b) from a single program for a single-core microcomputer having one core,
Core assignment for determining, for each task including a plurality of processing units included in the single program, allocation of the plurality of processing units to the plurality of cores and execution order based on a dependency of the plurality of processing units. And an execution order determination procedure (10a to 10d);
Generating the parallel program so that the plurality of processing units are executed by the plurality of cores of the multi-core microcomputer according to the allocation and execution order to the plurality of cores determined in the execution order determination step; A parallel program generation procedure (10e, 10f) for adding a start point instruction to a start point of each processing unit of the parallel program and adding an end point instruction to an end point.
The start point instruction and the end point instruction cause the multi-core microcomputer to perform data access arbitration so as not to access the same data by an instruction included in a processing unit executed simultaneously by the plurality of cores. A parallelization method for executing a processing unit of another task other than a processing unit of a corresponding task in a core for which data access is prohibited.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018113736A JP7073933B2 (en) | 2018-06-14 | 2018-06-14 | Multi-core microcomputer and parallelization method |
DE102019207629.7A DE102019207629A1 (en) | 2018-06-14 | 2019-05-24 | Multi-core microcomputers and parallelization processes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018113736A JP7073933B2 (en) | 2018-06-14 | 2018-06-14 | Multi-core microcomputer and parallelization method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2019215804A true JP2019215804A (en) | 2019-12-19 |
JP7073933B2 JP7073933B2 (en) | 2022-05-24 |
Family
ID=68724928
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2018113736A Active JP7073933B2 (en) | 2018-06-14 | 2018-06-14 | Multi-core microcomputer and parallelization method |
Country Status (2)
Country | Link |
---|---|
JP (1) | JP7073933B2 (en) |
DE (1) | DE102019207629A1 (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH10289129A (en) * | 1997-04-15 | 1998-10-27 | Mitsubishi Electric Corp | Task scheduler for debugging |
US20090164755A1 (en) * | 2007-12-19 | 2009-06-25 | International Business Machines Corporation | Optimizing Execution of Single-Threaded Programs on a Multiprocessor Managed by Compilation |
WO2012014287A1 (en) * | 2010-07-27 | 2012-02-02 | 富士通株式会社 | Multi-core processor system, control program and control method |
JP2017228029A (en) * | 2016-06-21 | 2017-12-28 | 株式会社デンソー | Parallelization method, parallelization tool, on-vehicle device |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6018022B2 (en) | 2013-06-14 | 2016-11-02 | 株式会社デンソー | Parallel compilation method, parallel compiler, parallel compilation device, and in-vehicle device |
-
2018
- 2018-06-14 JP JP2018113736A patent/JP7073933B2/en active Active
-
2019
- 2019-05-24 DE DE102019207629.7A patent/DE102019207629A1/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH10289129A (en) * | 1997-04-15 | 1998-10-27 | Mitsubishi Electric Corp | Task scheduler for debugging |
US20090164755A1 (en) * | 2007-12-19 | 2009-06-25 | International Business Machines Corporation | Optimizing Execution of Single-Threaded Programs on a Multiprocessor Managed by Compilation |
WO2012014287A1 (en) * | 2010-07-27 | 2012-02-02 | 富士通株式会社 | Multi-core processor system, control program and control method |
JP2017228029A (en) * | 2016-06-21 | 2017-12-28 | 株式会社デンソー | Parallelization method, parallelization tool, on-vehicle device |
Also Published As
Publication number | Publication date |
---|---|
DE102019207629A1 (en) | 2019-12-19 |
JP7073933B2 (en) | 2022-05-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Gai et al. | A comparison of MPCP and MSRP when sharing resources in the Janus multiple-processor on a chip platform | |
US7257814B1 (en) | Method and apparatus for implementing atomicity of memory operations in dynamic multi-streaming processors | |
US9170844B2 (en) | Prioritization for conflict arbitration in transactional memory management | |
US20090282407A1 (en) | Task switching apparatus, method and program | |
JP2004171234A (en) | Task allocation method in multiprocessor system, task allocation program and multiprocessor system | |
JP5745868B2 (en) | Multiprocessor system | |
US20060090168A1 (en) | Method and system for speeding up mutual exclusion | |
JP2008522290A (en) | Hardware multithread system and method | |
KR20070108329A (en) | Hardware sharing system and method | |
Anderson et al. | Using local-spin k-exclusion algorithms to improve wait-free object implementations | |
JP5533789B2 (en) | In-vehicle electronic control unit | |
JP2007188523A (en) | Task execution method and multiprocessor system | |
US20080184258A1 (en) | Data processing system | |
JP7073933B2 (en) | Multi-core microcomputer and parallelization method | |
EP1299801B1 (en) | Method and apparatus for implementing atomicity of memory operations in dynamic multi-streaming processors | |
JP2684993B2 (en) | Processor system and control method thereof | |
JP7346649B2 (en) | Synchronous control system and method | |
JP7204443B2 (en) | VEHICLE CONTROL DEVICE AND PROGRAM EXECUTION METHOD | |
JPH09293057A (en) | Task allocation method in hierarchical structure type multiprocessor system | |
WO2020213397A1 (en) | Processor and register inheritance method | |
JP7139633B2 (en) | Parallelization method, parallelization tool, and multicore microcomputer | |
JP7095513B2 (en) | Multi-core microcomputers and in-vehicle devices | |
JP2012113632A (en) | Information processor and method of managing exclusive access right of information processor | |
Strøm et al. | Hardware locks for a real‐time Java chip multiprocessor | |
Serrano | A time-predictable parallel programing model for real-time systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20210218 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20220114 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20220201 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20220323 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20220412 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220425 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 7073933 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |