JPH0728702A - Program converting method - Google Patents

Program converting method

Info

Publication number
JPH0728702A
JPH0728702A JP5174375A JP17437593A JPH0728702A JP H0728702 A JPH0728702 A JP H0728702A JP 5174375 A JP5174375 A JP 5174375A JP 17437593 A JP17437593 A JP 17437593A JP H0728702 A JPH0728702 A JP H0728702A
Authority
JP
Japan
Prior art keywords
array
arrays
program
same
description
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.)
Pending
Application number
JP5174375A
Other languages
Japanese (ja)
Inventor
Ichiro Kushima
伊知郎 久島
Masahiro Uminaga
正博 海永
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP5174375A priority Critical patent/JPH0728702A/en
Publication of JPH0728702A publication Critical patent/JPH0728702A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To convert a program in order to decrease the cache misses that are caused by the conflict of cache lines of a cache memory of a set associative system. CONSTITUTION:A part of a program that is repetitively carried out is specified in a step 101, and an array accessed in a loop is checked together with the access position in the array in a step 102. In a step 103, the array access position (subscript expression) changes at the same rate in the loop and the arrays are stored so that the arrays of the same reference and array types are put together. The arrays collected in the same group are changed into a single array in a step 104. In a step 105, the reference to the element of an unstructured array is changed to the reference to the element of a structured array.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、プログラムの変換もし
くはプログラムのコンパイルの技術に関し、特に、プロ
グラムを実行する計算機のキャッシュメモリのキャッシ
ュミスを低減できるようにプログラムを変換する技術に
関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a technique for converting a program or compiling a program, and more particularly to a technique for converting a program so as to reduce cache misses in a cache memory of a computer that executes the program.

【0002】[0002]

【従来の技術】現在の多くの計算機システムでは、高速
に動作するCPUとアクセス速度の遅い主メモリの速度
のギャップを埋めるために、キャッシュメモリと呼ばれ
るアクセス速度の速い小容量の記憶装置が、主メモリ
(主記憶)とCPUとの間の中間バッファとし備えられ
ることが多い。このようなキャッシュメモリはCPUが
高速にアクセス可能であるので、プログラム中の処理で
参照する多くのデータをキャッシュメモリ上にあるデー
タを参照する処理は、非常に高速に行うことができる。
2. Description of the Related Art In many current computer systems, a small-capacity storage device having a high access speed called a cache memory is mainly used in order to fill a speed gap between a CPU operating at high speed and a main memory having a low access speed. It is often provided as an intermediate buffer between the memory (main memory) and the CPU. Since such a cache memory can be accessed by the CPU at high speed, the process of referring to the data in the cache memory that is referred to in the process in the program can be performed very quickly.

【0003】さて、一般にプログラムがデータを参照す
る場合、次のような性質を持つことが多い。
Generally, when a program refers to data, it often has the following properties.

【0004】1.ある一定のアドレスのデータに対する
アクセスは比較的短い時間内に再発する。
1. Access to data at a certain address will occur again within a relatively short time.

【0005】2.ある一定時間内にアクセスされるデー
タは比較的近いアドレスに分布する。
2. Data accessed within a certain period of time is distributed to relatively close addresses.

【0006】前者は「時間的局所性」、後者は「空間的
局所性」と呼ばれる。キャッシュメモリを含む計算機シ
ステムはこれらの性質を利用するよう、次のように設計
されている。
The former is called "temporal locality" and the latter is called "spatial locality". A computer system including a cache memory is designed as follows to utilize these properties.

【0007】まず時間的局所性により、一度アクセスさ
れたアドレスは近い将来再びアクセスされる可能性が高
い。そこで、通常のキャッシュメモリでは、CPUが参
照するデータがキャッシュメモリ上にない場合は、それ
を必ずキャッシュメモリにフェッチして、将来の再参照
に備えるようにしている。ここでデータのキャッシュメ
モリへのフェッチはCPUによって自動的に行われの
で、プログラムはそのような命令を明示的に出す必要は
ない。
First, due to temporal locality, an address that has been accessed once is likely to be accessed again in the near future. Therefore, in a normal cache memory, if the data referred to by the CPU is not in the cache memory, it is always fetched in the cache memory to prepare for future re-reference. Since the CPU fetches the data to the cache memory automatically, the program does not need to explicitly issue such an instruction.

【0008】また、空間的局所性により、あるアドレス
がアクセスされたら、近い将来その近くのアドレスもア
クセスされる可能性が高い。そこで、あるデータを主メ
モリからキャッシュメモリにフェッチする場合は、その
データだけでなく、メモリの記憶空間を一定長(十数バ
イトから百バイト程度)の単位に分割したメモリブロッ
クごとキャッシュメモリにフェッチするようにしてい
る。
Further, due to the spatial locality, when an address is accessed, there is a high possibility that addresses near the address will be accessed in the near future. Therefore, when fetching certain data from the main memory to the cache memory, not only that data but also the memory blocks obtained by dividing the memory storage space into units of a fixed length (about 10 bytes to 100 bytes) are fetched into the cache memory. I am trying to do it.

【0009】このようにキャッシュメモリはプログラム
の一般的性質を利用して設計されているので個々のプロ
グラムは特にキャッシュメモリの存在を意識しないで記
述されていても、結果的にキャッシュメモリ装置を有効
利用できることが多い。
As described above, since the cache memory is designed by utilizing the general characteristics of the program, even if each program is written without paying attention to the existence of the cache memory, the cache memory device can be effectively used as a result. Often available.

【0010】なお、一般のキャッシュメモリ技術に対す
る解説としては、情報処理、ボリューム33、ナンバー
11(1992)、第1348頁から1357頁に記載
がある。
A description of general cache memory technology is given in Information Processing, Volume 33, Number 11 (1992), pages 1348 to 1357.

【0011】さて、ここで簡単にキャッシュメモリのア
ドレス・マッピングについて説明する。
Now, address mapping of the cache memory will be briefly described.

【0012】キャッシュメモリの各エントリにはメモリ
ブロックが入るが、どのメモリブロックを、どのエント
リに入れるかという点に関しては、いくつかの方式があ
る。
A memory block is placed in each entry of the cache memory, but there are some methods regarding which memory block is placed in which entry.

【0013】このメモリブロックとキャッシュメモリの
エントリの対応付けをアドレス・マッピングと呼ぶ。こ
の方式は大きく分けて3つある。
The association between the memory block and the cache memory entry is called address mapping. This method is roughly divided into three types.

【0014】ダイレクト・マッピングと呼ばれる方式
は、メモリブロックのアドレスによって、入るべきエン
トリを一意に決める方法である。具体的には、アドレス
をキャッシュメモリのサイズで割った余りを、そのメモ
リブロックを入れるべきエントリの番号とする。キャッ
シュメモリのサイズは通常2のべき乗であるので、たと
えばそれが2^Nであった場合には、アドレスの下位N
ビットにより入るべきエントリが決まる。この方法の場
合、2つのデータのアドレスの下位Nビットが偶然一致
していた場合、入るべきエントリが同じになるので、そ
の2つのデータは同時にはキャッシュメモリ上に存在で
きない。これをキャッシュメモリラインの競合と呼ぶ。
The method called direct mapping is a method for uniquely determining an entry to be entered by the address of the memory block. Specifically, the remainder obtained by dividing the address by the size of the cache memory is used as the entry number in which the memory block should be inserted. Since the size of the cache memory is usually a power of 2, if it is 2 ^ N, the lower N addresses
The bit determines the entry to enter. In the case of this method, if the lower N bits of the addresses of the two data happen to coincide, the entries to be entered are the same, so the two data cannot exist in the cache memory at the same time. This is called cache memory line competition.

【0015】セット・アソシアティブと呼ばれる方式
は、ダイレクトマップと同様にメモリアドレスの下位N
ビットよって入るエントリを決めるが、入るべきエント
リの候補が複数ある。この候補の数をセット数と呼ぶ。
たとえばセット数が2であれば、2つのデータのアドレ
スの下位Nビットが一致していても、(2つまでは)同
時にキャッシュメモリ上に存在できる。セット数は通常
2または4であることが多い。この方式でもやはりキャ
ッシュメモリラインの競合がおきる。
The method called set associative is similar to the direct map in that the lower N addresses of memory are
The entry to be entered is determined by the bit, but there are multiple entry candidates that should be entered. The number of candidates is called the number of sets.
For example, if the number of sets is two, even if the lower N bits of the addresses of the two data match, they can simultaneously exist (up to two) in the cache memory. Usually, the number of sets is usually 2 or 4. Even in this method, competition of cache memory lines still occurs.

【0016】完全・アソシアティブと呼ばれる方式は、
任意の空いているエントリにメモリブロックを入れられ
る方式である。この方式ではキャッシュメモリラインの
競合は起きないが、ハードウェア的に高価・低速である
ので実際には用いられることが少ない。
The method called perfect associative is
This is a method in which a memory block can be put in any vacant entry. In this method, competition of cache memory lines does not occur, but it is rarely used in practice because it is expensive and slow in terms of hardware.

【0017】[0017]

【発明が解決しようとする課題】しかし、あるデータを
主メモリからキャッシュメモリにフェッチする場合にメ
モリブロックごとキャッシュメモリにフェッチするのみ
では、キャッシュメモリを有効利用することのできない
プログラムがある。具体的には、プログラムの、繰り返
し実行される部分(ル−プ)でアクセスされる複数のデ
ータが、キャッシュメモリラインを競合する場合が、こ
れに当たる。
However, when a certain data is fetched from the main memory to the cache memory, there is a program in which the cache memory cannot be effectively used only by fetching the entire memory block into the cache memory. Specifically, this corresponds to a case where a plurality of data accessed in a repeatedly executed part (loop) of a program compete for a cache memory line.

