JP7040272B2 - Source code conversion program and source code conversion method - Google Patents
Source code conversion program and source code conversion method Download PDFInfo
- Publication number
- JP7040272B2 JP7040272B2 JP2018089902A JP2018089902A JP7040272B2 JP 7040272 B2 JP7040272 B2 JP 7040272B2 JP 2018089902 A JP2018089902 A JP 2018089902A JP 2018089902 A JP2018089902 A JP 2018089902A JP 7040272 B2 JP7040272 B2 JP 7040272B2
- Authority
- JP
- Japan
- Prior art keywords
- source code
- offload
- description
- tag
- algorithm information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Stored Programmes (AREA)
Description
本発明は、ソースコード変換プログラムおよびソースコード変換方法に関する。 The present invention relates to a source code conversion program and a source code conversion method.
近年、高位合成等の回路合成技術の進歩により、CやC++等の汎用的なソフトウェア言語でハードウェア設計が行われる場合がある。このため、CPU(Central Processing Unit)で動作するアプリケーションを、高速化のためにFPGA(Field Programmable Gate Array)やGPU(Graphics Processing Unit)等のハードウェアにオフロードして動作させることが提案されている。ところが、多くのアプリケーションは、CPUを対象に記述されており、そのままの記述では、十分なハードウェア性能を引き出すことが難しい。 In recent years, due to advances in circuit synthesis technology such as high-level synthesis, hardware design may be performed in a general-purpose software language such as C or C ++. Therefore, it has been proposed to offload an application running on a CPU (Central Processing Unit) to hardware such as FPGA (Field Programmable Gate Array) or GPU (Graphics Processing Unit) for speeding up. There is. However, many applications are written for the CPU, and it is difficult to bring out sufficient hardware performance with the description as it is.
従って、アプリケーションのソースコードについて、アルゴリズムに対応する部分と、ハードウェアのアーキテクチャに対応する部分とに分類して設計し、これらを纏めてオフロード記述に書き換えることが求められる。このオフロード記述への書き換えは、データ構造の変更、関数呼び出しや繰り返し等の制御構造の変更が多いため自動化が難しく、多大な工数を掛けた人手作業で行うことが一般的である。 Therefore, it is required to design the source code of the application by classifying it into the part corresponding to the algorithm and the part corresponding to the hardware architecture, and rewrite these into the offload description. This rewriting to the offload description is difficult to automate because there are many changes in the data structure and control structures such as function calls and repetitions, and it is common to manually perform a large amount of man-hours.
一方、アプリケーションのソースコードは、バージョンアップやバグ修正等により、頻繁に更新される傾向にある。ソースコードの更新には、パッチと呼ばれるソースコードの差分情報が提供されることが多い。しかしながら、ハードウェアに合わせて書き換えたオフロード記述に対して、ソースコード用のパッチを適用することは困難である。このため、更新後のソースコードに対応するオフロード記述の書き換えは、人手作業で行われることになり、アプリケーションの更新頻度が高い場合、書き換えに掛かる工数が増大することになる。 On the other hand, the source code of an application tends to be updated frequently due to version upgrades and bug fixes. Source code updates are often provided with source code diffs called patches. However, it is difficult to apply a patch for source code to an offload description rewritten according to the hardware. Therefore, the rewriting of the offload description corresponding to the updated source code is performed manually, and if the application is frequently updated, the man-hours required for rewriting will increase.
一つの側面では、アプリケーションの更新があった際に対応するオフロード記述の更新効率を向上できるソースコード変換プログラムおよびソースコード変換方法を提供することにある。 One aspect is to provide a source code conversion program and a source code conversion method that can improve the update efficiency of the corresponding offload description when the application is updated.
一つの態様では、ソースコード変換プログラムは、ソースコードを有するアプリケーションに基づいて、ハードウェアで動作させるオフロード記述に対応する、前記アプリケーションのアルゴリズム情報の挿入箇所をタグで示すとともに前記ハードウェアのアーキテクチャを表すオフロード記述テンプレートを取得する処理をコンピュータに実行させる。ソースコード変換プログラムは、前記ソースコードが更新された場合、更新を反映したソースコードから、前記タグに対応するアルゴリズム情報を抽出する処理をコンピュータに実行させる。ソースコード変換プログラムは、抽出した前記アルゴリズム情報を前記オフロード記述テンプレートの対応する箇所に挿入して前記オフロード記述を更新する処理をコンピュータに実行させる。 In one embodiment, the source code conversion program is based on the application having the source code, and indicates the insertion point of the algorithm information of the application corresponding to the offload description operated by the hardware with a tag and the architecture of the hardware. Causes the computer to execute the process of acquiring the offload description template that represents. When the source code is updated, the source code conversion program causes a computer to execute a process of extracting algorithm information corresponding to the tag from the source code reflecting the update. The source code conversion program inserts the extracted algorithm information into the corresponding portion of the offload description template and causes the computer to execute a process of updating the offload description.
アプリケーションの更新があった際に対応するオフロード記述の更新効率を向上できる。 It is possible to improve the update efficiency of the corresponding offload description when the application is updated.
以下、図面に基づいて、本願の開示するソースコード変換プログラムおよびソースコード変換方法の実施例を詳細に説明する。なお、本実施例により、開示技術が限定されるものではない。また、以下の実施例は、矛盾しない範囲で適宜組みあわせてもよい。 Hereinafter, examples of the source code conversion program and the source code conversion method disclosed in the present application will be described in detail with reference to the drawings. The disclosed technology is not limited by the present embodiment. In addition, the following examples may be appropriately combined as long as they do not contradict each other.
図1は、実施例の変換装置の構成の一例を示すブロック図である。図1に示す変換装置100は、アプリケーション(以下、アプリともいう。)のソースコードをハードウェア記述に変換する処理を行う情報処理装置の一例である。変換装置100は、ソースコードを有するアプリケーションに基づいて、ハードウェアで動作させるオフロード記述に対応するオフロード記述テンプレートを取得する。オフロード記述テンプレートは、アプリケーションのアルゴリズム情報の挿入箇所をタグで示すとともにハードウェアのアーキテクチャを表すものである。変換装置100は、ソースコードが更新された場合、更新を反映したソースコードから、タグに対応するアルゴリズム情報を抽出する。変換装置100は、抽出したアルゴリズム情報をオフロード記述テンプレートの対応する箇所に挿入してオフロード記述を更新する。これにより、変換装置100は、アプリケーションの更新があった際に対応するオフロード記述の更新効率を向上できる。
FIG. 1 is a block diagram showing an example of the configuration of the conversion device of the embodiment. The
まず、図2および図3を用いてソースコードとオフロード記述について説明する。図2は、ソースコードとオフロード記述の一例を示す図である。図2に示すソースコード10およびオフロード記述11は、それぞれ同じ処理を行うものである。なお、ソースコード10は、Cで記述されており、オフロード記述11は、SystemCで記述されている。また、オフロード記述11は、対象ハードウェアに実装するプログラム、または、回路データのコンパイル可能なソースコードである。
First, the source code and the offload description will be described with reference to FIGS. 2 and 3. FIG. 2 is a diagram showing an example of source code and offload description. The
オフロード記述11は、ハードウェア上のアーキテクチャを表現するため、記述12~14に示す点がソースコード10と異なっている。記述12は、入出力に関する記述であり、ソースコード10ではポインタ変数、オフロード記述11ではFIFO(First In First Out)変数となっている。記述13は、ループ構造に関する記述であり、ソースコード10では3個のfor文、オフロード記述11では1個のwhile文となっている。記述14は、変数名や変数へのアクセスに関する記述であり、記述12,13に起因するものである。
Since the
図3は、アルゴリズム情報とオフロード記述テンプレートの一例を示す図である。図3に示すオフロード記述15は、アルゴリズム情報16とオフロード記述テンプレート17とに分類することができる。アルゴリズム情報16は、オフロード記述15の中でデータに対する演算を行っている箇所を示す。オフロード記述テンプレート17は、オフロード記述15の中で入出力とメモリの宣言文、入出力とメモリへのアクセス、および、入出力とメモリへのアクセスを含む制御文を示す。制御文には、例えば、for文、while文、until文の様なループや、if文、else文、switch文の様な条件分岐が含まれる。
FIG. 3 is a diagram showing an example of algorithm information and an offload description template. The
次に、変換装置100の構成について説明する。図1に示すように、変換装置100は、通信部110と、表示部111と、操作部112と、記憶部120と、制御部130とを有する。なお、変換装置100は、図1に示す機能部以外にも既知のコンピュータが有する各種の機能部、例えば各種の入力デバイスや音声出力デバイス等の機能部を有することとしてもかまわない。
Next, the configuration of the
通信部110は、例えば、NIC(Network Interface Card)等によって実現される。通信部110は、図示しないネットワークを介して他の情報処理装置と有線または無線で接続され、他の情報処理装置との間で情報の通信を司る通信インタフェースである。通信部110は、例えば、他の端末からソースコードの更新パッチを受信する。また、通信部110は、他の端末に、更新後のオフロード記述を送信する。 The communication unit 110 is realized by, for example, a NIC (Network Interface Card) or the like. The communication unit 110 is a communication interface that is connected to another information processing device by wire or wirelessly via a network (not shown) and controls information communication with the other information processing device. The communication unit 110 receives, for example, a source code update patch from another terminal. Further, the communication unit 110 transmits the updated offload description to another terminal.
表示部111は、各種情報を表示するための表示デバイスである。表示部111は、例えば、表示デバイスとして液晶ディスプレイ等によって実現される。表示部111は、制御部130から入力された表示画面等の各種画面を表示する。
The
操作部112は、変換装置100のユーザから各種操作を受け付ける入力デバイスである。操作部112は、例えば、入力デバイスとして、キーボードやマウス等によって実現される。操作部112は、ユーザによって入力された操作を操作情報として制御部130に出力する。なお、操作部112は、入力デバイスとして、タッチパネル等によって実現されるようにしてもよく、表示部111の表示デバイスと、操作部112の入力デバイスとは、一体化されるようにしてもよい。
The operation unit 112 is an input device that receives various operations from the user of the
記憶部120は、例えば、RAM(Random Access Memory)、フラッシュメモリ(Flash Memory)等の半導体メモリ素子、ハードディスクや光ディスク等の記憶装置によって実現される。記憶部120は、ソースコード記憶部121と、タグ挿入パッチ記憶部122と、テンプレート記憶部123と、アルゴリズム情報記憶部124と、オフロード記述記憶部125とを有する。また、記憶部120は、制御部130での処理に用いる情報を記憶する。
The
ソースコード記憶部121は、アプリのソースコードを記憶する。また、ソースコード記憶部121は、ソースコードの更新パッチによって更新されたソースコードを記憶する。
The source
タグ挿入パッチ記憶部122は、ソースコードのアルゴリズムが記述された部分を特定する抽出用タグを挿入するためのタグ挿入パッチを記憶する。なお、初回のタグ挿入パッチは、初版のソースコードと、初版のソースコードに人手作業にて抽出用タグを挿入されたタグ挿入済みソースコードとに基づいて生成される。また、初版のソースコードとは、オフロード記述の生成が最初という意味であり、初版のソースコードには、アプリ自体の版数としては任意の版数のものを用いてもよい。
The tag insertion
テンプレート記憶部123は、オフロード記述テンプレートを記憶する。オフロード記述テンプレートは、アプリのアルゴリズム情報の挿入箇所をタグで示すとともに、ハードウェアのアーキテクチャを表すものである。
The
アルゴリズム情報記憶部124は、ソースコードのアルゴリズム部分を抽出したアルゴリズム情報を記憶する。 The algorithm information storage unit 124 stores the algorithm information obtained by extracting the algorithm portion of the source code.
オフロード記述記憶部125は、オフロード記述テンプレートとアルゴリズム情報とに基づいて生成されたオフロード記述を記憶する。
The offload
制御部130は、例えば、CPUやMPU(Micro Processing Unit)等によって、内部の記憶装置に記憶されているプログラムがRAMを作業領域として実行されることにより実現される。また、制御部130は、例えば、ASIC(Application Specific Integrated Circuit)やFPGA等の集積回路により実現されるようにしてもよい。制御部130は、取得部131と、抽出部132と、更新部133とを有し、以下に説明する情報処理の機能や作用を実現または実行する。なお、制御部130の内部構成は、図1に示した構成に限られず、後述する情報処理を行う構成であれば他の構成であってもよい。
The
取得部131は、例えば、通信部110を介して、他の端末から初版のソースコード、タグ挿入済みソースコードおよびオフロード記述テンプレートを取得する。取得部131は、取得した初版のソースコードおよびオフロード記述テンプレートを、それぞれソースコード記憶部121およびテンプレート記憶部123に記憶する。ここで取得するタグ挿入済みソースコードは、初版のソースコードに人手作業にて抽出用タグを挿入されたものである。また、ここで取得するオフロード記述テンプレートは、初版のソースコードから人手作業にて生成されたオフロード記述に対して、アルゴリズム情報に代えて挿入箇所を示すタグを記述したものである。
The acquisition unit 131 acquires the first edition source code, the tag-inserted source code, and the offload description template from another terminal, for example, via the communication unit 110. The acquisition unit 131 stores the acquired first edition source code and the offload description template in the source
取得部131は、初版のソースコードおよびタグ挿入済みソースコードに基づいて、タグ挿入パッチを生成する。取得部131は、生成したタグ挿入パッチをタグ挿入パッチ記憶部122に記憶する。
The acquisition unit 131 generates a tag insertion patch based on the source code of the first edition and the source code in which the tag has been inserted. The acquisition unit 131 stores the generated tag insertion patch in the tag insertion
抽出部132は、例えば、通信部110を介して、他の端末からソースコード更新パッチを取得する。抽出部132は、ソースコード記憶部121からパッチ対象のソースコードを読み出し、読み出したソースコードに対してソースコード更新パッチを適用する。つまり、抽出部132は、ソースコード更新パッチに基づいて、ソースコードを更新する。抽出部132は、更新したソースコードをソースコード記憶部121に記憶する。
The extraction unit 132 acquires a source code update patch from another terminal, for example, via the communication unit 110. The extraction unit 132 reads the source code to be patched from the source
抽出部132は、タグ挿入パッチ記憶部122を参照し、更新したソースコードにタグ挿入パッチを適用する。なお、タグ挿入パッチは、差分情報であるので、ソースコードが更新されても高い確率でタグ挿入箇所を特定できる。抽出部132は、タグ挿入パッチを適用できたか否かを判定する。抽出部132は、タグ挿入パッチを適用できないと判定した場合には、オフロード記述テンプレートの更新を要する旨のメッセージを表示部111に出力して表示させる。
The extraction unit 132 refers to the tag insertion
一方、抽出部132は、タグ挿入パッチを適用できると判定した場合には、タグ挿入済みソースコードを生成する。また、抽出部132は、オフロード記述テンプレートの更新が不要である旨のメッセージを表示部111に出力して表示させる。なお、抽出部132は、タグ挿入パッチに代えて、ソースコードのアルゴリズム情報の抽象構文木を用いて、タグ挿入済みソースコードを生成するようにしてもよい。パッチでは、ソースコードの行、インデント、引数の名前等が一致していないと使えない場合がある。一方、抽象構文木では、多少記述が変わっていてもアルゴリズム情報を抽出してタグ挿入済みソースコードを生成することができる。
On the other hand, when it is determined that the tag insertion patch can be applied, the extraction unit 132 generates the tag-inserted source code. Further, the extraction unit 132 outputs a message to the effect that the offload description template does not need to be updated to the
抽出部132は、生成したタグ挿入済みソースコードからアルゴリズム情報を抽出する。つまり、抽出部132は、タグ挿入済みソースコードのうち、タグで囲まれた箇所を抽出することでアルゴリズム情報を抽出する。抽出部132は、抽出したアルゴリズム情報をアルゴリズム情報記憶部124に記憶する。抽出部132は、アルゴリズム情報をアルゴリズム情報記憶部124に記憶すると、更新指示を更新部133に出力する。 The extraction unit 132 extracts the algorithm information from the generated source code with the tag inserted. That is, the extraction unit 132 extracts the algorithm information by extracting the part surrounded by the tag in the tag-inserted source code. The extraction unit 132 stores the extracted algorithm information in the algorithm information storage unit 124. When the extraction unit 132 stores the algorithm information in the algorithm information storage unit 124, the extraction unit 132 outputs an update instruction to the update unit 133.
言い換えると、抽出部132は、ソースコードが更新された場合、更新を反映したソースコードから、タグに対応するアルゴリズム情報を抽出する。また、抽出部132は、ソースコードが更新された場合、更新を反映したソースコードに、アルゴリズム情報の抽出用タグを挿入し、タグに対応するアルゴリズム情報を抽出する。また、抽出部132は、アルゴリズム情報の抽出用タグを挿入するパッチを用いて、抽出用タグを挿入する。また、抽出部132は、アルゴリズム情報の抽象構文木を用いて、抽出用タグを挿入する。また、抽出部132は、更新を反映したソースコードに、アルゴリズム情報の抽出用タグを挿入できない箇所がある場合、オフロード記述テンプレートの更新を要する旨を通知する。 In other words, when the source code is updated, the extraction unit 132 extracts the algorithm information corresponding to the tag from the source code reflecting the update. Further, when the source code is updated, the extraction unit 132 inserts a tag for extracting algorithm information into the source code reflecting the update, and extracts the algorithm information corresponding to the tag. Further, the extraction unit 132 inserts the extraction tag by using a patch for inserting the extraction tag of the algorithm information. Further, the extraction unit 132 inserts an extraction tag using an abstract syntax tree of algorithm information. Further, the extraction unit 132 notifies that the offload description template needs to be updated when there is a part in the source code reflecting the update where the tag for extracting the algorithm information cannot be inserted.
更新部133は、抽出部132から更新指示が入力されると、テンプレート記憶部123およびアルゴリズム情報記憶部124から、それぞれオフロード記述テンプレートおよびアルゴリズム情報を読み出す。更新部133は、読み出したオフロード記述テンプレートのタグ部分にアルゴリズム情報を挿入してオフロード記述を生成する。更新部133は、生成したオフロード記述をオフロード記述記憶部125に記憶する。
When the update instruction is input from the extraction unit 132, the update unit 133 reads the offload description template and the algorithm information from the
ここで、図4から図9を用いて、ソースコードからオフロード記述への変換の具体例について説明する。図4は、抽出用タグの挿入の一例を示す図である。図4に示すソースコード10は、行番号L6,L9,L12がアルゴリズム部分であるとする。ソースコード10が初版のソースコードである場合には、人手作業によりアルゴリズム情報の抽出用タグが挿入され、タグ挿入済みソースコード18が生成される。ソースコード10が二版以降のソースコードである場合には、抽出部132が、タグ挿入パッチを適用することで、タグ挿入済みソースコード18を生成する。
Here, a specific example of the conversion from the source code to the offload description will be described with reference to FIGS. 4 to 9. FIG. 4 is a diagram showing an example of inserting an extraction tag. In the
アルゴリズム情報の抽出用タグは、アルゴリズム部分の箇所ごとに関数ペアで囲む。つまり、抽出用タグは、例えば、「//_OFFLOAD_BEGIN()」と「//_OFFLOAD_END()」の関数ペアの呼び出しで表現する。また、関数ペアの引数には、アルゴリズム部分の箇所を識別するために、例えば、「offload_1」、「offload_2」、「offload_3」といったIDを与える。 The tag for extracting algorithm information is enclosed in a function pair for each part of the algorithm. That is, the extraction tag is expressed by, for example, calling the function pair of "// _OFFLOAD_BEGIN ()" and "// _ OFFLOAD_END ()". Further, in order to identify the part of the algorithm part, IDs such as "offload_1", "offload_2", and "offload_3" are given to the argument of the function pair.
図5は、タグ挿入パッチの一例を示す図である。図5に示すタグ挿入パッチ19は、初版のソースコードと、タグ挿入済みソースコードとの差分をdiffプログラムによって求めることで生成できる。抽出部132は、一度、差分情報であるタグ挿入パッチ19を生成すると、二版以降のソースコードに、パッチ(patch)プログラムを用いてタグ挿入パッチ19を適用することで、二版以降に対応するタグ挿入済みソースコードを生成できる。
FIG. 5 is a diagram showing an example of a tag insertion patch. The
図6は、アルゴリズム情報の一例を示す図である。図6に示すアルゴリズム情報20は、タグ挿入済みソースコードから抽出用タグの関数ペアで囲まれた箇所を、抽出用タグのIDと対応付けたものである。抽出部132は、例えば、図4に示すタグ挿入済みソースコード18から、「//_OFFLOAD_BEGIN(offload_1)」と「//_OFFLOAD_END(offload_1)」の関数ペアで囲まれた「c[i]=a[i]+b[i];」をアルゴリズムとして抽出する。抽出部132は、例えば、アルゴリズム情報20に示すように、アルゴリズム部分の箇所を識別するIDを引数にとるタグ「//_OFFLOAD_BODY(offload_1)」に続いて抽出したアルゴリズム「c[i]=a[i]+b[i];」をコピーする。抽出部132は、ID「offload_2」、「offload_3」についても同様にアルゴリズムを抽出し、タグと対応付けてコピーして、アルゴリズム情報20を生成する。
FIG. 6 is a diagram showing an example of algorithm information. The
図7は、グルーロジックの挿入の一例を示す図である。図7に示すオフロード記述11は、ソースコード10から人手により書き換え作業が行われた直後の生のオフロード記述である。一方、アルゴリズム情報20は、ソースコード10から抽出されたものであるため、オフロード記述11とはアルゴリズム部分の記述についても一対一の対応が取れない状態である。このため、人手作業によりアルゴリズム情報20の記述を直接オフロード記述に挿入できるように、橋渡しをするグルーロジックを挿入する。オフロード記述21は、オフロード記述11に対してグルーロジックの挿入を行うことでアルゴリズム情報20と整合性をとったものである。
FIG. 7 is a diagram showing an example of inserting glue logic. The
グルーロジックの挿入は、例えば、(1)要素数「1」の配列を定義、(2)ループ変数を定義、(3)入出力(FIFO)のアクセス関数に置換の3つのステップを行う。図7の例では、(1)として、オフロード記述11に、a[1],b[1],c[1],d[1],x[1]を定義する。(2)として、オフロード記述11に、i=0,j=0,k=0を定義する。(3)として、オフロード記述11のFIFOのアクセス方法を、afifo.read(),bfifo.read(),xfifo.write()に置換する。なお、グルーロジック自体は、高位合成ツールの最適化機能により削除される可能性が高く、性能劣化の原因にはなりにくいと考えられる。
Glue logic insertion involves, for example, three steps: (1) defining an array with the number of elements "1", (2) defining a loop variable, and (3) replacing it with an input / output (FIFO) access function. In the example of FIG. 7, as (1), a [1], b [1], c [1], d [1], and x [1] are defined in the
図8は、オフロード記述テンプレートの一例を示す図である。図8に示すオフロード記述テンプレート22は、オフロード記述21からタグ「//_OFFLOAD_BODY()」を残してアルゴリズムの記述を削除したものである。つまり、オフロード記述21のタグ「//_OFFLOAD_BODY()」以外の記述は、ハードウェアのアーキテクチャを表す記述である。
FIG. 8 is a diagram showing an example of an offload description template. The
図9は、オフロード記述の生成の一例を示す図である。図9に示すように、更新部133は、オフロード記述テンプレート22の各タグ「//_OFFLOAD_BODY()」に対して、アルゴリズム情報20の対応するIDのアルゴリズムの記述を挿入し、オフロード記述23を生成する。なお、図9の説明では、ソースコード10から抽出したアルゴリズム情報20を用いたので、オフロード記述23は、オフロード記述21と同じ記述となったが、更新されたソースコードに基づくアルゴリズム情報を用いれば、更新が適用されたオフロード記述となる。
FIG. 9 is a diagram showing an example of generation of an offload description. As shown in FIG. 9, the update unit 133 inserts the algorithm description of the corresponding ID of the
図10は、オフロード記述テンプレートの更新を要する場合におけるパッチプログラムの出力の一例を示す図である。図10に示すメッセージ24は、抽出部132においてタグ挿入パッチを適用できないと判定した場合に出力するメッセージの一例である。メッセージ24は、パッチプログラムが失敗した場合のメッセージであり、「FAILED」を含んだ警告メッセージである。抽出部132は、タグ挿入パッチを適用できないと判定した場合に、メッセージ24を表示してもよいし、メッセージ24に基づいて、例えば「オフロード記述テンプレートの更新が必要です。」といったメッセージを表示するようにしてもよい。なお、抽出部132は、タグ挿入パッチを適用できると判定した場合には、例えば「オフロード記述テンプレートの更新は不要です。」といったメッセージを表示する。
FIG. 10 is a diagram showing an example of the output of the patch program when the offload description template needs to be updated. The
続いて、図11から図13を用いて、タグ挿入パッチに代えて、ソースコードのアルゴリズム情報の抽象構文木を用いる場合について説明する。図11は、抽象構文木における差分の一例を示す図である。図11に示すソースコード25は、Cによる記述であり、抽象構文木26は、ソースコード25に対応する。また、ソースコード27は、ソースコード25を更新するソースコードである。抽象構文木28は、ソースコード27に対応する。ソースコード25とソースコード27とを比較すると、演算子「+」が「*」に更新されている。一方、抽象構文木26と抽象構文木28とを比較すると、演算子に関する記述29aが記述29bに更新されていることがわかる。つまり、記述29a,29bが抽象構文木における差分となる。
Subsequently, the case where the abstract syntax tree of the algorithm information of the source code is used instead of the tag insertion patch will be described with reference to FIGS. 11 to 13. FIG. 11 is a diagram showing an example of the difference in the abstract syntax tree. The
図12は、抽象構文木を用いてアルゴリズム情報の抽出を行う場合の一例を示す図である。図12の例では、抽出部132は、Cで記述されているソースコード30を抽象構文木31に変換し、アルゴリズムに対応する記述32を探索する。記述32は、ソースコード30の関数main中の変数xへの代入文に対応する。抽出部132は、記述32に基づいて、アルゴリズム情報33を抽出する。なお、アルゴリズム情報33では、タグは省略している。抽出部132は、抽出したアルゴリズム情報33に基づいて、タグ挿入済みソースコードを生成する。このように、抽象構文木を用いる場合、パッチの様な行単位ではなく、プログラム言語の文法単位でアルゴリズム箇所を特定できる。また、抽出部132は、抽象構文木を用いることで、プログラム言語変換を行うこともできる。
FIG. 12 is a diagram showing an example of a case where algorithm information is extracted using an abstract syntax tree. In the example of FIG. 12, the extraction unit 132 converts the
図13は、プログラム言語変換の一例を示す図である。図13は、FORTRANのソースコード34をCで記述されたアルゴリズム情報37に変換する場合の一例である。抽出部132は、ソースコード34を抽象構文木35に変換し、アルゴリズムに対応する記述36を探索する。記述36は、ソースコード34の関数main中の変数xへの代入文に対応する。抽出部132は、記述36に基づいて、アルゴリズム情報37を抽出する。抽出部132は、アルゴリズム情報37をCで記述されたソースコードのテンプレートに挿入することで、FORTRANからCに言語変換を行うことができる。なお、抽出部132は、アルゴリズム情報37に基づいて、オフロード記述を生成してもよい。
FIG. 13 is a diagram showing an example of programming language conversion. FIG. 13 is an example of converting the
次に、実施例の変換装置100の動作について説明する。まず、図14を用いて初回抽出処理について説明する。図14は、実施例の初回抽出処理の一例を示すフローチャートである。
Next, the operation of the
取得部131は、例えば、他の端末から初版のソースコード、タグ挿入済みソースコードおよびオフロード記述テンプレートを取得する(ステップS1)。取得部131は、取得した初版のソースコードおよびオフロード記述テンプレートを、それぞれソースコード記憶部121およびテンプレート記憶部123に記憶する。
The acquisition unit 131 acquires, for example, the source code of the first edition, the source code with the tag inserted, and the offload description template from another terminal (step S1). The acquisition unit 131 stores the acquired first edition source code and the offload description template in the source
取得部131は、初版のソースコードおよびタグ挿入済みソースコードに基づいて、タグ挿入パッチを生成する(ステップS2)。取得部131は、生成したタグ挿入パッチをタグ挿入パッチ記憶部122に記憶する。
The acquisition unit 131 generates a tag insertion patch based on the source code of the first edition and the source code in which the tag has been inserted (step S2). The acquisition unit 131 stores the generated tag insertion patch in the tag insertion
抽出部132は、タグ挿入済みソースコードからアルゴリズム情報を抽出する(ステップS3)。抽出部132は、抽出したアルゴリズム情報をアルゴリズム情報記憶部124に記憶する。これにより、変換装置100は、初版のソースコード、タグ挿入パッチ、オフロード記述テンプレート、および、アルゴリズム情報を記憶し、二版以降のソースコード変換処理の準備を整えることができる。すなわち、変換装置100は、アプリのアルゴリズム情報と、ハードウェア実装上のアーキテクチャを表すオフロード記述テンプレートとを分離して管理することができる。
The extraction unit 132 extracts the algorithm information from the tag-inserted source code (step S3). The extraction unit 132 stores the extracted algorithm information in the algorithm information storage unit 124. As a result, the
続いて、図15を用いてソースコードが更新された場合における変換処理について説明する。図15は、実施例の変換処理の一例を示すフローチャートである。 Subsequently, the conversion process when the source code is updated will be described with reference to FIG. FIG. 15 is a flowchart showing an example of the conversion process of the embodiment.
抽出部132は、例えば、他の端末からソースコード更新パッチを取得する(ステップS11)。抽出部132は、ソースコード更新パッチに基づいて、ソースコードを更新する(ステップS12)。抽出部132は、更新したソースコードをソースコード記憶部121に記憶する。
The extraction unit 132 acquires, for example, a source code update patch from another terminal (step S11). The extraction unit 132 updates the source code based on the source code update patch (step S12). The extraction unit 132 stores the updated source code in the source
抽出部132は、タグ挿入パッチ記憶部122を参照し、更新したソースコードにタグ挿入パッチを適用する(ステップS13)。抽出部132は、タグ挿入パッチを適用できたか否かを判定する(ステップS14)。抽出部132は、タグ挿入パッチを適用できると判定した場合には(ステップS14:肯定)、タグ挿入済みソースコードを生成する(ステップS15)。
The extraction unit 132 refers to the tag insertion
抽出部132は、オフロード記述テンプレートの更新が不要である旨のメッセージを表示部111に出力して表示させる(ステップS16)。抽出部132は、生成したタグ挿入済みソースコードからアルゴリズム情報を抽出する(ステップS17)。抽出部132は、抽出したアルゴリズム情報をアルゴリズム情報記憶部124に記憶し、更新指示を更新部133に出力する。
The extraction unit 132 outputs a message to the effect that the offload description template does not need to be updated to the
更新部133は、抽出部132から更新指示が入力されると、テンプレート記憶部123およびアルゴリズム情報記憶部124から、それぞれオフロード記述テンプレートおよびアルゴリズム情報を読み出す。更新部133は、読み出したオフロード記述テンプレートのタグ部分にアルゴリズム情報を挿入してオフロード記述を生成する(ステップS18)。更新部133は、生成したオフロード記述をオフロード記述記憶部125に記憶し、変換処理を終了する。
When the update instruction is input from the extraction unit 132, the update unit 133 reads the offload description template and the algorithm information from the
一方、抽出部132は、ステップS14において、タグ挿入パッチを適用できないと判定した場合には(ステップS14:否定)、オフロード記述テンプレートの更新を要する旨のメッセージを表示部111に出力して表示させ(ステップS19)、変換処理を終了する。これにより、変換装置100は、アプリケーションの更新があった際に対応するオフロード記述の更新効率を向上できる。つまり、変換装置100は、アプリまたはハードウェアの変更に対して柔軟な更新が可能となる。また、変換装置100は、タグ挿入パッチを適用できないと判定した場合に、更新したソースコードの対象箇所を容易に特定できる。従って、変換装置100は、オフロード記述テンプレートの変更箇所も容易に特定できる。
On the other hand, when the extraction unit 132 determines in step S14 that the tag insertion patch cannot be applied (step S14: negation), the extraction unit 132 outputs and displays a message to the effect that the offload description template needs to be updated to the
なお、上記実施例では、アプリのソースコードをCまたはC++、オフロード記述をSystemCで記述した場合について説明したが、これに限定されない。例えば、アプリのソースコードとして、FORTRAN、COBOL、Java(登録商標)、Perl、Python、Ruby等の各種の言語のソースコードを用いることができる。また、例えば、オフロード記述として、SystemVerilog等の各種の言語のオフロード記述を用いることができる。 In the above embodiment, the case where the source code of the application is described in C or C ++ and the offload description is described in SystemC has been described, but the present invention is not limited to this. For example, as the source code of the application, source codes of various languages such as FORTRAN, COBOL, Java (registered trademark), Perl, Python, and Ruby can be used. Further, for example, as the offload description, an offload description of various languages such as SystemVerilog can be used.
このように、変換装置100は、ソースコードを有するアプリケーションに基づいて、ハードウェアで動作させるオフロード記述に対応する、アプリケーションのアルゴリズム情報の挿入箇所をタグで示すとともにハードウェアのアーキテクチャを表すオフロード記述テンプレートを取得する。また、変換装置100は、ソースコードが更新された場合、更新を反映したソースコードから、タグに対応するアルゴリズム情報を抽出する。また、変換装置100は、抽出したアルゴリズム情報をオフロード記述テンプレートの対応する箇所に挿入してオフロード記述を更新する。その結果、変換装置100は、アプリケーションの更新があった際に対応するオフロード記述の更新効率を向上できる。
As described above, the
また、変換装置100は、ソースコードが更新された場合、更新を反映したソースコードに、アルゴリズム情報の抽出用タグを挿入し、タグに対応するアルゴリズム情報を抽出する。その結果、変換装置100は、更新されたソースコードに対応するアルゴリズム情報を取得できる。
Further, when the source code is updated, the
また、変換装置100は、アルゴリズム情報の抽出用タグを挿入するパッチを用いて、抽出用タグを挿入する。その結果、変換装置100は、アルゴリズムに関する記述を特定できる。
Further, the
また、変換装置100は、アルゴリズム情報の抽象構文木を用いて、抽出用タグを挿入する。その結果、変換装置100は、アルゴリズムに関する記述を特定できる。
Further, the
また、変換装置100は、更新を反映したソースコードに、アルゴリズム情報の抽出用タグを挿入できない箇所がある場合、オフロード記述テンプレートの更新を要する旨を通知する。その結果、変換装置100は、ハードウェアのアーキテクチャに関する部分の更新があったことをユーザに知らせることができる。
Further, the
また、図示した各部の各構成要素は、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各部の分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況等に応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。例えば、抽出部132と更新部133とを統合してもよい。また、図示した各処理は、上記の順番に限定されるものでなく、処理内容を矛盾させない範囲において、同時に実施してもよく、順序を入れ替えて実施してもよい。 Further, each component of each of the illustrated parts does not necessarily have to be physically configured as shown in the figure. That is, the specific form of distribution / integration of each part is not limited to the one shown in the figure, and all or part of them may be functionally or physically distributed / integrated in any unit according to various loads and usage conditions. Can be configured. For example, the extraction unit 132 and the update unit 133 may be integrated. Further, the illustrated processes are not limited to the above order, and may be performed simultaneously or in a different order as long as the processing contents do not contradict each other.
さらに、各装置で行われる各種処理機能は、CPU(またはMPU、MCU(Micro Controller Unit)等のマイクロ・コンピュータ)上で、その全部または任意の一部を実行するようにしてもよい。また、各種処理機能は、CPU(またはMPU、MCU等のマイクロ・コンピュータ)で解析実行されるプログラム上、またはワイヤードロジックによるハードウェア上で、その全部または任意の一部を実行するようにしてもよいことは言うまでもない。 Further, the various processing functions performed by each device may be executed on the CPU (or a microcomputer such as an MPU or a MCU (Micro Controller Unit)) in whole or in any part thereof. In addition, various processing functions may be executed in whole or in any part on a program analyzed and executed by a CPU (or a microcomputer such as an MPU or MCU) or on hardware by wired logic. Needless to say, it's good.
ところで、上記の各実施例で説明した各種の処理は、予め用意されたプログラムをコンピュータで実行することで実現できる。そこで、以下では、上記の各実施例と同様の機能を有するプログラムを実行するコンピュータの一例を説明する。図16は、ソースコード変換プログラムを実行するコンピュータの一例を示す図である。 By the way, various processes described in each of the above embodiments can be realized by executing a program prepared in advance on a computer. Therefore, in the following, an example of a computer that executes a program having the same functions as those of the above embodiments will be described. FIG. 16 is a diagram showing an example of a computer that executes a source code conversion program.
図16に示すように、コンピュータ200は、各種演算処理を実行するCPU201と、データ入力を受け付ける入力装置202と、モニタ203とを有する。また、コンピュータ200は、記憶媒体からプログラム等を読み取る媒体読取装置204と、各種装置と接続するためのインタフェース装置205と、他の情報処理装置等と有線または無線により接続するための通信装置206とを有する。また、コンピュータ200は、各種情報を一時記憶するRAM207と、ハードディスク装置208とを有する。また、各装置201~208は、バス209に接続される。
As shown in FIG. 16, the
ハードディスク装置208には、図1に示した取得部131、抽出部132および更新部133の各処理部と同様の機能を有するソースコード変換プログラムが記憶される。また、ハードディスク装置208には、ソースコード記憶部121、タグ挿入パッチ記憶部122、テンプレート記憶部123、アルゴリズム情報記憶部124、オフロード記述記憶部125、および、ソースコード変換プログラムを実現するための各種データが記憶される。入力装置202は、例えば、コンピュータ200のユーザから操作情報等の各種情報の入力を受け付ける。モニタ203は、例えば、コンピュータ200のユーザに対して表示画面等の各種画面を表示する。インタフェース装置205は、例えば印刷装置等が接続される。通信装置206は、例えば、図1に示した通信部110と同様の機能を有し図示しないネットワークと接続され、他の情報処理装置と各種情報をやりとりする。
The hard disk device 208 stores a source code conversion program having the same functions as the processing units of the acquisition unit 131, the extraction unit 132, and the update unit 133 shown in FIG. Further, the hard disk device 208 is for realizing a source
CPU201は、ハードディスク装置208に記憶された各プログラムを読み出して、RAM207に展開して実行することで、各種の処理を行う。また、これらのプログラムは、コンピュータ200を図1に示した取得部131、抽出部132および更新部133として機能させることができる。
The
なお、上記のソースコード変換プログラムは、必ずしもハードディスク装置208に記憶されている必要はない。例えば、コンピュータ200が読み取り可能な記憶媒体に記憶されたプログラムを、コンピュータ200が読み出して実行するようにしてもよい。コンピュータ200が読み取り可能な記憶媒体は、例えば、CD-ROMやDVD(Digital Versatile Disc)、USB(Universal Serial Bus)メモリ等の可搬型記録媒体、フラッシュメモリ等の半導体メモリ、ハードディスクドライブ等が対応する。また、公衆回線、インターネット、LAN等に接続された装置にこのソースコード変換プログラムを記憶させておき、コンピュータ200がこれらからソースコード変換プログラムを読み出して実行するようにしてもよい。
The above source code conversion program does not necessarily have to be stored in the hard disk device 208. For example, the
100 変換装置
110 通信部
111 表示部
112 操作部
120 記憶部
121 ソースコード記憶部
122 タグ挿入パッチ記憶部
123 テンプレート記憶部
124 アルゴリズム情報記憶部
125 オフロード記述記憶部
130 制御部
131 取得部
132 抽出部
133 更新部
100 Conversion device 110
Claims (6)
前記ソースコードが更新された場合、更新を反映したソースコードから、前記タグに対応するアルゴリズム情報を抽出し、
抽出した前記アルゴリズム情報を前記オフロード記述テンプレートの対応する箇所に挿入して前記オフロード記述を更新する、
処理をコンピュータに実行させることを特徴とするソースコード変換プログラム。 Based on the application having the source code, the offload description template corresponding to the offload description to be operated by the hardware is obtained by indicating the insertion point of the algorithm information of the application with a tag and representing the architecture of the hardware.
When the source code is updated, the algorithm information corresponding to the tag is extracted from the source code reflecting the update.
The extracted algorithm information is inserted into the corresponding part of the offload description template to update the offload description.
A source code conversion program characterized by having a computer execute processing.
ことを特徴とする請求項1に記載のソースコード変換プログラム。 In the extraction process, when the source code is updated, a tag for extracting the algorithm information is inserted into the source code reflecting the update, and the algorithm information corresponding to the tag is extracted.
The source code conversion program according to claim 1.
ことを特徴とする請求項2に記載のソースコード変換プログラム。 In the extraction process, the extraction tag is inserted by using a patch for inserting the extraction tag of the algorithm information.
The source code conversion program according to claim 2.
ことを特徴とする請求項2に記載のソースコード変換プログラム。 In the extraction process, the extraction tag is inserted using the abstract syntax tree of the algorithm information.
The source code conversion program according to claim 2.
ことを特徴とする請求項2~4のいずれか1つに記載のソースコード変換プログラム。 The extraction process notifies that the offload description template needs to be updated when there is a part in the source code reflecting the update where the tag for extracting the algorithm information cannot be inserted.
The source code conversion program according to any one of claims 2 to 4, wherein the source code conversion program is characterized by the above.
前記ソースコードが更新された場合、更新を反映したソースコードから、前記タグに対応するアルゴリズム情報を抽出し、
抽出した前記アルゴリズム情報を前記オフロード記述テンプレートの対応する箇所に挿入して前記オフロード記述を更新する、
処理をコンピュータが実行することを特徴とするソースコード変換方法。 Based on the application having the source code, the offload description template corresponding to the offload description to be operated by the hardware is obtained by indicating the insertion point of the algorithm information of the application with a tag and representing the architecture of the hardware.
When the source code is updated, the algorithm information corresponding to the tag is extracted from the source code reflecting the update.
The extracted algorithm information is inserted into the corresponding part of the offload description template to update the offload description.
A source code conversion method characterized by a computer performing processing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018089902A JP7040272B2 (en) | 2018-05-08 | 2018-05-08 | Source code conversion program and source code conversion method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018089902A JP7040272B2 (en) | 2018-05-08 | 2018-05-08 | Source code conversion program and source code conversion method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2019197308A JP2019197308A (en) | 2019-11-14 |
JP7040272B2 true JP7040272B2 (en) | 2022-03-23 |
Family
ID=68538393
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2018089902A Active JP7040272B2 (en) | 2018-05-08 | 2018-05-08 | Source code conversion program and source code conversion method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP7040272B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113821278B (en) * | 2021-09-06 | 2024-05-03 | 挂号网(杭州)科技有限公司 | Calling image size method, device, electronic equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003280956A (en) | 2002-03-26 | 2003-10-03 | Hitachi Software Eng Co Ltd | Database case device |
US20100122234A1 (en) | 2008-11-12 | 2010-05-13 | International Business Machines Corporation | System and method for reconciling software source code |
JP2014153777A (en) | 2013-02-05 | 2014-08-25 | Tokyo Kogei Univ | Source code inspection device |
JP2015198473A (en) | 2014-03-31 | 2015-11-09 | パナソニックIpマネジメント株式会社 | Cabinet for distribution board with measuring unit and distribution board |
WO2017210202A1 (en) | 2016-06-01 | 2017-12-07 | The Mathworks, Inc. | Systems and methods for creating model adaptors |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2015198473A1 (en) * | 2014-06-27 | 2015-12-30 | 富士通株式会社 | Test program, test device, and test method |
-
2018
- 2018-05-08 JP JP2018089902A patent/JP7040272B2/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003280956A (en) | 2002-03-26 | 2003-10-03 | Hitachi Software Eng Co Ltd | Database case device |
US20100122234A1 (en) | 2008-11-12 | 2010-05-13 | International Business Machines Corporation | System and method for reconciling software source code |
JP2014153777A (en) | 2013-02-05 | 2014-08-25 | Tokyo Kogei Univ | Source code inspection device |
JP2015198473A (en) | 2014-03-31 | 2015-11-09 | パナソニックIpマネジメント株式会社 | Cabinet for distribution board with measuring unit and distribution board |
WO2017210202A1 (en) | 2016-06-01 | 2017-12-07 | The Mathworks, Inc. | Systems and methods for creating model adaptors |
Also Published As
Publication number | Publication date |
---|---|
JP2019197308A (en) | 2019-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4396994B2 (en) | Resource file translation verification method, apparatus, and program | |
US9037595B2 (en) | Creating graphical models representing control flow of a program manipulating data resources | |
US20120174061A1 (en) | Code suggestion in a software development tool | |
US9202021B2 (en) | License verification method and apparatus, and computer readable storage medium storing program therefor | |
US10929149B2 (en) | Method and system for updating firmware | |
CN110990023A (en) | aar file dependency uploading method and device, storage medium and electronic equipment | |
CN105446725A (en) | Method and system for model driven development | |
US20080059957A1 (en) | Method of compiling source code, compiler, computer system, and computer program product | |
CN111078262A (en) | Application thermal restoration method and device | |
CN110109671A (en) | A kind of webpack label sizes pattern conversion method and device | |
CN110659210A (en) | Information acquisition method and device, electronic equipment and storage medium | |
CN107797805B (en) | Code packaging method and device and computer readable storage medium | |
US20070100897A1 (en) | System and method for automatic instance data mapping generation | |
CN112256670A (en) | Data migration method, terminal device and readable storage medium | |
JP7040272B2 (en) | Source code conversion program and source code conversion method | |
US20170329587A1 (en) | Program conversion method using comment-based pseudo-codes and computerreadable recording medium, onto which program is recorded, for implementing | |
JP2011008358A (en) | Information processor and information processing method | |
US20150268954A1 (en) | Apparatus and method for identifying correspondence between an installed program and an interface in a source code | |
US8276132B1 (en) | System and method for representing and managing a multi-architecture co-processor application program | |
JP6651974B2 (en) | Information processing apparatus, compiling method and compiler program | |
US9720690B2 (en) | Software architecture by untangling undesired code level dependencies using code refactoring | |
US20170017471A1 (en) | Multi-flavored software execution from a singular code base | |
US20170228243A1 (en) | Non-transitory computer-readable recording medium storing control program, control device and control method | |
US10983813B2 (en) | Automatic repetition of context-specific code edits | |
JP2018005315A (en) | Regulation conversion support apparatus and regulation conversion support program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20210210 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20220119 |
|
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: 20220208 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220221 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 7040272 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |