JPH07334366A - Method and apparatus for optimizing graph reduction mechanism - Google Patents

Method and apparatus for optimizing graph reduction mechanism

Info

Publication number
JPH07334366A
JPH07334366A JP12503694A JP12503694A JPH07334366A JP H07334366 A JPH07334366 A JP H07334366A JP 12503694 A JP12503694 A JP 12503694A JP 12503694 A JP12503694 A JP 12503694A JP H07334366 A JPH07334366 A JP H07334366A
Authority
JP
Japan
Prior art keywords
graph
subgraph
reduction
hash
ifib
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.)
Withdrawn
Application number
JP12503694A
Other languages
Japanese (ja)
Inventor
Hideki Yamanaka
英樹 山中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP12503694A priority Critical patent/JPH07334366A/en
Publication of JPH07334366A publication Critical patent/JPH07334366A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PURPOSE:To considerably reduce a memory space and a time length required for calculation to repeat partial recalculation. CONSTITUTION:An entire graph S to be the object of reduction is held in a first storage means 1, and a second storage means 2 is provided with a hash table 2a for storing the hash values of all the partial graphs of the graph S and stores the pairs of partial graphs existent in the past and partial graphs at the reduction destination reached at present. A reduction means 3 reduces the partial graphs held in the first storage means 1 and when any partial graph at the reduction destination is not registered on the second storage means 2, that partial graph at the reduction destination is registered on the second storage means 2 corresponding to its original partial graph.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、グラフリダクション機
構の最適化方法および装置に関し、特に本発明は、グラ
フリダクションに必要とされるメモリ空間、および、時
間をヒューリスティクにたよらず削減することができる
グラフリダクション機構の最適化方法および装置に関す
るものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method and apparatus for optimizing a graph reduction mechanism, and more particularly, the present invention can reduce the memory space and time required for graph reduction without relying on heuristics. The present invention relates to a method and an apparatus for optimizing a graph reduction mechanism that can be performed.

【0002】[0002]

【従来の技術】関数型言語LIPSの実現研究より発し
たヒープ領域(動的割り当て可能なアドレス空間)の再
利用技術であるガベージコレクションは、今まで様々な
方法が提案されてきた。その主なアプローチは、コピー
方式、マーク・スキャン方式とリファレンス・カウント
方式である。
2. Description of the Related Art Various methods have been proposed for garbage collection, which is a technique for reusing a heap area (dynamically allocable address space), which has been generated by research into the realization of a functional language LIPS. The main approaches are copy method, mark scan method and reference count method.

【0003】ヒープ領域は、通常、左右の2個のポイン
タをもつセルと呼ばれる単位で割り当て、回収再利用が
なされる。コピー方式は上記したヒープ領域を2つに割
り、ガベージコレクションの度に一方から他方へガベー
ジでない全てのセルをコピーする。割り当て可能な領域
は、コピーで使われなかった連続したメモリ領域であ
る。
The heap area is usually allocated in units called cells having two pointers on the left and right, and is collected and reused. In the copy method, the above-mentioned heap area is divided into two, and every time a garbage collection is performed, all cells that are not garbage are copied from one to the other. The allocatable area is a contiguous memory area that is not used for copying.

【0004】マーク・スキャン方式は、各セルにマーク
ビットと呼ばれる1ビットのフラグを設けて、ガベージ
コレクションの前処理として、ヒープ領域を直線的に辿
ることにより、全てのセルのマークビットをクリアして
おく。次に、現在使用されている全てのセルをルートか
らポインタを辿って行くことにより、そのマークビット
をセットし、最後にヒープ領域を直線的に辿って、マー
クビットがセットされていない全てのセルをフリーリス
トと呼ばれる再割り当て可能なセルのリストとして得
る。
In the mark scan method, each cell is provided with a 1-bit flag called a mark bit, and the heap area is linearly traced as a pre-process of garbage collection to clear the mark bits of all cells. Keep it. Next, set the mark bit by tracing the pointer from the root to all the cells that are currently used, and finally linearly trace the heap area to find all cells that do not have the mark bit set. As a list of reallocable cells called the free list.

【0005】リファレンス・カウント方式では、各セル
にリファレンス・カウンタと呼ばれる他のセルからの参
照回数を保持するカウンタを設ける。そして各リスト処
理の演算で、他のセルからの参照が増減する毎に上記リ
ファレンス・カウンタを増減させるが、ガベージコレク
ションは単に、ヒープ領域を直線的に辿り、リファレン
ス・カウンタが0である全てのセルを集めて、フリーリ
ストとして再構築する。あるいは、リファレンス・カウ
ントが0になったときにフリーリストに回収してしまう
だけですむ。
In the reference counting method, each cell is provided with a counter called a reference counter for holding the number of times of reference from another cell. Then, in the calculation of each list process, the reference counter is increased / decreased each time the reference from another cell is increased / decreased, but the garbage collection simply traces the heap area linearly and all reference counters are 0. Collect cells and rebuild as a freelist. Or you can just collect it on the freelist when the reference count reaches zero.

【0006】上記したガベージコレクションの機構は、
現在様々な高級プログラミングで現実に使われている。
副作用のない純関数型言語は、初期のLIPSの意味論
であるラムダ計算系、あるいは、等式理論に基づく計算
機構としての項書換え系を意味論として持ち、リダクシ
ョンと呼ばれる項の書換えにより計算が進んでいく。
The above garbage collection mechanism is as follows.
Currently used in various high-level programming.
A pure functional language without side effects has a lambda calculus system, which is the semantics of the early LIPS, or a term rewriting system as a calculation mechanism based on the equation theory, and the calculation is performed by rewriting terms called reduction. Go ahead.

【0007】例えば、次のようにフィナボッチ関数fi
bの定義を与え、 fib(0) =0 fib(s(0)) =s(0) fib(s(s(X))) =fib(s(X))+ fib(X) 0 + X =X s(X) + Y =s(X+Y) fib(s(s(s(0)))) を計算してみる。
For example, the Finabotti function fi is as follows:
Given the definition of b, fib (0) = 0 fib (s (0)) = s (0) fib (s (s (X))) = fib (s (X)) + fib (X) 0 + X = X s (X) + Y = s (X + Y) Try to calculate fib (s (s (s (0)))).

【0008】 fib(s(s(s(0)))) →fib(s(s(0))) +fib(s(0)) →fib(s(0))+fib(0)+ fib(s(0)) → … →s(s(0)) となり、計算結果s(s(0)) を得る。ここで、s(X)は、X
より1だけ大きい自然数を表し、0,1,2,3,…は0,s(0),s
(s(0)),s(s(s(0))), …と対応付けられ、任意の自然数
は、それと同じ数のsと1個の0で表すことができる。
なお、実際の計算では、このように自然数を表現せず、
始めから組み込まれた型としての整数を使うが、ここで
は、典型的な容易な例として示した。
Fib (s (s (s (0)))) → fib (s (s (0))) + fib (s (0)) → fib (s (0)) + fib (0) + fib (s (0)) →… → s (s (0)) and the calculation result s (s (0)) is obtained. Where s (X) is X
Represents a natural number larger by 1, and 0,1,2,3, ... is 0, s (0), s
Corresponding to (s (0)), s (s (s (0))), ..., an arbitrary natural number can be represented by the same number of s and one 0.
In the actual calculation, we do not express natural numbers like this,
We use integer as a built-in type from the beginning, but we have shown it here as a typical easy example.

【0009】上の例を厳密にトレースすると、まず、書
き換えられる項の部分項と関数の定義の左辺のどれか一
つの項がマッチング(後者の変数に適当な項を代入し、
前者と後者が一致)するかどうかを調べる。そして、マ
ッチングした場合には、マッチングした部分項を、定義
の左辺をコピーしてそれにマッチングに使われた代入
(変数をそれに対応する項のコピーで置き換える)を施
した項で置き換え、置き換えられた元の部分項全体がガ
ベージになるというプロセスを繰り返す。
Strictly tracing the above example, first, the subterms of the term to be rewritten and one of the terms on the left side of the function definition match (substitute an appropriate term for the latter variable,
Check whether the former and the latter match). Then, if there is a match, the matched sub-term is replaced by the term obtained by copying the left side of the definition and performing the substitution used to match it (replacing the variable with a copy of the corresponding term). Repeat the process that the entire original subterm is garbage.

【0010】例えば、fib(s(s(s(0)))) はfib(s(s(X)))
にマッチングするので、fib(s(s(X)))をコピーして、X
をs(0)で置き換えて、fib(s(s(0))) +fib(s(0)) を得
て、fib(s(s(s(0)))) をガベージとする。通常の関数型
言語における実現では、このような効率の悪いコピーを
避けるため、代入をポインタによる部分項の共有で置き
換える。ポインタの共有によって項の表現がダグ(非循
環有向グラフ)になり、この上でリダクションが行われ
るので、このような計算はグラフリダクションと呼ばれ
る。
For example, fib (s (s (s (0)))) is fib (s (s (X)))
Since it matches with, copy fib (s (s (X))) to X
By replacing s (0) with fib (s (s (0))) + fib (s (0)), where fib (s (s (s (0)))) is garbage. In the usual implementation in a functional language, substitution is replaced by sharing of partial terms by pointers in order to avoid such inefficient copying. Such a calculation is called a graph reduction because the representation of terms becomes a doug (acyclic directed graph) by sharing pointers and reduction is performed on this.

【0011】上記例では、計算の途中にfib(s(0)) とい
う部分項が2個重複して現れるが、これは、変数に代入
されたことがないので、変数による共有の枠組では共有
できない。これもポインタにより共有させるためには、
グラフのすべての部分項をハッシュしておいて、リダク
ションが行われる毎に書き換えられた部分項を含む全て
の部分項のハッシュテーブルを更新し、常に同じ部分項
がポインタで共有されるようにしなければならない。
In the above example, two sub-terms fib (s (0)) appear twice in the middle of the calculation, but since this has never been assigned to a variable, it is shared in the framework of sharing by variables. Can not. In order to share this with the pointer as well,
Hash all the subterms of the graph and update the hash table of all subterms including the rewritten subterms every time a reduction is performed so that the same subterm is always shared by pointers. I have to.

【0012】もし、このハッシュテーブルの更新のオー
バヘッドが問題の大きさに関して、線形オーダ程度であ
れば、セルの消費量の削減の現実的な方法と言えると考
えられる。さらに、例えば、前の例のような素朴なフィ
ナボッチ関数のように指数オーダの計算時間・空間消費
量をもつ関数の計算を考えると、この共有によって線形
オーダの空間消費量だけでなく、計算時間を画期的に削
減することができる。
If the overhead of updating the hash table is of a linear order with respect to the size of the problem, it can be said that it is a realistic method for reducing the cell consumption. Furthermore, considering the calculation of a function that has exponential-order calculation time and space consumption, such as the simple Finabotti function as in the previous example, this sharing not only reduces the linear-order space consumption but also the calculation time. Can be dramatically reduced.

【0013】一方、計算時間・空間消費量を削減する古
くからある方法に、過去に行った部分的な計算の断片を
記録しておき、それを再利用することにより同じ計算を
繰り返さないという手法がある。例えば、次の組み込み
関数型の整数を使ったフィナボッチ数列を計算するifib
プログラムを考えてみる。
On the other hand, an old method for reducing the calculation time and space consumption is to record a fragment of partial calculation performed in the past and reuse the fragment so that the same calculation is not repeated. There is. For example, ifib computes the Finaboch sequence using the following built-in function type integers
Consider a program.

【0014】ifib(X)=if(eq(X,0),0, if(eq(X,1),1, +(ifib(-(X,1)),ifib(-(X,2))))) 上記式は、もし、Xが0であればifib(X) は0となり、
Xが1であればifib(X) は1となる。また、Xが2であ
れば、ifib(X) は +(ifib(-(X,1)),ifib(-(X,2))) 、す
なわち、ifib(2-1)+ifib(2-2) でifib(1)+ifib(0) とな
る。
Ifib (X) = if (eq (X, 0), 0, if (eq (X, 1), 1, + (ifib (-(X, 1)), ifib (-(X, 2)) )))) The above formula shows that if X is 0, ifib (X) is 0,
If X is 1, ifib (X) becomes 1. If X is 2, ifib (X) is + (ifib (-(X, 1)), ifib (-(X, 2))), that is, ifib (2-1) + ifib (2- In 2), it becomes ifib (1) + ifib (0).

【0015】同様に、Xが3であれば、ifib(2)+ifib
(1) 、すなわち、(ifib(1)+ifib(0))+ifib(1)とな
る。すなわち、通常のCall-by-value (深さ優先の逐次
計算)で ifib(5)を計算すると、図10に示すように、
計算を表す木が得られる。図10において、計算の手順
は矢印に示すように、まず、 ifib(5)を得るためifib
(4) を求め、次に、ifib(4) を求めるために、ifib(3)
を求め、以下同様に、(1) 〜(14)に示す手順で行われ
る。ここで、同図の点線で囲まれた領域(同図において
再計算部分として示した部分)の計算は、既に一度計算
されている。例えば、同図の(8)(9)の再計算部分ifib
(2) は(4),(5) で既に計算されている。
Similarly, if X is 3, ifib (2) + ifib
(1), that is, (ifib (1) + ifib (0)) + ifib (1). That is, when ifib (5) is calculated by the normal Call-by-value (depth-first sequential calculation), as shown in FIG.
A tree representing the calculation is obtained. In FIG. 10, the calculation procedure is as shown by an arrow. First, ifib (5) is obtained to obtain ifib (5).
(4) and then ifib (3) to find ifib (4)
Then, similarly, the steps shown in (1) to (14) are performed. Here, the calculation of the region surrounded by the dotted line in the figure (the part shown as the recalculation part in the figure) has already been performed once. For example, the recalculation part ifib of (8) and (9) in the figure
(2) has already been calculated in (4) and (5).

【0016】したがって、計算の途中で、ifib(1),ifib
(2),ifib(3) とその計算結果を組にして適当な場所に記
録しておいて、計算の定義通りに進める前にこの組を検
索して、既に計算結果が得られていれば、それで置き換
えるようにすることによって計算時間・空間量を減らす
ことができる。一般に、ifib(N+2) の計算では、ifib
(N) はifib(N+1) の計算の中で既に計算されているの
で、再度計算する必要がない。そして、ifib(N+1) の結
果を得てからifib(N+2) を計算するためには、足し算を
一度するだけなので、ifib(N+2) の計算量は線形オーダ
となる。ただし、過去の計算結果の検索が十分高速で、
計算量が線形オーダ以下であれば。(通常、検索にはハ
ッシングが使われるので個々の検索の計算量は定数オー
ダとなり、また、ifib(N+2) の計算全体ではN回の検索
が行われるので、合計は線形オーダの計算量となる。)
Therefore, ifib (1), ifib
(2), ifib (3) and its calculation result are recorded as a set and recorded in an appropriate place, and if this set is searched before proceeding according to the definition of calculation and the calculation result has already been obtained. , It is possible to reduce the calculation time and space amount by replacing it with that. Generally, ifib (N + 2) is calculated by ifib
Since (N) has already been calculated in the calculation of ifib (N + 1), it does not need to be calculated again. Then, in order to calculate ifib (N + 2) after obtaining the result of ifib (N + 1), the addition is done only once, so the amount of calculation of ifib (N + 2) is in linear order. However, searching for past calculation results is fast enough,
If the amount of calculation is less than or equal to the linear order. (Usually, hashing is used for searching, so the amount of calculation for each search is a constant order. Also, since the total number of ifib (N + 2) calculations is N times, the total calculation amount is in linear order. It becomes.)

【0017】[0017]

【発明が解決しようとする課題】以上のように、過去の
計算結果を登録し、それを再利用して部分的な再計算を
繰り返さずに計算処理を行う手法においては、過去の計
算結果の検索が十分高速で、計算量が線形オーダ以下で
あれば、メモリ空間・時間量にナイーブな、例えば上記
したフィボナッチ数列の計算を線形オーダの計算量で計
算することができる。
As described above, in the method of registering past calculation results and reusing them to perform calculation processing without repeating partial recalculation, the past calculation results are If the search is sufficiently fast and the calculation amount is less than or equal to the linear order, the calculation of the Fibonacci sequence, which is naive to the memory space / time amount, can be calculated with the calculation amount of the linear order.

【0018】しかしながら、従来の手法は、過去の計算
結果、すなわち、部分的な計算断片とその計算結果の組
をテーブル等に記録しそれを再利用するものであり、シ
ステムにより、過去の計算結果を自動的、かつ、動的に
登録することはできず、また、計算の中間結果を登録し
再利用することはできなかった。本発明は上記した従来
技術を考慮してなされたものであって、本発明の第1の
目的は、部分的な計算の断片と、計算の中間結果のグラ
フのルートノードのセルを対応付け、この対応付けられ
ている部分グラフを、さらに計算された中間結果により
動的に更新していくことにより、部分的な再計算を繰り
返す計算に必要とされるメモリ空間、および、時間量を
大幅に削減したグラフリダクション機構の最適化方法お
よび装置を提供することである。
However, the conventional method records past calculation results, that is, a set of partial calculation fragments and their calculation results in a table or the like and reuses them. Could not be registered automatically and dynamically, and the intermediate result of calculation could not be registered and reused. The present invention has been made in consideration of the above-mentioned conventional technique, and a first object of the present invention is to associate a partial calculation fragment with a cell of a root node of a graph of intermediate calculation results, By dynamically updating the associated subgraphs with the intermediate results that have been calculated, the memory space and time required for the calculation that repeats partial recalculations can be significantly increased. An object of the present invention is to provide an optimized method and apparatus for a reduced graph reduction mechanism.

【0019】本発明の第2の目的は、記憶空間を使い果
たすまで、全ての計算の断片を登録し続け、ガベージコ
レクションに同期して、現在の全体のグラフを最大に共
有させるために必要な部分を除いた全ての登録を削除す
ることにより、登録された部分的な計算の断片を効率的
に削除して記憶空間を回収することができるグラフリダ
クション機構の最適化方法および装置を提供することで
ある。
A second object of the invention is to keep registering all the computational fragments until the storage space is exhausted, and in synchronization with garbage collection, to get the maximum share of the current overall graph. By providing a method and apparatus for optimizing a graph reduction mechanism that can efficiently delete registered partial calculation fragments and reclaim storage space by deleting all registrations except is there.

【0020】[0020]

【課題を解決するための手段】図1は本発明の原理図で
ある。同図において、1はリダクションの対象となる全
体のグラフSを保持する第1の記憶手段、2はグラフS
の全ての部分グラフのハッシュ値をハッシュテーブル2
aに記憶するとともに,過去に存在した部分グラフと現
在到達しているそのリダクション先の部分グラフの組を
記憶する第2の記憶手段、3は第1の記憶手段1に保持
された部分グラフをリダクションして第2の記憶手段2
に登録するリダクション手段、4はガベージコレクショ
ンに同期して、ガベージを回収するガベージコレクタで
ある。
FIG. 1 shows the principle of the present invention. In the figure, 1 is a first storage means for holding an entire graph S to be reduced, and 2 is a graph S.
Hash table 2 for the hash values of all subgraphs of
The second storage means 3 stores the set of the subgraph existing in the past and the subgraph of the reduction destination which is currently reached in the second storage means 3 and stores the subgraph held in the first storage means 1. Second storage means 2 by reduction
The reduction means 4 registered in 1. is a garbage collector that collects the garbage in synchronization with the garbage collection.

【0021】上記課題を解決するため、本発明の請求項
1の発明は、ハッシュテーブル2aによりグラフSを共
有化し、ある部分グラフg3について、ハッシュ値を求
め、求めたハッシュ値に基づき、ハッシュテーブル2a
を参照してハッシュテーブル2aに登録されたポインタ
により、上記部分グラフg3と同一構造の部分グラフg
1のリダクション先の部分グラフg2を求め、上記部分
グラフg3のポインタをリダクション先の部分グラフの
ポインタg2に置き換えることにより、過去の計算断片
を再利用して部分的な再計算を繰り返さずに計算を行う
ようにしたものである。
In order to solve the above-mentioned problems, the invention of claim 1 of the present invention shares a graph S with a hash table 2a, obtains a hash value for a certain subgraph g3, and based on the obtained hash value, the hash table is obtained. 2a
With the pointer registered in the hash table 2a, the subgraph g having the same structure as the above subgraph g3.
1 is calculated as the reduction target subgraph g2, and the pointer of the subgraph g3 is replaced with the pointer of the reduction target subgraph g2, whereby the past calculation fragments are reused and calculation is performed without repeating partial recalculation. Is to do.