【0018】いま、一例として図4に示すプログラムを
考えてみる。なお、ここでは、キャッシュメモリはセッ
ト数2のアソシアティブキャッシュメモリ、キャッシュ
メモリ1エントリは32バイト(8語)、エントリ数は
128の場合を想定する(したがってサイズは2*32
*128=8192バイト)。またキャッシュメモリ置
換方式はLRU(最後にアクセスされた時刻が最も古い
エントリをキャッシュメモリから追い出す方式)とす
る。
As an example, consider the program shown in FIG. It is assumed here that the cache memory is an associative cache memory with a set number of 2, the cache memory 1 entry is 32 bytes (8 words), and the number of entries is 128 (therefore, the size is 2 * 32).
* 128 = 8192 bytes). The cache memory replacement method is LRU (a method of expelling from the cache memory the entry with the oldest access time).

【0019】さて、図4に示したプログラムは、Cとし
て知られているプログラミング言語を用いて記述したプ
ログラム例である。この例では、まず、401〜404
の定義文で、4つの配列a,b,c,dの要素の型in
t(整数型)と要素数2048が定義されている。
The program shown in FIG. 4 is an example of a program written in a programming language known as C. In this example, first,
Definition statement of four array types a, b, c, d
t (integer type) and the number of elements 2048 are defined.

【0020】そして、処理main405中の407で
i,jの型int(整数型)が定義された後、408で
iに関するル−プが、409でjに関するループが宣言
されている。そして、iに関するル−プ409〜411
内のjに関するループ410、411内で4つの配列要
素a[j],b[j],c[j],d[j]が参照さ
れ、a[j]の値がb[j]に代入され410、c
[j]の値がd[j]に代入される411。
After the type int (integer type) of i, j is defined at 407 in the processing main 405, a loop for i is declared at 408 and a loop for j is declared at 409. And loops 409-411 for i
The four array elements a [j], b [j], c [j], d [j] are referred to in the loops 410 and 411 for j in j, and the value of a [j] is assigned to b [j]. 410, c
The value of [j] is substituted into d [j] 411.

【0021】ここで、これらの4つの要素はキャッシュ
メモリラインを競合する。なぜなら4つの配列の大きさ
はすべて8192(=2048*4)バイトであり、キ
ャッシュメモリの大きさと同じであるので、a[j],
b[j],d[j],c[j]のアドレスを8192で
割った余りはかならず等しくなるからである。
Here, these four elements compete for a cache memory line. Because the sizes of all four arrays are 8192 (= 2048 * 4) bytes, which is the same as the size of the cache memory, a [j],
This is because the remainders obtained by dividing the addresses of b [j], d [j], and c [j] by 8192 will always be the same.

【0022】いま、配列要素a[J]を参照した時点で
(Jはjのある特定の値)、キャッシュミスが発生した
とする。すると、a[J]を含むブロック(a[J..
J+7])がキャッシュメモリにフェッチされる。次
に、配列要素b[J]を参照した時点で、キャッシュミ
スが発生するとb[J]を含むブロック(b[J..J
+7])がキャッシュメモリにフェッチされる。このと
き、これら2つのブロックはキャッシュメモリラインを
競合するが、キャッシュメモリのセット数が2であるの
で、a[J..J+7]とb[J..J+7]は同時に
キャッシュメモリ上に存在できる。
It is assumed that a cache miss has occurred at the time when the array element a [J] is referenced (J is a certain value of j). Then, a block (a [J ..
J + 7]) is fetched into the cache memory. Next, when a cache miss occurs at the time when the array element b [J] is referred to, a block (b [J..J
+7]) is fetched into the cache memory. At this time, these two blocks compete for the cache memory line, but since the number of sets of the cache memory is 2, a [J. . J + 7] and b [J. . J + 7] can simultaneously exist in the cache memory.

【0023】しかし、この場合、次に配列要素c[J]
を参照した時点で、キャッシュミスが発生する。そし
て、c[J]を含むブロック(c[J..J+7])が
キャッシュメモリにフェッチされ、a[J..J+7]
がキャッシュメモリから追い出される。したがい、この
時点で、b[J..J+7]とc[J..J+7]がキ
ャッシュメモリ上に同時に存在することになる。また、
次に、配列要素d[J]を参照すると、やはりキャッシ
ュミスが発生し、d[J]を含むブロックd[J..J
+7]がキャッシュメモリにフェッチされ、b[J..
J+7]がキャッシュメモリから追い出される。したが
い、この時点では、c[J..J+7]とd[J..J
+7]がキャッシュメモリに同時に存在している。
However, in this case, the array element c [J]
A cache miss occurs when you refer to. Then, the block (c [J..J + 7]) including c [J] is fetched into the cache memory, and a [J. . J + 7]
Are flushed from cache memory. Therefore, at this point, b [J. . J + 7] and c [J. . J + 7] are simultaneously present in the cache memory. Also,
Next, referring to the array element d [J], a cache miss still occurs, and the block d [J. . J
+7] is fetched into the cache memory, and b [J. .
J + 7] is expelled from the cache memory. Therefore, at this point, c [J. . J + 7] and d [J. . J
+7] exists in the cache memory at the same time.

【0024】さて、ループイタレーションの次の回では
以下のようになる。まず配列要素a[J+1]を参照す
る。するとキャッシュミスが発生する。というのは競合
するキャッシュメモリラインにはc[J..J+7]と
d[J..J+7]が格納されておりa[J..J+
7]は追い出されているからである。このようにして配
列要素の参照b[J+1],c[J+1],d[J+
1],...,d[J+7]毎に、ことごとくキャッシ
ュミスが発生することになる。また、同様に、a[J+
8]以降のアクセスについても、同じ状況になるので、
結局すべての配列要素の参照についてキャシュミスが発
生する。
Now, the next round of loop iteration is as follows. First, the array element a [J + 1] is referenced. Then, a cache miss occurs. This is because c [J. . J + 7] and d [J. . J + 7] is stored and a [J. . J +
7] has been kicked out. In this way, array element references b [J + 1], c [J + 1], d [J +
1] ,. . . , D [J + 7], a cache miss will occur. Similarly, a [J +
8] Since the same situation applies to access after that,
Eventually a cache miss will occur for all array element references.

【0025】以上、図4のプログラムのル−プ内ではす
べての配列参照が、キャッシュミスを発生させることを
示した。このようなプログラムに関してキャッシュメモ
リを有効に利用するためには、キャッシュメモリの容量
の増大させるか、または、セット数の増大することが有
効である。
As described above, it has been shown that all the array references in the program loop of FIG. 4 cause a cache miss. In order to effectively use the cache memory for such programs, it is effective to increase the capacity of the cache memory or increase the number of sets.

【0026】すなわち、キャッシュメモリ容量を増大さ
せることにより、間接的にキャッシュメモリラインの競
合の機会を低減することができる。図4の例の場合、キ
ャッシュメモリの容量を2倍とすれば、その派生効果と
してキャッシュメモリラインの競合が4から2へ低減さ
れ、空間的局所性を活用できる。しかしキャッシュメモ
リ容量の増大はコスト増大を招くという大きな欠点があ
る。
That is, by increasing the cache memory capacity, it is possible to indirectly reduce the chance of competition for the cache memory lines. In the case of the example of FIG. 4, if the capacity of the cache memory is doubled, the contention of the cache memory lines is reduced from 4 to 2 as a derivative effect, and the spatial locality can be utilized. However, there is a major drawback in that the increase in cache memory capacity causes an increase in cost.

【0027】一方、セット数の増大は直接的にキャッシ
ュメモリライン競合の可能性を低減するものである。2
セットを4セットにした場合、a[J],b[J],c
[J],d[J]の4つの参照が同時期に発生したとし
てもa[J],b[J],c[J],d[J]を含むラ
インは同時にキャッシュメモリに存在できる。だたし、
セット数の増大はキャッシュメモリアクセス時間を長く
してしまう欠点がある。そして、これはプロセッサの動
作周波数を低くしてしまう原因となる。
On the other hand, the increase in the number of sets directly reduces the possibility of cache memory line competition. Two
When the number of sets is 4, a [J], b [J], c
Even if four references [J] and d [J] occur at the same time, a line including a [J], b [J], c [J], and d [J] can exist in the cache memory at the same time. However,
Increasing the number of sets has the drawback of increasing the cache memory access time. And this causes the operating frequency of the processor to be lowered.

【0028】このように、キャッシュメモリ容量の増大
やセット数の増大等のハードウェアの面からの対策には
種々の問題が生じてしまう。
As described above, various problems occur in the measures from the viewpoint of hardware such as an increase in the cache memory capacity and an increase in the number of sets.

【0029】そこで、本発明は、ハードウェアの変更な
しに、プログラムの繰り返し実行される部分(ル−プ)
でアクセスされる複数のデータについても、キャッシュ
メモリのヒット率を向上することのできるプログラムの
変換方法を提供することを目的とする。
Therefore, according to the present invention, a portion (loop) of a program that is repeatedly executed without changing hardware.
It is an object of the present invention to provide a program conversion method capable of improving the hit rate of a cache memory even for a plurality of data accessed by.

【0030】[0030]

【課題を解決するための手段】前記目的は、キャッシュ
メモリ装置自体に変更を加えるのではなく、キャッシュ
メモリラインの競合を回避するようにプログラムを変換
することによって達成される。すなわち、ループ内で参
照される配列要素がキャッシュメモリラインを競合する
可能性があるプログラムに対して、それらの配列のメモ
リ上での配置が、キャッシュメモリラインを競合しない
ような配置に変更されるようにプログラムを変更すれば
よい。
The above objects are achieved by transforming a program to avoid cache memory line conflicts, rather than making changes to the cache memory device itself. That is, for a program in which array elements referenced in a loop may conflict with cache memory lines, the placement of those arrays in memory is changed to an arrangement that does not conflict with cache memory lines. Change the program as follows.

