JPH047748A - Automatic array element assignment processing system based on reference order - Google Patents

Automatic array element assignment processing system based on reference order

Info

Publication number
JPH047748A
JPH047748A JP2108661A JP10866190A JPH047748A JP H047748 A JPH047748 A JP H047748A JP 2108661 A JP2108661 A JP 2108661A JP 10866190 A JP10866190 A JP 10866190A JP H047748 A JPH047748 A JP H047748A
Authority
JP
Japan
Prior art keywords
array
order
array element
processing means
referenced
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
JP2108661A
Other languages
Japanese (ja)
Inventor
Noboru Higuchi
登 樋口
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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP2108661A priority Critical patent/JPH047748A/en
Publication of JPH047748A publication Critical patent/JPH047748A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

PURPOSE:To attain the effective use of a cache memory by assigning the array elements to the memory in accordance with the order in which an array is referred to in a program. CONSTITUTION:The reference order of array elements included in a loop in a source program 1 is analyzed by an array element reference order analysis processing means 5. Then the reference order information and the reference frequency are stored in an array element assignment information table 3. An array element assignment order decision processing means 6 decides the assignment order of array elements based on the table 3. Then a code generation processing means 7 outputs an object code 8 to refer to the array elements according to the decided assignment order. Therefore the array elements to be referred to for execution of the program 1 are continuously obtained in a cache memory. Then the effective use of the cache memory is attained.

Description

【発明の詳細な説明】 [産業上の利用分野] 本発明はプログラム中の配列の配列要素の割付方式に関
し、特にループの中で使用される配列要素をその参照順
にメモリに割り付ける参照順による自動配列要素割付処
理方式に関する。
Detailed Description of the Invention [Field of Industrial Application] The present invention relates to a method for allocating array elements of an array in a program, and in particular, an automatic reference order method for allocating array elements used in a loop to memory in the order in which they are referenced. Concerning array element allocation processing method.

〔従来の技術〕[Conventional technology]

従来の言語処理系ではプログラム内で定義されている配
列の領域に配列要素を割り付ける場合、配列要素の参照
順序とは無関係にあらかじめ決められた固有の順序に従
って機械的に割り付けている。第6図に3次元配列A 
(100,100,100)の配列要素の従来方式によ
る割付例を示す。このように、−船釣には下位次元(右
側の要素)の添字から変化していく順序で割り付けるの
が標準的な割付方式であり、これはコンパイルに使用す
る言語処理系に固有のものである。
In conventional language processing systems, when array elements are allocated to an array area defined within a program, they are mechanically allocated according to a predetermined unique order, regardless of the reference order of the array elements. Figure 6 shows the three-dimensional array A.
An example of layout of array elements (100, 100, 100) according to the conventional method is shown. In this way, the standard allocation method for -Funetsuri is to allocate in the order that changes from the subscript of the lower dimension (the element on the right), and this is unique to the language processing system used for compilation. be.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

しかしながら、従来の配列要素の割付方式では以下に説
明するような問題があった。
However, the conventional array element allocation method has the following problems.

このような配列はループの中の命令によって集中的に実
行されるので、連続的に参照されるのが普通である。し
たがって、第6図の配列Aを参照する場合、下位次元の
添字を変化させるループが上位次元の添字を変化させる
ループの内側にあるプログラムを実行するときは割り付
けられた順序と参照する順序とが一致するので特に間B
無いが、これと反対に、上位次元の添字を変化させるル
ープが下位次元の添字を変化させるループの内側にある
プログラムを実行するときは割り付けられた順序と参照
する順序とが一致しない。したがって、同図の81で示
す配列要素A(1,1,1)の次はS2で示す配列要素
A(2,1,ILその次はS3の配列要素A(3,1,
1)のように10,000ワード飛びに配列を参照する
ことになる。このように、参照されるメモリのアドレス
が離れてしまうので、キャッシュメモリにロードされて
いる範囲を逸脱してしまい、主メモリからキャッシュメ
モリへのロードが多発してキャッシュメモリを備えてい
る意味が失われてしまう。また、たとえ、キャッシュメ
モリに一度にロードできるサイズの配列でも、メモリを
連続して参照することができないためにオブジェクトコ
ードが複雑になり、プログラムの実行速度が遅くなる。
Since such arrays are executed intensively by instructions within a loop, they are normally referenced continuously. Therefore, when referring to array A in Figure 6, when executing a program in which a loop that changes the subscript of a lower dimension is inside a loop that changes the subscript of an upper dimension, the order in which it is allocated and the order in which it is referenced are different. Since it matches, especially between B
However, on the other hand, when executing a program in which a loop that changes the subscript of a higher dimension is inside a loop that changes the subscript of a lower dimension, the allocated order and the reference order do not match. Therefore, the next array element A (1, 1, 1) shown at 81 in the figure is the array element A (2, 1, IL) shown at S2, and the next is the array element A (3, 1, IL) shown at S3.
As in 1), the array will be referenced every 10,000 words. In this way, since the referenced memory address is far apart, it deviates from the range that is loaded into the cache memory, and the main memory is loaded frequently to the cache memory, which makes the point of having a cache memory go away. It will be lost. Furthermore, even if the array is large enough to be loaded into the cache memory at once, the object code becomes complicated and the program execution speed slows down because the memory cannot be referenced continuously.

本発明は上記従来の問題に鑑みてなされたものであり、
プログラム内で配列を参照するときの順序に合わせて配
列要素をメモリに割り付けること番こより、キャッシュ
メモリの有効利用と生成するオブジェクトコードの簡潔
化をはかり、プログラムの実行速度を高めることができ
る参照順による自動配列要素割付処理方式を提供するこ
とを目的とするものである。
The present invention has been made in view of the above-mentioned conventional problems,
By allocating array elements in memory in accordance with the order in which arrays are referenced in a program, the reference order allows for effective use of cache memory, simplification of generated object code, and increases program execution speed. The purpose is to provide an automatic array element allocation processing method using

〔課題を解決するための手段〕[Means to solve the problem]

上記の目的を達成するために、本発明においては、原始
プログラム内で定義されている配列に対して、少なくと
もその配列を識別する配列識別子とその配列要素が参照
されている順序を識別する参照順序情報とその配列の参
照回数とから成る配列要素割付情報テーブルと、前記配
列識別子を前記配列要素割付情報テーブルに登録する配
列識別子登録処理手段と、前記配列が原始プログラム内
のループの中で参照されている場合に、その配列要素の
参照順序を解析し、前記配列要素割付情報テーブルの参
照順序情報および参照回数にその情報を格納する配列要
素参照順序解析処理手段と、前記配列要素割付情報テー
ブルに基づいて配列要素の割付順序を決定する配列要素
割付順序決定処理手段と、この配列要素割付順序決定処
理手段によって決められた順序に従って配列要素を参照
するオブジェクトコードを出力するコード生成処理手段
を備えるものである。
In order to achieve the above object, in the present invention, for an array defined in a source program, at least an array identifier that identifies the array and a reference order that identifies the order in which the array elements are referenced are provided. an array element allocation information table comprising information and the number of times the array is referenced; an array identifier registration processing means for registering the array identifier in the array element allocation information table; an array element reference order analysis processing means for analyzing the reference order of the array element and storing the information in the reference order information and the number of references in the array element allocation information table; array element allocation order determining processing means for determining the allocation order of array elements based on the array element allocation order determining processing means; and code generation processing means for outputting an object code that refers to the array elements in accordance with the order determined by the array element allocation order determining processing means. It is.

〔作 用〕[For production]

本発明はこのように構成されているので、配列要素参照
順序解析処理手段において、原始プログラム内のループ
の中での配列要素の参照順序を解析して参照順序情報と
参照回数とを配列要素割付情報テーブルに格納し、配列
要素割付順序決定処理手段において前記配列要素割付情
報テーブルに基づいて配列要素の割付順序を決定し、コ
ード生成処理手段においてこの決定された順序に従って
配列要素を参照するオブジェクトコードを出力すること
ができる。
Since the present invention is configured in this manner, the array element reference order analysis processing means analyzes the reference order of array elements in a loop in a source program and uses the reference order information and the number of references to allocate array elements. an object code that is stored in an information table, that an array element allocation order determination processing means determines the allocation order of array elements based on the array element allocation information table, and that a code generation processing means refers to the array elements according to the determined order; can be output.

(実施例] 以下本発明の実施例を図面を参照して説明する。(Example] Embodiments of the present invention will be described below with reference to the drawings.

