JP2004029982A - Parallelization conversion system, parallelization conversion method, program, and compiler - Google Patents

Parallelization conversion system, parallelization conversion method, program, and compiler Download PDF

Info

Publication number
JP2004029982A
JP2004029982A JP2002182292A JP2002182292A JP2004029982A JP 2004029982 A JP2004029982 A JP 2004029982A JP 2002182292 A JP2002182292 A JP 2002182292A JP 2002182292 A JP2002182292 A JP 2002182292A JP 2004029982 A JP2004029982 A JP 2004029982A
Authority
JP
Japan
Prior art keywords
parallelization
character string
directive
program
procedure
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
Application number
JP2002182292A
Other languages
Japanese (ja)
Other versions
JP4019361B2 (en
Inventor
Yasuhito Nishitani
西谷 康仁
Ichiro Honma
本間 一朗
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2002182292A priority Critical patent/JP4019361B2/en
Publication of JP2004029982A publication Critical patent/JP2004029982A/en
Application granted granted Critical
Publication of JP4019361B2 publication Critical patent/JP4019361B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To discriminate a parallelization directive sentence described by a user from a parallelization directive sentence automatically generated by a processing system at the time of converting a sequential program into a parallel program. <P>SOLUTION: In the parallelization compiler 11, a directive sentence generating part 16 generates the result of automatic parallelization analysis performed by a parallelization analyzing part 13 as a parallelization directive sentence in a source file 18. In this case, a unitary character string("hash value") obtained by transmitting the character string of the parallelization directive sentence through uni-directional functions("hash functions") is added as a comment so as to be discriminated from the parallelization directive sentence generated/changed/inserted by a user. <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明は、コンピュータプログラムの変換技術に係わり、特に、逐次的に処理を行なうように記述されたプログラムを、自動的あるいはプログラマの指示に従って、並列に処理を行なうプログラムに変換するコンピュータ処理技術に関するものである。
【0002】
【従来の技術】
従来、並列処理を行なうプログラムを作成する技術として、プログラマが、逐次的に処理を行なうよう記述されたプログラムに対し、並列化を指示する指示文を挿入し、コンピュータが並列化コンパイラにより、その指示文を解析して並列処理を行なうプログラムに変換するものがある。
【0003】
例えば、共有メモリ型並列計算機向けの並列化言語であるOpenMPを規定した、”OpenMP Fortran Application Program Interface Version 2.0, November 2000, http://www.openmp.org/”では、プログラマがループ並列化や変数のプライベート化等の指示文をプログラム中に挿入し、コンパイラはその指示に従って並列化変換を行なう。
【0004】
しかし、並列化指示を全てプログラマが行なうのは負担が大きい。これを解決する技術として、コンピュータにおいて、コンパイラ、あるいは並列化支援ツール等により、自動的に、プログラムの並列性を解析し、結果をプログラム中に並列化指示文として生成するものがある。
【0005】
このようなコンピュータにより自動的に並列化指示文をプログラム中に生成する従来技術は、例えば、「Haoqiang Jin , Michael Frumkin , Jerry Yan ”Automatic Generation of OpenMP Directives and Its Application to Computational Fluid Dynamics Codes”, Volume 1940, Issue , pp 440− Lecture Notes in Computer Science」に記載されている。
【0006】
このようにしてコンピュータで自動的に生成される並列化指示文は、プログラムのポータビリティを確保するために、例えばOpenMP指示文のような、汎用性のある指示文である必要がある。
【0007】
しかし、従来技術においては、以下のような問題点がある。
【0008】
すなわち、一度、処理系(コンピュータ)によって指示文が付加されたソースプログラムは、プログラマが修正をして再度処理系に入力する場合があり得る。この時、プログラマが実行文を修正することによって、処理系が過去に付加した指示文が正しくなくなる場合がある。処理系は、このような指示文を、プログラマが修正したプログラムに合うように、生成し直す必要がある。
【0009】
一方で、同様の並列化指示文は、プログラマによって手動で付加される場合もある。処理系は、プログラマの指示に従わなければならないため、このような指示文は変更しないようにする必要がある。
【0010】
ここで、ポータビリティを保つために、処理系が例えばOpenMP指示文のような汎用性のある指示文を付加する場合、プログラム中に記述されている指示文が、プログラマが記述したものなのか、処理系が以前に自動的に付加したものであるかの判別がつかないという問題が生じる。
【0011】
このため、処理系は、処理系が過去に生成した指示文を修正することができない。あるいは、プログラマが付加した指示文も修正してしまう可能性がある。
【0012】
【発明が解決しようとする課題】
解決しようとする問題点は、従来の技術では、並列処理を行なうプログラムにおける並列化を指示する指示文が、プログラマが記述したものなのか、処理系(コンピュータ)が以前に自動的に付加したものであるかを、処理系で判別することができない点である。
【0013】
本発明の目的は、これら従来技術の課題を解決し、逐次的に処理を行なうよう記述されたソースプログラムの、並列に処理を行なうオブジェクトプログラムへの、コンピュータによる自動変換を効率化することを可能にすることである。
【0014】
【課題を解決するための手段】
上記目的を達成するため、本発明では、並列化処理系(コンピュータ)が、逐次的に処理を行なうよう記述された入力プログラムを、並列に処理を行なうプログラムに変換する際、自動並列化解析の結果で得られた並列化指示文を、元のソースプログラム中に生成すると共に、当該並列化指示文の文字列を一方向関数に通すことで求められる一意な文字列をコメント文として、当該並列化指示文と同じ行に生成し、そのプログラムを再び入力して並列化する際に、並列化指示文の文字列を前記と同じ一方向関数に通すことで求められる一意な文字列と、当該プログラム上に記述された、前記並列化指示文の文字列を一方向関数に通すことで求められた一意な文字列との一致を調べることで、その指示文が処理系が自動的に挿入したものであり、かつユーザが変更していないことの検出を行なう。そして、処理系が挿入しかつユーザが変更していない指示文および文字列を並列処理プログラムから削除した後、この並列処理プログラムに対して、並列化指示文とその文字列の自動生成を含む再並列化処理を行なう。
【0015】
【発明の実施の形態】
以下、本発明の実施の形態を、図面により詳細に説明する。
【0016】
図1は、本発明に係わる並列化システムを設けたコンパイラを実行するコンピュータ装置の構成例を示すブロック図であり、図2は、図1のコンピュータ装置によるコンパイル動作時における本発明に係わる並列化処理動作例を示すフローチャート、図3は、図1におけるコンピュータ装置で生成された並列処理プログラムの構成例を示す説明図、図4は、図1における中間語生成部の処理動作例を示すフローチャート、図5は、図1における指示文生成部の処理動作例を示すフローチャートである。
【0017】
図1におけるコンピュータ装置は、CPU(Central Processing Unit)や主メモリ、表示装置、入力装置、外部記憶装置などからなり、例えば光ディスク駆動装置を介してCD−ROMに記録されたプログラムやデータを外部記憶装置内にインストールした後、この外部記憶装置から主メモリに読み込みCPUで処理することにより、本発明に係わる並列化システムとしての機能を具備した並列化コンパイラ11としての各機能を実行する。
【0018】
図1において、10は逐次的に処理を行なうよう記述された入力プログラム(ソースファイル)(図中「入力ソース」と記載)、11は並列化コンパイラ、17は並列化コンパイラ11により入力プログラム10から生成されたコンピュータ実行可能なコード形態の並列処理用オブジェクトプログラム((図中「目的コード」と記載)、18は並列処理用オブジェクトプログラム17のソースファイル(図中「出力ソース」と記載)である。
【0019】
並列化コンパイラ11は,中間語生成部12、並列化解析部13、並列化変換部14、目的コード生成部15、指示文生成部16、および、これらの中間語生成部12により生成され、並列化解析部13、並列化変換部14、目的コード生成部15、指示文生成部16により参照・更新される中間語19と、各処理部12〜16でのコンパイル処理時に生成・参照される情報を格納する各種情報テーブル20からなる。
【0020】
中間語生成部12は、入力プログラム10を読み込み、字句解析、構文解析、意味解析等を行なって、中間語19を生成する。中間語19には、指示文による並列化指示の情報も含まれる。
【0021】
並列化解析部13は、中間語生成部12で生成・登録された中間語19および各種情報テーブル20を参照して、プログラムの制御構造、データの参照関係を解析し、並列化可能なループの判定、及び並列化に必要な通信の決定を行ない、中間語19および各種情報テーブル20を更新する。
【0022】
並列化変換部14は、中間語19および各種情報テーブル20を参照して並列化解析部13での並列化解析の結果を基に、プログラムの制御構造の変換及び通信文の生成等を行ない中間語19および各種情報テーブル20を更新する。
【0023】
目的コード生成部15は、中間語19に対して最適化を行なった後、並列処理用オブジェクトプログラム17を出力する。
【0024】
そして、指示文生成部16は、入力プログラム10を読み込み、これに、並列化解析部13で得られた並列化の情報を基に、並列化指示文を生成して挿入すると共に、この並列化指示文の文字列を一方向関数に通す等することでユニーク(唯一無比)な文字列を生成し、この文字列を並列化指示文と同一の行にコメントとして挿入し、ソースファイル18として出力する。
【0025】
このような構成により、コンピュータ装置は、並列化コンパイラ11としての動作において、指示文生成部16により本発明に係わる並列化処理動作を図2に示すようにして行なう。
【0026】
すなわち、指示文生成部16において、入力プログラム10を読み込み(ステップ201)、並列化解析部13で得られた並列化の情報を基に、並列化指示文を生成してこの入力プログラム10に挿入すると共に(ステップ202)、この並列化指示文の文字列を一方向関数に通す等することでユニーク(唯一無比)な文字列を生成し、この文字列を並列化指示文と同一の行にコメントとして挿入し(ステップ203)、ソースファイル18として出力する(ステップ204)。
【0027】
このような手順で指示文生成部16から出力されたソースファイル18の例を図3に示す。
【0028】
並列化コンパイラ11は、図3に示すプログラムにおいて「DO jループ」が並列化できることが分かるので、指示文生成部16により、そのことを指示する「OpenMP」のPARALLEL DO指示文31(「!$OMP PARALLEL DO PRIVATE (I,J)」)を生成して挿入する。
【0029】
さらに、指示文生成部16は、挿入したPARALLEL DO指示文31と同じ行に、並列化指示文の文字列を一方向関数に通すことで求められる一意な文字列32 (ここではハッシュ値「0123456789fedcba」)を、コメントの形式(「!HASH0123456789fedcba」)で挿入する。
【0030】
このようにして、文字列32を付与することにより、このソースファイル18に対してコンパイルを行なう際には、指示文生成部16において、前回並列化指示文を挿入したときと同じハッシュ関数で並列化指示文の字面からハッシュ値を計算し、例えば中間語生成部12において、このハッシュ値と、ソースファイル18上のハッシュ値とを比較・照合することで、並列化コンパイラ11が自動的に生成した並列化指示文をユーザが変更したか否か自動的に検出して調べることができる。
【0031】
尚、ハッシュ値を記述するコメントには適当なプリフィックスを付加して、ユーザが、ユーザ記述のコメントと混同したり、誤って消去したりすることのないようにする。図3に示す例では、コメント記号(「!」)の後ろに、コンパイラが挿入したハッシュ値であることをしめす「HASH」という文字列を付加している。また、この時用いるハッシュ関数は、値域を十分大きくし、異なる字面に対して同一のハッシュ値が生成されることが実用上起きないようなものを選ぶ。
【0032】
このようにすることにより、ユーザが出力ソースに対して再度指示文を挿入し直したいときに、並列化コンパイラ11が自動生成した並列化指示文のみを更新し、ユーザが挿入した並列化指示文、ならびに、並列化コンパイラ11が自動生成してユーザが変更した並列化指示文には手を加えずに保存することが可能となる。
【0033】
次に、指示文生成部16により並列化指示文と文字列とを生成して入力プログラムに挿入したソースファイル18を再変換する際の本発明に係わる処理動作内容の内、上述した中間語生成部12による、並列化指示文を読み込む処理について図4を用いて説明する。
【0034】
図1の中間語生成部12は、ステップ401の処理において並列化指示文を読み込んだ後、ステップ402の処理において、当該並列化指示文に対して指示文生成オプションが指定されているかどうかによって処理を分ける。
【0035】
指示文生成オプションが指定されていなければ、全ての並列化指示文に従ってコンパイルを行なうようにするため、ステップ405の処理に移動して、従来技術と同様に、無条件に、並列化指示文情報として各種情報テーブル20に登録する。
【0036】
また、指示文生成オプションが指定されていれば、並列化コンパイラ11自身が自動生成した並列化指示文は、再解析して挿入し直し、ユーザ(操作者、プログラマ)が指示した並列化指示文のみを読み込むために、ステップ403,304の処理を行なう。
【0037】
すなわち、ステップ403において、並列化指示文の字面から求めたハッシュ値と、ソースファイル18上にコメントとして埋め込まれたハッシュ値とを比較・照合し、一致しているか否かを調べる。尚、ハッシュ値がソースファイル18上にコメントとして埋め込まれていない場合は、ハッシュ値が一致しないものとみなす。
【0038】
ステップ404において、ハッシュ値が一致し、並列化コンパイラ11自身により自動生成された並列化指示文であると分かった場合は、その指示文の情報はテーブルに登録せずに破棄し(ステップ406)、また、ハッシュ値が一致しない場合は、その指示文をユーザ指示とみなし、ステップ405における処理を実行し、並列化指示文の情報を各種情報テーブル20に取り込む。
【0039】
次に、図5を用いて、図1における指示文生成部16の処理動作を説明する。
【0040】
図1における指示文生成部16は、まず、ステップ501における処理で、入力プログラム10に指示文生成オプションが指定されているか否かを調べ、指定されていない場合は何もせずに終了する。
【0041】
指示文生成オプションが指定されている場合、入力プログラム10中の並列化指示文を全て消去する(ステップ502)。その後、ステップ503〜506における処理を繰り返し、図1の並列化解析部13による並列化解析結果の情報(各種情報テーブル20)を基に、入力プログラム10に対する並列化指示文の生成と挿入を行なう。
【0042】
すなわち、図4の処理により図1の中間語生成部12が生成して各種情報テーブル20に登録した並列化指示文が、並列化コンパイラ11自身が自動生成した並列化指示文であるか否かを判定し(ステップ503)、並列化コンパイラ11自身が自動生成した並列化指示文に対しては、当該並列化指示文の字面からハッシュ値を生成して当該並列化指示文と同一の行に付加して(ステップ504)、また、ユーザが入力した並列化指示文に対しては、当該並列化指示文のみを、入力プログラム10に挿入し(ステップ505)、全ての並列化指示文に対して繰り返す(ステップ506)。
【0043】
尚、並列化指示文が対象とする文または有効域に対して、既に並列化指示文が指定されている場合は、並列化指示文は挿入せず、既に存在している指示文を保存する。ユーザ指示は保存したままで指示文を再生成することが可能となる。
【0044】
以上、図1〜図5を用いて説明したように、本例の並列化コンパイラ11では、コンピュータ装置が、逐次的に処理を行なうよう記述された入力プログラムを、並列に処理を行なうプログラムに変換する際、自動並列化解析の結果で得られた並列化指示文を、元のソースプログラム中に生成すると共に、当該並列化指示文の文字列を一方向関数(ハッシュ関数)に通すことで求められる一意な文字列(ハッシュ値)をコメント文として、当該並列化指示文と同じ行に生成して挿入する。
【0045】
このコメント文により、ユーザは、並列処理用に変換されたプログラムのソースファイルにおける、コンパイラが自動的に生成した並列化指示文を容易に特定することができる。
【0046】
さらに、本例では、並列処理用に変換されたプログラムを再び入力して並列化する際に、並列化指示文の文字列を前記と同じ一方向関数に通すことで求められる一意な文字列と、当該プログラム上に記述された、前記並列化指示文の文字列を一方向関数に通すことで求められた一意な文字列との一致を調べることで、その指示文が処理系(コンピュータ)が自動的に挿入したものであり、かつユーザが変更していないことの検出を自動的に行なうことができる。
【0047】
そして、処理系(コンピュータ)が挿入しかつユーザが変更していない指示文および文字列を並列処理プログラムから削除した後、この並列処理プログラムに対して、並列化指示文とその文字列の自動生成を含む再並列化処理を行なう。
【0048】
このように、並列化コンパイラ11自身が自動生成した並列化指示文の入ったソースプログラム(ソースファイル18)を再びコンパイルする際に、プログラマが記述した並列化指示文と並列化コンパイラ11自身が自動生成した並列化指示文とを区別し、並列化コンパイラ11自身が自動生成した並列化指示文のみを消去し、再生成することにより、並列処理プログラムの再変換を効率的に行なうことができる。
【0049】
尚、本発明は、図1〜図5を用いて説明した例に限定されるものではなく、その要旨を逸脱しない範囲において種々変更可能である。例えば、本例では、本発明の並列化変換システムを並列化コンパイラ11の一機能として説明したが、本発明は、逐次プログラムを入力し、並列化指示文の入ったソースを出力するツールとして実現しても良い。
【0050】
また、本例では、共有メモリ型並列計算機向けの並列化指示仕様であるOpenMPを指示文言語として用いていたが、本発明は、分散メモリ型計算機向けの並列化言語を用いて実施することも可能である。例えば、逐次プログラムを入力とし、分散メモリ型並列計算機向けの並列化解析を行ない、結果を分散メモリ型計算機向けの並列化言語であるHPFの並列化指示文として、入力ソース中に挿入することができる。
【0051】
また、本例では、指示文生成部16で生成した文字列(ハッシュ値)を並列化指示文と同一の行にコメントとして挿入した並列処理プログラムを、ソースファイル18として別ファイルで出力しているが、元の入力プログラム10を置き換えることでも良い。
【0052】
また、コンピュータ構成に関しても、キーボードや光ディスクの駆動装置の無いコンピュータ構成としても良い。また、本例では、光ディスクを記録媒体として用いているが、FD(Flexible Disk)等を記録媒体として用いることでも良い。また、プログラムのインストールに関しても、通信装置を介してネットワーク経由でプログラムをダウンロードしてインストールすることでも良い。
【0053】
【発明の効果】
本発明によれば、並列処理を行なうプログラムにおける並列化を指示する指示文(並列化指示文)が、プログラマが記述したものなのか、処理系(コンピュータ)が以前に自動的に付加したものであるかを、処理系で自動的に判別することができ、逐次的に処理を行なうよう記述されたソースプログラムの、並列に処理を行なうオブジェクトプログラムへの、コンピュータによる自動変換を効率化することが可能である。
【図面の簡単な説明】
【図1】本発明に係わる並列化システムを設けたコンパイラを実行するコンピュータ装置の構成例を示すブロック図である。
【図2】図1のコンピュータ装置によるコンパイル動作時における本発明に係わる並列化処理動作例を示すフローチャートである。
【図3】図1におけるコンピュータ装置で生成された並列処理プログラムの構成例を示す説明図である。
【図4】図1における中間語生成部の処理動作例を示すフローチャートである。
【図5】図1における指示文生成部の処理動作例を示すフローチャートである。
【符号の説明】
10:入力プログラム(「入力ソース」)、11:並列化コンパイラ、12:中間語生成部、13:並列化解析部、14:並列化変換部、15:目的コード生成部、16:指示文生成部、17:オブジェクトプログラム(「目的コード」)、18:ソースファイル(「出力ソース」)、19:中間語、20:各種情報テーブル、31:PARALLEL DO指示文、32:文字列(「ハッシュ値」)。
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a computer program conversion technique, and more particularly to a computer processing technique for converting a program written to perform processing sequentially into a program that performs parallel processing automatically or according to a programmer's instruction. It is.
[0002]
[Prior art]
Conventionally, as a technique for creating a program for performing parallel processing, a programmer inserts a directive for instructing parallelization into a program written to perform processing sequentially, and the computer uses a parallelizing compiler to issue the instruction using a parallelizing compiler. There is a program that analyzes a sentence and converts it into a program that performs parallel processing.
[0003]
For example, in "OpenMP Fortran Application Program Interface Version 2.0, November 2000, http://www.openmp.org/", a programmer loop is defined, which defines OpenMP which is a parallel language for a shared memory type parallel computer. Instruction is inserted into the program, and the compiler performs parallel conversion according to the instruction.
[0004]
However, it is burdensome for a programmer to issue all the parallelization instructions. As a technique for solving this problem, there is a technique in which a computer automatically analyzes the parallelism of a program using a compiler or a parallelization support tool, and generates a result as a parallelization directive in the program.
[0005]
A conventional technique for automatically generating a parallelization directive in a program by such a computer is described in, for example, "Haoqiang Jin, Michael Frumkin, Jerry Yan", "Automatic Generation of OpenMP Direction Appointments and Recommendations. 1940, Issue, pp 440-Lecture Notes in Computer Science.
[0006]
The parallelization directive automatically generated by the computer in this way needs to be a versatile directive such as, for example, an OpenMP directive in order to ensure the portability of the program.
[0007]
However, the prior art has the following problems.
[0008]
That is, a source program to which a directive has been once added by the processing system (computer) may be corrected by the programmer and input to the processing system again. At this time, if the programmer corrects the executable statement, the instruction sent by the processing system in the past may become incorrect. The processing system needs to regenerate such directives so as to match the program modified by the programmer.
[0009]
On the other hand, similar parallelization directives may be manually added by a programmer. Since the processing system must follow the instructions of the programmer, it is necessary to keep such directives unchanged.
[0010]
Here, in order to maintain portability, when the processing system adds a versatile directive such as an OpenMP directive, for example, it is determined whether the directive described in the program is the one described by the programmer. The problem arises that it is not possible to determine whether the system has been automatically added before.
[0011]
For this reason, the processing system cannot correct the instruction sentence generated in the past by the processing system. Alternatively, there is a possibility that the instruction sentence added by the programmer is also modified.
[0012]
[Problems to be solved by the invention]
The problem to be solved is that, in the conventional technique, the instruction to instruct parallelization in a program for performing parallel processing is written by a programmer or automatically added by a processing system (computer) before. Is not determined by the processing system.
[0013]
SUMMARY OF THE INVENTION An object of the present invention is to solve the problems of the prior art, and to improve efficiency of automatic conversion by a computer of a source program written to perform sequential processing into an object program that performs parallel processing. It is to be.
[0014]
[Means for Solving the Problems]
In order to achieve the above object, according to the present invention, when a parallel processing system (computer) converts an input program described so as to perform processing sequentially into a program that performs processing in parallel, it performs automatic parallelization analysis. The parallelization directive obtained as a result is generated in the original source program, and a unique character string obtained by passing the character string of the parallelization directive through a one-way function is used as a comment statement. Generated on the same line as the parallelization directive, and when the program is input again and parallelized, a unique character string obtained by passing the character string of the parallelization directive through the same one-way function as above, By checking the character string of the parallelization directive described in the program with a unique character string obtained by passing the parallelization directive through a one-way function, the directive was automatically inserted by the processing system. What is And to detect that the user has not changed. Then, after deleting the directive and the character string which are inserted by the processing system and not changed by the user from the parallel processing program, the parallel processing program is re-written including the parallelization directive and the automatic generation of the character string. Perform parallel processing.
[0015]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0016]
FIG. 1 is a block diagram showing a configuration example of a computer device that executes a compiler provided with a parallelization system according to the present invention. FIG. 2 is a block diagram showing a parallelization process according to the present invention at the time of compiling operation by the computer device of FIG. 3 is an explanatory diagram showing a configuration example of a parallel processing program generated by the computer device in FIG. 1, FIG. 4 is a flowchart showing a processing operation example of the intermediate language generation unit in FIG. 1, FIG. 5 is a flowchart illustrating an example of a processing operation of the directive generating unit in FIG. 1.
[0017]
1 includes a CPU (Central Processing Unit), a main memory, a display device, an input device, an external storage device, and the like. For example, programs and data recorded on a CD-ROM via an optical disk drive are stored in an external storage device. After being installed in the apparatus, the main memory is read from the external storage device and processed by the CPU, thereby executing each function as the parallelizing compiler 11 having the function as the parallelizing system according to the present invention.
[0018]
In FIG. 1, reference numeral 10 denotes an input program (source file) described so as to perform processing sequentially (described as "input source" in the figure), 11 denotes a parallelizing compiler, 17 denotes a parallelizing compiler 11 A generated object program for parallel processing in the form of a computer-executable code (described as “object code” in the figure), and a source file 18 for the object program 17 for parallel processing (described as “output source” in the figure) .
[0019]
The parallelizing compiler 11 is generated by the intermediate language generation unit 12, the parallelization analysis unit 13, the parallelization conversion unit 14, the object code generation unit 15, the directive generation unit 16, and the intermediate language generation unit 12, and Intermediate language 19 that is referred to and updated by the conversion analysis unit 13, the parallelization conversion unit 14, the object code generation unit 15, and the directive sentence generation unit 16, and information that is generated and referred to at the time of compile processing in each of the processing units 12 to 16. Is stored in the information table 20.
[0020]
The intermediate language generation unit 12 reads the input program 10 and performs lexical analysis, syntax analysis, semantic analysis, and the like to generate an intermediate language 19. The intermediate language 19 also includes information on a parallel instruction by a directive.
[0021]
The parallelization analysis unit 13 refers to the intermediate language 19 and the various information tables 20 generated and registered by the intermediate language generation unit 12 to analyze the control structure of the program and the reference relation of the data, and to determine the loop that can be parallelized. The communication required for the determination and the parallelization is determined, and the intermediate language 19 and the various information tables 20 are updated.
[0022]
The parallelization conversion unit 14 performs conversion of the control structure of the program, generation of a communication message, and the like based on the result of the parallelization analysis by the parallelization analysis unit 13 with reference to the intermediate language 19 and the various information tables 20. The word 19 and the various information tables 20 are updated.
[0023]
After optimizing the intermediate language 19, the target code generation unit 15 outputs the parallel processing object program 17.
[0024]
Then, the directive generation unit 16 reads the input program 10, generates and inserts a parallelization directive into the input program 10 based on the parallelization information obtained by the parallelization analysis unit 13. The character string of the directive is passed through a one-way function to generate a unique (unrivaled) character string, and this character string is inserted as a comment on the same line as the parallelization directive and output as the source file 18 I do.
[0025]
With such a configuration, the computer device performs the parallel processing operation according to the present invention by the directive generating unit 16 as shown in FIG.
[0026]
That is, the instruction sentence generation unit 16 reads the input program 10 (step 201), generates a parallelization instruction sentence based on the parallelization information obtained by the parallelization analysis unit 13, and inserts it into the input program 10. At the same time (step 202), a unique (unrivaled) character string is generated by passing the character string of the parallelization directive through a one-way function, and the character string is placed on the same line as the parallelization directive. It is inserted as a comment (Step 203) and output as the source file 18 (Step 204).
[0027]
FIG. 3 shows an example of the source file 18 output from the instruction generating unit 16 in such a procedure.
[0028]
Since the parallelizing compiler 11 knows that the “DO j loop” can be parallelized in the program shown in FIG. 3, the directive generating unit 16 indicates the PARALLEL DO directive 31 of “OpenMP” (“! OMP PARALLEL DO PRIVATE (I, J) ") is generated and inserted.
[0029]
Furthermore, the directive generation unit 16 generates a unique character string 32 (here, the hash value “012345789 fedcba”) obtained by passing the character string of the parallelization directive through the one-way function on the same line as the inserted PARALLEL DO directive 31. )) Is inserted in the form of a comment (“! HASH012234789feedcba”).
[0030]
By adding the character string 32 in this manner, when compiling the source file 18, the directive generation unit 16 performs parallel processing using the same hash function as when the previous parallelization directive was inserted. The parallelizing compiler 11 automatically calculates a hash value from the character face of the conversion instruction sentence, and compares and compares the hash value with the hash value in the source file 18 in, for example, the intermediate language generation unit 12. It is possible to automatically detect and check whether the user has changed the parallelized instruction sentence.
[0031]
An appropriate prefix is added to the comment describing the hash value so that the user does not confuse the comment with the user description or accidentally delete the comment. In the example shown in FIG. 3, a character string “HASH” indicating that the hash value is inserted by the compiler is added after the comment symbol (“!”). The hash function used at this time is selected so that the value range is sufficiently large and the generation of the same hash value for different character faces does not practically occur.
[0032]
By doing so, when the user wants to reinsert the directive into the output source, only the parallelization directive automatically generated by the parallelizing compiler 11 is updated, and the parallelization directive inserted by the user is updated. , And the parallelization directive automatically generated by the parallelizing compiler 11 and changed by the user can be stored without any modification.
[0033]
Next, among the processing operations according to the present invention when the parallelization directive and the character string are generated by the directive generation unit 16 and the source file 18 inserted into the input program is reconverted, the above-described intermediate language generation The process of reading the parallelization instruction sentence by the unit 12 will be described with reference to FIG.
[0034]
After reading the parallelization directive in the processing of step 401, the intermediate language generation unit 12 of FIG. 1 performs processing in step 402 depending on whether a directive generation option is specified for the parallelization directive. Divide.
[0035]
If the directive generation option is not specified, the process moves to step 405 to compile according to all the parallelization directives, and unconditionally executes the parallelization directive information as in the related art. Is registered in the various information tables 20.
[0036]
If the directive generation option is specified, the parallelization directive automatically generated by the parallelizing compiler 11 itself is re-analyzed and re-inserted, and the parallelization directive issued by the user (operator, programmer). To read only the data, the processing of steps 403 and 304 is performed.
[0037]
That is, in step 403, the hash value obtained from the character face of the parallelization instruction sentence is compared with the hash value embedded as a comment in the source file 18 to check whether or not they match. If the hash value is not embedded in the source file 18 as a comment, it is determined that the hash values do not match.
[0038]
If it is determined in step 404 that the hash values match and the parallelization directive is automatically generated by the parallelizing compiler 11 itself, the information of the directive is discarded without being registered in the table (step 406). If the hash values do not match, the instruction is regarded as a user instruction, the processing in step 405 is executed, and the information on the parallel instruction is fetched into the various information tables 20.
[0039]
Next, the processing operation of the directive generating unit 16 in FIG. 1 will be described with reference to FIG.
[0040]
The instruction generating unit 16 in FIG. 1 first checks whether or not an instruction generating option is specified in the input program 10 in the processing in step 501, and terminates without doing anything if it is not specified.
[0041]
If the directive generation option is specified, all the parallelization directives in the input program 10 are deleted (step 502). Thereafter, the processes in steps 503 to 506 are repeated, and the parallelization instruction sentence for the input program 10 is generated and inserted based on the information (various information tables 20) of the parallelization analysis result by the parallelization analysis unit 13 in FIG. .
[0042]
That is, whether or not the parallelization directive sentence generated by the intermediate language generation unit 12 of FIG. 1 and registered in the various information tables 20 by the processing of FIG. 4 is a parallelization directive sentence automatically generated by the parallelization compiler 11 itself. (Step 503), and for a parallelization directive automatically generated by the parallelizing compiler 11 itself, a hash value is generated from the face of the parallelization directive and the hash value is generated on the same line as the parallelization directive. In addition, for the parallelization directive sent by the user (step 504), only the parallelization directive is inserted into the input program 10 (step 505). (Step 506).
[0043]
If the parallelization directive is already specified for the statement or effective area targeted by the parallelization directive, the parallelization directive is not inserted and the existing directive is saved. . It is possible to regenerate the instruction while retaining the user instruction.
[0044]
As described above with reference to FIGS. 1 to 5, in the parallelizing compiler 11 of the present example, the computer device converts an input program described to perform processing sequentially into a program that performs processing in parallel. At the same time, the parallelization directive obtained as a result of the automatic parallelization analysis is generated in the original source program, and the character string of the parallelization directive is passed through a one-way function (hash function). The generated unique character string (hash value) is generated and inserted as a comment statement on the same line as the parallelization instruction statement.
[0045]
With this comment statement, the user can easily specify the parallelization directive sentence automatically generated by the compiler in the source file of the program converted for parallel processing.
[0046]
Furthermore, in this example, when the program converted for parallel processing is input again and parallelized, a unique character string obtained by passing the character string of the parallelization directive through the same one-way function as above By checking the character string of the parallelization directive described in the program with a unique character string obtained by passing the character string of the parallelization directive through a one-way function, the directive is processed by a processing system (computer). It can be automatically detected that the data has been automatically inserted and has not been changed by the user.
[0047]
Then, after deleting a directive and a character string that the processing system (computer) has inserted and the user has not changed from the parallel processing program, automatic generation of a parallelization directive and a character string for this parallel processing program is performed. Is performed.
[0048]
As described above, when the source program (the source file 18) containing the parallelization directive automatically generated by the parallelization compiler 11 itself is recompiled, the parallelization directive written by the programmer and the parallelization compiler 11 itself are automatically compiled. By distinguishing the generated parallelization directive from the generated parallelization directive and erasing and regenerating only the parallelization directive automatically generated by the parallelizing compiler 11, the parallel processing program can be efficiently re-converted.
[0049]
The present invention is not limited to the examples described with reference to FIGS. 1 to 5 and can be variously modified without departing from the gist thereof. For example, in this example, the parallelization conversion system of the present invention is described as a function of the parallelizing compiler 11, but the present invention is realized as a tool for inputting a sequential program and outputting a source containing a parallelization directive. You may.
[0050]
Further, in this example, OpenMP which is a parallelization instruction specification for a shared memory type parallel computer is used as a directive statement language. However, the present invention may be implemented using a parallelization language for a distributed memory type computer. It is possible. For example, it is possible to input a sequential program, perform parallel analysis for a distributed memory type parallel computer, and insert the result into the input source as a parallelization directive of HPF which is a parallel language for the distributed memory type computer. it can.
[0051]
Further, in this example, a parallel processing program in which the character string (hash value) generated by the directive generation unit 16 is inserted as a comment on the same line as the parallelization directive is output as a source file 18 as a separate file. However, the original input program 10 may be replaced.
[0052]
Further, the computer may be configured without a keyboard or an optical disk drive. In this example, the optical disk is used as the recording medium, but an FD (Flexible Disk) or the like may be used as the recording medium. As for the installation of the program, the program may be downloaded and installed via a network via a communication device.
[0053]
【The invention's effect】
According to the present invention, whether a directive (parallelization directive) instructing parallelization in a program for performing parallel processing is written by a programmer or automatically added before by a processing system (computer). It is possible for the processing system to automatically determine whether or not there is, and it is possible to improve the efficiency of automatic conversion by a computer from a source program written to perform processing sequentially to an object program that performs processing in parallel. It is possible.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a configuration example of a computer device that executes a compiler provided with a parallelization system according to the present invention.
FIG. 2 is a flowchart illustrating an example of a parallel processing operation according to the present invention when a compiling operation is performed by the computer device of FIG. 1;
FIG. 3 is an explanatory diagram illustrating a configuration example of a parallel processing program generated by a computer device in FIG. 1;
FIG. 4 is a flowchart illustrating an example of a processing operation of an intermediate language generation unit in FIG. 1;
FIG. 5 is a flowchart illustrating an example of a processing operation of a directive generation unit in FIG. 1;
[Explanation of symbols]
10: Input program ("input source"), 11: Parallelizing compiler, 12: Intermediate language generating unit, 13: Parallelizing analyzing unit, 14: Parallelizing converting unit, 15: Object code generating unit, 16: Directive statement generating Part, 17: object program (“object code”), 18: source file (“output source”), 19: intermediate language, 20: various information tables, 31: PARALLEL DO directive, 32: character string (“hash value )).