【0031】そこで、このために、本発明は、プログラ
ムを変換する方法であって、プログラムのループする処
理を記述している部分を判別するステップと、判別した
ループする処理を記述している部分内で、参照すること
を記述されている複数の配列のうち、配列の型が等し
く、かつ、前記ル−プ処理の各回の処理で参照される、
配列の要素の配列内の位置が同じ配列どうしを同じ類別
にまとめるステップと、同じ類別にまとめられた複数の
配列を定義する記述を、当該複数の配列により構成され
る1つの配列を定義する記述に変換するステップと、前
記ループ処理部分内の、同じ類別にまとめられた複数の
配列の要素を参照する記述を、当該複数の配列により構
成される1つの配列の対応する要素を参照する記述に変
換するステップとを有することを特徴とするプログラム
の変換方法を提供する。
Therefore, for this purpose, the present invention is a method for converting a program, which comprises a step of determining a portion describing a looping process of the program, and a portion describing a determined looping process. Among the plurality of arrays described to be referred to, the types of the arrays are the same, and are referenced in each processing of the loop processing,
A step of grouping arrays that have the same position in the array of elements of the array into the same group, and a description that defines a plurality of arrays grouped into the same group, and a description that defines one array composed of the plurality of arrays. And a description that refers to elements of a plurality of arrays that are grouped in the same category in the loop processing part is changed to a description that refers to corresponding elements of one array configured by the plurality of arrays. And a converting step, which provides a program converting method.

【0032】[0032]

【作用】本発明に係るプログラムの変換方法によれば、
プログラムのループする処理を記述している部分を判別
し、判別したループする処理を記述している部分内で、
参照することを記述されている複数の配列のうち、配列
の型が等しく、かつ、前記ル−プ処理の各回の処理で参
照される、配列の要素の配列内の位置が同じ配列どうし
を同じ類別にまとめ、プログラムの同じ類別にまとめら
れた複数の配列を定義する記述を、当該複数の配列によ
り構成される1つの配列を定義する記述に変換すると共
に、前記ループ処理部分内の、同じ類別にまとめられた
複数の配列の要素を参照する記述を、当該複数の配列に
より構成される1つの配列の対応する要素を参照する記
述に変換する。そして、このように記述を変換したプロ
グラムに対しては、前記1つの配列を構成する複数の配
列間のキャッシュラインの競合は生じない。また、前記
1つの配列を構成する複数の配列の配列内の位置が同じ
各配要素が、プログラムの実行時にプログラムを実行す
る計算機に主記憶上の連続した位置に、順次配置すれ
ば、より効率的にキャッシュメモリを利用するこができ
る。
According to the program conversion method of the present invention,
Determine the part of the program that describes the looping process, and in the part that describes the determined looping process,
Among a plurality of arrays described to be referenced, the arrays have the same type, and the elements of the arrays referred to in each processing of the loop processing have the same position in the array. The description defining a plurality of arrays grouped into the same group and converted into a description defining one array composed of the plurality of arrays is performed, and the same grouping in the loop processing part is performed. The description referring to the elements of the plurality of arrays summarized in (1) is converted into the description referring to the corresponding element of one array configured by the plurality of arrays. Then, with respect to the program whose description is converted in this way, there is no competition of cache lines between a plurality of arrays forming the one array. Further, it is more efficient if the respective array elements having the same position in the array of the plurality of arrays forming the one array are sequentially arranged at the continuous position in the main memory in the computer executing the program at the time of executing the program. The cache memory can be used.

【0033】[0033]

【実施例】以下、本発明の一実施例について説明する。EXAMPLES An example of the present invention will be described below.

【0034】図2に、本実施例に係る計算機システムの
構成を示す。
FIG. 2 shows the configuration of the computer system according to this embodiment.

【0035】図示するように、計算機システムはCPU
201、主記憶装置202、外部記憶装置203、ディ
スプレイ装置204、キーボード205より構成されて
いる。
As shown, the computer system is a CPU
It comprises 201, a main storage device 202, an external storage device 203, a display device 204, and a keyboard 205.

【0036】外部記憶装置203にはソースプログラム
206と、オブジェクトプログラム207が格納され
る。主記憶装置202には、コンパイル処理を記述した
コンパイラプログラム211、コンパイル過程で必要と
なる中間語208、シンボルテーブル209、および、
ループ内配列参照テーブルテーブル210が格納され
る。コンパイル処理とは、ユ−ザによってC等の高級言
語によって記述されたソ−スプログラム206より、計
算機が直接解釈可能なアセンブリ言語やマシン語等によ
って記述したオブジェクトプログラム207を生成する
処理であり、CPU201がコンパイラプログラムを実
行することにより実現される。
A source program 206 and an object program 207 are stored in the external storage device 203. In the main storage device 202, a compiler program 211 describing a compiling process, an intermediate language 208 required in the compiling process, a symbol table 209, and
The in-loop array reference table table 210 is stored. The compiling process is a process for generating an object program 207 described by an assembly language or a machine language that can be directly interpreted by a computer from a source program 206 written by a user in a high-level language such as C. It is realized by the CPU 201 executing the compiler program.

【0037】さて、キーボード205は、ユーザからの
コンパイラ起動命令を受け付ける。ディスプレイ装置2
04は、コンパイル終了メッセージやエラーメッセージ
を表示する。
The keyboard 205 receives a compiler activation instruction from the user. Display device 2
04 displays a compilation end message and an error message.

【0038】以下、本実施例に係るコンパイル処理の詳
細について説明する。
The details of the compiling process according to this embodiment will be described below.

【0039】図3はコンパイラの処理を示すフローチャ
ートである。コンパイルは語彙解析301、構文解析3
02、構造体化303、最適化304、コード生成30
5の順に進む。
FIG. 3 is a flow chart showing the processing of the compiler. Compile is lexical analysis 301, syntactic analysis 3
02, structuring 303, optimization 304, code generation 30
Proceed in the order of 5.

【0040】このうち語彙解析、構文解析、最適化、コ
ード生成は従来のコンパイラにおける処理と同じである
ので簡単に説明する。
Of these, the vocabulary analysis, the syntax analysis, the optimization, and the code generation are the same as the processing in the conventional compiler, and therefore will be briefly described.

【0041】語彙解析301では、単に文字の列として
格納されているソースプログラムを外部記憶装置203
より逐次読み出し、単語(lexicon)の列にす
る。たとえば、前述した図4に示すプログラミング言語
Cで記述されたソ−スプログラムを語彙解析すると、図
5に示すような単語の列となる。
In the lexical analysis 301, the source program stored simply as a character string is stored in the external storage device 203.
It is read out more sequentially and made into a row of words (lexicon). For example, when the source program described in the programming language C shown in FIG. 4 described above is lexically analyzed, a string of words as shown in FIG. 5 is obtained.

【0042】ここで、図示するように、各単語は種別5
01と字句502の組で表現される。また、各単語はソ
ースプログラムの出現順に並べられる。種別のkeyw
ordはプログラムのキーワード、idは識別子、pu
ncは区切り記号、numは数字を表す。
Here, as shown in the figure, each word is of type 5
It is expressed by a set of 01 and the token 502. The words are arranged in the order of appearance of the source program. Type of keyw
ord is a keyword of the program, id is an identifier, pu
nc represents a delimiter and num represents a number.

【0043】次に、構文解析302は、単語の列を解析
する。構文解析は解析される文が宣言文であるか実行文
であるかによって異なる処理を行う。宣言文に対して
は、宣言される識別子をシンボルテーブル209に登録
し、実行文に対しては中間語208を主記憶装置202
上に作成する。
Next, the syntactic analysis 302 analyzes the string of words. The syntax analysis performs different processing depending on whether the analyzed statement is a declarative statement or an executable statement. For the declaration statement, the declared identifier is registered in the symbol table 209, and for the execution statement, the intermediate word 208 is stored in the main storage device 202.
Create on top.

【0044】ここで、シンボルテーブル209の例を図
6に示す。なお、図6に示した例は、先に説明した図4
のソ−スプログラムに対応している。
An example of the symbol table 209 is shown in FIG. Note that the example shown in FIG. 6 corresponds to the example shown in FIG.
It corresponds to the source program of.

【0045】図示するように、シンボルテーブル209
に登録されている情報は名称601、出現位置602、
型603、構造体化フラグ604等である。名称601
は識別子の名称、出現位置602は識別子が宣言された
位置(関数内か関数外か)を表す。型603は識別子の
型を表し、たとえば「array(int,204
8)」は「要素型がint(整数型)で要素数が204
8の配列」という型を表現する。構造体化フラグ604
は後述する構造体化処理303で設定されるフラグであ
り、最初はすべてoffとなっている。
As shown, the symbol table 209
The information registered in is the name 601, the appearance position 602,
A mold 603, a structured flag 604, and the like. Name 601
Indicates the name of the identifier, and the appearance position 602 indicates the position where the identifier is declared (whether inside the function or outside the function). The type 603 represents the type of the identifier, and for example, “array (int, 204
8) ”is“ the element type is int (integer type) and the number of elements is 204
8 array ". Structured flag 604
Is a flag set in the structuring process 303 described later, and is initially off.

【0046】次に、中間語208の例を図7に示す。な
お、この例も図4のプログラムに対応している。
Next, an example of the intermediate word 208 is shown in FIG. This example also corresponds to the program of FIG.

【0047】図示するように中間語208は木構造で表
現されている。木はノード(節)とエッジ(辺)の集合
である。図7でノードは四角で囲った部分、エッジはそ
れらを結ぶ線である。各ノードは1つの親ノードと0個
以上の子ノードを持つ(ただしルートと呼ばれる特別な
ノードだけは親ノードを持たない)。図では各ノードか
ら上に延びたエッジが親ノードを、下に延びたエッジが
子ノードを示す。子は左から第1子、第2子、…と呼
ぶ。たとえば「{}」(703)の親ノードは「fuc
n」(701)であり、子ノードは「for」(70
4)である。ルートノードは「func」(701)で
ある。木はプログラムの論理構造を表現するのに適して
いるでコンパイラで多く用いられている。
As shown in the figure, the intermediate word 208 is represented by a tree structure. A tree is a set of nodes and edges. In FIG. 7, nodes are parts surrounded by squares, and edges are lines connecting them. Each node has one parent node and zero or more child nodes (however, only a special node called the root has no parent node). In the figure, the edge extending upward from each node is a parent node, and the edge extending downward is a child node. The children are called the first child, the second child, ... From the left. For example, the parent node of “{}” (703) is “fuc
n ”(701), and the child node is“ for ”(70
4). The root node is "func" (701). Trees are suitable for representing the logical structure of programs and are often used in compilers.