第1図は本発明の方式の一実施例におけるブロック図で
ある。第1図においで、】はコンパイル対象の原始プロ
グラム、2はコンパイラ、3は原始プログラム内で定義
されている配列に対して、その配列を識別する配列識別
子とその配列要素が参照されている順序を識別する参照
順序情報とその配列の参照回数とから成る配列要素割付
情報テーブル、4は配列識別子を配列要素割付情報テー
ブル3に登録する配列識別子登録処理手段、5は前記配
列が原始プログラム内のループの中で参照されている場
合に、その配列要素の参照順序を解析し、配列要素割付
情報テーブル3の参照順序情報および参照回数にその情
報を格納する配列要素参照順序解析処理手段、6は配列
要素割付情報テーブル3に基づいて配列要素の割付順序
を決定する配列要素割付順序決定処理手段、7はこの配
列要素割付順序決定処理手段によって決められた順序に
従って配列要素を参照するオブジェクトコードを出力す
るコード生成処理手段、8は生成されたオブジェクトコ
ードである。
FIG. 1 is a block diagram of one embodiment of the method of the present invention. In Figure 1, ] is the source program to be compiled, 2 is the compiler, and 3 is the array identifier that identifies the array and the order in which the array elements are referenced for the array defined in the source program. 4 is an array identifier registration processing means for registering an array identifier in the array element allocation information table 3; 5 is an array element allocation information table consisting of reference order information for identifying the array and the number of times the array is referenced; Array element reference order analysis processing means 6 analyzes the reference order of the array element when it is referenced in the loop, and stores the information in the reference order information and reference count of the array element allocation information table 3; Array element allocation order determining processing means that determines the allocation order of array elements based on the array element allocation information table 3; 7 outputs an object code that refers to array elements in accordance with the order determined by the array element allocation order determining processing means; 8 is a generated object code.

次に、上記実施例の動作について説明する。コンパイラ
2が原始プログラム1を入力してオブジェクトコード8
を出力する過程で、構文解析または意味解析中に配列の
定義が現われる度に配列識別子登録処理手段4を呼び出
す。配列識別子登録処理手段4はその配列名を配列要素
割付情報テーブル3の配列識別子に登録する。配列要素
が原始プログラム1のループの中で参照されている場合
には配列要素参照順序解析処理手段5を呼び出し、最も
内側のループの繰り返しによって配列要素がどのような
順序で参照されているかを調べる。そして、配列の下位
次元の添字が先に変化する順序で参照されている場合に
は、例えば1を、上位次元の添字が先に変化する順序で
参照されている場合には、例えば2を、第2図に示す配
列要素割付情報テーブル3の参照順序情報に加算すると
ともに参照回数に1を加算する。同図において配列aは
2回参照され、2回とも上位次元の添字が先に変化する
順序で参照されていることを示す、また、配列すは3回
参照され、3回とも下位次元の添字が先に変化する順序
で参照されていることを示す。
Next, the operation of the above embodiment will be explained. Compiler 2 inputs source program 1 and generates object code 8.
In the process of outputting , the array identifier registration processing means 4 is called every time an array definition appears during syntactic or semantic analysis. The array identifier registration processing means 4 registers the array name as an array identifier in the array element allocation information table 3. If the array elements are referenced in the loop of the source program 1, the array element reference order analysis processing means 5 is called to check in what order the array elements are referenced by repeating the innermost loop. . If the subscripts of the lower dimension of the array are referenced in the order that they change first, then, for example, 1, and if the subscripts of the upper dimension are referenced in the order that they change first, then, for example, 2, It is added to the reference order information in the array element allocation information table 3 shown in FIG. 2, and 1 is added to the number of references. In the same figure, array a is referenced twice, both times indicating that the subscript of the higher dimension is referenced in the order that changes first, and array a is referenced three times, and each time the subscript of the lower dimension is referenced. indicates that they are referenced in the order in which they change first.

同様に、配列Cは1回参照され、上位次元の添字が先に
変化する順序で参照されていることを示す。
Similarly, array C is referenced once, indicating that the subscripts of higher dimensions are referenced in the order of change first.

次に、構文解析および意味解析が終了すると、配列要素
割付順序決定処理手段6を呼び出す。配列要素割付順序
決定処理手段6は上記のようにして作成された配列要素
割付情報テーブル3に基づいて配列要素の割付順序を決
定する。すなわち、配列要素割付情報テーブル3の参照
順序情報を参照回数で割った値が、例えば1.5未満の
場合は参照順序情報を1に書き換え、1.5以上の場合
は2に書き換えることによって、それぞれの配列毎に下
位次元の添字が先に変化するような参照のされ方が多け
れば、参照順序情報を1に、その反対の場合は2に決定
する。
Next, when the syntax analysis and semantic analysis are completed, the array element allocation order determining processing means 6 is called. The array element allocation order determination processing means 6 determines the allocation order of array elements based on the array element allocation information table 3 created as described above. That is, if the value obtained by dividing the reference order information in the array element allocation information table 3 by the number of references is less than 1.5, the reference order information is rewritten to 1, and if it is 1.5 or more, it is rewritten to 2. If there are many references in which the subscript of the lower dimension changes first for each array, the reference order information is determined to be 1, and in the opposite case, it is determined to be 2.