Claims (7)

逐次的に処理を行なうよう記述された入力プログラムの並列性を解析し並列化指示文を生成して該入力プログラムに挿入する第1の手段を有し、該入力プログラムを、並列に処理を行なう並列処理プログラムに変換する並列化変換システムであって、
上記第1の手段で生成した並列化指示文からユニークな文字列を生成し、該並列化指示文と共に挿入する第2の手段と、
入力された上記並列処理プログラムにおける上記文字列と、該文字列が共に挿入された並列化指示文から上記第2の手段により生成される文字列とを照合し一致すれば、該並列化指示文が上記第1の手段により生成され、かつ、ユーザ変更されていないものであると判別する第3の手段と
を有することを特徴とする並列化変換システム。
First means for analyzing the parallelism of an input program written so as to perform processing sequentially, generating a parallelization directive, and inserting the generated instruction into the input program, and processing the input program in parallel A parallel conversion system for converting into a parallel processing program,
A second means for generating a unique character string from the parallelization directive generated by the first means, and inserting the character string together with the parallelization directive;
If the character string in the input parallel processing program is matched with the character string generated by the second means from the parallelization instruction sent with the character string inserted, if the character strings match, the parallelization instruction Is generated by the first means and is determined to have not been changed by the user.
請求項1に記載の並列化変換システムであって、
上記第2の手段は、上記並列化指示文の文字列を一方向関数に通すことで上記文字列を生成し、該文字列を当該並列化指示文と同一の行にコメントとして挿入することを特徴とする並列化変換システム。
The parallelization conversion system according to claim 1, wherein
The second means generates the character string by passing the character string of the parallelization directive through a one-way function, and inserts the character string as a comment on the same line as the parallelization directive. Characterized parallel conversion system.
請求項1、もしくは、請求項2のいずれかに記載の並列化変換システムであって、上記入力プログラムに上記並列化指示文と上記文字列を挿入したプログラムのソースファイルを記憶装置に格納する手段を有することを特徴とする並列化変換システム。3. The parallelization conversion system according to claim 1, wherein a source file of a program in which the parallelization directive and the character string are inserted in the input program is stored in a storage device. A parallel conversion system comprising: コンピュータを、請求項1から請求項3のいずれかに記載の並列化変換システムにおける各手段として機能させるためのプログラム。A program for causing a computer to function as each unit in the parallelization conversion system according to claim 1. 逐次的に処理を行なうよう記述された入力プログラムの並列性を解析し並列化指示文を生成して該入力プログラムに挿入する第1の手順を有し、該入力プログラムを、並列に処理を行なう並列処理プログラムに変換するシステムの並列化変換方法であって、
上記第1の手順で生成した並列化指示文からユニークな文字列を生成し、該並列化指示文と共に挿入する第2の手順と、
入力された上記並列処理プログラムにおける上記文字列と、該文字列が共に挿入された並列化指示文から上記第2の手段により生成される文字列とを照合する第3の手順と、
該照合結果で両文字列が一致すれば、上記並列化指示文が上記第1の手順で生成され、かつ、ユーザ変更されていないものであると判別する第4の手順と、
上記並列処理プログラムから上記文字列と上記特定指示文を削除する第5の手順とを有し、
上記第5の手順で上記文字列と上記特定指示文を削除した上記並列処理プログラムに対して上記第1,第2の手順を実行して、該並列処理プログラムに対する再変換を行なうことを特徴とする並列化変換方法。
A first procedure of analyzing the parallelism of an input program described to be sequentially processed, generating a parallelization directive, and inserting it into the input program, and performing the input program in parallel A parallelization conversion method for a system for converting into a parallel processing program,
A second procedure of generating a unique character string from the parallelization directive generated in the first procedure and inserting the same with the parallelization directive;
A third procedure of comparing the input character string in the parallel processing program with a character string generated by the second means from the parallelization instruction sentence in which the character string is inserted;
If the two character strings match as a result of the collation, a fourth procedure for determining that the parallelization instruction sentence has been generated in the first procedure and has not been changed by the user;
A fifth procedure for deleting the character string and the specific directive from the parallel processing program,
The first and second procedures are executed on the parallel processing program from which the character string and the specific directive have been deleted in the fifth procedure, and the parallel processing program is re-converted. Parallelization conversion method.
請求項5に記載の並列化変換方法であって、
上記第2の手順では、上記並列化指示文の文字列を一方向関数に通すことで上記文字列を生成し、該文字列を当該並列化指示文と同一の行にコメントとして挿入することを特徴とする並列化変換方法。
The parallelization conversion method according to claim 5, wherein
The second procedure includes generating the character string by passing the character string of the parallelization directive through a one-way function, and inserting the character string as a comment on the same line as the parallelization directive. Characteristic parallelization conversion method.
コンピュータに、逐次的に処理を行なうよう記述されたソースプログラムを、並列に処理を行なうオブジェクトプログラムに変換させるコンパイラであって、
上記コンピュータに、
上記ソースプログラムの並列性を解析し並列化指示文を生成して挿入する第1の手順と、
上記並列化指示文からユニークな文字列を生成し、該並列化指示文と共に挿入する第2の手順と、
上記並列化指示文と上記文字列を挿入した上記並列処理プログラムのソースファイルを記憶装置に格納する第3の手順と、
再変換のために入力した上記並列処理プログラムにおける文字列と、該文字列が共に挿入された並列化指示文から上記第2の手順により生成される文字列とが一致すれば、該並列化指示文が上記第1の手順により生成され、かつ、ユーザ変更されていない特定指示文であると判別する第4の手順と、
上記並列処理プログラムから上記文字列と上記特定指示文を削除する第5の手順と、
上記文字列と上記特定指示文を削除した上記並列処理プログラムに対する上記第1〜第3の手順を含めたコンパイル手順とを実行させることを特徴とするコンパイラ。
A compiler for converting a source program written to perform sequential processing to a computer into an object program that performs parallel processing,
In the above computer,
A first procedure for analyzing the parallelism of the source program and generating and inserting a parallelization directive;
A second procedure of generating a unique character string from the parallelization directive and inserting it together with the parallelization directive;
A third procedure of storing a source file of the parallel processing program into which the parallel processing instruction and the character string are inserted, in a storage device;
If the character string input in the parallel processing program for reconversion matches the character string generated by the second procedure from the parallelization instruction sentence in which the character string is inserted, the parallelization instruction A fourth procedure for determining that the sentence is a specific instruction sentence generated by the first procedure and not changed by the user;
A fifth procedure for deleting the character string and the specific directive from the parallel processing program;
A compiler which executes a compile procedure including the first to third procedures for the parallel processing program from which the character string and the specific directive have been deleted.
JP2002182292A 2002-06-24 2002-06-24 Parallelization conversion system, parallelization conversion method, program, and compiler Expired - Fee Related JP4019361B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002182292A JP4019361B2 (en) 2002-06-24 2002-06-24 Parallelization conversion system, parallelization conversion method, program, and compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002182292A JP4019361B2 (en) 2002-06-24 2002-06-24 Parallelization conversion system, parallelization conversion method, program, and compiler