【0048】このようにして作成されたシンボルテーブ
ル209と中間語208は、ソ−スプログラムと等価な
プログラムということができる。
The symbol table 209 and the intermediate language 208 thus created can be said to be a program equivalent to the source program.

【0049】次に、最適化303では、木構造で表現さ
れた実行文の部分を操作する。そして冗長な部分を見つ
けてその冗長部分を削除するなどの最適化処理を行う。
Next, in the optimization 303, the part of the executable statement represented by the tree structure is operated. Then, optimization processing such as finding a redundant portion and deleting the redundant portion is performed.

【0050】最後のコード生成305では、アセンブリ
言語で表現されたオブジェクトプログラムを生成する。
なお、マシン語で表現されたオブジェクトモジュ−ルを
生成するものもある。
In the final code generation 305, an object program expressed in assembly language is generated.
There is also one that generates an object module expressed in machine language.

【0051】すなわち、コード生成305では、シンボ
ルテーブル209からはアセンブリ言語の領域定義命令
や定数定義命令を生成し、中間語208からはアセンブ
リ言語の機械語命令を生成する。
That is, in the code generation 305, an assembly language area definition instruction and a constant definition instruction are generated from the symbol table 209, and an assembly language machine language instruction is generated from the intermediate language 208.

【0052】次に、構造体化303の処理手順について
説明する。
Next, the processing procedure of the structuring 303 will be described.

【0053】図1は構造体化303の処理手順を、詳し
く表したフローチャートである。
FIG. 1 is a flow chart showing in detail the processing procedure of the structuring 303.

【0054】図示するように、構造体化303の処理
は、ループ構造の認識101、ループ内配列参照の解析
102、配列群の類別103、配列要素の構造体化10
4、配列要素参照の構造体化メンバ参照への変更105
の順で進む。
As shown in the figure, the processing of structuring 303 is performed by recognizing a loop structure 101, analyzing an array reference in a loop 102, classifying an array group 103, and structuring an array element 10
4. Change of array element reference to structured member reference 105
In order.

【0055】以下これらの処理を具体的に説明する。These processes will be specifically described below.

【0056】構造体化303では、まずステップ101
で中間語208よりループ構造の認識101を行う。こ
の処理では中間語208を走査し、ループを表すノード
を見つけ、そのループで繰り返し実行される文(これ
を、以降単に「ループ実行文」と呼ぶ)を認識する。ル
ープ認識処理は、木のルートから走査を始める。たとえ
ば図7の中間語において、ルートのfunc701は関
数定義を表し、その第1子が関数名mainを、第2子
が関数本体を表す。第2子は{}703である。{}の
第1子に移ると、for704(ループノードの1種)
が見つかる(最初のfor文)。forノードで実行さ
れる文を表すのは第4子である(第1子は初期値設定
文、第2子は繰り返し判定文、第3子は制御変数更新文
である)ので、第4子に移る。第4子のfor708は
再びforノードである(2番目のfor文)。そこで
さらにその第4子へ移ると、それは{}709であり、
さらに{}709の子には2つの代入文(=で示され
る)があることがわかる。したがって2番目のfor文
のループ実行文は2つの代入文であることがわかる。以
上でループ構造の認識が終わる。
In structuring 303, first, step 101
Then, the loop structure is recognized 101 from the intermediate word 208. In this process, the intermediate word 208 is scanned, a node representing a loop is found, and a statement repeatedly executed in the loop (hereinafter, simply referred to as “loop execution statement”) is recognized. The loop recognition process starts scanning from the root of the tree. For example, in the intermediate language of FIG. 7, the root func 701 represents a function definition, the first child of which represents the function name main and the second child represents the function body. The second child is {} 703. Moving to the first child of {}, for704 (a kind of loop node)
Is found (first for sentence). The fourth child represents the statement executed by the for node (the first child is the initial value setting statement, the second child is the repeat determination statement, and the third child is the control variable update statement). Move on to. The fourth child for708 is again a for node (second for sentence). So when I moved to the fourth child, it was {} 709,
Furthermore, it can be seen that the child of {} 709 has two assignment statements (indicated by =). Therefore, it is understood that the loop execution statement of the second for statement is two assignment statements. This is the end of recognition of the loop structure.

【0057】次にステップ102で、ループ内の配列要
素参照解析を行う。この処理ではステップ101で認識
したループ実行文の中間語208を走査し、配列要素参
照ノードを見つけ、配列名、添字式、参照状況(使用/
定義の別)を調べ、これを、主記憶装置202の配列要
素参照テーブル210に登録する。ここで、添字式と
は、配列a[F(x)]の関数Fが表す式をいう。
Next, at step 102, the array element reference analysis in the loop is performed. In this processing, the intermediate word 208 of the loop execution statement recognized in step 101 is scanned to find the array element reference node, and the array name, subscript expression, reference status (use /
The definition) is checked and registered in the array element reference table 210 of the main memory 202. Here, the subscript expression is an expression represented by the function F of the array a [F (x)].

【0058】たとえば、図7に示した中間語では配列要
素参照ノード([]で示される)の第1子が配列名を、
第2子が添字式を表す。また代入ノード(=で示され
る)の第1子が代入先(定義側)を、第2子が代入元
(使用側)を表すとする。図7の中間語におけるループ
実行文は2つの代入文である。
For example, in the intermediate language shown in FIG. 7, the first child of the array element reference node (indicated by []) is the array name,
The second child represents a subscript expression. Further, it is assumed that the first child of the assignment node (denoted by =) represents the assignment destination (definition side) and the second child represents the assignment source (use side). The loop execution statement in the intermediate language of FIG. 7 is two assignment statements.

【0059】最初の代入文(710)は、配列名a、添
字式jで指定される配列要素(ソースプログラム上の表
現ではa[j]に対応)を配列名b、添字式jで指定さ
れる配列要素(ソースプログラム上の表現ではb[j]
に対応)に代入する形である。以下、配列要素について
は説明を明瞭にするために、ソースプログラム上の表現
を便宜的に用いる。次の代入文(711)は、配列要素
c[j]を配列要素d[j]に代入する形である。よっ
て、図7に示した中間語より、ステップ102によって
図8に示す配列要素参照テーブル210が作成される。
なお、配列要素が定義され、かつ使用されている場合は
配列要素参照テーブル210の参照状況は「定義」とす
る。
In the first assignment statement (710), the array element designated by the array name a and the subscript expression j (corresponding to a [j] in the expression on the source program) is designated by the array name b and the subscript expression j. Array element (b [j] in the source program representation)
Corresponding to) is the form to substitute. Hereinafter, for the sake of clarity, the expression on the source program will be used for the array elements for the sake of clarity. The following assignment statement (711) has a form of assigning the array element c [j] to the array element d [j]. Therefore, in step 102, the array element reference table 210 shown in FIG. 8 is created from the intermediate language shown in FIG.
When the array element is defined and used, the reference status of the array element reference table 210 is “definition”.

【0060】次に、ステップ103で、配列群を類別す
る。
Next, in step 103, the array groups are classified.

【0061】この処理は、各配列要素参照が同じ類に属
するか否かを判定する。ここで、配列要素参照とは、配
列の要素の参照を表す記述をいい、ソ−スプログラム上
ではa[j]やc[j]等の記述が該当し、中間語上で
は、配列要素参照ノード([]で示される)と、その子
の記述が該当する。
This process determines whether each array element reference belongs to the same class. Here, the array element reference refers to a description indicating a reference to an element of an array, which corresponds to a description such as a [j] or c [j] on the source program, and an array element reference on the intermediate language. The description of the node (indicated by []) and its children correspond.

【0062】この処理のフローチャートを図9に示す。A flowchart of this processing is shown in FIG.

【0063】この処理では、まずステップ901で、与
えられた配列要素参照の添字式がともにループ制御変数
の1次式となっているかを調べる。ここで1次式とは
「定数1*ループ制御変数+定数2」の形をしているこ
とである(ただし定数1、定数2は0でもよい)。少な
くともどちらか一方がループ制御変数の1次式になって
いない場合は、同じ類に属さないと判定して(906)
処理終了する。
In this processing, first, at step 901, it is checked whether both the subscript expressions of the given array element references are linear expressions of the loop control variable. Here, the linear expression has a form of “constant 1 * loop control variable + constant 2” (however, constant 1 and constant 2 may be 0). If at least one of them is not a linear expression of the loop control variable, it is judged that they do not belong to the same class (906).
Processing ends.

【0064】ともに1次式である場合は次にステップ9
02で、添字式の係数と定数項がそれぞれ等しいかどう
か(定数1、定数2がそれぞれ等しいかどうか)を調べ
る。等しくない場合は、同じ類に属さないと判定して
(906)処理を終了する。
If both are linear expressions, then step 9
In 02, it is checked whether the coefficient of the subscript expression and the constant term are equal (whether constant 1 and constant 2 are equal). If they are not equal, it is determined that they do not belong to the same class (906), and the process is terminated.

【0065】等しい場合は次にステップ903で、2つ
の配列の型が等しいかを調べる。ここで型が等しいと
は、配列要素の型と配列の要素数がともに等しいことを
意味する。等しくない場合は、同じ類に属さないと判定
して(906)処理を終了する。
If they are equal, then in step 903, it is checked whether the two arrays have the same type. Equal type here means that the type of array element and the number of elements of the array are equal. If they are not equal, it is determined that they do not belong to the same class (906), and the process is terminated.

【0066】型が等しい場合は次にステップ904で、
参照状況が等しいかどうかを調べる。ここで参照状況が
等しいとは、2つの参照がいずれも定義であるか、また
はいずれも使用であるということを意味する。等しけれ
ば同じ類に属すると判定して(905)処理終了する。
等しくなければ同じ類に属さないと判定して(906)
処理を終了する。
If the types are the same, then in step 904,
Check if the reference statuses are equal. Here, the reference situations being equal means that the two references are both definitions or both are uses. If they are equal, it is determined that they belong to the same class (905), and the process ends.
If they are not equal, it is determined that they do not belong to the same class (906)
The process ends.