第3図は第2図に示した配列要素割付情報テーブル3に
ついて配列要素割付順序決定処理を実行した結果であり
、配列aおよび配列Cは上位次元の添字が先に変化する
順序で、配列すは下位次元の添字が先に変化する順序で
メモリに割り付けられる。次に、コード生成処理手段7
が呼び出され、配列要素割付順序決定処理手段6によっ
て決められた配列要素割付情報テーブル3の参照順序情
報に従って配列要素を参照するようなオブジェクトコー
ド8を出力する。すなわち、参照順序情報が1であれば
下位次元の添字が先に変化する順序で配列要素がメモリ
に割り付けられるものとして、配列要素を参照するオブ
ジェクトコード8を出力する。同様に、参照順序情報が
2であれば上位次元の添字が先に変化する順序で配列要
素がメモリに割り付けられるものとして、配列要素を参
照するオブジェクトコード8を出力する。
Figure 3 shows the result of executing array element allocation order determination processing for array element allocation information table 3 shown in Figure 2. Arrays a and array C are arranged in the order in which the subscript of the upper dimension changes first. are allocated in memory in the order in which sub-dimension subscripts change first. Next, the code generation processing means 7
is called and outputs an object code 8 that refers to array elements according to the reference order information of the array element allocation information table 3 determined by the array element allocation order determination processing means 6. That is, if the reference order information is 1, it is assumed that the array elements are allocated to the memory in the order in which the subscript of the lower dimension changes first, and the object code 8 that references the array elements is output. Similarly, if the reference order information is 2, it is assumed that the array elements are allocated to memory in the order in which the subscript of the higher dimension changes first, and an object code 8 that references the array elements is output.

第4図は二つの3次元配列AおよびBの参照例を示すF
ORTRANプログラムの例であり、配列AはループL
1において下位次元の添字Kから順に参照され、配列B
はプログラムL2において上位次元の添字Kから順に参
照されている。
Figure 4 shows an example of referencing two three-dimensional arrays A and B.
This is an example of an ORTRAN program, where array A is loop L
1, it is referenced sequentially from the subscript K of the lower dimension, and the array B
are referenced in the program L2 in order from the subscript K of the upper dimension.

第5図は前記FORTRANプログラムを上記実施例に
より処理した配列要素の割付順序を示すものであり、配
列Aは下位次元の添字を連続して参照できるように割り
付けられ、配列Bは上位次元の添字を連続して参照でき
るように割り付けられている。
FIG. 5 shows the allocation order of array elements when the FORTRAN program is processed according to the above embodiment, where array A is allocated so that the subscripts of the lower dimension can be referenced continuously, and array B is allocated so that the subscripts of the upper dimension can be referenced continuously. are allocated so that they can be referenced consecutively.

したがって、以上のような実施例の構成によれば、原始
プログラムのコンパイル単位で、それぞれの配列要素が
プログラムの中で参照されている順序に合わせて配列要
素をメモリに割り付けることができる。また、複数回の
参照回数がある場合は、最も多い参照順序に合わせて配
列要素をメモリに割り付けることができる。
Therefore, according to the configuration of the embodiment as described above, array elements can be allocated to memory in the compilation unit of a source program in accordance with the order in which each array element is referenced in the program. Furthermore, if there are multiple references, array elements can be allocated in memory according to the order of reference most often.

〔発明の効果〕〔Effect of the invention〕

本発〜明によれば、上記実施例から明らかなように、プ
ログラムを実行するときに参照される配列要素がメモリ
上で連続して得られるため、キャッシュメモリを効果的
に利用することができる。また、配列要素がメモリ上で
連続しているため、ポストインクリメント命令などを用
いることによって、繰り返し時に次の配列要素のアドレ
ス計算が要らなくなり、配列要素を参照するためのオブ
ジェクトニードが簡潔になり、プログラムの実行速度が
速くなるという効果がある。
According to the present invention, as is clear from the above-mentioned embodiments, the array elements referenced when executing the program are obtained consecutively on the memory, so that the cache memory can be used effectively. . In addition, since array elements are contiguous in memory, by using a post-increment instruction, there is no need to calculate the address of the next array element during repetition, and object needs for referencing array elements are simplified. This has the effect of increasing program execution speed.

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