Publications (2)

Publication Number Publication Date
JP2004029982A true JP2004029982A (en) 2004-01-29
JP4019361B2 JP4019361B2 (en) 2007-12-12

Family

ID=31178843

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002182292A Expired - Fee Related JP4019361B2 (en) 2002-06-24 2002-06-24 Parallelization conversion system, parallelization conversion method, program, and compiler

Country Status (1)

Country Link
JP (1) JP4019361B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100749945B1 (en) * 2004-12-02 2007-08-16 에이에스엠엘 네델란즈 비.브이. Lithographic apparatus and device manufacturing method
JP2012510661A (en) * 2008-12-01 2012-05-10 ケーピーアイティ クミンズ インフォシステムズ リミテッド Method and system for parallel processing of sequential computer program code

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100749945B1 (en) * 2004-12-02 2007-08-16 에이에스엠엘 네델란즈 비.브이. Lithographic apparatus and device manufacturing method
JP2012510661A (en) * 2008-12-01 2012-05-10 ケーピーアイティ クミンズ インフォシステムズ リミテッド Method and system for parallel processing of sequential computer program code

Also Published As

Publication number Publication date
JP4019361B2 (en) 2007-12-12

Similar Documents

Publication Publication Date Title
Rodrigues et al. Sparse representation of implicit flows with applications to side-channel detection
US10261889B2 (en) Techniques for edit-and-continue and enhanced optimized debugging on optimized code
US6978450B2 (en) Method and system for optimizing compilation time of a program by selectively reusing object code
US7917899B2 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
US10942718B2 (en) Systems and/or methods for type inference from machine code
JPH07105012A (en) Compiling processing system for language processing program
CN107203535B (en) Information query method and device
WO2015035827A1 (en) Method and apparatus for providing string encryption and decryption in program files
JP2011065220A (en) Compiler program, compilation method and computer system
US8291397B2 (en) Compiler optimized function variants for use when return codes are ignored
TW201502985A (en) Method and device for processing file
JP2008276735A (en) Program code converter and program code conversion method
Ansel et al. PyTorch 2: Faster Machine Learning Through Dynamic Python Bytecode Transformation and Graph Compilation
JP6790869B2 (en) Compilation method, compilation program and information processing equipment
US8887140B2 (en) System and method for annotation-driven function inlining
JP2004029982A (en) Parallelization conversion system, parallelization conversion method, program, and compiler
JP2005165919A (en) Program execution method, program creation method, information processor and program
CN111796832B (en) Hot patch file generation method, device, equipment and storage medium
JP5891976B2 (en) Compile execution / management method, apparatus, and program
JP6326838B2 (en) Program processing apparatus, program processing method, and program processing program
CN113138797A (en) Intel SGX-oriented program automatic transplanting system
CN113260976A (en) Techniques for scheduling instructions in compiled source code
KR102130016B1 (en) Method and system for compiling for automatic caching, and recoding medium therefor
JP2007265098A (en) Macro definition information acquisition device
JP2017151903A (en) Compilation device, compilation method and compilation program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20040813

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070521

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070525

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070719

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: 20070831

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20070913

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101005

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111005

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121005

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121005

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131005

Year of fee payment: 6

LAPS Cancellation because of no payment of annual fees