JP3918274B2 - COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM - Google Patents

COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM Download PDF

Info

Publication number
JP3918274B2
JP3918274B2 JP01416898A JP1416898A JP3918274B2 JP 3918274 B2 JP3918274 B2 JP 3918274B2 JP 01416898 A JP01416898 A JP 01416898A JP 1416898 A JP1416898 A JP 1416898A JP 3918274 B2 JP3918274 B2 JP 3918274B2
Authority
JP
Japan
Prior art keywords
instruction
prefetch
processing
intermediate text
memory
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.)
Expired - Fee Related
Application number
JP01416898A
Other languages
Japanese (ja)
Other versions
JPH11212802A (en
Inventor
政人 森島
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP01416898A priority Critical patent/JP3918274B2/en
Publication of JPH11212802A publication Critical patent/JPH11212802A/en
Application granted granted Critical
Publication of JP3918274B2 publication Critical patent/JP3918274B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Advance Control (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は原始プログラムを中間テキストに変換し、変換した中間テキストに対して最適化を行い、機械語を生成するコンパイル装置において、データキャッシュを有効に活用したプログラムを生成して実行時性能を向上するようにしたコンパイル装置に関する。
【0002】
【従来の技術】
コンピュータの性能は従来より種々の技術的改良により飛躍的に向上してきている。特にその中心であるCPUについても命令実行速度の向上が著しいRISC(Reduced Instruction Set Computer)型アーキテクチャが多く採用されている。一方主記憶装置(メモリ)はCPUに比較してあまり早くなっていない。このような状態のとき、データをメモリからロードしようとすると、メモリから長い時間(CPUに比べて相対的に)をかけて演算のためのレジスタに格納されるので、その完了を待って短い演算処理時間の後結果が得られることになる。すなわち、高速化されたCPUもメモリにあるデータの処理の大部分をメモリからレジスタへのロード時間待ちのために全体としての性能向上はわずかなものとなってしまうことになる。
【0003】
このようなRISC型アーキテクチャにおいては、演算に使用されるデータは必ずレジスタに格納されている必要があり、従来の汎用コンピュータのように、演算命令のオペランドにメモリを指定するアドレッシング方法は行われない。また、CPU時間とメモリのアクセス時間の比較をしてみると、マシンサイクルをτとするとほとんどの演算命令が1τから数τの程度であるのに比較してメモリの動作時間は数十τ必要である。すなわち、実行時間の大部分はメモリアクセスの待ち時間(レイテンシとも言う)に費やされてしまうことになる。
【0004】
この遅延時間を減らすことがRISC型アーキテクチャにおける性能向上の要件ということになる。そこで、このために考案されたのがデータキャッシュ機能であり、メモリを階層化してアクセスの早いキャッシュメモリを備えるもので、現在のCPUのほとんどに実装されている。データキャッシュはその名のとおりメモリの内容を一時的にため込んでおいて、繰り返し使用できればアクセスのおそいメモリに対するアクセス回数を減らすことができる。しかし、データキャッシュは大変速く動作する変わりに実装される容量は小さい。
【0005】
CPUから近い順に一次キャッシュ、二次キャッシュ、メモリで階層的に構成される場合、CPUからロード要求があった時の遅延時間の程度を先に述べたマシンサイクル時間τにより例示すると、一次キャッシュにデータが存在している場合は0τ、二次キャッシュにあれば一次キャッシュへのコピーを伴い10τ、メモリに要求データがあれば一次/二次キャッシュへのコピーを伴い100τの遅延時間が伴うことになる。このように、ロード命令が実行されるとき目的のデータが上記したCPUに近い階層に存在する場合ほど待ち時間が少なく処理が高速に行われるようになる。
【0006】
上記のように従来のコンピュータにおいても、メモリを階層化してアクセスの早いキャッシュメモリを備え、繰り返しアクセスされるメモリ上のデータ群についてのアクセスの高速化が実現されていた。また、単に一度アクセスされたメモリ上のデータ群についてのアクセス高速化を期待するだけでなく積極的に実行されるプログラムの命令を解析して後に実行されるはずのメモリアクセスを伴う命令について前以って必要部分を通常のメモリから高速のキャッシュメモリにデータをコピーしておく工夫も開示されている。例えば、特開平8−161226にはキャッシュメモリを使用するシステムにおけるデータ先読み制御方法として、ロード命令のアクセス対象となるデータの配置パターンに応じたタイプによってロード命令の種類を分けて、この種類をオペレーション・コード等により識別できるようにして、ロード命令が先に発行したロード命令と関係づけられるとき、先行するロード命令の処理時に、ロード命令の種類に応じて後続するロード命令のロードアドレスを予測し、そのデータをキャッシュメモリに先読みする技術が示されている。
【0007】
従来はこの様にプログラムの実行時にハード的に先読みの効果のある条件を検出してデータキャッシュの活用をすすめていたが、最近ソフト的に命令によりデータキャッシュにメモリの内容を先読みする機能すなわちデータプリフェッチ命令を持ったコンピュータが開発されるようになってきた。このデータプリフェッチ命令を利用したデータキャッシュの活用が期待されている。
【0008】
【発明が解決しようとする課題】
上記したようにメモリ上のデータをロードするときの待ちによる遅延時間は繰り返しアクセスされるデータ群についてはデータキャッシュにより格段に削減されるが、データキャッシュに存在しないときには効果が無い。上記公知例に示すような条件のとき実行時に先読みで期待される効果を検出して事前にロードされるデータをデータキャッシュに先読みするものもあるが上記ロード命令の条件に合わない場合にはデータキャッシュの高速アクセスを有効に活用できていない。
【0009】
従来はこの様にプログラムの実行時にハード的に先読みの効果のある条件を検出してデータキャッシュの活用をすすめていたが、実行時に検出できるようなデータキャッシュを有効とするメモリ先読みの条件は限られたものとなり、プログラム作成段階でのデータキャッシュの活用手続きの組み込みが課題でありその解決策が求められていた。
【0010】
本発明はこのような点にかんがみて、ソースプログラム作成段階あるいはコンパイル段階でプログラムの構造の特徴を解析してロード命令に先立ってデータキャッシュに必要なメモリの内容をコピーしておくようにする手段を提供することを目的とする。
【0011】
【課題を解決するための手段】
上記の課題は下記の如くに構成されたコンパイル装置によって解決される。
図1は、本発明の構成図である。
【0012】
図において、1は原始プログラムを中間テキストに変換し、変換した中間テキストに対して最適化を行い、機械語を生成するコンパイル装置において、あらかじめ設定された1以上の原始プログラム命令種類に対応して変換された中間テキストを検索する中間テキスト検索手段であり、2は検索した中間テキストに基づいてデータキャッシュへコピーするメモリのアドレスを算出し、検索した中間テキストより前の実行順序位置に上記算出したアドレスを指定したデータキャッシュプリフェッチ命令を挿入するプリフェッチ命令挿入手段である。(請求項1)
3は上記検索した中間テキストの実行順序位置から、あらかじめ原始プログラム命令種類毎に設定された遡及すべきプログラム実行時間に基づいてプログラムの制御の流れをさかのぼり、上記プリフェッチ命令を挿入する実行順序位置を決定するプリフェッチ命令挿入位置最適化手段である(請求項2)。
【0013】
また、上記コンパイル装置は複数の単純な命令を複数のスロットに格納して構成するVLIW命令を持つVLIW型アーキテクチャのコンピュータで実行するプログラムを生成するコンパイル装置であって、プリフェッチ命令挿入手段2は空きスロットにデータキャッシュプリフェッチ命令を生成するものであるとき、4は空きスロットがないときに、データキャッシュプリフェッチ命令の挿入を抑止するか、新たに独立したVLIW命令を生成するかを設定するプリフェッチ命令挿入モード設定手段である(請求項7)。
【0014】
【発明の実施の形態】
図2は本発明の実施の形態の構成図である。
22はコンパイル装置であり、ソースプログラム21で示される原始プログラムをソースプログラム解析部23で中間テキストに変換し、変換した中間テキストに対して最適化実施部24で最適化を行い、スケジューリング&コード生成部25でオブジェクトプログラム26で示す機械語を生成するものである。本発明の特徴とするデータキャッシュプリフェッチ命令の生成と挿入の制御は上記最適化実施部24で行うようになっている。コンパイル装置22はコンピュータ上で動作するものである。
【0015】
すなわち、本実施の形態においては、パーソナルコンピュータ、ワークステーション等の汎用的な目的で使用される計算機上で実行するコンピュータプログラムにより実現する形態を示す。
【0016】
本発明のコンパイル装置は、処理装置、主記憶装置、補助記憶装置、入出力装置などから構成される計算機上で、コンピュータプログラムを実行して実現される。また、コンピュータプログラムは、フロッピーディスクやCD−ROM等の可搬型媒体やネットワーク接続された他の計算機の主記憶装置や補助記憶装置等に格納されて提供される。本発明の記録媒体は、上記可搬型媒体、主記憶装置、補助記憶装置に該当する。
【0017】
提供されたコンピュータプログラムは、可搬型媒体から直接計算機の主記憶装置にロードされ、または、可搬型媒体から一旦補助記憶装置にコピーまたはインストール後に、主記憶装置にロードされて実行する。また、ネットワーク接続された他の装置に格納されて提供された場合も、他の装置からネットワークを経由して受信後に、補助記憶装置にコピー、主記憶装置にロードされ実行するものである。
【0018】
以下にデータプリフェッチ命令の挿入の仕組みと動作について図とフローチャートを参照しながら説明する。
図3はデータプリフェッチ命令の説明図である。図3(a)にはメモリ上のデータを処理対象とする関数として「strcpy」(string copy、すなわち、文字列をコピーする関数)を例にとり、アドレス「ad2」で示されるメモリ上の位置に文字列「a,b,c,d,e」31があるときREG32を経由してアドレス「ad1」のメモリ33にコピーするものであることを示している。
【0019】
図3(b)は上記関数「strcpy」がコンパイル装置22のソースプログラム解析部23で生成された「LOAD命令▲1▼、▲2▼」および関数「strcpyの呼び出し命令:CALL▲4▼」を示している。すなわち「CALL」の引数の二つのアドレス、ad1、ad2はそれぞれREG1、REG2に格納して渡し、「strcpy」ルーチンを呼び出すように中間テキストを生成していることを示している。ここで中間テキストはオブジェクトプログラムとしてマシン命令を作り出す中間の命令でおおむねマシン命令に対応するものである。ただし、コンパイル装置の後の処理工程で必要とする情報を合わせて持っている。例えば、最適化のときに必要な情報として、どの中間テキストから制御が渡されるのかを示す「経路情報」などがある。
【0020】
ここで、▲3▼により示される「PREFETCH REG2」は「strcpyの呼び出し命令:CALL▲4▼」の引数としてコピーする元の文字列のアドレスを含むメモリ上のデータの塊を対応するデータキャッシュにコピーすることを示すものである。これは、「strcpy」でメモリからレジスタに文字データをロードする必要性が分かっているのでロード命令の実行前にアクセスの速いデータキャッシュにコピーする命令を挿入するものである。
【0021】
すなわち、図3(c)に示すようにREG3を用いて「LOAD命令、STORE命令」によりREG2で示される文字データをREG1で示されるメモリにコピーする。このLOAD命令でアクセスするメモリの内容が含まれる部分がLOAD命令の実行前にデータキャッシュにコピー完了していることが望ましいが、もしメモリからのコピーが途中の状態であってもLOAD命令が発行されたとき全く新たにメモリからデータキャッシュにコピーする動作を開始することに比べれば時間短縮の効果は確実に得られる。つまり、LOAD命令が発行されたときに指定のアドレスのメモリの内容がデータキャッシュに存在すればデータキャッシュからロードされ、もし無ければLOAD命令で指定されたアドレスのメモリの内容をまずデータキャッシュに移し完了を待ってレジスタにロードされるようになっている。したがって、事前に発行されたPREFETCH命令によりメモリからデータキャッシュにデータの転送が始まっていればその完了を待ってデータキャッシュからレジスタにロードされるので時間短縮の効果が出るのである。
【0022】
図4には中間テキストの説明図(その1)を示す。ここには、ユーザ関数定義文の例をソースプログラムのイメージで示す。foo()によりユーザ定義の関数を表し、「・・・(1)・・・」により先頭部分の文を示す。続いてif文で条件が成り立つ[then」のとき「・・・(2)・・・」の文を実行し、否「else」の場合「・・・(3)・・・」の文を実行し、(2)または(3)の後に「・・・(4)・・・」を実行して終了する関数の定義を行うものである。
【0023】
図5の中間テキストの説明図(その2)は上記図4のソースプログラムの構造をブロック図として示している。ここで、先頭の51で入口/退避、最後の56で出口/復元のように示したものは、定義する関数の中で使用するレジスタの内、グローバルレジスタと呼ばれるレジスタについて、その内容を関数の実行後も保証するために入口でメモリに退避し、出口で退避していた内容をレジスタに復元することを示している。つまり、グローバルレジスタの内容は各関数が呼ばれたときにはある固有の意味を持ったものであり関数の出口で呼び出し元に戻るときにはその内容を元に戻す約束ごとである。これらの「退避」あるいは「復元」も関数として呼び出すようにしている。
【0024】
図6は中間テキストの説明図(その3)である。上記した図4および図5に対応して生成された中間テキストをアセンブラ命令レベルの構造で示したものである。詳しく図示はしていないが複数のアセンブラ命令をソース命令文の単位にくくった「節」が存在する。「then節」、「else節」などがこれである。また、入口、出口の「退避」、「復元」も同様に一塊の処理であることが処理の種類と制御の流れなどについての情報とともに記録されている。
【0025】
中間テキスト(命令)を区別して説明するために「#」により番号を示しているが、そこに示す上向きの矢印は中間テキスト(命令)の制御が渡される元の中間テキスト(命令)を指し示す経路情報である。これはコンパイル装置のソースプログラム解析部が後の工程で必要な情報として記録するものの一つであり、同様に順方向の制御の流れも記録されている。
【0026】
具体的に対応を見てみると、関数の実行に先立つレジスタの退避(#1、#2)、if文の分岐(#3)、then節(#4、#5、および#6で後処理への分岐)、else節(#7、#8)、後処理(#9)、関数の出口での復元(#10、#11)のように構成されていることがわかる。また、上向き矢印は実行時の制御の流れを溯る方向を示している。#3には#4および#7からの矢印が指し示しているがif文の条件の判定により二通りに別れることに対応している。同様に#9では実行時の制御の流れが#6あるいは#8から渡されることを意味している。
【0027】
図7はプリフェッチ対象処理テーブル説明図である。図2に示した最適化実施部24が図4乃至6に示した中間テキストをソースプログラム解析部23から受け取り、データプリフェッチ命令を事前に挿入することが効果的であるものを見つけるために、そのキーとなる中間テキストに記録されている処理名情報を一覧としたものでありコンピュータに記憶されている。図7に見るようにタイプがシステム関数であるものとしては、strcpy(文字列コピー)、strncpy(文字数指定の文字列コピー)、strlen(文字列長さ)、strcmp(文字列比較)、memcpy(メモリ内容コピー)、memcmp(メモリ内容比較)等がある。これらは、何れもメモリ上のデータをレジスタにロードした後処理するものであり、処理の前のメモリからのロード待ち時間をいかに短くするかにより実行時間が大きく左右されるシステム関数である。対象とするシステム関数はあらかじめこのテーブルに登録しておくようにしている。
【0028】
同様にタイプがユーザ定義関数のfoox、fooy、foozもメモリ上のデータをレジスタにロードした後処理するユーザ定義関数であり、効果の期待できるものだけをこのテーブルに登録しておく。
【0029】
タイプがレジスタ復元のものはプログラム開発の部品として復元内容別にいくつかの種類が登録されるもので前記したようにグローバルレジスタとして共通に内容を受け渡すために利用するレジスタを局部的に別の用途に使用するとき自分で退避しておいた内容を復元して処理を呼び出し元に返すものである。すなわち必ずメモリからレジスタへのロードが実行されるのであらかじめアクセスされるアドレスのメモリをプリフェッチしてデータキャッシュにコピーしておくことが望ましいものである。
【0030】
タイプがユーザ指定プリフェッチとしたものはソースプログラムに記述して、陽にプリフェッチを指示するハード命令を発行するものである。
プリフェッチ対象処理テーブルの各処理名に対応して引数の並びとload命令の対象引数、遡及命令数が示されている。このload命令の対象引数に示される引数の位置を引数の並びから探すことにより各処理でロードされるメモリのアドレス、すなわちプリフェッチすべきメモリのアドレスを知ることができる。さらに、遡及命令数は各処理ごとに実行時にその処理の先頭からどの程度処理が進んだ位置にメモリからレジスタへのロード命令が実行されるのかに対応して逆にどれだけ先行してプリフェッチ命令を実行したら良いのかを示すものである。ここに示す数値はこのように溯った位置に命令を挿入するために溯る命令数に見合った数値を記録するようにしている。ただし、各命令毎に若干の命令実行時間、すなわちマシンサイクルを単位とした時間が異なるので溯る命令数は各関数で調整して設定するようにしている。
【0031】
次に、図8、図9にVLIW命令の空きスロットとプリフェッチ命令配置の説明図(その1)および(その2)を示す。これはVLIW型アーキテクチャのコンピュータに本発明を実施したときの形態を説明するためのものである。
【0032】
上記VLIW型アーキテクチャを備えたコンピュータの特徴は、複数の単純な命令を複数のスロットに格納して構成するVLIW命令を持つものである。そして当然コンパイル装置もVLIW型アーキテクチャのコンピュータで実行するプログラムを生成するコンパイル装置が使用される。
【0033】
まず図8(a)VLIW命令とスロットに示すようにVLIW命令は複数のスロット、ここではスロットa乃至スロットdの4個のスロットを備えた命令であり、各スロットに格納された命令は同時に実行されるようになる。
【0034】
図8(b)命令配置の並列化によって一つのVLIW命令に一緒に格納可能な命令について説明する。まず通常のコンピュータであれば順番に実行される命令列を▲1▼に示している。これはアドレスAとアドレスBのデータをレジスタREG1とREG2にロードしてADD命令で加算してレジスタREG3に結果を作り出し、STORE命令でREG3の結果をアドレスCに格納するための命令群である。続いて▲2▼には並列に実行可能なものは横に並べ、順序を必要とする命令は縦方向に並べたものを示す。すなわち、REG1、REG2へのロードは別々のレジスタであり順序性はないので同時に実行可能であり、加算およびその結果を格納する命令はそれぞれ順番に前の命令の完了を待ってはじめて実行できるので順序が必要であることを示す。図8(c)には上記並列に実行可能なLOAD命令を一つのVLIW命令に収めた例を示している。ここで、スロットbおよびスロットdに格納されている「NOP」はNo Operationを意味する命令であり、並列に実行可能な命令が無く、やむを得ず空きスロットとして残すときに埋める命令コードである。
【0035】
次に、図9(d)プリフェッチ命令の配置について説明する。図8(b)に示した命令列においてプリフェッチ命令を挿入する位置は▲1▼に示すようにLOAD命令の後、ADD命令の前となる。これをVLIW命令として挿入したものを▲2▼に示す。すなわちPREFETCH命令だけのためにVLIW命令を一つ挿入しているが上記説明したNOP命令が多くを占めることになる。そこで、本発明ではVLIW命令においては既にNOP命令つまり空きがあるときにはそこにPREFETCH命令を配置して格納するようにする。このように配置したものを図9(d)▲3▼に示す。このようにすることにより命令数の削減、命令実行待ち時間の削減の効果が得られる。逆にループの中などではVLIW命令を単純に一つ挿入して追加するときのコストが余分にかかることにもなり、空きスロットがあるときだけプリフェッチ命令を挿入することも可能とする。これは図1のプリフェッチ命令挿入モード設定手段4により実現している。
【0036】
図10にはプリフェッチ命令挿入フローチャートを示す。ここには図2のソースプログラム解析部23の出力である図6に示すような中間テキストを入力としてプリフェッチ命令をその前に挿入する効果のある処理を見つけてプリフェッチすべきメモリ上のデータのアドレスを指定したプリフェッチ命令を生成して最適な位置に挿入する手順を説明する。
【0037】
ステップS101ではコンパイルするときにコンパイルモードとして利用者からプリフェッチオプションが指定されていることを確認する。ステップS102で順番に中間テキストを一つずつ取出す。ステップS103でまずそれが関数呼び出しの中間テキストかを調べる中間テキストにおいては関数は図3(b)に示すように「CALL」命令またはここには例示していないが、前記した図7におけるタイプがユーザ指定プリフェッチのとき指定する拡張命令である「pragm」命令の引数として関数名を表すのでこれを取出して調べることになる。
【0038】
ステップS104では取出した関数名が図7のプリフェッチ対象処理テーブルに登録されている処理名と比較していずれかと一致しているかを調べる。テーブルに登録されていない場合はプリフェッチ命令を挿入しても効果が無いものであるとして何も行わずステップS107に移り次の中間テキストの処理に移る。
【0039】
テーブルにあった場合にはステップS105において見つかった関数の引数並びとload命令対象引数からプリフェッチ命令に指定するアドレスを調べてPREFETCHテキストを生成する。生成したPREFETCHテキストの配置についてはステップS106において後に別途フローチャートで説明する最適化を行い、挿入位置を決定して上記生成したPREFETCHテキストを挿入する。あとはステップS107で終わりを確認して終了する。
【0040】
最後に図11と図12でプリフェッチ命令の配置の最適化を説明する。図11および図12にはプリフェッチ命令挿入位置最適化フローチャート(その1)および(その2)を示す。フローチャート(その2)はフローチャート(その1)から呼び出されるもので挿入位置検出プログラムの動作を示す。
【0041】
プリフェッチ命令挿入位置最適化フローチャート(その1)は上記説明したようにプリフェッチ命令を挿入するべき関数を検出し、挿入すべきPREFETCHテキストを生成したときにそれを配置するべく呼び出されて起動されるプログラムである。したがってステップS111では中間テキストの位置、溯って挿入する位置を数えるための初期値0を与えたカウンタおよびその関数に対応する図7のテーブルに示した遡及命令数を引数として設定して、ステップS112において図12に示すPREFETCHテキスト挿入位置検出プログラムを呼び出す。挿入位置は図6で分かるように↑で示される複数の経路情報を溯ってたどるので1以上のプリフェッチ命令の配置が起こり得るのでPREFETCHテキスト挿入位置検出プログラムからはそれらの1以上の位置情報を返される。
【0042】
ステップS113では生成されたPREFETCHテキストを上記記憶されて返された1以上の挿入位置に配置する。
図12のフローチャートの説明に入る。これは上記プリフェッチ命令を配置するとき呼び出されるもので、PREFETCHテキスト挿入位置検出プログラムの処理手順を示すものである。このプログラムは図6の↑で示す経路情報をたどり引数で示される遡及すべき命令数だけ溯った位置を最適配置位置として記憶するものであり途中で溯る経路情報が複数あるテキストも存在するので溯りながら最も近い複数の経路情報のあった中間テキストの位置に戻って別の経路を溯るようにするため、後で説明するようにステップS126においては自分自身を呼び出す再起呼び出しの形式をとっている。
【0043】
ステップS121では引数として与えられたテキスト位置、カウンタアドレスを受け取る。ステップS122で、まずテキスト位置を一つ溯りカウンタに1を加える。ステップS123ではカウンタが遡及命令数に到達していないか、すなわちもっと溯ってプリフェッチ命令を配置すべきかを調べる。到達したときにはステップS127においてその時点のテキスト位置をPREFETCHテキストの挿入位置として蓄積して記憶して呼び出し元に返る。
【0044】
ステップS124では現在の中間テキストに未処理の経路情報があるかをチェックする。ない場合このプログラムを終了して呼び出し元に帰る。
未処理経路情報がある場合にはステップS125において未処理経路情報を取出し、ステップS126において取出した経路について溯るように、現在のテキスト位置と、カウンタを引数として自分自身すなわちPREFETCHテキスト挿入位置検出プログラムを呼び出す。これにより枝別れした経路を溯ってステップS123の条件を満足する位置が見つかる度にステップS127でPREFETCHテキストの挿入位置として蓄積して記憶する。一つの経路を溯り目的の位置を見つける度に記憶されたPREFETCHテキスト挿入位置は図11の最初の呼び出しに対応して戻ったときにステップS113において取出されプリフェッチ命令がそれに基づいて配置されることになる。ステップS126での戻りはステップS124として次の別れた経路を探索するようにしている。
【0045】
なお、フローチャートには図示していないが中間テキストの経路情報と並んで記録された付加情報によりそれ以上溯れないテキスト、例えば関数定義の先頭とか中間テキストが関数呼び出しである場合にはカウンタが遡及命令数に達したとして扱い、ステップS123においてステップS127に制御を移すように処理する。
【0046】
このようにして中間テキストについてプリフェッチ命令を挿入すべき関数の呼び出し毎に有効なプリフェッチ命令を生成して実行時の経路の可能性を溯ってたどり最適な位置に配置して挿入することができる。
【0047】
なお、ステップの短いユーザ定義関数などで溯る命令数が図7のテーブルにある遡及命令数を満足する位置とならず最適化の配置が完全なものではなくても、前記したようにロード命令の完了がデータキャッシュへのメモリからのコピー完了待ち時間がより少なくなるという効果が期待できる。極端にいえばプリフェッチ命令を挿入すべき関数の直前に配置したとしても効果は得られるものである。
【0048】
また、原始プログラム作成段階でプリフェッチ命令をプログラム作成者が原始プログラムの適当な位置に記述して組み込み実行時性能を向上させる効果を得ることは通常の手段であり、上記実施の形態における図7のプリフェッチ対象処理テーブルにおけるユーザ指定プリフェッチによって組み込む方法もある。
【0049】
【発明の効果】
以上の説明から明らかなように本発明によれば、コンパイル段階でプログラムの構造の特徴を解析してロード命令に先立ってデータキャッシュに必要なメモリの内容をコピーしておくようにすることが可能となり、データキャッシュのヒット率を向上し、あるいはメモリからデータキャッシュへのコピー待ち時間を削減することができることにより、コンピュータの命令実行性能を向上するという著しい工業的効果がある。
【図面の簡単な説明】
【図1】 本発明の構成図
【図2】 本発明の実施の形態の構成図
【図3】 データプリフェッチ命令の説明図
【図4】 中間テキストの説明図(その1)
【図5】 中間テキストの説明図(その2)
【図6】 中間テキストの説明図(その3)
【図7】 プリフェッチ対象処理テーブル説明図
【図8】 VLIW命令の空きスロットとプリフェッチ命令配置の説明図(その1)
【図9】 VLIW命令の空きスロットとプリフェッチ命令配置の説明図(その2)
【図10】 プリフェッチ命令挿入フローチャート
【図11】 プリフェッチ命令挿入位置最適化フローチャート(その1)
【図12】 プリフェッチ命令挿入位置最適化フローチャート(その2)
【符号の説明】
1 中間テキスト検索手段
2 プリフェッチ命令挿入手段
3 プリフェッチ命令挿入位置最適化手段
4 プリフェッチ命令挿入モード設定手段
[0001]
BACKGROUND OF THE INVENTION
The present invention converts a source program into intermediate text, optimizes the converted intermediate text, and generates a program that effectively uses the data cache in a compiling device that generates machine language to improve runtime performance. The present invention relates to a compiling device.
[0002]
[Prior art]
The performance of computers has been dramatically improved by various technical improvements. In particular, the RISC (Reduced Instruction Set Computer) type architecture, in which the instruction execution speed is remarkably improved, is often adopted for the central CPU. On the other hand, the main memory (memory) is not so fast as compared with the CPU. In such a state, if data is loaded from the memory, it takes a long time (relative to the CPU) from the memory and is stored in the register for the operation. Results will be obtained after processing time. That is, the speeded-up CPU also has a slight improvement in overall performance because most of the processing of data in the memory waits for the load time from the memory to the register.
[0003]
In such a RISC type architecture, data used for calculation must be stored in a register, and an addressing method for specifying a memory as an operand of an operation instruction is not performed unlike a conventional general-purpose computer. . Also, when comparing the CPU time and the memory access time, if the machine cycle is τ, the operation time of the memory is tens of τ compared to most arithmetic instructions ranging from 1τ to several τ. It is. That is, most of the execution time is spent on the memory access waiting time (also referred to as latency).
[0004]
Reducing the delay time is a requirement for improving the performance of the RISC type architecture. In view of this, a data cache function has been devised for this purpose. The data cache function is provided with a cache memory having a fast access by hierarchizing memories, and is implemented in most of current CPUs. As the name suggests, the data cache temporarily stores the contents of the memory, and if it can be used repeatedly, the number of accesses to the stale memory can be reduced. However, instead of the data cache operating very fast, the capacity implemented is small.
[0005]
In the case where the primary cache, the secondary cache, and the memory are hierarchically arranged in the order from the CPU, the degree of delay time when there is a load request from the CPU is exemplified by the machine cycle time τ described above, the primary cache If data exists, it is 0τ, if it is in the secondary cache, it is accompanied by a copy to the primary cache, 10τ, and if there is requested data in the memory, it is accompanied by a copy to the primary / secondary cache and a delay time of 100τ. Become. In this way, when the load instruction is executed, the waiting time is less and the processing is performed faster as the target data exists in the hierarchy closer to the CPU.
[0006]
As described above, the conventional computer also has a cache memory that is quickly accessed by hierarchizing the memory, and speeding up the access to the data group on the memory that is repeatedly accessed has been realized. In addition, it is not only expected to increase the access speed for the data group on the memory that has been accessed once, but also the instruction with memory access that should be executed later by analyzing the instructions of the program that is actively executed. Thus, a device for copying data from a normal memory to a high-speed cache memory is also disclosed. For example, Japanese Patent Application Laid-Open No. 8-161226 discloses a data prefetch control method in a system using a cache memory, in which the type of load instruction is divided according to the type according to the arrangement pattern of the data to be accessed by the load instruction. When the load instruction is related to the previously issued load instruction so that it can be identified by a code etc., the load address of the subsequent load instruction is predicted according to the type of the load instruction when the preceding load instruction is processed. A technique for prefetching the data into the cache memory is shown.
[0007]
In the past, the use of data caches was promoted by detecting conditions that had the effect of prefetching in hardware during program execution. However, recently, the function of prefetching the memory contents into the data cache by software instructions, that is, data Computers with prefetch instructions have been developed. Utilization of a data cache using this data prefetch instruction is expected.
[0008]
[Problems to be solved by the invention]
As described above, the delay time due to waiting when loading data on the memory is remarkably reduced by the data cache for the data group that is repeatedly accessed, but there is no effect when it does not exist in the data cache. Some of the conditions shown in the above known example detect the effect expected by prefetching at the time of execution and prefetch data loaded in advance into the data cache. The cache's high-speed access cannot be effectively used.
[0009]
In the past, it was recommended to use data caches by detecting conditions that have the effect of prefetching in hardware during program execution. However, there are limited memory prefetching conditions that enable data caches that can be detected during execution. As a result, the incorporation of data cache utilization procedures at the program creation stage was an issue and a solution was sought.
[0010]
In view of these points, the present invention is a means for analyzing the characteristics of the program structure at the source program creation stage or the compilation stage and copying the memory contents necessary for the data cache prior to the load instruction. The purpose is to provide.
[0011]
[Means for Solving the Problems]
The above problem is solved by a compiling apparatus configured as follows.
FIG. 1 is a block diagram of the present invention.
[0012]
In the figure, reference numeral 1 denotes a compiling device that converts a source program into intermediate text, optimizes the converted intermediate text, and generates a machine language, corresponding to one or more types of preset source program instructions. An intermediate text search means for searching the converted intermediate text. 2 calculates the address of the memory to be copied to the data cache based on the searched intermediate text, and the above calculation is performed at the execution order position before the searched intermediate text. This is prefetch instruction insertion means for inserting a data cache prefetch instruction specifying an address. (Claim 1)
3 goes back to the control flow of the program based on the program execution time to be retroactively set in advance for each source program instruction type from the execution order position of the retrieved intermediate text, and determines the execution order position to insert the prefetch instruction. It is a prefetch instruction insertion position optimizing means for determining (claim 2).
[0013]
The compiling device is a compiling device for generating a program to be executed by a computer having a VLIW type architecture having a VLIW instruction configured by storing a plurality of simple instructions in a plurality of slots, and the prefetch instruction inserting means 2 is empty. When a data cache prefetch instruction is generated in a slot, 4 is a prefetch instruction insertion for setting whether to suppress insertion of a data cache prefetch instruction or to generate a new independent VLIW instruction when there is no empty slot Mode setting means (Claim 7).
[0014]
DETAILED DESCRIPTION OF THE INVENTION
FIG. 2 is a configuration diagram of the embodiment of the present invention.
A compiling device 22 converts a source program indicated by the source program 21 into an intermediate text by the source program analysis unit 23, optimizes the converted intermediate text by the optimization execution unit 24, and generates scheduling and code. The unit 25 generates a machine language indicated by the object program 26. The generation and insertion control of the data cache prefetch instruction, which is a feature of the present invention, is performed by the optimization execution unit 24. The compiling device 22 operates on a computer.
[0015]
That is, in the present embodiment, a form realized by a computer program executed on a computer used for general purposes such as a personal computer or a workstation is shown.
[0016]
The compiling device of the present invention is realized by executing a computer program on a computer including a processing device, a main storage device, an auxiliary storage device, an input / output device, and the like. The computer program is stored and provided in a portable medium such as a floppy disk or CD-ROM, or in a main storage device or auxiliary storage device of another computer connected to the network. The recording medium of the present invention corresponds to the portable medium, the main storage device, and the auxiliary storage device.
[0017]
The provided computer program is loaded directly from the portable medium into the main storage device of the computer, or once copied or installed from the portable medium to the auxiliary storage device, then loaded into the main storage device and executed. In addition, when the data is stored and provided in another device connected to the network, it is copied to the auxiliary storage device after being received from the other device via the network, and loaded into the main storage device for execution.
[0018]
The mechanism and operation for inserting a data prefetch instruction will be described below with reference to the drawings and flowcharts.
FIG. 3 is an explanatory diagram of a data prefetch instruction. In FIG. 3A, “strcpy” (string copy, ie, a function for copying a character string) is taken as an example of a function for processing data on the memory, and the function is set at a position on the memory indicated by the address “ad2”. When the character string “a, b, c, d, e” 31 is present, it indicates that the character string “a, b, c, d, e” is to be copied to the memory 33 at the address “ad1” via the REG 32.
[0019]
FIG. 3B shows that the function “strcpy” is generated by the “LOAD instruction (1), (2)” generated by the source program analysis unit 23 of the compiling device 22 and the function “strcpy call instruction: CALL (4)”. Show. In other words, the two addresses ad1 and ad2 of the argument “CALL” are stored in REG1 and REG2, respectively, and intermediate text is generated so as to call the “strcpy” routine. Here, the intermediate text is an intermediate instruction that generates a machine instruction as an object program, and generally corresponds to a machine instruction. However, it also has information necessary for the processing steps after the compiling device. For example, information necessary for optimization includes “route information” indicating from which intermediate text control is passed.
[0020]
Here, “PREFETCH REG2” indicated by {circle over (3)} is a block of data on the memory including the address of the original character string to be copied as an argument of “strcpy call instruction: CALL <4>” in the corresponding data cache. Indicates copying. In this case, since it is known that the character data needs to be loaded from the memory into the register by “strcpy”, an instruction to be copied to the fast-access data cache is inserted before the load instruction is executed.
[0021]
That is, as shown in FIG. 3C, the character data indicated by REG2 is copied to the memory indicated by REG1 using the LOAD instruction and the STORE instruction using REG3. It is desirable that the portion including the contents of the memory accessed by the LOAD instruction has been copied to the data cache before the execution of the LOAD instruction. However, even if copying from the memory is in progress, the LOAD instruction is issued. When this is done, the effect of shortening the time can be surely obtained as compared with starting the operation of copying from the memory to the data cache anew. In other words, if the contents of the memory at the specified address are present in the data cache when the LOAD instruction is issued, the contents of the memory at the address specified by the LOAD instruction are first transferred to the data cache. It waits for completion and is loaded into the register. Therefore, if the transfer of data from the memory to the data cache is started by the PREFETCH instruction issued in advance, the data cache is loaded from the data cache to the register after completion of the transfer, so that the time can be shortened.
[0022]
FIG. 4 shows an explanatory diagram (part 1) of the intermediate text. Here, an example of a user function definition statement is shown as an image of a source program. foo () represents a user-defined function, and “... (1). Subsequently, the statement “... (2)...” Is executed when “if” satisfies the condition [then], and the statement “... (3). The function to be executed is defined by executing “... (4)...” After (2) or (3).
[0023]
The explanatory diagram (part 2) of the intermediate text in FIG. 5 shows the structure of the source program in FIG. 4 as a block diagram. Here, the ones indicated as entry / save at the first 51 and exit / restore at the last 56 are the registers used in the function to be defined, and the contents of the registers called global registers are In order to guarantee even after execution, the contents are saved in the memory at the entrance, and the contents saved at the exit are restored to the register. In other words, the contents of the global register have a specific meaning when each function is called, and are each promise to restore the contents when returning to the caller at the exit of the function. These “save” or “restore” are also called as functions.
[0024]
FIG. 6 is an explanatory diagram (part 3) of the intermediate text. The intermediate text generated corresponding to FIGS. 4 and 5 is shown in an assembler instruction level structure. Although not shown in detail, there is a “clause” in which a plurality of assembler instructions are difficult to unit in a source instruction sentence. These are “then clause”, “else clause”, and the like. Similarly, “evacuation” and “restoration” at the entrance and exit are recorded as a single process, together with information on the type of process and the flow of control.
[0025]
In order to distinguish and explain the intermediate text (command), a number is indicated by “#”, but the upward arrow shown there indicates a path indicating the original intermediate text (command) to which control of the intermediate text (command) is passed. Information. This is one of the information recorded by the source program analysis unit of the compiling device as necessary information in a later process, and the forward control flow is also recorded.
[0026]
Looking specifically at the correspondence, register saving prior to function execution (# 1, # 2), branching of if statement (# 3), post-processing in the then clauses (# 4, # 5, and # 6) ), Else clause (# 7, # 8), post-processing (# 9), restoration at function exit (# 10, # 11). Further, the upward arrow indicates the direction in which the control flow during execution is directed. The arrow from # 4 and # 7 points to # 3, but it corresponds to the fact that it is separated into two ways depending on the determination of the condition of the if sentence. Similarly, # 9 means that the control flow during execution is passed from # 6 or # 8.
[0027]
FIG. 7 is an explanatory diagram of a prefetch target processing table. In order for the optimization execution unit 24 shown in FIG. 2 to receive the intermediate text shown in FIGS. 4 to 6 from the source program analysis unit 23 and to find out that it is effective to insert a data prefetch instruction in advance, The processing name information recorded in the intermediate text as a key is listed and stored in the computer. As shown in FIG. 7, the type is a system function. Strcppy (character string copy), strncpy (character string copy specifying the number of characters), strlen (character string length), strcmp (character string comparison), memcpy ( Memory content copy), memcmp (memory content comparison), and the like. These are system functions that are processed after loading the data in the memory into the register, and are system functions whose execution time is greatly influenced by how short the load waiting time from the memory before processing is reduced. The target system function is registered in advance in this table.
[0028]
Similarly, fox, foo, and foo whose types are user-defined functions are user-defined functions that are processed after loading the data on the memory into the register, and only those that can be expected to be effective are registered in this table.
[0029]
If the type is register restoration, some types are registered as part of program development as a part of program development. As mentioned above, the register used to transfer contents in common as a global register is used for other purposes locally. The contents saved by itself are restored and the process is returned to the caller. That is, since the load from the memory to the register is always executed, it is desirable to prefetch the memory at the address accessed in advance and copy it to the data cache.
[0030]
When the type is user-specified prefetch, it is described in the source program and a hardware instruction that explicitly instructs prefetching is issued.
The list of arguments, the target argument of the load instruction, and the number of retroactive instructions are shown corresponding to each processing name in the prefetch target processing table. The address of the memory loaded in each process, that is, the address of the memory to be prefetched can be found by searching the argument position indicated by the target argument of the load instruction from the argument list. In addition, the number of retroactive instructions is the number of prefetch instructions ahead of each other, corresponding to how far the processing load instruction is executed from the beginning of the processing at the time of execution. Indicates what should be done. The numerical values shown here are recorded so as to correspond to the number of instructions to be inserted in order to insert an instruction at such a position. However, since the instruction execution time is slightly different for each instruction, that is, the time in units of machine cycles is different, the number of instructions is adjusted and set by each function.
[0031]
Next, FIGS. 8 and 9 are explanatory views (No. 1) and (No. 2) of empty slots and prefetch instruction arrangements of VLIW instructions. This is for explaining a form when the present invention is implemented in a computer having a VLIW architecture.
[0032]
A feature of the computer having the VLIW type architecture is that it has a VLIW instruction configured by storing a plurality of simple instructions in a plurality of slots. As a matter of course, a compiling device that generates a program to be executed by a computer having a VLIW architecture is used.
[0033]
First, as shown in FIG. 8 (a) VLIW instruction and slot, the VLIW instruction is an instruction having a plurality of slots, here, four slots, slot a to slot d, and instructions stored in each slot are executed simultaneously. Will come to be.
[0034]
FIG. 8B illustrates an instruction that can be stored together in one VLIW instruction by parallelizing instruction arrangement. First, in the case of a normal computer, a sequence of instructions executed in order is shown in (1). This is an instruction group for loading the data of address A and address B into registers REG1 and REG2, adding them with an ADD instruction to create a result in register REG3, and storing the result of REG3 into address C with a STORE instruction. Subsequently, in (2), instructions that can be executed in parallel are arranged horizontally, and instructions that require an order are arranged vertically. In other words, loads to REG1 and REG2 are separate registers and are not ordered and can be executed simultaneously, and instructions for storing additions and results thereof can be executed only after waiting for completion of the previous instruction in order. Indicates that is required. FIG. 8C shows an example in which the LOAD instructions that can be executed in parallel are stored in one VLIW instruction. Here, “NOP” stored in the slot b and the slot d is an instruction meaning No Operation, and is an instruction code to be filled when there is no instruction that can be executed in parallel and is unavoidably left as an empty slot.
[0035]
Next, the arrangement of prefetch instructions in FIG. The position where the prefetch instruction is inserted in the instruction sequence shown in FIG. 8B is after the LOAD instruction and before the ADD instruction as shown in (1). The result of inserting this as a VLIW instruction is shown in (2). That is, one VLIW instruction is inserted only for the PREFETCH instruction, but the above-described NOP instruction occupies many. Therefore, in the present invention, in the VLIW instruction, when there is already a NOP instruction, that is, there is a vacancy, the PREFETCH instruction is arranged and stored therein. The arrangement thus arranged is shown in FIG. By doing so, the effect of reducing the number of instructions and the instruction execution waiting time can be obtained. Conversely, in a loop or the like, an extra cost is required for inserting and adding one VLIW instruction, and a prefetch instruction can be inserted only when there is an empty slot. This is realized by the prefetch instruction insertion mode setting means 4 in FIG.
[0036]
FIG. 10 shows a prefetch instruction insertion flowchart. Here, the address of the data on the memory to be prefetched by finding a process effective to insert the prefetch instruction before the intermediate text as shown in FIG. 6 which is the output of the source program analysis unit 23 of FIG. 2 is input. A procedure for generating a prefetch instruction designating and inserting it at an optimum position will be described.
[0037]
In step S101, it is confirmed that a prefetch option is designated by the user as a compilation mode when compiling. In step S102, intermediate texts are extracted one by one in order. In step S103, in the intermediate text to check whether it is an intermediate text of the function call, the function is not “CALL” instruction or illustrated here as shown in FIG. 3B, but the type in FIG. Since the function name is expressed as an argument of the “pragm” instruction which is an extension instruction specified at the time of user-specified prefetch, this is taken out and examined.
[0038]
In step S104, the extracted function name is compared with the process name registered in the prefetch target process table of FIG. If it is not registered in the table, it is assumed that there is no effect even if a prefetch instruction is inserted, and nothing is performed and the process proceeds to step S107 and the next intermediate text process is performed.
[0039]
If it is in the table, the PREFETCH text is generated by examining the address specified in the prefetch instruction from the argument list of the function found in step S105 and the load instruction target argument. The arrangement of the generated PREFETCH text is optimized in a later step in step S106, and an insertion position is determined and the generated PREFETCH text is inserted. After that, the end is confirmed in step S107 and the process is ended.
[0040]
Finally, optimization of the prefetch instruction arrangement will be described with reference to FIGS. FIG. 11 and FIG. 12 show a prefetch instruction insertion position optimization flowchart (part 1) and part (part 2). The flowchart (part 2) is called from the flowchart (part 1) and shows the operation of the insertion position detection program.
[0041]
The prefetch instruction insertion position optimization flowchart (part 1) detects a function to insert a prefetch instruction as described above, and is a program that is called and started when a PREFETCH text to be inserted is generated and placed. It is. Accordingly, in step S111, the counter that gave the initial value 0 for counting the position of the intermediate text, the position to be inserted, and the number of retroactive instructions shown in the table of FIG. 7 corresponding to the function are set as arguments, and step S112. In FIG. 12, the PREFETCH text insertion position detection program shown in FIG. 12 is called. As shown in FIG. 6, since the insertion position follows a plurality of path information indicated by ↑, one or more prefetch instructions can be arranged. Therefore, the PREFETCH text insertion position detection program returns one or more pieces of position information. It is.
[0042]
In step S113, the generated PREFETCH text is placed at one or more insertion positions stored and returned.
The description of the flowchart of FIG. This is called when the prefetch instruction is arranged, and shows the processing procedure of the PREFETCH text insertion position detection program. This program traces the route information indicated by ↑ in FIG. 6 and stores the position as many as the number of instructions to be retroactively indicated as an argument as the optimum arrangement position. There is also text with a plurality of route information in the middle. However, in order to return to the position of the intermediate text having the closest plurality of route information and go to another route, in the step S126, a re-calling form for calling itself is used as described later.
[0043]
In step S121, the text position and counter address given as arguments are received. In step S122, the text position is incremented by one and 1 is added to the counter. In step S123, it is checked whether the counter has reached the number of retroactive instructions, that is, whether more prefetch instructions should be arranged. When it has been reached, in step S127, the text position at that time is accumulated and stored as the insertion position of the PREFETCH text and returned to the caller.
[0044]
In step S124, it is checked whether there is unprocessed route information in the current intermediate text. If not, exit this program and return to the caller.
If there is unprocessed path information, the unprocessed path information is extracted in step S125, and the current text position and the counter are used as arguments, ie, the PREFETCH text insertion position detection program so as to talk about the path extracted in step S126. call. Thus, every time a position satisfying the condition of step S123 is found over the branched path, it is accumulated and stored as the insertion position of the PREFETCH text in step S127. The stored PREFETCH text insertion position every time a target position is found through one path is fetched in step S113 when returning in response to the first call in FIG. 11, and the prefetch instruction is arranged based on it. Become. The return in step S126 searches for the next separated route in step S124.
[0045]
Although not shown in the flowchart, the counter is retroactive when the text cannot be further moved by the additional information recorded along with the path information of the intermediate text, for example, the head of the function definition or the intermediate text is a function call. It is handled that the number of instructions has been reached, and processing is performed so as to transfer control to step S127 in step S123.
[0046]
In this way, an effective prefetch instruction can be generated for each call of a function in which a prefetch instruction should be inserted with respect to the intermediate text, and can be inserted at an optimal position by tracing the possibility of a path at the time of execution.
[0047]
Even if the number of instructions struck by a user-defined function with a short step does not satisfy the number of retroactive instructions in the table of FIG. 7 and the optimization layout is not perfect, as described above, The effect that the completion waiting time for the completion of copying from the memory to the data cache becomes smaller can be expected. In extreme terms, even if the prefetch instruction is placed immediately before the function to be inserted, the effect can be obtained.
[0048]
In addition, it is a normal means for the program creator to describe the prefetch instruction at an appropriate position in the source program at the source program creation stage to obtain the effect of improving the built-in execution performance. FIG. There is also a method of incorporating by user-specified prefetch in the prefetch target processing table.
[0049]
【The invention's effect】
As is clear from the above description, according to the present invention, it is possible to analyze the characteristics of the structure of the program at the compilation stage and copy the memory contents necessary for the data cache prior to the load instruction. Thus, there is a significant industrial effect of improving the instruction execution performance of the computer by improving the hit rate of the data cache or reducing the waiting time for copying from the memory to the data cache.
[Brief description of the drawings]
FIG. 1 is a block diagram of the present invention.
FIG. 2 is a configuration diagram of an embodiment of the present invention.
FIG. 3 is an explanatory diagram of a data prefetch instruction.
FIG. 4 is an explanatory diagram of intermediate text (part 1).
FIG. 5 is an explanatory diagram of intermediate text (part 2).
FIG. 6 is an explanatory diagram of intermediate text (part 3).
FIG. 7 is an explanatory diagram of a prefetch target processing table.
FIG. 8 is an explanatory diagram of empty slots of VLIW instructions and prefetch instruction arrangement (part 1).
FIG. 9 is an explanatory diagram of empty slots of VLIW instructions and arrangement of prefetch instructions (part 2)
FIG. 10 is a flowchart for inserting a prefetch instruction.
FIG. 11 is a flowchart of optimizing the prefetch instruction insertion position (part 1).
FIG. 12 is a flowchart of optimizing the prefetch instruction insertion position (part 2).
[Explanation of symbols]
1 Intermediate text search means
2 Prefetch instruction insertion means
3 Prefetch instruction insertion position optimization means
4 Prefetch instruction insertion mode setting means

Claims (6)

原始プログラムを変換して記憶した中間テキストに対して、メモリからレジスタへのロード処理命令に対応して先行した実行順序位置に該メモリからデータキャッシュにプリフェッチする命令を挿入して最適化するコンパイル装置であって、
あらかじめ設定された1以上の原始プログラム命令について該原始プログラム命令が変換されて中間テキストに記録される処理名情報の該処理名に対応させて該処理に先行して実行させるプリフェッチ命令を挿入する実行順序位置を中間テキストに記憶された実行経路情報に沿って遡及してカウントして決定する命令数を記憶したプリフェッチ対象処理テーブルと、
上記原始プログラムから変換して記憶した中間テキストの各処理命令について処理名を上記プリフェッチ対象処理テーブルに記憶されたいずれかの処理名との一致を検索し、一致した処理名に対応して該プリフェッチ対象処理テーブルに記憶された遡及する命令数を一時記憶する中間テキスト検索手段と、
上記検索して処理名が一致した中間テキストの処理命令の実行順序位置から上記一時記憶された遡及する命令数に基づいて中間テキストに記憶された実行経路情報に沿ってプログラムの制御の流れをさかのぼり、上記プリフェッチ命令を挿入する実行順序位置を決定するプリフェッチ命令挿入位置最適化手段と、
上記決定した実行順序位置に上記検索して処理名が一致した中間テキストの処理命令がロードするメモリのアドレスを指定したデータキャッシュプリフェッチ命令を挿入するプリフェッチ命令挿入手段と、
を備えることを特徴とするコンパイル装置。
A compiling device for optimizing an intermediate text stored by converting a source program by inserting a prefetch instruction from the memory into the data cache at a preceding execution order position corresponding to the load processing instruction from the memory to the register Because
Execution of inserting a prefetch instruction to be executed prior to the processing corresponding to the processing name of the processing name information recorded in the intermediate text by converting the source program instruction with respect to one or more source program instructions set in advance A prefetch target processing table that stores the number of instructions that are determined by retroactively counting the sequential positions along the execution path information stored in the intermediate text;
For each processing instruction of the intermediate text converted and stored from the original program, the processing name is searched for a match with any of the processing names stored in the prefetch target processing table, and the prefetch corresponding to the matching processing name is searched. Intermediate text search means for temporarily storing the number of retroactive instructions stored in the target processing table;
The control flow of the program is traced back along the execution path information stored in the intermediate text based on the number of retrospectively stored instructions from the execution order position of the processing instruction of the intermediate text whose search name matches the search. , Prefetch instruction insertion position optimization means for determining an execution order position for inserting the prefetch instruction;
Prefetch instruction insertion means for inserting a data cache prefetch instruction designating an address of a memory to be loaded by the processing instruction of the intermediate text whose processing name is matched by the search at the determined execution order position;
A compiling device comprising:
上記プリフェッチ対象処理テーブルにあらかじめ設定された原始プログラム命令はメモリからレジスタにロードするデータのアドレスを引数として指定するシステム関数であることを特徴とする請求項1記載のコンパイル装置。  2. The compiling apparatus according to claim 1, wherein the source program instruction preset in the prefetch target processing table is a system function that specifies an address of data to be loaded from a memory to a register as an argument. 上記プリフェッチ対象処理テーブルにあらかじめ設定された原始プログラム命令はメモリからレジスタにロードするデータのアドレスを引数として指定するユーザ定義関数であることを特徴とする請求項1記載のコンパイル装置。  2. The compiling apparatus according to claim 1, wherein the source program instruction preset in the prefetch target processing table is a user-defined function that specifies an address of data to be loaded from a memory to a register as an argument. 上記プリフェッチ対象処理テーブルにあらかじめ設定された原始プログラム命令は手続きおよびユーザ定義関数を記述するプログラムにおけるメモリからレジスタにロードするデータのアドレスを引数として指定するレジスタ復元関数であることを特徴とする請求項1記載のコンパイル装置。  The primitive program instruction preset in the prefetch target processing table is a register restoration function that specifies an address of data to be loaded from a memory in a program describing a procedure and a user-defined function as an argument. 1. The compiling device according to 1. 原始プログラムを変換して記憶した中間テキストに対して、メモリからレジスタへのロード処理命令に対応して先行した実行順序位置に該メモリからデータキャッシュにプリフェッチする命令を挿入して最適化するコンパイル方法であって、
あらかじめ設定された1以上の原始プログラム命令について該原始プログラム命令が変換されて中間テキストに記録される処理名情報の該処理名に対応させて該処理に先行して実行させるプリフェッチ命令を挿入する実行順序位置を中間テキストに記憶された実行経路情報に沿って遡及してカウントして決定する命令数をプリフェッチ対象処理テーブルに記憶手段が記憶するステップ、
上記原始プログラムから変換して記憶した中間テキストの各処理命令について処理名を上記プリフェッチ対象処理テーブルに記憶されたいずれかの処理名との一致を検索手段が検索し、一致した処理名に対応して該プリフェッチ対象処理テーブルに記憶された遡及する命令数を記憶手段が一時記憶する中間テキスト検索ステップ、
上記検索して処理名が一致した中間テキストの処理命令の実行順序位置から上記一時記憶された遡及する命令数に基づいて中間テキストに記憶された実行経路情報に沿ってプログラムの制御の流れをさかのぼり、上記プリフェッチ命令を挿入する実行順序位置を決定手段が決定するプリフェッチ命令挿入位置最適化ステップ、
上記決定した実行順序位置に上記検索して処理名が一致した中間テキストの処理命令がロードするメモリのアドレスを指定したデータキャッシュプリフェッチ命令を挿入手段が挿入するプリフェッチ命令挿入ステップ、
を有するコンパイル方法。
A compiling method for optimizing an intermediate text stored by converting a source program by inserting a prefetch instruction from the memory into the data cache at a preceding execution order position corresponding to the load processing instruction from the memory to the register Because
Execution of inserting a prefetch instruction to be executed prior to the processing corresponding to the processing name of the processing name information recorded in the intermediate text by converting the source program instruction with respect to one or more source program instructions set in advance A storage unit stores in the prefetch target processing table the number of instructions that are determined by retroactively counting the sequential positions along the execution path information stored in the intermediate text.
The search means searches for a match with one of the process names stored in the prefetch target process table for each process instruction of the intermediate text converted and stored from the source program, and corresponds to the matched process name. An intermediate text search step in which the storage means temporarily stores the number of retroactive instructions stored in the prefetch target processing table;
The control flow of the program is traced back along the execution path information stored in the intermediate text based on the number of retrospectively stored instructions from the execution order position of the processing instruction of the intermediate text whose search name matches the search. A prefetch instruction insertion position optimizing step in which the determining means determines an execution order position for inserting the prefetch instruction,
A prefetch instruction insertion step in which an insertion means inserts a data cache prefetch instruction specifying an address of a memory to be loaded by a processing instruction of an intermediate text whose processing name is matched by the search at the determined execution order position;
Compile method having
原始プログラムを変換して記憶した中間テキストに対して、メモリからレジスタへのロード処理命令に対応して先行した実行順序位置に該メモリからデータキャッシュにプリフェッチする命令を挿入して最適化するコンパイラプログラムを記録した記録媒体であって、
コンピュータを、
あらかじめ設定された1以上の原始プログラム命令について該原始プログラム命令が変換されて中間テキストに記録される処理名情報の該処理名に対応させて該処理に先行して実行させるプリフェッチ命令を挿入する実行順序位置を中間テキストに記憶された実行経路情報に沿って遡及してカウントして決定する命令数をプリフェッチ対象処理テーブルに記憶する手段、
上記原始プログラムから変換して記憶した中間テキストの各処理命令について処理名を上記プリフェッチ対象処理テーブルに記憶されたいずれかの処理名との一致を検索し、一致した処理名に対応して該プリフェッチ対象処理テーブルに記憶された遡及する命令数を一時記憶する中間テキスト検索手段、
上記検索して処理名が一致した中間テキストの処理命令の実行順序位置から上記一時記憶された遡及する命令数に基づいて中間テキストに記憶された実行経路情報に沿ってプログラムの制御の流れをさかのぼり、上記プリフェッチ命令を挿入する実行順序位置を決定するプリフェッチ命令挿入位置最適化手段、
上記決定した実行順序位置に上記検索して処理名が一致した中間テキストの処理命令がロードするメモリのアドレスを指定したデータキャッシュプリフェッチ命令を挿入するプリフェッチ命令挿入手段、
として機能させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体。
A compiler program that optimizes an intermediate text stored by converting a source program by inserting a prefetch instruction from the memory into the data cache at a preceding execution order position corresponding to the load processing instruction from the memory to the register A recording medium on which
Computer
Execution of inserting a prefetch instruction to be executed prior to the processing corresponding to the processing name of the processing name information recorded in the intermediate text by converting the source program instruction with respect to one or more source program instructions set in advance Means for storing in the prefetch target processing table the number of instructions that are determined by retroactively counting the sequential positions along the execution path information stored in the intermediate text;
For each processing instruction of the intermediate text converted and stored from the original program, the processing name is searched for a match with any of the processing names stored in the prefetch target processing table, and the prefetch corresponding to the matching processing name is searched. Intermediate text search means for temporarily storing the number of retroactive instructions stored in the target processing table;
The control flow of the program is traced back along the execution path information stored in the intermediate text based on the number of retrospectively stored instructions from the execution order position of the processing instruction of the intermediate text whose search name matches the search. , Prefetch instruction insertion position optimization means for determining an execution order position for inserting the prefetch instruction,
Prefetch instruction insertion means for inserting a data cache prefetch instruction designating an address of a memory to be loaded by the processing instruction of the intermediate text whose processing name is matched by the search at the determined execution order position;
A computer-readable recording medium in which a program for functioning as a computer is recorded.
JP01416898A 1998-01-27 1998-01-27 COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM Expired - Fee Related JP3918274B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP01416898A JP3918274B2 (en) 1998-01-27 1998-01-27 COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP01416898A JP3918274B2 (en) 1998-01-27 1998-01-27 COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM

Publications (2)

Publication Number Publication Date
JPH11212802A JPH11212802A (en) 1999-08-06
JP3918274B2 true JP3918274B2 (en) 2007-05-23

Family

ID=11853623

Family Applications (1)

Application Number Title Priority Date Filing Date
JP01416898A Expired - Fee Related JP3918274B2 (en) 1998-01-27 1998-01-27 COMPILING DEVICE, COMPILING METHOD, AND RECORDING MEDIUM CONTAINING COMPILER PROGRAM

Country Status (1)

Country Link
JP (1) JP3918274B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4374221B2 (en) 2003-08-29 2009-12-02 パナソニック株式会社 Computer system and recording medium
JP4486383B2 (en) * 2004-03-08 2010-06-23 株式会社アドバンテスト Pattern generator and test apparatus
JP6651974B2 (en) 2016-05-10 2020-02-19 富士通株式会社 Information processing apparatus, compiling method and compiler program

Also Published As

Publication number Publication date
JPH11212802A (en) 1999-08-06

Similar Documents

Publication Publication Date Title
US9798528B2 (en) Software solution for cooperative memory-side and processor-side data prefetching
US6931635B2 (en) Program optimization
Franklin et al. The expandable split window paradigm for exploiting fine-grain parallelsim
Callahan et al. Software prefetching
Hwu et al. Comparing software and hardware schemes for reducing the cost of branches
US6993753B2 (en) Compiler for parallel computer
US20020066081A1 (en) Speculative caching scheme for fast emulation through statically predicted execution traces in a caching dynamic translator
US6178498B1 (en) Storing predicted branch target address in different storage according to importance hint in branch prediction instruction
US20020095665A1 (en) Marking memory elements based upon usage of accessed information during speculative execution
US7366880B2 (en) Facilitating value prediction to support speculative program execution
US6721943B2 (en) Compile-time memory coalescing for dynamic arrays
US6658451B1 (en) Parallel join operation to support space and time dimensional program execution
US8352686B2 (en) Method and system for data prefetching for loops based on linear induction expressions
JPH07129412A (en) Method and equipment for compilation
JP3546341B2 (en) Data prefetch method and program generation method for multiple loops
EP1039382B1 (en) Memory access optimizing method
EP1190315B1 (en) Facilitating garbage collection during object versioning for space and time dimensional computing
US6430675B1 (en) Hardware system for fetching mapped branch target instructions of optimized code placed into a trace memory
JP3623360B2 (en) Loop creation method
US6314431B1 (en) Method, system, and apparatus to improve instruction pre-fetching on computer systems
JP2016040691A (en) Program optimization method, program optimization program and program optimization apparatus
WO2001067239A2 (en) Method and apparatus for facilitating exception handling using a conditional trap instruction
Carr et al. Unroll-and-jam using uniformly generated sets
US7234136B2 (en) Method and apparatus for selecting references for prefetching in an optimizing compiler
JP2004362216A (en) Compiler apparatus, compiling method, compiler program, and recording medium

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20060718

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060907

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20061024

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20061201

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20070205

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

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20110223

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20120223

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20130223

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20130223

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20140223

Year of fee payment: 7

LAPS Cancellation because of no payment of annual fees