【0022】本発明の請求項2の発明は、請求項1の発
明において、記憶空間を使い果たすまで、全ての部分グ
ラフを登録しつづけ、ガベージコレクションに同期し
て、現在の全体グラフを最大に共有できる部分を除い
た、全ての登録を削除して記憶空間を回収するようにし
たものである。本発明の請求項3の発明は、グラフリダ
クション機構の最適化装置を、リダクションの対象とな
る全体のグラフSを保持する第1の記憶手段1と、第1
の記憶手段1に記憶されたグラフSの全ての部分グラフ
のハッシュ値をハッシュテーブル2aに記憶するととも
に,過去に存在した部分グラフと現在到達しているその
リダクション先の部分グラフの組を記憶する第2の記憶
手段2と、第1の記憶手段1に保持された部分グラフを
リダクションし、リダクション先の部分グラフが、第2
の記憶手段2に登録されていないとき、リダクション先
の部分グラフを、元の部分グラフに対応付けて第2の記
憶手段2に登録するリダクション手段3とから構成した
ものである。
According to a second aspect of the present invention, in the first aspect of the invention, all subgraphs are continuously registered until the storage space is used up, and the current whole graph is shared at maximum in synchronization with garbage collection. All the registrations except the part that can be deleted are deleted and the storage space is collected. According to a third aspect of the present invention, there is provided a graph reduction mechanism optimizing device comprising: a first storage unit 1 for holding an entire graph S to be reduced;
The hash values of all the subgraphs of the graph S stored in the storage means 1 are stored in the hash table 2a, and a set of a subgraph existing in the past and a subgraph of the reduction destination currently reached is stored. The second storage unit 2 and the subgraph held in the first storage unit 1 are redacted, and the subgraph of the reduction destination is the second subgraph.
When it is not registered in the storage means 2, the reduction destination subgraph is associated with the original subgraph and registered in the second storage means 2.

【0023】本発明の請求項4の発明は、請求項3の発
明において、ガベージコレクションに同期して、現在の
全体のグラフを最大に共有させるために必要な部分を除
いた全ての登録を削除するガベージコレクタ4を設けた
ものである。
According to a fourth aspect of the present invention, in the third aspect of the invention, all the registrations except the part necessary for maximally sharing the current entire graph are deleted in synchronization with the garbage collection. The garbage collector 4 is provided.

【0024】[0024]

【作用】前記したようにハッシングにより共有可能部分
を見つけ、ポインタの共有に置き換えるだけでなく、こ
のハッシュテーブルを拡張して、過去に存在した部分グ
ラフと、それが現在どの部分グラフまでリダクションさ
れて来ているかを対応付けるようにし、過去に行われた
全てのリダクシヨンを繰り返さないようにすれば、計算
時間・空間消費量を大幅に削減することができる。な
お、現在までその部分グラフのどのグラフもリダクショ
ンされていなければ、拡張前と同じ対応となる。
As described above, not only the sharable part is found by hashing and replaced by the sharing of the pointer, but also this hash table is expanded so that the subgraph existing in the past and which subgraph it is currently reduced to are reduced. It is possible to significantly reduce the calculation time and space consumption by associating whether or not it has come and not repeating all the reductions performed in the past. Note that, until now, if none of the subgraphs have been reduced, the correspondence will be the same as before expansion.

【0025】ここで、注意が必要なのは、前記したよう
な古くからある計算結果の再利用と異なり、部分的な計
算の断片とその計算結果の組を記憶するだけではなく、
部分的な計算の断片と計算の中間結果のグラフのルート
ノードのセルを対応付ける。しかも、この対応付けられ
ている部分グラフは、計算対象となっているグラフの一
部を構成しているので、それに対する直接あるいは関節
的なリダクションによって、動的にさらに計算された中
間結果あるいは、完全な計算結果となって行く。
It should be noted that, unlike the old reuse of the calculation result as described above, not only the partial calculation fragment and the set of the calculation results are stored,
The partial calculation fragment is associated with the cell of the root node of the graph of the intermediate calculation result. Moreover, since this associated subgraph forms a part of the graph to be calculated, the intermediate result dynamically calculated by direct or joint reduction of the graph, or Complete calculation results will be obtained.

【0026】ただし、リダクションにより部分グラフは
書き換えられるがそのルートノードのセルは不変である
ので、中間結果をセルのアドレスとして対応付けておけ
ば、常に最新の中間結果を得ることができる。しかしな
がら、このような計算結果の再利用は、全体の計算結果
が進むにつれて膨大な計算の断片を登録することにな
り、記憶空間を消費して行く(なお、各計算の中間結果
は、全体のグラフ中の部分グラフとして共有されている
ので、その登録は、単にポインタ1個分の記憶空間しか
必要としない)。
However, since the subgraph is rewritten by the reduction but the cell of the root node is invariable, the latest intermediate result can always be obtained by associating the intermediate result with the cell address. However, such reuse of the calculation results results in registering a huge number of calculation fragments as the entire calculation result progresses, and consumes storage space (note that the intermediate result of each calculation is the entire calculation result). Since it is shared as a subgraph in the graph, its registration requires only one pointer storage space).

【0027】上記のように登録された全ての断片が再利
用されるとは限らないので、何らかの方法で再利用され
る可能性の低いものを削除して記憶空間の再利用を促す
必要がある。しかしながら、将来に再利用される可能性
があるかないかを予測するの非常に難しい。そこで、ヒ
ューリスティックに頼らずに、記憶空間を使い果たすま
で全ての計算の断片を登録し続け、その後ガベージコレ
クションに同期して、現在のグラフを最大に共有させる
ために必要な部分を除いた全ての登録を削除して記憶空
間を回収する。すなわち、何度も再利用されるものは一
旦削除されても再計算され、それがまた再利用されるの
で、オーバヘッドはかなり小さくなると予想されるから
である。
Since not all the fragments registered as described above are reused, it is necessary to delete the ones that are unlikely to be reused by some method to promote the reuse of the storage space. . However, it is very difficult to predict whether it may be reused in the future. So, instead of relying on heuristics, keep registering all the pieces of computation until you run out of storage space, and then synchronize with garbage collection to remove all but the part needed to maximize sharing of the current graph. To recover the storage space. That is, it is expected that the overhead, which is reused many times, will be recomputed even if it is deleted once, and that it will be reused again, so that the overhead is considerably reduced.

【0028】また、小さな計算では、一度もガベージコ
レクションを起こすことなく計算できるので、ヒューリ
スティクに頼るよりも良い結果が得られる。本発明は上
記考え方に基づき、グラフリダクション機構の最適化を
図ったものであり、次に、本発明におけるハッシュ・テ
クニックと、計算断片の登録、検索、更新、削除につい
て説明する。 (1)ハッシュテクニック グラフのハッシングの機構は、グラフのハッシュ関数と
登録・削除の機構からなる。
Further, since a small calculation can be performed without causing garbage collection even once, a better result can be obtained than relying on heuristics. The present invention is intended to optimize the graph reduction mechanism based on the above concept. Next, the hash technique and the registration, search, update, and deletion of calculation fragments in the present invention will be described. (1) Hash technique The graph hashing mechanism consists of a graph hash function and a registration / deletion mechanism.

【0029】今、gをダグ、fをgのルート・ノードの
関数記号、g1 ,g2 ,…,gn をgの引数を表す子の
ダグとする。ハッシュ関数hash: G→N(Gはダグの集
合、Nは自然数)を考えると、グラフが構造を持つデー
タであることから、通常次のような再帰的な形で与える
ことになる。 hash(g)=α(h(f),hash(g1),hash(g2),… hash(gn)), ここで、α:N+ →Nとh:F→Nとする(N+ は自然
数の有限列で、Fは関数記号の集合)。すなわち、ハッ
シュ値hash(g) はそのルート・ノードの関数記号f によ
り定まる値h(f)と、その子ノードのハッシュ値hash(g
1),hash(g2),… hash(gn) から定まる再帰的な形で与え
られる。
Now, let g be Doug, f be the function symbol of the root node of g, and g1, g2, ..., Gn be child Dougs representing the arguments of g. Considering the hash function hash: G → N (G is a set of Doug, N is a natural number), since the graph is structured data, it is usually given in the following recursive form. hash (g) = α (h (f), hash (g1), hash (g2), ... hash (gn)), where α: N + → N and h: F → N (where N + is A finite sequence of natural numbers, where F is a set of function symbols). That is, the hash value hash (g) is the value h (f) determined by the function symbol f of the root node and the hash value hash (g
1), hash (g2), ... Given in a recursive form determined by hash (gn).

【0030】ハッシュ関数は、検索を高速化するための
ヒントを得るためのものなので、本来任意のもので良い
訳であるが、ハッシュ関数自身の計算が十分高速で本来
の計算のオーバヘッドとならず、また、検索が最も高速
に行われるためには、ハッシュ関数が単射に近いことが
望ましいとされる。上のハッシュ関数は、再帰的である
が、実際の計算では、子のグラフは既にハッシュによっ
て共有化されていて、ルートのセルのアドレスをそのハ
ッシュ値と見なして計算を簡略化しても、十分有効なハ
ッシュ関数となる。
Since the hash function is for obtaining a hint for speeding up the search, it may be any arbitrary, but the calculation of the hash function itself is sufficiently fast and does not cause the overhead of the original calculation. In addition, it is desirable that the hash function be close to injective in order for the search to be performed at the highest speed. The above hash function is recursive, but in the actual calculation, the child graph is already shared by the hash, and it is enough to simplify the calculation by regarding the address of the root cell as its hash value. It is a valid hash function.