第1図は本発明の方式の一実施例におけるブロック図、
第2図と第3図は配列要素割付情報テーブルの格納状態
を示す説明図、第4図はFORTRANプログラムリス
ト、第5図は本発明による配列要素の割付状態を示す説
明図、第6図は従来例による配列要素の割付状態を示す
説明図である。 1・・・原始プログラム、2・・・コンパイラ、3・・
・配列要素割付情報テーブル、4・・・配列識別子登録
処理手段、5・・・配列要素参照順序解析処理手段、6
・・・配列要素割付順序決定処理手段、7・・・コード
生成処理手段、
FIG. 1 is a block diagram of an embodiment of the method of the present invention;
2 and 3 are explanatory diagrams showing the storage state of the array element allocation information table, FIG. 4 is an explanatory diagram showing the FORTRAN program list, FIG. 5 is an explanatory diagram showing the arrangement state of array elements according to the present invention, and FIG. FIG. 2 is an explanatory diagram showing an allocation state of array elements according to a conventional example. 1... Source program, 2... Compiler, 3...
- Array element allocation information table, 4... Array identifier registration processing means, 5... Array element reference order analysis processing means, 6
. . . Array element allocation order determination processing means; 7. Code generation processing means;

Claims (1)

【特許請求の範囲】 原始プログラム内で定義されている配列に対して、少な
くともその配列を識別する配列識別子とその配列要素が
参照されている順序を識別する参照順序情報とその配列
の参照回数とから成る配列要素割付情報テーブルと、 前記配列識別子を前記配列要素割付情報テーブルに登録
する配列識別子登録処理手段と、前記配列が原始プログ
ラム内のループの中で参照されている場合に、その配列
要素の参照順序を解析し、前記配列要素割付情報テーブ
ルの参照順序情報および参照回数にその情報を格納する
配列要素参照順序解析処理手段と、 前記配列要素割付情報テーブルに基づいて配列要素の割
付順序を決定する配列要素割付順序決定処理手段と、 この配列要素割付順序決定処理手段によって決められた
順序に従って配列要素を参照するオブジェクトコードを
出力するコード生成処理手段とを備えることを特徴とす
る参照順による自動配列要素割付処理方式。
[Claims] For an array defined in a source program, at least an array identifier that identifies the array, reference order information that identifies the order in which the array elements are referenced, and the number of times the array is referenced. an array element allocation information table consisting of; an array identifier registration processing means for registering the array identifier in the array element allocation information table; and when the array is referenced in a loop in a source program, the array element an array element reference order analysis processing means for analyzing the reference order of the array element allocation information table and storing the information in the reference order information and reference count of the array element allocation information table; An array element allocation order determining processing means for determining an array element allocation order, and a code generation processing means for outputting an object code that refers to array elements in accordance with the order determined by the array element allocation order determining processing means. Automatic array element allocation processing method.
JP2108661A 1990-04-26 1990-04-26 Automatic array element assignment processing system based on reference order Pending JPH047748A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2108661A JPH047748A (en) 1990-04-26 1990-04-26 Automatic array element assignment processing system based on reference order

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2108661A JPH047748A (en) 1990-04-26 1990-04-26 Automatic array element assignment processing system based on reference order

Publications (1)

Publication Number Publication Date
JPH047748A true JPH047748A (en) 1992-01-13

Family

ID=14490473

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2108661A Pending JPH047748A (en) 1990-04-26 1990-04-26 Automatic array element assignment processing system based on reference order

Country Status (1)

Country Link
JP (1) JPH047748A (en)

Similar Documents

Publication Publication Date Title
KR101360512B1 (en) Register allocation with simd architecture using write masks
JP2500079B2 (en) Program optimization method and compiler system
US7111287B2 (en) Global processor resource assignment in an assembler
JP2008009957A (en) Compiling device
EP0798636A1 (en) Method and system for register allocation using multiple interference graphs
JPH01118931A (en) Program conversion system
JPH047748A (en) Automatic array element assignment processing system based on reference order
US8566813B2 (en) Method and system generating execution file system device
JPH11345127A (en) Compiler
JP2003330730A (en) Operating system arranging device
JPH08212081A (en) Memory allocation method, compiling method and compiler
JP3004340B2 (en) Program optimization device
JPH04241630A (en) System for optimizing register allocation by graph painting
JP2809073B2 (en) Array memory allocation method
JPS63163636A (en) Executing system for parallel processing
JPH0371233A (en) Optimum data allocating system for compiler
JP2003271392A (en) Register allocation method
JPH07129408A (en) Executing system for language processing program
JPH04178738A (en) Register allocation system
JPH02171831A (en) Data access system for compiler
JP2003271393A (en) Optimization method by in-line allocation and its compiler
JPH02183833A (en) Compiling system for multiprocessor
JP2001184320A (en) Distributed executing device and recording medium
JPH0769831B2 (en) Register allocation method in compiler
JPS62163145A (en) Compiler device