【0067】以上の処理によって、たとえば図4に示し
たソ−スのプログラムでは参照a[j]とc[j]が同
じ類に、また参照b[j]とd[j]が同じ類に含まれ
ると判定される(jはループ制御変数である)。
By the above processing, for example, in the source program shown in FIG. 4, the references a [j] and c [j] are in the same class, and the references b [j] and d [j] are in the same class. It is determined to be included (j is a loop control variable).

【0068】さて、図1に戻り、次にステップ104
で、配列要素の構造体化を行う。
Now, returning to FIG.
Then, the array elements are structured.

【0069】この処理では、1つの類に属する配列参照
によって参照される複数の配列をまとめて1つの配列に
する。その配列の要素型は構造体型となるが、それは次
のように求める。1つの類に属する配列をA1,…,A
nとし、それらの要素型をt、配列要素数をNとする
(同類であれば配列の要素型・要素数は同じである)。
すると合体して1つにした配列の要素型は(C言語で表
せば)、 という型になる。これは、合体して1つにした配列のi
番目の要素は、n個の配列A1,…,Anそれぞれのi
番目の整数型要素による配列であることを表している。
なお、合体して1つにした配列の要素数はNのままであ
る。
In this processing, a plurality of arrays referred to by the array reference belonging to one class are put together into one array. The element type of the array is a structure type, which is calculated as follows. Sequences belonging to one class are A1, ..., A
Let n be the element type thereof, and t be the number of array elements (if they are of the same type, the element type and number of elements of the array are the same).
Then, the element types of the combined array are (in C language): It becomes the type. This is the i of the combined sequence.
The th element is the i of each of the n arrays A1, ..., An.
Indicates that the array is the th integer type element.
Note that the number of elements in the array that has been merged into one remains N.

【0070】さて合体して1つにした配列の配列名はユ
ニークな(他の名前と競合しない)名前とするが、ここ
では元の配列名を単につなげたもの(A1…An)を便
宜的に用いることにする。
The sequence names of the combined sequences are made unique (do not conflict with other names), but here, the original sequence names are simply combined (A1 ... An) for convenience. I will use it for.

【0071】さて、このように新たに生成した配列は、
シンボルテーブル209に登録する。そして、もとの配
列に対しては、構造体化されたことを示す「構造体化フ
ラグ」をオンにする。さらに構造体化した後の配列シン
ボルを登録する。図4のプログラムに対してステップ1
04の処理を行うと、シンボルテーブルは図10に示す
ようになる。図10では配列aとcが構造体化されて1
つの配列ac(1001)となり、配列bとdが構造体
化されて1つの配列bd(1002)になっている。こ
れらの配列の型はともに「array(struct
(int,int),2048)」になる。そして配列
a,b,c,dに対しては構造体化フラグがオンにな
る。また構造体化した後のシンボルを示すフィールド
(605)には、配列a,cに対しては配列ac、配列
b,dに対しては配列bdが登録される。
Now, the array newly generated in this way is
Register in the symbol table 209. Then, the "structuring flag" indicating that the original array has been structured is turned on. The array symbol after further structuring is registered. Step 1 for the program in Figure 4
When the processing of 04 is performed, the symbol table becomes as shown in FIG. In FIG. 10, arrays a and c are structured into 1
One array ac (1001) is formed, and the arrays b and d are structured into one array bd (1002). The types of these arrays are both "array (struct
(Int, int), 2048) ”. The structuring flag is turned on for the arrays a, b, c and d. Further, in the field (605) indicating the symbol after being structured, the array ac is registered for the arrays a and c, and the array bd is registered for the arrays b and d.

【0072】次にステップ105で、配列要素参照を構
造体化メンバ参照へ変更する。これは、中間語を再度走
査し、構造体化フラグがオンである配列要素への参照が
あれば、それを構造体化した後の配列要素参照(構造体
メンバ参照)に置き換える処理である。図11はこの処
理での中間語の変更を示す図である。もとの配列参照を
A、構造体化後の配列をBとすると、1101が変更前
の木を、1102が変更後の木を表す。図11で「.」
というノードは構造体のメンバ参照を表すノードであ
る。
Next, at step 105, the array element reference is changed to a structured member reference. This is a process of scanning the intermediate word again, and if there is a reference to an array element whose structuring flag is on, replaces it with the array element reference (structure member reference) after structuring. FIG. 11 is a diagram showing the change of the intermediate language in this processing. Letting A be the original array reference and B be the array after structuring, 1101 represents the tree before the change and 1102 represents the tree after the change. In Fig. 11, "."
Is a node that represents the member reference of the structure.

【0073】図11の変更は、ソースプログラム表現で
表現すればA[e]がB[e].Aに変わることを意味
する。図4のプログラムでは図10のシンボルテーブル
で示されるように配列a,b,c,dが書き換えの対象
となる。したがって図7の中間語を走査すると配列参照
a[j],b[j],c[j],d[j]が変更の対象
として見つかり、以下のように変更される(実際には、
図11に示すように中間語レベルで変更する) a[j] → ac[j].a b[j] → bd[j].b c[j] → ac[j].c d[j] → bd[j].d ここで、ac[j].aは、配列acの要素のうち、配
列acに構造体化されている配列aのj番目の要素を表
している。
The modification of FIG. 11 is that A [e] is changed to B [e]. It means to change to A. In the program of FIG. 4, arrays a, b, c, and d are rewritten as shown in the symbol table of FIG. Therefore, when scanning the intermediate word of FIG. 7, array references a [j], b [j], c [j], d [j] are found to be changed and are changed as follows (actually,
Change at intermediate language level as shown in FIG. 11) a [j] → ac [j]. a b [j] → bd [j]. bc [j] → ac [j]. cd [j] → bd [j]. d where ac [j]. a represents the j-th element of the array a that is structured into the array ac among the elements of the array ac.

【0074】以上で構造体化処理の説明を終わる。This is the end of the explanation of the structuring process.

【0075】図12は構造体化処理が終った時点でのプ
ログラムをソースプログラムイメージで示したものであ
る。ただし、以上の処理は、ソ−スプログラムと等価な
中間語208やシンボルテ−ブル209に対して行うの
で、実際にソースプログラムが変更されるわけではな
い。
FIG. 12 is a source program image showing a program at the time when the structuring process is completed. However, since the above processing is performed on the intermediate language 208 and the symbol table 209 equivalent to the source program, the source program is not actually changed.

【0076】さて、このようにして、構造体化303に
よって変更された中間語208やシンボルテ−ブル20
9は、前述したように、最適化30で、中間後の木構造
で表現された実行文の冗長部分を削除するなどの最適化
処理を行われる。そして、コード生成305では、構造
体化303によって変更された中間語208やシンボル
テ−ブル209より、アセンブリ言語もしくはマシン語
で表現されたオブジェクトプログラムを生成する。すな
わち、前述したように、コード生成305は、シンボル
テーブル209からはアセンブリ言語の領域定義命令や
定数定義命令を生成し、中間語208からはアセンブリ
言語の機械語命令を生成する。
Now, the intermediate language 208 and the symbol table 20 changed by the structuring 303 in this way are described.
As described above, 9 is the optimization 30 in which optimization processing such as deleting the redundant portion of the executable statement represented by the tree structure after the intermediate processing is performed. Then, in the code generation 305, an object program expressed in assembly language or machine language is generated from the intermediate language 208 and the symbol table 209 changed by the structuring 303. That is, as described above, the code generator 305 generates an assembly language area definition instruction and a constant definition instruction from the symbol table 209, and generates an assembly language machine language instruction from the intermediate language 208.

【0077】この、シンボルテーブル209からのアセ
ンブリ言語の領域定義命令の生成に際して、コード生成
305は、シンボルテーブル209の構造体化フラグ6
04がオンに設定されている配列についての領域定義命
令は生成しない。すなわち、たとえば、構造体化された
配列acについて領域は定義するが、この元となった配
列a,cそれぞれについては領域の定義を行わない。
When generating the assembly language area definition instruction from the symbol table 209, the code generator 305 uses the structuring flag 6 of the symbol table 209.
No area definition instruction is generated for an array in which 04 is set to ON. That is, for example, the area is defined for the structured array ac, but the area is not defined for each of the original arrays a and c.

【0078】また、構造体化された配列は、オブジェク
トプログラムの実行時、オブジェクトプログラムを実行
する計算機の主記憶上の、配列acについての領域定義
命令によって定義された領域にac[0].a,ac
[0].c,ac[1].a,ac[1].c,…,a
c[2047].a,ac[2047].cの順に格納
される。
When the object program is executed, the structured array is stored in the area defined by the area definition command for the array ac on the main memory of the computer that executes the object program. a, ac
[0]. c, ac [1]. a, ac [1]. c, ..., a
c [2047]. a, ac [2047]. It is stored in the order of c.

【0079】以下、このようにして生成したオブジェク
トプログラム207が実行される際に、キャッシュメモ
リででキャッシュミスがどの程度発生するかを説明す
る。
Hereinafter, it will be described how many cache misses occur in the cache memory when the object program 207 thus generated is executed.

【0080】いま、図13に示すようなキャッシュメモ
リを想定する。
Now, assume a cache memory as shown in FIG.

【0081】図13に示したキャッシュメモリは、セッ
ト数2のアソシアティブキャッシュである。キャッシュ
容量は全体で8kバイト、すなわち1つのセットの容量
は4kバイトである。1セットは128個のエントリを
持つ。エントリの番号をインデクスと呼び、同じインデ
クスをもつ2つのエントリを合わせてラインと呼ぶ。1
ラインには1つのラインは制御ビット(1201)、タ
グ(1202)、データ(1203)の3つの部分から
なる。データ部には32バイト(8語)分のメモリデー
タが格納される。タグはデータ部に格納しているデータ
が、どのメモリアドレスに対応するものかを特定するフ
ィールドである。制御ビットはemptyビット(12
04)、recentビット(1205)、dirty
ビット(1206)等からなる。emptyビットは当
ラインが空きであるかを示す(真のとき空き)。rec
entビットは当エントリが、他方のエントリよりも後
にアクセスされたかどうかを示す(真のとき後)。di
rtyビットは当エントリに書き込みがあったかを示す
(真のとき書き込み有り)。
The cache memory shown in FIG. 13 is an associative cache having two sets. The total cache capacity is 8 kbytes, that is, the capacity of one set is 4 kbytes. One set has 128 entries. The entry number is called an index, and two entries having the same index are collectively called a line. 1
In each line, one line consists of three parts: control bit (1201), tag (1202), and data (1203). 32 bytes (8 words) of memory data are stored in the data section. The tag is a field that specifies to which memory address the data stored in the data section corresponds. The control bit is the empty bit (12
04), recent bit (1205), dirty
It consists of bits (1206) and the like. The empty bit indicates whether this line is empty (when it is true, it is empty). rec
The ent bit indicates whether this entry is accessed later than the other entry (when true, after). di
The rty bit indicates whether or not there is a write in this entry (when true, there is a write).