【0031】すなわち、次の関数の形となる。 hash(g)=α(h(f),#(g1),#(g2),… #(gn)), ここで、#(g)は、ダグgのルートのセルのアドレスであ
る。また、組み込み型の値は、実際上無限個あるので、
これらの値をハッシュ・テーブルに登録するのは現実的
でない。そこで、グラフのマッチングのアルゴリズムを
改良して、たとえ2つの組み込み型の値が同じセルの上
になくても、同じ値であるときは、同じセルを共有して
とみなすようにする。
That is, the form of the function is as follows. hash (g) = α (h (f), # (g1), # (g2), ... # (gn)), where # (g) is the address of the root cell of Doug g. Also, since there are practically infinite numbers of built-in types,
It is not practical to register these values in the hash table. Therefore, the graph matching algorithm is improved so that even if two built-in type values are not on the same cell, they are considered to share the same cell when they have the same value.

【0032】また、ハッシュ関数も、子グラフが組み込
み型の値のときには、そのセルのアドレスでなく、その
値自身を使うことにすれば、事実上、組み込み型のデー
タは、値が同じであれば、常に全て同じセルを共有して
いると見なすことができる。さらに、ハッシュテーブル
を関数記号ごとに分割することにすると、h(f)を計算す
る必要はなく、ハッシュ値は次のようになる。
Also, in the hash function, when the child graph has a built-in type value, if the value itself is used instead of the address of the cell, the built-in type data may actually have the same value. For example, they can always be regarded as sharing the same cell. Furthermore, if the hash table is divided for each function symbol, it is not necessary to calculate h (f), and the hash value is as follows.

【0033】hash(g)=α(#(g1),#(g2), … #(gn)), ただし、giが組み込み型の値のときは、#(gi) を値その
もの、すなわち、giそのものとする。また、ハッシュテ
ーブルを始めに一度で割り当ててしまうと、あまり使わ
れない関数記号とよく使われる関数記号のハッシュテー
ブルが同じだけメモリ空間を使ってしまい、効率がよく
ない。そこで、ハッシュテーブルを2次元とし、1次元
の部分ハッシュテーブルとそのハッシュテーブルへのポ
インタの配列の構成とし、部分ハッシュテーブルはハッ
シュ関数の値により、そのテーブルが必要になったとき
動的に割り当てるようにする。 (2)計算断片(部分グラフ)の登録、検索、更新、削
除 図2は本発明におけるハッシュの仕組みを説明する図で
あり、同図を参照して本発明における計算断片(部分グ
ラフ)の登録、検索、更新について説明する。なお、図
10で説明したifib(1),ifib(2),ifib(3) のような計算
断片を部分グラフと呼ぶ。
Hash (g) = α (# (g1), # (g2), ... # (gn)), However, when gi is a built-in value, # (gi) is the value itself, that is, gi Let it be. Also, if the hash table is allocated at the beginning at once, the hash table of the function symbol that is rarely used and the hash table of the function symbol that is often used use the same memory space, which is not efficient. Therefore, the hash table is two-dimensional, and the one-dimensional partial hash table and an array of pointers to the hash table are configured, and the partial hash table is dynamically allocated when the table is needed according to the value of the hash function. To do so. (2) Registration, Retrieval, Update, and Deletion of Computation Fragment (Subgraph) FIG. 2 is a diagram for explaining the hash mechanism of the present invention. Referring to FIG. 2, registration of a computation fragment (subgraph) of the present invention. , Search, and update will be described. Note that the calculation fragments such as ifib (1), ifib (2), ifib (3) described in FIG. 10 are called subgraphs.

【0034】図2において、大きくハッチングされた領
域Sは全体のグラフを示し、全体のグラフが既に登録さ
れハッシュされていると仮定し、ここでは説明のため、
同図のA,B,Cの3個のハッチングされた多角形の部
分(グラフ)について考える。また、グラフAはリダク
ションされるグラフ、グラフBはリダクション先のグラ
フ、グラフCはグラフAと同じハッシュ値を持つグラフ
である。
In FIG. 2, a large hatched area S indicates the whole graph, and it is assumed that the whole graph has already been registered and hashed.
Consider three hatched polygonal portions (graphs) A, B, and C in FIG. Further, the graph A is a graph to be reduced, the graph B is a graph of a reduction destination, and the graph C is a graph having the same hash value as the graph A.

【0035】同図において、各グラフはセルを単位とし
て構成され、各セル11a,11b,11cには、図3
に示すように、通常、そのセルに割り当てられている
関数記号(あるいは組み込む型の値、同図では関数fが
示されている)、その引数を表す部分グラフのルート
セルへの何個かのポインタP1,P2,P3,…、そ
の関数記号に割り当てられている属性リスト12へのポ
インタPli、さらに、この枠組では、グラフ構造のハッ
シングを行うので、ハッシュテーブルの保守のための
ポインタPm が付いている。
In the figure, each graph is composed of cells as a unit, and each cell 11a, 11b, 11c has a structure shown in FIG.
, The function symbol (or the value of the built-in type, the function f is shown in the figure) normally assigned to the cell, and some pointers to the root cell of the subgraph representing the argument. P1, P2, P3, ..., A pointer Pli to the attribute list 12 assigned to the function symbol, and further, in this framework, since the graph structure is hashed, a pointer Pm for maintenance of the hash table is attached. There is.

【0036】図2にもどり、12は属性リストであり、
ハッシュテーブルが各関数毎に分割されているので、各
関数毎に設けられた属性リスト12には、その関数のハ
ッシュテーブル全体をたどるためのポインタPhaが入れ
られている。ハッシュテーブルは、前記したように2次
元構造となっており、一次元の部分ハッシュテーブル1
4a〜14bと、その部分ハッシュテーブル14a〜1
4bへのポインタを格納した配列13から構成され、部
分ハッシュテーブル14a〜14bのポインタは、複数
のグラフに対応したハッシュリスト15aを指してい
る。
Returning to FIG. 2, 12 is an attribute list,
Since the hash table is divided for each function, the attribute list 12 provided for each function contains a pointer Pha for tracing the entire hash table of that function. The hash table has a two-dimensional structure as described above, and the one-dimensional partial hash table 1
4a-14b and its partial hash tables 14a-1
The partial hash tables 14a to 14b are composed of an array 13 in which pointers to 4b are stored, and the pointers of the partial hash tables 14a to 14b point to a hash list 15a corresponding to a plurality of graphs.

【0037】なお、ハッシュテーブルのメモリ空間は、
全てが予め割り当てられていないので、登録する場所に
空間が割り当てられていないときは、その都度割り当て
る。また、違うグラフに同じハッシュ値が割り当てられ
ることがあるので、一般的には複数のグラフが登録され
る。例えば、図2に示すように、グラフAと同じハッシ
ュ値を持つ異なった構造のグラフとして、グラフCが登
録されている。
The memory space of the hash table is
All are not pre-allocated, so if space is not allocated at the registration location, it is allocated each time. Moreover, since the same hash value may be assigned to different graphs, generally, a plurality of graphs are registered. For example, as shown in FIG. 2, the graph C is registered as a graph having a different hash structure and the same hash value as the graph A.

【0038】登録は、同図に示すように、ハッシュリス
ト15aの最後に、新しい3要素からなるハッシュリス
ト15bを作ってつなぎ、その第1の要素151と第2
の要素152にハッシュしようとするグラフへのポイン
タPg1,Pg2(最初は同一のセルを指している)を入
れ、最後の要素153には空リストを入れる。そして、
グラフがリダクションされたとき、ハッシュリスト15
aに示されるように、上記ポインタPg2はリダクション
先のグラフ(例えば、同図のグラフB)を指すようにな
る。また、新たに登録するときには、上記最後の要素1
53に新たなハッシュリストへのポインタPg3を入れ
る。
For registration, as shown in the figure, at the end of the hash list 15a, a hash list 15b consisting of three new elements is created and connected, and the first element 151 and the second element 151 are connected.
The pointers Pg1 and Pg2 (pointing to the same cell at the beginning) to the graph to be hashed are put in the element 152, and the empty list is put in the last element 153. And
When the graph is redacted, hash list 15
As indicated by a, the pointer Pg2 points to the reduction-destination graph (for example, graph B in the same figure). Also, when newly registering, the last element 1 above
A pointer Pg3 to a new hash list is put in 53.

【0039】図2において、ある部分グラフ(これを以
下グラフXという)をハッシュしようとすると、まず、
その部分グラフXからハッシュ関数でハッシュ値を得
る。次に、その部分グラフXのルートセルから属性リス
ト12を得て、その部分グラフXの関数のハッシュテー
ブル13,14を得る。ついで、既に計算してあったハ
ッシュ値に対応するハッシュテーブル内の位置にそのグ
ラフXのルートセルへのポインタを登録する。
In FIG. 2, when trying to hash a certain subgraph (hereinafter referred to as graph X), first,
A hash value is obtained from the subgraph X by a hash function. Next, the attribute list 12 is obtained from the root cell of the subgraph X, and the hash tables 13 and 14 of the functions of the subgraph X are obtained. Then, the pointer to the root cell of the graph X is registered at the position in the hash table corresponding to the already calculated hash value.

【0040】ここで、前記したように、ハッシュテーブ
ルのメモリ空間は、全てが予め割り当てられていないの
で、登録する空間に割り当てられていないときには、割
り当てる。そして、登録する位置に何も登録されていな
いときには、上記部分グラフXを登録し、他のグラフの
ハッシュリストが登録されてるときには、その中に同じ
構造のグラフがあるか否かを判定し、無ければそのハッ
シュリストにハッシュしようとするグラフXを登録す
る。
Here, as described above, since the memory space of the hash table is not allotted in advance, it is assigned when it is not assigned to the space to be registered. Then, when nothing is registered at the position to be registered, the subgraph X is registered, and when a hash list of another graph is registered, it is determined whether or not there is a graph having the same structure, If not, the graph X to be hashed is registered in the hash list.

【0041】すなわち、ルートセルのアドレスが一致す
るか、あるいは、その全ての引数のグラフのルートセル
のアドレスが登録しようとしているグラフの対応する引
数のそれと一致するグラフ(これを同じ構造のグラフと
いう)が登録されていなければ、そのハッシュリストに
ハッシュしようとするグラフXを登録する。例えば、同
図において、グラフCを新たに登録する場合には、前記
したように、ハッシュリスト15aの最後に、新しい3
要素からなるハッシュリスト15bを作ってつなぎ、ハ
ッシュリスト15bの第1要素151,152に登録し
ようとするグラフCのルートへのポインタを登録する。
That is, a graph in which the addresses of the root cells are the same or the addresses of the root cells of the graph of all the arguments are the same as those of the corresponding arguments of the graph to be registered (this is called a graph of the same structure) If it is not registered, the graph X to be hashed is registered in the hash list. For example, in the figure, when a graph C is newly registered, as described above, a new 3 is added at the end of the hash list 15a.
A hash list 15b composed of elements is created and connected, and a pointer to the root of the graph C to be registered is registered in the first elements 151 and 152 of the hash list 15b.

【0042】また、もし、同じ構造のグラフが登録され
ている場合には,このグラフへのポインタがあるハッシ
ュリストの第2の要素のグラフで、ハッシュしようとし
たグラフXを置き換える。図2の例においては、あるグ
ラフXをハッシュしようとしたとき、そのグラフと同じ
構造のグラフAが既に登録されていれば、グラフAへの
ポインタがあるハッシュリスト15aの第2要素152
が指すグラフBで、ハッシュしようとしたグラフXを置
き換える。上記ハッシュリスト15aの第2要素152
には、後述するように、グラフAのリダクション先のグ
ラフBを指すポインタPg2が登録されているので、上記
置き換えにより、ハッシュしようとしたグラフXは、リ
ダクション先のグラフBにより置き換えられる。
If a graph having the same structure is registered, the graph X to be hashed is replaced with the graph of the second element of the hash list having a pointer to this graph. In the example of FIG. 2, when trying to hash a certain graph X, if a graph A having the same structure as the graph is already registered, the second element 152 of the hash list 15a having a pointer to the graph A is present.
Replace graph X, which is to be hashed, with graph B pointed to by. The second element 152 of the hash list 15a
As will be described later, since a pointer Pg2 pointing to the graph B of the reduction destination of the graph A is registered, the graph X to be hashed is replaced by the graph B of the reduction destination by the above replacement.

【0043】上記置き換えは、グラフXのルートのセル
への全てのポインタ(このセルからは、どのセルから指
されているかは分からない)の置き換えであるが、イン
ダイレクション法(回り道法)と呼ばれる方法を使い、
置き換えを先延ばしする。すなわち、図4に示すよう
に、ハッシュしようとしたグラフのセルからでている引
数へのポインタ(図4においては、ポインタP1,P
2)をクリアし、そのかわりに、置き換え先のセルへの
ポインタを入れ、グラフのセルには、インダイレクシヨ
ンに使われていることを表す属性を付ける(このような
属性が付けられたセルをインダイレクションセルと呼
ぶ)。
The above replacement is replacement of all pointers to the root cell of the graph X (which cell does not know which cell is pointed to), which is called the indirection method (detour method). Using the method
Postpone replacement. That is, as shown in FIG. 4, pointers to the arguments (pointers P1, P in FIG.
2) is cleared, a pointer to the cell to be replaced is inserted instead, and an attribute indicating that it is used for indirection is added to the cell of the graph (cells with such an attribute are added. Is called an indirection cell).

【0044】上記のようにしておいて、後に、全体のグ
ラフを辿りながら、このインダイレクションセルを見つ
けたその都度、このセルへのポインタをこのセルの先の
ポインタに置き換えて行く。このようにすることによ
り、実際にはインダクレンションなしでハッシュ時に全
てのルートセルへのリンクを置き換えたのと同じことに
なる。
In the above-described manner, the pointer to this cell is replaced with the pointer ahead of this cell each time this indirection cell is found while tracing the entire graph. By doing this, it is actually the same as replacing the links to all the root cells during hashing without induction.

【0045】ここで、前記したようにハッシュリストの
第2の要素のグラフで置き換えるのは、この中に第1要
素のグラフを何度かリダクションした先のグラフが入っ
ているからである。最初グラフを登録したときには、ハ
ッシュリストの第1の要素と第2の要素は同じグラフを
指している(例えば、図3に示したように、ハッシュリ
スト15の第1の要素151と第2の要素152は同じ
グラフを指している)。
Here, the reason why the graph of the second element of the hash list is replaced as described above is that the graph after reduction of the graph of the first element is included in this graph. When the graph is first registered, the first element and the second element of the hash list point to the same graph (for example, as shown in FIG. 3, the first element 151 and the second element of the hash list 15). Element 152 points to the same graph).

【0046】そして、任意のグラフをリダクションする
ときに、そのグラフのルートセルから保守用のポインタ
Pm を使って、自分自身のハッシュリストを見つけ(そ
のグラフのルートセルからは自分自身のハッシュリスト
は分からない)、それの第2要素にリダクションされた
先のグラフへのポインタを入れる。例えば、図2におい
て、グラフAをリダクションするとき、そのルートセル
11aからハッシュリスト15aは分からないので、保
守用のポインタPm を使ってハッシュリスト15aを見
つけ、ハッシュリスト15aの第2要素152にリダク
ション先のグラフBのルートセル11bへのポインタを
入れる。
When redacting an arbitrary graph, it finds its own hash list using the maintenance pointer Pm from the root cell of the graph (the own hash list cannot be known from the root cell of the graph). ), Put a pointer to the redacted destination graph in its second element. For example, in FIG. 2, when the graph A is redacted, the hash list 15a is not known from its root cell 11a, so the hash pointer 15a is found using the maintenance pointer Pm, and the reduction destination is set to the second element 152 of the hash list 15a. The pointer to the root cell 11b of the graph B is inserted.

【0047】さらに、リダクションされたグラフの部分
グラフがリダクションされると、上記第2要素の先は、
2回リダクションされた先になり、そのサイクルが何度
も繰り返される。その結果、間接的に、また、動的に第
2要素が最もリダクションされた先へのポインタへと変
わって行くことになる。すなわち、過去にリダクション
された全ての部分グラフとその現在最新のリダクション
された先の部分グラフの組が動的に更新されていく。
Further, when the subgraph of the reduced graph is reduced, the tip of the second element is
After being reduced twice, the cycle is repeated many times. As a result, the second element is indirectly and dynamically changed to the pointer to the most redacted destination. That is, the set of all the subgraphs that have been reduced in the past and the current latest latest subgraph that has been reduced is dynamically updated.

【0048】ただし、ハッシュリストの第2要素を更新
するときには、第1要素の先のグラフ(つまり、リダク
ションされるグラフ)を一部書き換える必要がある。こ
れは、インダイレクション法を使っているので、前記し
たように、リダクションされるグラフのルートセルがリ
ダクションされた先のグラフを作るのに使われてしまう
からである。
However, when updating the second element of the hash list, it is necessary to rewrite a part of the graph preceding the first element (that is, the graph to be reduced). This is because the indirection method is used, and as described above, the root cell of the graph to be redacted is used to create the graph of the redacted destination.

【0049】そこで、リダクションが終わる前に、第1
要素の先のグラフのルートセルを、引数の部分グラフへ
のポインタも含めてコピーし、第1要素のポインタをリ
ダクションされるグラフから、このコピーへと付け換え
ることが必要となる。ここで、このコピーされたセルを
参照するセルが存在しないことに注意する必要がある。
すなわち、このコピーされたセルは、ガベージコレクタ
にとってはガベージであるから、ヒープ領域が使い果た
さるとガベージとして回収される。
Therefore, before the reduction is finished, the first
It is necessary to copy the root cell of the graph preceding the element, including the pointer to the subgraph of the argument, and replace the pointer of the first element from the redacted graph to this copy. Note that there are no cells that reference this copied cell.
That is, the copied cells are garbage for the garbage collector, and are collected as garbage when the heap area is used up.

【0050】図5は上記したグラフの共有を説明する図
であり、同図は前記したifibプログラムにおけるグラフ
を共有を示している。同図において、前記したようにif
ib(3) はifib(2)+ifib(1) であるので、同図(a)に示
すifib(3) のグラフがリダクションされると、同図
(b)に示すように、ifib(3) のグラフがコピーされて
ガベージとなり、そのセルはインダイレクションノード
となる。そして、インダイレクシヨンノードには、リダ
クション先の部分グラフ(この場合には、ifib(2)+ifib
(1) )のセルへのポインタが入れられる。また、前記し
たように、ハッシュリストの第1の要素は上記ifib(3)
を指し、第2要素が上記インダイレクションノードを指
すようになる。
FIG. 5 is a diagram for explaining the sharing of the above-mentioned graph, which shows sharing of the graph in the above-mentioned ifib program. In the figure, if
Since ib (3) is ifib (2) + ifib (1), if the graph of ifib (3) shown in (a) of the figure is reduced, as shown in (b) of the figure, ifib (3 ) Graph is copied and becomes garbage, and its cell becomes an indirection node. Then, the indirection node contains the reduction target subgraph (in this case, ifib (2) + ifib
A pointer to the cell in (1)) is inserted. Also, as mentioned above, the first element of the hash list is the above ifib (3).
, And the second element now points to the above indirection node.

【0051】同図(b)に示す状態から、さらにifib
(2) のグラフがリダクションされると、同図(c)に示
すように、ifib(2) のグラフがガベージとなり、インダ
イレクシヨンノードには、リダクション先の部分グラフ
(この場合には、ifib(1)+ifib(0) )のセルへのポイン
タが入れられる。ここで、同図の点線で囲まれた部分A
とBは同一のグラフであり、共有可能である。そこで、
前記したように、上記部分Bのグラへのポインタが付け
換えられる。
From the state shown in FIG.
When the graph of (2) is reduced, the graph of ifib (2) becomes garbage, and the indirection node has a subgraph of the reduction destination (in this case, ifib (1) + ifib (0)) cell pointer is inserted. Here, the part A surrounded by the dotted line in the figure
And B are the same graph and can be shared. Therefore,
As described above, the pointer to the graph of the part B is replaced.

【0052】図6および図7は計算履歴を考慮したグラ
フの共有を説明する図であり、同図により、前記したif
ibプログラムにおける計算履歴を考慮したグラフの共有
について説明する。図6(a)において、ルートセルの
ポインタはそれぞれifib(2) とifib(3) の部分グラフを
指しており、ハッシュリスト15a,15bの第1要
素、第2要素は、それぞれともにifib(2) とifib(3) の
部分グラフのセルを指している。
FIGS. 6 and 7 are diagrams for explaining the sharing of the graph in consideration of the calculation history.
The sharing of graphs considering the calculation history in the ib program is explained. In FIG. 6A, the pointer of the root cell points to the subgraphs of ifib (2) and ifib (3), respectively, and the first and second elements of the hash lists 15a and 15b are both ifib (2). And ifib (3) point to a subgraph cell.

【0053】同図(a)の状態からifib(2) の部分グラ
フがリダクションされると、同図(b)に示すように、
ifib(2) のセルがコピーされてガベージとなり、インダ
イレクシヨンノードには、リダクション先の部分グラフ
(この場合には、ifib(1)+ifib(0) )のセルへのポイン
タが入れられる。また、前記したように、ハッシュリス
ト15aの第1の要素は上記ガベージとなったifib(2)
を指し、第2要素が上記インダイレクションノードを指
すようになる。さらに、ifib(1) のセルへのポインタが
ハッシュリスト15cの第1要素と第2要素に入れられ
る。
When the subgraph of ifib (2) is reduced from the state shown in FIG. 9A, as shown in FIG.
The cell of ifib (2) is copied to become garbage, and the pointer to the cell of the reduction target subgraph (in this case, ifib (1) + ifib (0)) is put in the indirection node. Further, as described above, the first element of the hash list 15a becomes the above garbage ifib (2).
, And the second element now points to the above indirection node. Further, the pointer to the cell of ifib (1) is put in the first element and the second element of the hash list 15c.

【0054】さらに同図(b)の状態から、ifib(3) の
部分グラフがリダクションされると、図7に示すよう
に、ifib(3) のセルがコピーされてガベージとなり、ハ
ッシュリスト15bの第1要素はガベージとなったifib
(3) のセルを指すようになり、また、第2要素はインダ
イレクションノードを指すようになる。ここで、ifib
(3) はifib(2) とifib(1) の部分グラフにリダクション
されるが、図6(a)から図6(b)へのリダクショク
により、ifib(2) の部分グラフが既に登録されており、
これらは共有可能である。同様に、ifib(1) の部分グラ
フについても、ifib(1) の部分グラフが既に登録されて
おり、これらは共有可能である。そこで、ifib(3) のリ
ダクションにより生成されたifib(2) の部分グラフは既
に登録されているifib(2) の部分グラフに置き換えられ
る。
Further, if the subgraph of ifib (3) is reduced from the state of FIG. 7B, the cell of ifib (3) is copied and becomes garbage, as shown in FIG. The first element is garbage ifib
The cell of (3) will be pointed to, and the second element will point to the indirection node. Where ifib
(3) is reduced to the subgraphs of ifib (2) and ifib (1), but the subgraph of ifib (2) has already been registered by the reduction from Fig. 6 (a) to Fig. 6 (b). Cage,
These can be shared. Similarly, ifib (1) subgraphs are already registered, ifib (1) subgraphs can be shared. Therefore, the ifib (2) subgraph generated by the ifib (3) reduction is replaced with the already registered ifib (2) subgraph.

【0055】すなわち、ifib(3) のリダクションにより
生成されたインダイレクションノードが指すセルにおい
て、ifib(2) の部分グラフを指すポインタの先が、同図
に示すように、既に登録されているifib(2) の部分グラ
フに置き換えられる。同様に、ifib(3) のリダクション
により生成されたifib(1) の部分グラフは既に登録され
ているifib(1) の部分グラフに置き換えられる。 (3)計算断片(部分グラフ)の削除 上記したように、リダクションが終わる前に、第1要素
の先のグラフのルートセルを、引数の部分グラフへのポ
インタも含めてコピーし、第1要素のポインタをリダク
ションされるグラフから、このコピーへと付け換え、こ
のコピーされたセルをヒープ領域が使い果たされたと
き、ガベージとして回収する。
That is, in the cell pointed to by the indirection node generated by the reduction of ifib (3), the tip of the pointer pointing to the subgraph of ifib (2) is already registered as shown in FIG. It is replaced by the subgraph in (2). Similarly, the ifib (1) subgraph generated by the ifib (3) reduction is replaced by the already registered ifib (1) subgraph. (3) Deletion of calculation fragment (subgraph) As described above, before the reduction ends, the root cell of the graph preceding the first element is copied including the pointer to the subgraph of the argument, and the The pointer is changed from the redacted graph to this copy, and the copied cell is collected as garbage when the heap area is exhausted.

【0056】例えば、前記した図5(c)において、ガ
ベージとなったifib(2) 、ifib(3)のセルは回収され
る。これにより、現在のグラフを最大に共有させるため
に必要な部分、すなわち、前記図3に示した、ハッシュ
リスト15の第1要素151と第2要素152のポイン
タが共に同じセルを指しているものを除き、全ての登録
が削除される。
For example, in FIG. 5C, the ifib (2) and ifib (3) cells that have become garbage are collected. As a result, the part necessary for maximally sharing the current graph, that is, the pointers of the first element 151 and the second element 152 of the hash list 15 shown in FIG. 3 both point to the same cell. All registrations are deleted except for.

【0057】しかし、このままでは、ハッシュテーブル
に、回収されたセルへのポインタ(例えば、上記 ifib
(2) 、ifib(3) のセルへのポインタ)が残ってしまうこ
とになって、後のリダクションで矛盾が起こってしま
う。そこで、ガベージコレクション時に、カベージとし
て回収されるセルへのポインタを持つハッシュテーブル
のエンリトを削除しなければならない。
However, as it is, a pointer to the collected cells (for example, ifib
(2) and ifib (3) cell pointers) will remain, and inconsistency will occur in later reduction. Therefore, at the time of garbage collection, it is necessary to delete the enlit of the hash table that has the pointer to the cell to be collected as garbage.

【0058】各セルにハッシュの保守用のポインタPm
があるのは、この削除を高速に行うためである。すなわ
ち、ガベージコレクタが、ガベージのセルを見つける
と、それのハッシュの保守用ポインタを辿って、そのセ
ルを指すハッシュリストへのポインタを得る。次に、そ
のハッシュリストの次のリストへのポインタを次の次の
リストへのポインタで置き換える。
Hash maintenance pointer Pm for each cell
The reason is that this deletion is performed at high speed. That is, when a garbage collector finds a garbage cell, it will follow the hash's maintenance pointer and get a pointer to the hash list pointing to that cell. Then replace the pointer to the next list in the hash list with the pointer to the next next list.

【0059】例えば、前記図2において、セル11aが
カベージであるとすると、保守用のポインタPm を辿っ
てハッシュリスト15aを指すハッシュテーブル14b
のポインタをハッシュリスト15aの次のハッシュリス
ト15bを指すポインタに置き換える。これにより、カ
ベージとして回収されるセルへのポインタを持つハッシ
ュテーブルのエンリトが削除される。
For example, in FIG. 2, assuming that the cell 11a is a garbage table, the hash table 14b that points to the hash list 15a by tracing the maintenance pointer Pm.
Of the hash list 15a is replaced with a pointer pointing to the hash list 15b next to the hash list 15a. As a result, the enlit of the hash table having the pointer to the cell collected as the garbage is deleted.

【0060】また、先に、インダイレクションセルへの
リンクが見つかったその都度、そのリンク先をそのセル
の先のセルへ付け換えることで、実際には、インダイレ
クションセルがないのと同じになると説明したが、詳し
くみると、このリンクを付け換えるときに、リンク先の
アドレスが変わってしまう。すなわち、本発明において
は、前記したように、部分グラフのルートセルのアドレ
スに基づいたハッシュ関数を使っているので、この部分
グラフを含む全ての部分グラフのハッシュ値を再計算し
て、登録する場所を移動しないと、ハッシュに不要なエ
ンリトが溜まって計算の効率が落ちる。
Also, each time a link to an indirection cell is found, the link destination is replaced with the cell ahead of the cell, so that it becomes the same as when there is no indirection cell. As I explained, in detail, when changing this link, the address of the link destination changes. That is, in the present invention, as described above, since the hash function based on the address of the root cell of the subgraph is used, the hash values of all subgraphs including this subgraph are recalculated, and the location to register is calculated. If you don't move, unnecessary hash will be accumulated in the hash and the efficiency of the calculation will decrease.

【0061】しかしなから、この再計算のコストは膨大
なので、許容できない程不要なエントリが残らない程度
の部分グラフの再ハッシュを行う。このため、インダイ
レクションセルへのリンクをもっていたセルをルートと
する部分グラフだけを再ハッシュする。このハッシュで
この部分グラフの置き換えが起こらなければ、すなわ
ち、ルートのアドレスが変わらなければ、それを含む部
分グラフのハッシュ値は再計算しても元のままで、再計
算の必要はない。
However, since the cost of this recalculation is enormous, the subgraph is rehashed so that unacceptably unnecessary entries do not remain. Therefore, only the subgraph rooted at the cell having the link to the indirection cell is rehashed. If replacement of this subgraph does not occur in this hash, that is, if the address of the root does not change, the hash value of the subgraph including it remains unchanged even if it is recalculated, and recalculation is not necessary.

【0062】一方、部分グラフの置き換えが起こったと
きには、それを含む部分グラフの再ハッシュをし直さな
いと、全体のグラフを常時、最大の共有構造のダグに保
つことはできなくなる。つまり、ハッシュテーブルに登
録されていない部分グラフができて、後で、別の部分グ
ラフで構造が同じものができたときに、前の部分グラフ
と共有されず、この前の部分グラフは、どこかで再ハッ
シュが行われないと、いつまでも共有の対象から外れる
ことになる。
On the other hand, when replacement of a subgraph occurs, the entire graph cannot always be kept at the maximum shared structure Doug unless the subgraph including it is rehashed. This means that when you have a subgraph that is not registered in the hashtable, and later you have another subgraph with the same structure, it will not be shared with the previous subgraph, and this previous subgraph will If you don't rehash it, you'll never be shared.

【0063】しかし、この場合でも、この部分グラフを
含む外側のグラフのハッシュは有効である。すなわち、
これらのクラフのハッシュに関係するセルのアドレスは
変わっていないからである。本発明は上記した原理に基
づき、前記課題を解決したものであり、本発明の請求項
1の発明においては、ハッシュテーブル2aによりグラ
フSを共有化し、ある部分グラフg3について、ハッシ
ュ値を求め、求めたハッシュ値に基づき、ハッシュテー
ブル2aを参照してハッシュテーブル2aに登録された
ポインタにより、上記部分グラフg3と同一構造の部分
グラフg1のリダクション先の部分グラフg2を求め、
上記部分グラフg3のポインタをリダクション先の部分
グラフのポインタg2に置き換えるようにしたので、過
去の計算断片を再利用して部分的な再計算を繰り返さず
に計算を行うことができ、部分的な再計算を繰り返す計
算に必要とされるメモリ空間、および時間量を大幅に削
減することができる。
However, even in this case, the hash of the outer graph including this subgraph is valid. That is,
This is because the addresses of the cells involved in the hash of these crafts have not changed. The present invention is based on the above principle and solves the above problems. In the invention of claim 1 of the present invention, a graph S is shared by a hash table 2a, and a hash value is obtained for a certain subgraph g3. Based on the obtained hash value, a pointer registered in the hash table 2a with reference to the hash table 2a is used to obtain the reduction target subgraph g2 of the subgraph g1 having the same structure as the subgraph g3.
Since the pointer of the subgraph g3 is replaced with the pointer g2 of the reduction target subgraph, it is possible to reuse the past calculation fragment and perform the calculation without repeating the partial recalculation. It is possible to significantly reduce the memory space and the amount of time required for the calculation that repeats the recalculation.

【0064】本発明の請求項2の発明においては、請求
項1の発明において、記憶空間を使い果たすまで、全て
の部分グラフを登録しつづけ、ガベージコレクションに
同期して、現在の全体グラフを最大に共有できる部分を
除いた、全ての登録を削除して記憶空間を回収するよう
にしたので、ヒューリステックに頼らずに、オーバヘッ
ドを小さくして記憶空間を効率的に回収することができ
る。
In the invention of claim 2 of the present invention, in the invention of claim 1, all subgraphs are continuously registered until the storage space is used up, and the current entire graph is maximized in synchronization with garbage collection. The storage space is collected by deleting all the registrations except the sharable part, so that the overhead can be reduced and the storage space can be collected efficiently without resorting to heuristics.

【0065】本発明の請求項3の発明においては、グラ
フリダクション機構の最適化装置を、リダクションの対
象となる全体のグラフSを保持する第1の記憶手段1
と、第1の記憶手段1に記憶されたグラフSの全ての部
分グラフのハッシュ値をハッシュテーブル2aに記憶す
るとともに,過去に存在した部分グラフと現在到達して
いるそのリダクション先の部分グラフの組を記憶する第
2の記憶手段2と、第1の記憶手段1に保持された部分
グラフをリダクションし、リダクション先の部分グラフ
が、第2の記憶手段2に登録されていないとき、リダク
ション先の部分グラフを、元の部分グラフに対応付けて
第2の記憶手段2に登録するリダクション手段3とから
構成したので、過去にリダクションされた全ての部分グ
ラフとその最新のリダクション先の部分グラフの組を動
的に更新していくことができ、過去の計算断片を再利用
して計算を行う際のメモリ空間、および時間量を大幅に
削減することができる。
In the invention of claim 3 of the present invention, the optimization device of the graph reduction mechanism is provided with the first storage means 1 for holding the entire graph S to be reduced.
And the hash values of all subgraphs of the graph S stored in the first storage unit 1 are stored in the hash table 2a, and the subgraphs that existed in the past and the subgraphs of the reduction destination that are currently reached are stored. The second storage unit 2 for storing the set and the subgraph held in the first storage unit 1 are reduced, and when the reduction-target subgraph is not registered in the second storage unit 2, the reduction destination Since it is composed of the reduction means 3 which registers the subgraph in the second storage means 2 in association with the original subgraph, all the subgraphs reduced in the past and the latest reduction destination subgraph. The set can be updated dynamically, and the memory space and the amount of time when reusing past calculation fragments to perform calculations can be significantly reduced. That.

【0066】本発明の請求項4の発明においては、請求
項3の発明において、ガベージコレクションに同期し
て、現在の全体のグラフを最大に共有させるために必要
な部分を除いた全ての登録を削除するガベージコレクタ
4を設けたので、ヒューリステックに頼らずに、オーバ
ヘッドを小さくして記憶空間を効率的に回収することが
できる。
In the invention of claim 4 of the present invention, in the invention of claim 3, all the registrations except the part necessary for maximally sharing the current entire graph are synchronized with the garbage collection. Since the garbage collector 4 for deleting is provided, the overhead can be reduced and the storage space can be efficiently collected without depending on the heuristic.

【0067】[0067]

【実施例】図8は本発明の実施例を示す図であり、同図
において、21は書き換えの対象となる全体のグラフ
(セルを単位とする)を保持する第1の記憶装置、22
は書き換えのルール(あるいは、検索の高速化のため
に、ルールに何らかの変換を加えたもの)を保持する第
2の記憶装置、23は本発明に係わる第3の記憶装置で
あり、記憶装置23は後述するリダクション装置25と
ガベージコレクタ26との間で通信しながらデータをや
り取りし、第1の記憶装置21に記憶されたグラフの全
ての部分グラフをハッシュテーブルに記憶するととも
に,過去の存在した部分グラフとそれが現在書き換えら
れて到達している先の部分グラフの組を記憶する。
FIG. 8 is a diagram showing an embodiment of the present invention, in which reference numeral 21 is a first storage device for holding an entire graph (cell unit) to be rewritten, 22.
Is a second storage device that holds a rewrite rule (or a rule that has undergone some kind of conversion for speeding up search), and 23 is a third storage device according to the present invention, and the storage device 23 Exchanges data while communicating between a reduction device 25 and a garbage collector 26, which will be described later, stores all subgraphs of the graph stored in the first storage device 21 in a hash table, and exists in the past. It remembers the set of subgraphs and the previous subgraphs it is currently being rewritten to.

【0068】24は各セルに付加する属性(関数記号、
型情報、各種ハッシュテーブル)を記憶する第4の記憶
装置、25は書き換えルールと部分グラフのマッチング
を取りながらグラフを書き換えるリダクション装置、2
6はガベージコレクション時にガベージを回収するガベ
ージコレクタである。なお、同図においては、記憶装置
を第1から第4の記憶装置に分割しているが、記憶装置
は必ずしも4つの装置を設ける必要はなく、物理的には
一つの装置とし、その中を分けて使ってもよい。
24 is an attribute (function symbol,
A fourth storage device for storing type information and various hash tables), a reduction device 25 for rewriting a graph while matching a rewriting rule with a subgraph, 2
A garbage collector 6 collects the garbage at the time of garbage collection. Although the storage device is divided into the first to fourth storage devices in the figure, the storage device does not necessarily have to be provided with four devices, and is physically one device, and You may use it separately.

【0069】次に図8に示した本発明の実施例の動作に
ついて説明する。本実施例の装置はリダクション装置2
5を中心にして周辺の記憶装置21,22,23,24
と通信しながら動作する。また、ガベージコレクタ26
は、リダクション装置25とは独立に動作し、記憶装置
21の中のセルがリダクション装置25により使い尽く
されたのを検出して、自動的にこのセルの中で他から参
照されないもの、すなわち、ガベージを回収して再び利
用可能な状態とする。
Next, the operation of the embodiment of the present invention shown in FIG. 8 will be described. The apparatus of this embodiment is a reduction apparatus 2
5, peripheral storage devices 21, 22, 23, 24
Work while communicating with. Also, the garbage collector 26
Operates independently of the reduction device 25, detects that a cell in the storage device 21 has been exhausted by the reduction device 25, and automatically refers to no other cell in this cell, that is, Garbage is collected and made available again.

【0070】図9は本実施例におけるリダクション装置
25の動作を示すフローチャートであり、同図を参照し
てリダクション装置25の動作を説明する。なお、図9
には図示していないが、リダクション装置26には入出
力装置が設けられ、これを介して記憶装置21,22,
23,24とデータをやり取りする。
FIG. 9 is a flow chart showing the operation of the reduction device 25 in this embodiment, and the operation of the reduction device 25 will be described with reference to the figure. Note that FIG.
Although not shown in the figure, the reduction device 26 is provided with an input / output device through which the storage devices 21, 22, 22 are connected.
Data is exchanged with 23 and 24.

【0071】リダクション装置26は、先ず、図9のス
テップS1に示すように、第1の記憶装置21の全て
のセルを利用可能な状態に初期化し、書き換えルール
を第2の記憶装置22にロードし,初期グラフ(書き
換え対象のグラフ)をロードする。また、これに付随し
て各種の属性を第4の記憶装置24にロードする。ス
テップS2において、第1の記憶装置21の初期グラフ
の全ての部分グラフを第3の記憶装置のハッシュテーブ
ルに登録する。
The reduction device 26 first initializes all cells of the first storage device 21 to an available state and loads the rewrite rule into the second storage device 22, as shown in step S1 of FIG. Then, the initial graph (graph to be rewritten) is loaded. Also, accompanying this, various attributes are loaded into the fourth storage device 24. In step S2, all subgraphs of the initial graph of the first storage device 21 are registered in the hash table of the third storage device.

【0072】ステップS3において、リダクション装置
26は記憶装置21からリダクション可能な部分グラフ
を見つけ、ステップS4において、第2の記憶手段22
のルールを参照して、それにマッチしたルールで部分グ
ラフをリダクションする。ステップS5において、上記
リダクションされた後の部分グラフが、記憶装置23の
ハッシュテーブルに既に登録されているかどうかを調
べ、登録されていない場合には、登録する。
In step S3, the reduction device 26 finds a redactable subgraph from the storage device 21, and in step S4, the second storage means 22.
Refer to the rule of and reduce the subgraph by the rule that matches it. In step S5, it is checked whether or not the reduced partial graph is already registered in the hash table of the storage device 23, and if it is not registered, it is registered.

【0073】そして、そのハッシュ結果として、その部
分グラフと組になっている、その部分グラフがさらにリ
ダクションされた先を記憶装置23に返す。ここで、前
記したように、書き換えたグラフの登録ののち、そのグ
ラフを包含するグラフの再ハッシュの再計算が必要であ
る。上記処理を繰り返し、もうこれ以上リダクションで
きる部分が無くなると、ステップS7において、書き換
え終わった全てのグラフを出力して計算を終了する。以
上のようにして、リダクションを行い、利用可能なセル
がなくなることが検出されると、ガベージコレクタ26
はガベージの回収にかかり、第2の記憶装置23と通信
してガベージをそれが登録されているハッシュテーブル
から削除する。
Then, as a result of the hash, the destination of the further reduction of the subgraph, which is paired with the subgraph, is returned to the storage device 23. Here, as described above, after the rewritten graph is registered, it is necessary to recalculate the rehash of the graph including the graph. When the above process is repeated and there is no more part that can be reduced, in step S7, all the graphs that have been rewritten are output and the calculation ends. As described above, when the reduction is performed and it is detected that there are no available cells, the garbage collector 26
Collects garbage, communicates with the second storage device 23, and deletes the garbage from the hash table in which it is registered.

【0074】[0074]

【発明の効果】以上説明したように、本発明において
は、部分的な再計算を繰り返すに必要とされるメモリ空
間、および時間をヒューリスティクに頼らずに大幅に削
減することができる。例えば、O(2N )のメモリ空
間、時間量のナイーブなフィボナッチ数列の計算を、問
題の大きさNが小さく、ハッシュテーブルの検索がほと
んど一定時間で可能で、ガベージコレクションが計算の
最中に起こらないとすれば、動的に、すなわちプログラ
ムによる変換なしで、O(N)程度の計算とすることが
できる。
As described above, according to the present invention, the memory space and time required for repeating partial recalculation can be significantly reduced without relying on heuristics. For example, to calculate a naive Fibonacci sequence with O (2 N ) memory space and time amount, the problem size N is small, the hash table can be searched almost in a certain time, and the garbage collection can be performed during the calculation. If it does not occur, it is possible to perform the calculation on the order of O (N) dynamically, that is, without conversion by the program.

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

【図1】本発明の原理図である。FIG. 1 is a principle diagram of the present invention.

【図2】本発明のハッシュの仕組みを説明する図であ
る。
FIG. 2 is a diagram illustrating a hash mechanism of the present invention.

【図3】グラフのセルの構造を示す図である。FIG. 3 is a diagram showing a structure of cells of a graph.

【図4】インダイレクション法による置き換えを説明す
る図である。
FIG. 4 is a diagram illustrating replacement by the indirection method.

【図5】本発明におけるグラフの共有を説明する図であ
る。
FIG. 5 is a diagram illustrating sharing of graphs in the present invention.

【図6】計算履歴を利用したグラフの共有を説明する図
である。
FIG. 6 is a diagram illustrating sharing of a graph using a calculation history.

【図7】計算履歴を利用したグラフの共有を説明する図
(続き)である。
FIG. 7 is a diagram (continuation) illustrating sharing of a graph using a calculation history.

【図8】本発明の実施例の構成を示す図である。FIG. 8 is a diagram showing a configuration of an exemplary embodiment of the present invention.

【図9】本発明の実施例の動作を示すフローチャートで
ある。
FIG. 9 is a flowchart showing the operation of the embodiment of the present invention.

【図10】再計算を行う計算木の一例を示す図である。FIG. 10 is a diagram showing an example of a calculation tree for recalculation.

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

1 第1の記憶手段 2 第2の記憶手段 2a ハッシュテーブル 3 リダクション手段 4 ガベージコレクタ 12 属性リスト 11a,11b,11c セル 21 第1の記憶装置 22 第2の記憶装置 23 第3の記憶装置 24 第4の記憶装置 25 リダクション装置 26 ガベージコレクタ g1,g2,g3 部分グラフ S グラフ 1 1st memory | storage means 2 2nd memory | storage means 2a Hash table 3 Reduction means 4 Garbage collector 12 Attribute list 11a, 11b, 11c Cell 21 1st memory | storage device 22 2nd memory | storage device 23 3rd memory | storage device 24 4th 4 storage device 25 reduction device 26 garbage collector g1, g2, g3 partial graph S graph

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 ハッシュテーブル(2a)によりグラフ(S)
を共有化し、 ある部分グラフ(g3)について、ハッシュ値を求め、 求めたハッシュ値に基づき、ハッシュテーブル(2a)を参
照してハッシュテーブル(2a)に登録されたポインタによ
り、上記部分グラフ(g3)と同一構造の部分グラフ(g1)の
リダクション先の部分グラフ(g2)を求め、 上記部分グラフ(g3)のポインタをリダクション先の部分
グラフのポインタ(g2)に置き換えることにより、過去の
計算断片を再利用して部分的な再計算を繰り返さずに計
算を行うことを特徴とするグラフリダクション機構の最
適化方法。
1. A graph (S) using a hash table (2a)
Is shared, a hash value is calculated for a certain subgraph (g3), and based on the calculated hash value, the hash table (2a) is referred to and the pointer registered in the hash table (2a) is used. ), Find the reduction target subgraph (g2) of the subgraph (g1), and replace the pointer of the above subgraph (g3) with the pointer of the reduction target subgraph (g2) A method for optimizing a graph reduction mechanism, which is characterized by reusing and recalculating without repeating partial recalculation.
【請求項2】 記憶空間を使い果たすまで、全ての部分
グラフを登録しつづけ、ガベージコレクションに同期し
て、現在の全体グラフを最大に共有できる部分を除い
た、全ての登録を削除して記憶空間を回収することを特
徴とする請求項1のグラフリダクション機構の最適化方
法。
2. A storage space in which all subgraphs are continuously registered until the storage space is used up, and all registrations are deleted in synchronization with garbage collection except for a portion where the current whole graph can be shared to the maximum extent. The method for optimizing a graph reduction mechanism according to claim 1, wherein
【請求項3】 リダクションの対象となる全体のグラフ
(S) を保持する第1の記憶手段(1) と、 第1の記憶手段(1) に記憶されたグラフ(S) の全ての部
分グラフのハッシュ値をハッシュテーブル(2a)に記憶す
るとともに,過去に存在した部分グラフと現在到達して
いるそのリダクション先の部分グラフの組を記憶する第
2の記憶手段(2) と、 第1の記憶手段(1) に保持された部分グラフをリダクシ
ョンし、リダクション先の部分グラフが、第2の記憶手
段(2) に登録されていないとき、リダクション先の部分
グラフを、元の部分グラフに対応付けて第2の記憶手段
(2) に登録するリダクション手段(3) とを備えたことを
特徴とするグラフリダクション機構の最適化装置。
3. An overall graph subject to reduction
A first storage means (1) holding (S) and hash values of all subgraphs of the graph (S) stored in the first storage means (1) are stored in a hash table (2a). , A second storage means (2) for storing a set of a subgraph existing in the past and a subgraph of the reduction destination that has arrived now, and the subgraph held in the first storage means (1) If the reduction-destination subgraph is not registered in the second storage means (2), the reduction-destination subgraph is associated with the original subgraph and the second storage means
An optimization device for a graph reduction mechanism, comprising: a reduction means (3) registered in (2).
【請求項4】 ガベージコレクションに同期して、現在
の全体のグラフを最大に共有させるために必要な部分を
除いた全ての登録を削除するガベージコレクタ(4) を備
えたことを特徴とする請求項3のグラフリダクション機
構の最適化装置。
4. A garbage collector (4) for synchronizing all garbage collections and deleting all registrations except those necessary for maximally sharing the current whole graph. An optimization device of the graph reduction mechanism according to item 3.
JP12503694A 1994-06-07 1994-06-07 Method and apparatus for optimizing graph reduction mechanism Withdrawn JPH07334366A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP12503694A JPH07334366A (en) 1994-06-07 1994-06-07 Method and apparatus for optimizing graph reduction mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP12503694A JPH07334366A (en) 1994-06-07 1994-06-07 Method and apparatus for optimizing graph reduction mechanism

Publications (1)

Publication Number Publication Date
JPH07334366A true JPH07334366A (en) 1995-12-22

Family

ID=14900264

Family Applications (1)

Application Number Title Priority Date Filing Date
JP12503694A Withdrawn JPH07334366A (en) 1994-06-07 1994-06-07 Method and apparatus for optimizing graph reduction mechanism

Country Status (1)

Country Link
JP (1) JPH07334366A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011001806A1 (en) 2009-06-30 2011-01-06 インターナショナル・ビジネス・マシーンズ・コーポレーション Graph similarity calculation system, method, and program
JP2014225077A (en) * 2013-05-15 2014-12-04 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation Method for managing object in computer, and program and system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011001806A1 (en) 2009-06-30 2011-01-06 インターナショナル・ビジネス・マシーンズ・コーポレーション Graph similarity calculation system, method, and program
JP5306461B2 (en) * 2009-06-30 2013-10-02 インターナショナル・ビジネス・マシーンズ・コーポレーション Graph similarity calculation system, method and program
US8588531B2 (en) 2009-06-30 2013-11-19 International Business Machines Corporation Graph similarity calculation system, method and program
US9122771B2 (en) 2009-06-30 2015-09-01 International Business Machines Corporation Graph similarity calculation system, method and program
JP2014225077A (en) * 2013-05-15 2014-12-04 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation Method for managing object in computer, and program and system

Similar Documents

Publication Publication Date Title
JP3771271B2 (en) Apparatus and method for storing and retrieving ordered collections of keys in a compact zero complete tree
Dial et al. A computational analysis of alternative algorithms and labeling techniques for finding shortest path trees
US5241673A (en) System for garbage collecting unused memory space represented by a digraph by assigning values of node identifiers to selected variables based upon predetermined conditions
US5548751A (en) Dynamic data storage system allowing variable size records and fields by using linked record segments
JP4581962B2 (en) Information retrieval system, index management method and program
AU690282B2 (en) A method for storing and retrieving data and a memory arrangement
JP2003114816A (en) Data structure storing indexes in computer memory
GB2407417A (en) Index tree structure and key existence determination for a database
JPH1173325A (en) Program conversion device and recording medium
US7653619B1 (en) Integrated search engine devices having pipelined search and tree maintenance sub-engines therein that support variable tree height
JP4351247B2 (en) Dynamic storage structure and method of computer-based compact 0 complete tree for processing stored data
JPH07121377A (en) Resource allocation device
US7725450B1 (en) Integrated search engine devices having pipelined search and tree maintenance sub-engines therein that maintain search coherence during multi-cycle update operations
US5297239A (en) Compile type knowledge processing tool, a high-speed inference method therefor and a system using the tool
JPH06149589A (en) Reference target variable determination processing method and translation processing system
US5923837A (en) Method of accessing data using approximate data structures
JPH07334366A (en) Method and apparatus for optimizing graph reduction mechanism
CN118708192A (en) A high-performance sparse computing programming framework implementation method and system
JP4673299B2 (en) Information processing method and information processing system
JPH0581102A (en) System for controlling table
Clarke et al. Escher-a geometrical layout system for recursively defined circuits
Fitchett et al. CPU-less parallel execution of lambda calculus in digital logic
JPH0833899B2 (en) Index update method
CN119759860B (en) File system synchronization method and system based on vectorizable summary algorithm
JP7540830B2 (en) Data storage method and system for a data set - Patents.com

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20010904