【0082】メモリアクセスが発生すると、メモリアド
レス(1207)のうち、下位から6番目から12番目
の7ビットの値をインデクス(1209)としてキャッ
シュライン中のラインを特定する。セット数2であるの
で、1つのラインに2つのエントリがある。次に当該の
メモリアドレスの上位20ビットの値をタグ(120
8)として取り出し、それとエントリ内に格納されたタ
グ(1202)の値をそれぞれ比較器(1210)で比
較する。一致するエントリがあればキャッシュヒットと
なる。そうでなければキャッシュミスになる。キャッシ
ュミスの場合はデータをメモリからフェッチし、2つの
エントリのうち空(制御ビットのemtpyビットが
真)のエントリに格納する。いずれのエントリも空でな
ければ、最後にアクセスされた時刻がより古い(rec
entビットが真でない)エントリに格納する。ただし
格納する前に、そのエントリに書き込みがあったかどう
か(dirtyビットが真かどうか)を調べ、書き込み
があれば以前のエントリ内容を主メモリに書き戻す。書
き込みがなければ主メモリに書き戻す必要はない。
When a memory access occurs, the line in the cache line is specified by using the 6th to 12th lowest 7-bit value of the memory address (1207) as an index (1209). Since the number of sets is 2, there are two entries in one line. Next, the value of the upper 20 bits of the relevant memory address is set to the tag (120
8), and the value of the tag (1202) stored in the entry is compared by the comparator (1210). If there is a matching entry, it is a cache hit. Otherwise, you will get a cache miss. In the case of a cache miss, the data is fetched from the memory and stored in the empty entry (the emtppy bit of the control bit is true) of the two entries. If neither entry is empty, the last accessed time is older (rec
ent bit is not true) Store in entry. However, before storing, it is checked whether or not the entry has been written (whether the dirty bit is true), and if there is the writing, the previous entry contents are written back to the main memory. If there is no writing, there is no need to write it back to the main memory.

【0083】このようなキャッシュメモリを備えた計算
機において、先に生成したオブジェクトプログラムを実
行すると、各配列データは、主メモリに、図14に示す
ように配置されることになる。
When the previously created object program is executed in a computer having such a cache memory, each array data is arranged in the main memory as shown in FIG.

【0084】図14は、構造体化した配列ac,bdの
主メモリ内での配置を示した図である。図示するよう
に、配列acは00000000番地から00002F
FC番地に、ac[0].a,ac[0].c,ac
[1].a,ac[1].c,…,ac[2047].
a,ac[2047].cの順に格納される。配列bd
は00003000番地から00004FFC番地に、
bd[0].b,bd[0].d,bd[1].b,b
d[1].d,…,bd[2047].b,bd[20
47].dの順に格納される。
FIG. 14 is a diagram showing the arrangement of the structured arrays ac and bd in the main memory. As shown in the figure, the array ac is from 00000000 to 00002F
At the FC address, ac [0]. a, ac [0]. c, ac
[1]. a, ac [1]. c, ..., ac [2047].
a, ac [2047]. It is stored in the order of c. Array bd
From address 003000 to address 00004FFC,
bd [0]. b, bd [0]. d, bd [1]. b, b
d [1]. d, ..., bd [2047]. b, bd [20
47]. They are stored in the order of d.

【0085】配列要素データがキャッシュメモリにフェ
ッチされるときは8要素(8語)分が1度にフェッチさ
れる。たとえば、配列要素ac[0].aがアクセスさ
れ、もしそれがキャッシュになかった場合、ac
[0].aを含む8語分のメモリブロック(ac
[0].a,…,ac[3].c)がキャッシュにフェ
ッチされる。また、この場合は、任意のIに対して、a
c[I]とbd[I]のアドレスの下位12ビット部分
の値は等しくなる。たとえばac[1]のアドレスは0
0000004、bd[1]のアドレスは000030
04で、下位12ビットはともに004である。下位1
2ビットによりキャッシュラインが決まるので、これら
は同じキャッシュラインに格納される。すなわち、ac
[I]とbd[I]はキャッシュラインを競合する。
When array element data is fetched into the cache memory, 8 elements (8 words) are fetched at once. For example, array element ac [0]. If a is accessed and it is not in the cache, ac
[0]. 8 word memory block including a (ac
[0]. a, ..., ac [3]. c) is fetched into the cache. In this case, for any I, a
The values of the lower 12 bits of the addresses of c [I] and bd [I] are equal. For example, the address of ac [1] is 0
The address of 00000004, bd [1] is 000030
In 04, the lower 12 bits are both 004. Bottom 1
Since the cache line is determined by 2 bits, they are stored in the same cache line. That is, ac
[I] and bd [I] compete for a cache line.

【0086】さて、図4に示したソ−スプログラムのオ
ブジェクトプログラム実行に沿って、キャッシュメモリ
の振舞いを示すと次のようになる。
The behavior of the cache memory along with the object program execution of the source program shown in FIG. 4 is as follows.

【0087】先ず配列要素ac[0].aが参照され
る。最初のアクセスでありac[0].aを含むメモリ
ブロック(ac[0].a,…,ac[3].c)がキ
ャッシュメモリにフェッチされる。次にbc[0].b
が参照される。これも最初の参照でありbd[0].b
を含むメモリブロック(bd[0].b,…,bd
[3].d)がキャッシュメモリにフェッチされる。こ
れら2つのメモリブロックはキャッシュラインを競合す
るが、セット数が2であるので共にキャッシュメモリに
残る。以降、ac[0].c,bd[0].d,ac
[1].a,bd[1].b,ac[1].c,bd
[1].d,…,bd[3].dの順に参照するが、こ
れらはすべて既にキャッシュメモリにフェッチしてある
のでキャッシュヒットとなる。まとめると、16回の参
照でキャッシュミスが2回である。その次の配列参照は
ac[4].aであるが、この部分は最初のac
[0].aの参照と同じ状況となる。したがって、16
回の参照毎に2回キャッシュミスが発生することにな
る。
First, the array element ac [0]. Reference is made to a. This is the first access and ac [0]. A memory block (ac [0] .a, ..., ac [3] .c) including a is fetched into the cache memory. Next, bc [0]. b
Is referred to. This is also the first reference, bd [0]. b
, Including memory block (bd [0] .b, ..., bd
[3]. d) is fetched into the cache memory. These two memory blocks compete for the cache line, but both sets remain in the cache memory because the number of sets is two. After that, ac [0]. c, bd [0]. d, ac
[1]. a, bd [1]. b, ac [1]. c, bd
[1]. d, ..., bd [3]. Although they are referred to in the order of d, they are cache hits because they have already been fetched into the cache memory. In summary, 16 references refer to two cache misses. The next sequence reference is ac [4]. a, but this part is the first ac
[0]. It becomes the same situation as the reference of a. Therefore, 16
A cache miss will occur twice for each reference.

【0088】ここで、比較のために、図15に、配列を
構造体化しなかった場合の、配列a,b,c,dの主メ
モリ内での配置を示す。この場合、配列aは00000
000番地から00001FFC番地に、配列bは00
002000番地から00002FFC番地に、配列c
は00003000番地から00003FFC番地に、
配列dは00004000番地から00004FFC番
地に連続して格納される。また、任意のIに対して、a
[I]、b[I]、c[I]、d[I]のアドレスの下
位12ビット部分の値はすべて等しい。すなわち、これ
らはキャッシュラインを競合する。したがい、この場
合、前述したように16回の参照で16回、すなわち毎
回キャッシュミスが発生することになる。
For comparison, FIG. 15 shows the arrangement of the arrays a, b, c and d in the main memory when the arrays are not structured. In this case, the array a is 00000
Array b is 00 from address 000 to address 00001FFC
Array c from address 002000 to address 00002FFC
From 00003000 to 0000FFFC,
The array d is continuously stored from the address 0004000 to the address 0000440FFC. Also, for any I, a
The values of the lower 12 bits of the addresses of [I], b [I], c [I], and d [I] are all equal. That is, they compete for cache lines. Therefore, in this case, as described above, the cache miss occurs 16 times, that is, every time the reference is made 16 times.

【0089】したがい、本実施例によれば、ず4に示し
たソ−スプログラムについて、キャッシュミスを1/8
(=2/16)に減ずることができたことになる。
Therefore, according to the present embodiment, with respect to the source program shown in step 4, the cache miss is 1/8.
This means that we were able to reduce it to (= 2/16).

【0090】なお、本実施例によれば、参照状況が同じ
配列をまとめて一つの配列に構造体化しているので、参
照状況が「使用」の配列をまとめた配列は、キャッシュ
メモリ上で変更されない。したがい、この配列について
主メモリへの書き戻しが不要になる。すなわち、配列a
cは、キャッシュメモリ上で変更されないので、配列a
cの部分を含むキャッシュラインがキャッシュから追い
出されるとき、dirtyはセットされておらず主メモ
リへの書き戻しが不要となる。このことは、前述したよ
うな、特に主メモリへの書き戻し方式としてストアイン
方式を採用する計算機にとって有利である。なぜなら
ば、主メモリへの書き戻しを行う必要が生じるデータ、
メモリブロックを局在化できるので書き戻し回数を低減
することができるからである。しかし、もし、書き戻し
方式としてストアスル−方式を採用する計算機上でのみ
実行されるプログラムであれば、このような効果は期待
できない。そこで、このような場合等には、参照状況が
異なる配列であっても、まとめて一つの配列に構造体化
するようにしてもよい。すなわち、図9の904のステ
ップを省略するようにしてもよい。もちろん、書き戻し
方式としてストアイン方式を採用する計算機で実行され
るプログラムにおいて、参照状況が異なる配列であって
も、まとめて一つの配列に構造体化するようにしても前
述したキャッシュミスを低減する効果を達成することが
できる。この場合、図4に示した例では、配列a,b,
c,dが一つの配列abcdに構造体化されることにな
る。そして、この場合、キャッシュラインの競合は発生
せず、8回の参照毎に1度、キャッシュメモリへのフェ
ッチが生じることになる。これは、ダイレクト・マッピ
ング方式においても同様である、したがい、このように
することにより、ダイレクト・マッピング方式において
もキャッシュミスを低減することができる。
According to the present embodiment, since the arrays having the same reference status are grouped into a single array, the array in which the reference status is "used" is changed in the cache memory. Not done. Therefore, there is no need to write back this array to main memory. That is, array a
Since c is not changed in the cache memory, array a
When the cache line including the part of c is evicted from the cache, the dirty is not set and the writing back to the main memory is unnecessary. This is advantageous for a computer that employs the store-in method as a method for writing back to the main memory, as described above. Because the data that needs to be written back to the main memory,
This is because the memory blocks can be localized and the number of write backs can be reduced. However, if the program is executed only on a computer that adopts the store-through method as the write-back method, such an effect cannot be expected. Therefore, in such a case, even arrays having different reference situations may be collectively structured into one array. That is, step 904 in FIG. 9 may be omitted. Of course, in a program executed on a computer that uses the store-in method as the write-back method, even if the arrays have different reference conditions, the cache misses described above are reduced even if they are structured into a single array. The effect of doing can be achieved. In this case, in the example shown in FIG. 4, the arrays a, b,
c and d are structured into one array abcd. In this case, cache line contention does not occur, and a fetch to the cache memory occurs once every eight references. This is also the case with the direct mapping method. Therefore, by doing so, cache misses can be reduced also in the direct mapping method.

【0091】なお、以上の実施例では、Cとして知られ
るプログラミング言語により記述されたソ−スプログラ
ムを対象とする場合を例にとり説明したが、たとえば、
FORTRANとして知られるプログラミング言語等、
他のプログラミング言語についても同様に実施すること
ができる。
In the above embodiments, the source program written in the programming language known as C is described as an example.
A programming language known as FORTRAN,
Other programming languages can be implemented similarly.

【0092】また、本実施例では、コンパイル時に、中
間言語やシンボルテ−ブルに対して、配列の構造体化や
配列要素参照の変換を行ったが、この結果を反映するよ
うにソ−スプログラムを変換するようにしてもよい。た
とえば、図4に示したソ−スプログラムを図12に示し
たソ−スプログラムに変換するようにしてもよい。この
場合は、この後、図12に示したソ−スプログラムを従
来と同様にコンパイルすればよい。
In the present embodiment, the structure of the array and the conversion of the array element reference are performed for the intermediate language and the symbol table at the time of compiling, but the source program is made to reflect the result. May be converted. For example, the source program shown in FIG. 4 may be converted into the source program shown in FIG. In this case, after that, the source program shown in FIG. 12 may be compiled in the same manner as the conventional one.

【0093】以上述べたように本実施例によれば、キャ
ッシュラインの競合によりキャッシュミスが頻発するプ
ログラムを、自動的にキャッシュミスの発生が少ないプ
ログラムに変換することができる。これによりキャッシ
ュ装置の変更なしに、プログラムの実行性能を向上する
ことができる。また、本実施例によれば、このようなプ
ログラムの変換が計算機によって自動的にできるので、
プログラマがプログラムを人手で変更するのに比べて手
間や間違いが少くなるという効果がある。
As described above, according to this embodiment, a program in which cache misses frequently occur due to cache line competition can be automatically converted into a program in which cache misses are less likely to occur. As a result, the execution performance of the program can be improved without changing the cache device. Further, according to the present embodiment, since such program conversion can be automatically performed by the computer,
This has the effect of reducing the effort and error compared to the programmer manually changing the program.

【0094】[0094]

【発明の効果】以上のように本発明によれば、ハードウ
ェアの変更なしに、プログラムの繰り返し実行される部
分(ル−プ)でアクセスされる複数のデータについて
も、キャッシュメモリのヒット率を向上することのでき
るプログラムの変換方法を提供することができる。
As described above, according to the present invention, the hit rate of the cache memory can be set even for a plurality of data accessed in the repeatedly executed part (loop) of the program without changing the hardware. It is possible to provide a program conversion method that can be improved.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の一実施例に係る構造体化処理の処理手
順を示すフロ−チャ−トである。
FIG. 1 is a flow chart showing a processing procedure of a structuring processing according to an embodiment of the present invention.

【図2】本発明の一実施例に係る計算機システムの構成
を示すブロック図である。
FIG. 2 is a block diagram showing a configuration of a computer system according to an embodiment of the present invention.

【図3】本発明の一実施例に係るコンパイル処理の処理
手順を示すフロ−チャ−トである。
FIG. 3 is a flowchart showing a processing procedure of a compile processing according to an embodiment of the present invention.

【図4】ソ−スプログラムの例を示す説明図である。FIG. 4 is an explanatory diagram showing an example of a source program.

【図5】語彙解析結果の例を示す説明図である。FIG. 5 is an explanatory diagram showing an example of a vocabulary analysis result.

【図6】シンボルテ−ブルの例を示す説明図である。FIG. 6 is an explanatory diagram showing an example of a symbol table.

【図7】中間語の例を示す説明図である。FIG. 7 is an explanatory diagram showing an example of an intermediate language.

【図8】本発明の一実施例に係る語彙要素算所テ−ブル
の構成を示す説明図である。
FIG. 8 is an explanatory diagram showing the structure of a vocabulary element place table according to an embodiment of the present invention.

【図9】本発明の一実施例に係る構造体化処理後のシン
ボルテ−ブルを示す説明図である。
FIG. 9 is an explanatory diagram showing a symbol table after structuring processing according to an embodiment of the present invention.

【図10】本発明の一実施例に係る構造体化処理による
中間語の変更のようすを示す説明図である。
FIG. 10 is an explanatory diagram showing how an intermediate language is changed by the structuring processing according to the embodiment of the present invention.

【図11】本発明の一実施例に係る構造体化処理による
変換後のプログラムをソ−スプログラムレベルで示した
説明図である。
FIG. 11 is an explanatory diagram showing a program after conversion by a structuring process according to an embodiment of the present invention at a source program level.

【図12】キャッシュメモリの構成例を示した説明図で
ある。
FIG. 12 is an explanatory diagram showing a configuration example of a cache memory.

【図13】本発明の一実施例に係る配列要素参照の類判
定を行う処理の処理手順を示すフロ−チャ−トである。
FIG. 13 is a flowchart showing a processing procedure of processing for making a type determination of array element reference according to an embodiment of the present invention.

【図14】本発明の一実施例に係る構造体化された配列
の主メモリ上の配置を示した説明図である。
FIG. 14 is an explanatory diagram showing an arrangement on a main memory of a structured array according to an embodiment of the present invention.

【図15】従来の技術に係る配列の主メモリ上の配置を
示した説明図である。
FIG. 15 is an explanatory diagram showing an arrangement on a main memory of an array according to a conventional technique.

【符号の説明】[Explanation of symbols]

101…ループ構造の認識 102…ループ内配列参照の解析 103…配列群の類別 104…配列要素の構造体化 105…配列要素参照の構造体メンバ参照への変更 101 ... Recognition of loop structure 102 ... Analysis of in-loop array reference 103 ... Classification of array group 104 ... Structuring of array element 105 ... Change of array element reference to structure member reference

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】プログラムを変換する方法であって、 プログラムのループする処理を記述している部分を判別
するステップと、 判別したループする処理を記述している部分内で、参照
することを記述されている複数の配列のうち、配列の型
が等しく、かつ、前記ル−プ処理の各回の処理で参照さ
れる、配列の要素の配列内の位置が同じ配列どうしを同
じ類別にまとめるステップと、 同じ類別にまとめられた複数の配列を定義する記述を、
前記複数の配列より構成される1つの配列を定義する記
述に変換するステップと、 前記ループ処理部分内の、同じ類別にまとめられた複数
の配列の要素を参照する記述を、当該複数の配列により
構成される1つの配列の対応する要素を参照する記述に
変換するステップとを有することを特徴とするプログラ
ムの変換方法。
1. A method for converting a program, which comprises a step of determining a part describing a looping process of the program, and a reference in the part describing the determined looping process. A plurality of arranged arrays, the types of the arrays are the same, and the steps of grouping the arrays having the same position in the array elements of the arrays referred to in each processing of the loop processing into the same category, , A description defining multiple arrays grouped into the same category,
The step of converting into a description defining one array composed of the plurality of arrays, and the description referring to the elements of the plurality of arrays grouped in the same category in the loop processing part, by the plurality of arrays. And a step of converting a description that refers to a corresponding element of one configured array, to a program conversion method.
【請求項2】請求項1記載のプログラムの変換方法あっ
て、 前記類別にまとめるステップは、判別したループする処
理を記述している部分内で、参照することを記述されて
いる複数の配列のうち、配列の型が等しく、かつ、前記
ル−プ処理の各回の処理で参照される、配列の要素の配
列内の位置が同じ配列どうしであって、さらに、 前記配列を参照する記述の内容が、共に当該配列の内容
を変更する記述である配列どうしを同じ類別にまとめ、
前記配列を参照する記述の内容が、共に当該配列の内容
を変更しない記述である配列どうしを同じ類別にまとめ
るステップであることを特徴とするプログラムの変換方
法。
2. The program conversion method according to claim 1, wherein the step of grouping the plurality of arrays includes a plurality of arrays described to be referred to in a part describing the determined looping process. Among them, the types of the arrays are the same, and the positions of the elements of the arrays referred to in each processing of the loop processing are the same in the arrays, and further, the contents of the description that refers to the array However, both of the arrays that are descriptions that change the contents of the array are grouped in the same class,
A method of converting a program, characterized in that the contents of the description referring to the array are the steps of grouping the arrays which are descriptions that do not change the content of the array.
【請求項3】請求項1または2記載のプログラムの変換
方法であって、 前記類別にまとめるステップにおいて、前記配列を参照
する記述中、前記ル−プ処理の各回の処理で参照する要
素の位置を指定する添字式の内容が等しい場合に、前記
各回の処理で参照される、配列の要素の配列内の位置が
同じ配列とすることを特徴とするプログラムの変換方
法。
3. The program conversion method according to claim 1, wherein in the step of classifying, the position of an element referred to in each process of the loop process in the description that refers to the array. When the contents of the subscript expressions that specify are equal, the positions of the elements of the array referred to in the processing of each time in the array are the same array, and the program conversion method.
【請求項4】プログラムより、主記憶とキャッシュメモ
リを備えた計算機上で実行されるオブジェクトコ−ド列
を生成するプログラムのコンパイル方法であって、 プログラムのループする処理を記述している部分を判別
するステップと、 判別したループする処理を記述している部分内で、参照
することを記述されている複数の配列のうち、配列の型
が等しく、かつ、前記ル−プ処理の各回の処理で参照さ
れる、配列の要素の配列内の位置が同じ配列どうしを同
じ類別にまとめるステップと、 プログラムの同じ類別にまとめられた複数の配列を定義
する記述を、当該複数の配列により構成される1つの配
列を定義する記述に変換するステップと、 前記ループ処理部分内の、同じ類別にまとめられた複数
の配列の要素を参照する記述を、当該複数の配列により
構成される1つの配列の対応する要素を参照する記述に
変換するステップと、 記述を変換されたプログラムより、前記1つの配列を構
成する複数の配列の配列内の位置が同じ各要素が、プロ
グラムの実行時にプログラムを実行する計算機の主記憶
上の連続した位置に、順次配置されるよう前記複数の配
列より構成される1つの配列を配置するオブジェクトコ
ードを含む、オブジェクトコ−ド列を生成するステップ
とを有することを特徴とするプログラムのコンパイル方
法。
4. A method of compiling a program for generating an object code sequence to be executed on a computer having a main memory and a cache memory from a program, the portion describing a looping process of the program. Among the plurality of arrays that are described to be referred to in the part that describes the determining step and the determined looping processing, the array types are the same, and the processing of each time of the loop processing is performed. The steps of grouping arrays that have the same position in the array of the elements of the array referred to in, and the description that defines multiple arrays grouped in the same group of the program are configured by the multiple arrays. The step of converting into a description defining one array, and the description referring to the elements of a plurality of arrays grouped in the same category in the loop processing part, A step of converting a description that refers to a corresponding element of one array configured by an array of numbers, and a plurality of arrays that form the one array have the same position in the array, according to the converted program. An object code in which an element includes an object code for arranging one array composed of the plurality of arrays so as to be sequentially arranged at consecutive positions on a main memory of a computer that executes the program when the program is executed And a step of generating a sequence.
【請求項5】プログラムより、主記憶とキャッシュメモ
リを備えた計算機上で実行されるオブジェクトコ−ドを
生成するプログラムのコンパイル方法であって、 プログラムのループする処理を記述している部分を判別
するステップと、 判別したループする処理を記述している部分内で、参照
することを記述されている複数の配列のうち、配列の型
が等しく、かつ、前記ル−プ処理の各回の処理で参照さ
れる、配列の要素の配列内の位置が同じ配列どうしを同
じ類別にまとめるステップと、 前記ループ処理部分内の、同じ類別にまとめられた複数
の配列の要素を参照する記述を、当該複数の配列により
構成される1つの配列の対応する要素を参照する記述に
変換するステップと記述を変換されたプログラムより、
プログラムの同じ類別にまとめられた複数の配列の配列
内の位置が同じ各配列の要素が、プログラムの実行時に
プログラムを実行する計算機の主記憶上の連続した位置
に、順次配置されるよう指定するオブジェクトコードを
含む、オブジェクトコ−ド列を生成するステップとを有
することを特徴とするプログラムのコンパイル方法。
5. A method of compiling a program for generating an object code to be executed on a computer having a main memory and a cache memory from a program, and determining a part describing a looping process of the program. In the part that describes the looping process and the step that is determined, among the multiple arrays that are described to be referenced, the array types are the same, and in each processing of the loop processing The step of grouping arrays that are referred to and having the same position in the array within the same group, and the description that refers to the elements of a plurality of arrays grouped in the same group within the loop processing part From the step of converting the description that refers to the corresponding element of one array configured by the array of
Specifies that the elements of each array that have the same position in an array of multiple arrays that are grouped into the same category of the program are sequentially arranged at consecutive positions in the main memory of the computer that executes the program when the program is executed. And a step of generating an object code string including object code.
【請求項6】ソ−スプログラムを記憶した記憶装置と、
前記ソ−スプログラムを変換する処理装置とを備えた計
算機システムであって、 前記処理装置は、プログラムのループする処理を記述し
ている部分を判別する手段と、判別したループする処理
を記述している部分内で、参照することを記述されてい
る複数の配列のうち、配列の型が等しく、かつ、前記ル
−プ処理の各回の処理で参照される、配列の要素の配列
内の位置が同じ配列どうしに同じ類別を割り当てる手段
と、プログラムの同じ類別が割り当てられた複数の配列
を定義する記述を、当該複数の配列により構成される1
つの配列を定義する記述に変更する手段と、前記ループ
処理を記述している部分内の、同じ類別にまとめられた
複数の配列の要素を参照する記述を、当該複数の配列に
より構成される1つの配列の対応する要素を参照する記
述に変更する手段とを有することを特徴とする計算機シ
ステム。
6. A storage device storing a source program,
A computer system comprising a processing device for converting the source program, wherein the processing device describes means for determining a portion describing a looping process of the program, and the determined looping process. Position of the elements of the array in the array that are of the same array type and are referenced in each processing of the loop processing among the plurality of arrays described to be referenced. Means for assigning the same category to the same sequences, and a description defining a plurality of arrays to which the same category of the program is assigned is configured by the plurality of arrays.
A means for changing to a description that defines one array and a description that refers to elements of a plurality of arrays that are grouped in the same category in the portion that describes the loop processing are configured by the plurality of arrays. And a means for changing the description to refer to the corresponding element of one array.
【請求項7】請求項6記載の計算機システムであって、 前記処理装置は、さらに、 記述を変換されたプログラムより、前記1つの配列を構
成する複数の配列の配列内の位置が同じ各要素が、プロ
グラムの実行時に、プログラムを実行する計算機の主記
憶上の連続した位置に、順次配置されるよう前記複数の
配列より構成される1つの配列を配置するオブジェクト
コードを含むオブジェクトコ−ド列を生成する手段を有
していることを特徴とする計算機システム。
7. The computer system according to claim 6, wherein the processor further includes, from the program whose description has been converted, each element having the same position in the array of a plurality of arrays forming the one array. When the program is executed, an object code sequence including an object code for arranging one array composed of the plurality of arrays so as to be sequentially arranged at consecutive positions in the main memory of the computer that executes the program A computer system having means for generating.
JP5174375A 1993-07-14 1993-07-14 Program converting method Pending JPH0728702A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5174375A JPH0728702A (en) 1993-07-14 1993-07-14 Program converting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5174375A JPH0728702A (en) 1993-07-14 1993-07-14 Program converting method

Publications (1)

Publication Number Publication Date
JPH0728702A true JPH0728702A (en) 1995-01-31

Family

ID=15977518

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5174375A Pending JPH0728702A (en) 1993-07-14 1993-07-14 Program converting method

Country Status (1)

Country Link
JP (1) JPH0728702A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004066146A1 (en) * 2003-01-20 2004-08-05 Fujitsu Limited List management program and list management device
JP2019185486A (en) * 2018-04-12 2019-10-24 富士通株式会社 Code conversion device, code conversion method, and code conversion program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004066146A1 (en) * 2003-01-20 2004-08-05 Fujitsu Limited List management program and list management device
JP2019185486A (en) * 2018-04-12 2019-10-24 富士通株式会社 Code conversion device, code conversion method, and code conversion program

Similar Documents

Publication Publication Date Title
US7571432B2 (en) Compiler apparatus for optimizing high-level language programs using directives
KR100384905B1 (en) Relation-based ordering of objects in an object heap
US6871341B1 (en) Adaptive scheduling of function cells in dynamic reconfigurable logic
US8595439B1 (en) Optimization of cache configuration for application design
KR100297172B1 (en) Binary program conversion apparatus and binary program conversion method
JP6572610B2 (en) Information processing apparatus, compiling method, and compiling program
US10592430B2 (en) Memory structure comprising scratchpad memory
US20040205740A1 (en) Method for collection of memory reference information and memory disambiguation
US7243195B2 (en) Software managed cache optimization system and method for multi-processing systems
US5822591A (en) Virtual code system
JPH04225431A (en) Method for compiling computer instruction for increasing instruction-cache efficiency
CN115809063B (en) Storage process compiling method, system, electronic equipment and storage medium
CN115757462B (en) Object-oriented database dynamic interface generation method and operation method
US7689976B2 (en) Compiler apparatus and linker apparatus
US7530063B2 (en) Method and system for code modification based on cache structure
US20040205320A1 (en) Method and apparatus for refining an alias set of address taken variables
US20050027953A1 (en) Automatically reordering variables as a part of compiling and linking source code
CN1894674A (en) Memory access instruction vectorization
JPH0728702A (en) Program converting method
Meier et al. An architecture for prolog extensions
US6055627A (en) Compiling method of accessing a multi-dimensional array and system therefor
JP5238797B2 (en) Compiler device
US20060004863A1 (en) Method, system and program for simplifying data flow in a statement with sequenced subexpressions
JP5272346B2 (en) Cache coloring method
CN110928550A (en) Method for eliminating redundancy of GCC abstract syntax tree based on keyword Trie tree