JP2004355365A - Cache management device and cache memory management method - Google Patents
Cache management device and cache memory management method Download PDFInfo
- Publication number
- JP2004355365A JP2004355365A JP2003152762A JP2003152762A JP2004355365A JP 2004355365 A JP2004355365 A JP 2004355365A JP 2003152762 A JP2003152762 A JP 2003152762A JP 2003152762 A JP2003152762 A JP 2003152762A JP 2004355365 A JP2004355365 A JP 2004355365A
- Authority
- JP
- Japan
- Prior art keywords
- data
- cache
- level memory
- access
- block
- 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
Links
Images
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
Abstract
Description
【0001】
【発明の属する技術分野】
本発明はキャッシュ管理装置およびキャッシュメモリ管理方法に関し、特に使用頻度の高いデータを上位レベルメモリに格納することができるキャッシュ管理装置およびキャッシュメモリ管理方法に関する。
【0002】
【従来の技術】
一般に、コンピュータシステムの高速化のためにキャッシュメモリが利用されている。キャッシュメモリは、CPUと主記憶装置との間に配置される。キャッシュメモリには、主記憶装置に使用されるメモリよりも高速なメモリが用いられる。そのため、CPUは、キャッシュメモリに格納されたデータに対し高速にアクセスできる。なお、キャッシュメモリは、ブロック単位の領域に分割して管理されており、ブロック単位でデータの書き込みや書き出し等の処理が行われる。
【0003】
ところで、データのキャッシングは、データの読み込み時(リードキャッシュ)だけでなく、データの書き出し時(ライトキャッシュ)にも行われる。
主記憶装置へのデータの書き出し方式には、ライトスルー方式とライトバック方式とがある。ライトスルー方式では、CPUがデータの書き出しを行うとき、キャッシュメモリへの書き込みと同時に主記憶装置にも書き込む。一方、ライトバック方式では、CPUがデータの書き出しを行うとき、書き込みはキャッシュメモリに行う。そして、任意のタイミングでキャッシュメモリに書き込まれたデータを主記憶装置に書き出す。ライトスルー方式とライトバック方式とを適時選択し、選択した方式によりデータの書き出しを行うこともできる(たとえば、特許文献1、特許文献2参照)。
【0004】
【特許文献1】
米国特許5,469,555号
【特許文献2】
米国特許5,522,057号
【0005】
【発明が解決しようとする課題】
しかし、従来技術では、キャッシュにミスヒットした場合、アクセス対象のデータを含む全てのブロックを無差別にキャッシングする。そのため、キャッシングされてもほとんど参照されることなく追い出されてしまうようなブロックもキャッシュメモリに格納される。このような再利用性のないブロックをキャッシュメモリに入れることは、以下のような不利益を生む。
【0006】
・ほとんど参照されないデータをキャッシュメモリ内に格納することで、そのデータより参照頻度の高いデータが追い出されてしまいアクセス速度向上の恩恵を得る機会が減る。
【0007】
・平均アクセス時間の短縮に寄与しないブロックの転送に、時間とバスの使用帯域を費やすことで、システムの処理効率の低下を招く。
なお、プログラムを組む段階で再利用性のないことがあらかじめ分かっているデータについては、プログラマが意図的にキャッシングしないように指定することも可能である。ただし、キャッシュブロックの再利用性はキャッシュ容量、データ規模等によって異なってくるため、多くの場合は実行時でないと把握できない。
【0008】
このように、使用頻度の少ないデータをキャッシュメモリに書き込むことは、コンピュータシステムの性能に悪影響を及ぼす。そのため、過去の使用頻度が高いデータにアクセスした場合にのみ、そのデータ(あるいは、そのデータを含むブロック)をキャッシュメモリに書き込むことができるシステムが求められている。
【0009】
なお、上記特許文献1および特許文献2に記載された技術では、データの書き込み方式の切り替えに際し、データの使用頻度を考慮していない。そのため、システムの運用中に、各データの使用頻度に応じたデータの書き込み方式の切り替えはできない。
【0010】
本発明はこのような点に鑑みてなされたものであり、データの過去の使用頻度に応じて、キャッシングの要否を判断できるキャッシュ管理装置およびキャッシュメモリ管理方法を提供することを目的とする。
【0011】
【課題を解決するための手段】
本発明では上記課題を解決するために、図1に示すようなキャッシュ管理装置が提供される。本発明に係るキャッシュ管理装置は、CPU1からのアクセス要求に応じたキャッシュ処理を制御するようにしたものであるキャッシュ管理装置は、以下の要素で構成される。
【0012】
上位レベルメモリ2は、CPU1に接続されている。カウンタ2cは、上位レベルメモリ2に格納された各データのアクセス回数を計数する。下位レベルメモリ3は、CPU1と上位レベルメモリ2とに接続され、上位レベルメモリ2に格納された各データに対応するデータを格納する。アクセス回数ログ3cは、下位レベルメモリ3に格納された各データに対応づけて設けられている。メモリコントローラ1aは、CPU1が出力するアクセス要求で指定されたアクセス対象データが上位レベルメモリ2にヒットすると、アクセス対象データに対応するカウンタ2cの値をカウントアップし、上位レベルメモリ2内の置き換え対象データを無効化したとき、置き換え対象データに対応するカウンタ2cの値を、下位レベルメモリ3内の置き換え対象データに対応するアクセス回数ログ3cに設定し、アクセス対象データが上位レベルメモリ2にミスヒットしたとき、下位レベルメモリ3内のアクセス対象データのアクセス回数ログ3cの値が所定値より大きければ、アクセス対象データを上位レベルメモリに格納する。
【0013】
このようなキャッシュ管理装置によれば、上位レベルメモリ2上で各データのアクセス回数が計数される。上位レベルメモリ2で無効化された置き換え対象データのアクセス回数は、下位レベルメモリ3のアクセス回数ログ3cに設定される。そして、上位レベルメモリ2でミスヒットした場合、アクセス対象データに対応するアクセス回数ログの値が所定値以上であれば、アクセス対象データが上位レベルメモリ2に格納される。
【0014】
また、上記課題を解決するために、CPUからのアクセス要求に応じたキャッシュ処理を制御するキャッシュ管理装置において、前記CPUに接続された上位レベルメモリと、前記上位レベルメモリに格納された各データのアクセス回数を計数するカウンタと、前記CPUと前記上位レベルメモリとに接続され、前記上位レベルメモリに格納された各データに対応するデータを格納する下位レベルメモリと、前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップするとともに、前記アクセス要求がデータライト要求である場合、前記上位レベルメモリへデータの書き込みを行い、前記アクセス要求がデータライト要求であり、且つ前記アクセス対象データの前記カウンタの値が前記所定値以下である場合、前記下位レベルメモリへもデータの書き込みを行うメモリコントローラと、を有することを特徴とするキャッシュ管理装置が提供される。
【0015】
このようなキャッシュ管理装置によれば、CPUが出力するアクセス要求で指定されたアクセス対象データが上位レベルメモリにヒットすると、アクセス対象データに対応するカウンタの値がカウントアップされる。また、アクセス要求がデータライト要求である場合、上位レベルメモリへデータの書き込みが行われる。さらに、アクセス要求がデータライト要求であり、且つアクセス対象データのカウンタの値が所定値以下である場合、下位レベルメモリへもデータの書き込みが行われる。
【0016】
また、上記課題を解決するために、上位レベルメモリと、前記上位レベルメモリに格納されたデータに対応するデータを格納する下位レベルメモリとへのCPUからのアクセス要求に応じたキャッシュ処理を制御するためのキャッシュメモリ管理方法において、前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応するカウンタの値をカウントアップし、前記上位レベルメモリ内の置き換え対象データを無効化したとき、前記置き換え対象データに対応する前記カウンタの値を、前記下位レベルメモリ内の前記置き換え対象データに対応するアクセス回数ログに設定し、前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納する、ことを特徴とするキャッシュメモリ管理方法が提供される。
【0017】
このようなキャッシュメモリ管理方法によれば、上位レベルメモリ上で各データのアクセス回数が計数される。上位レベルメモリで無効化された置き換え対象データのアクセス回数は、下位レベルメモリのアクセス回数ログに設定される。そして、上位レベルメモリでミスヒットした場合、アクセス対象データに対応するアクセス回数ログの値が所定値以上であれば、アクセス対象データが上位レベルメモリに格納される。
【0018】
【発明の実施の形態】
以下、本発明の実施の形態を図面を参照して説明する。
まず、実施の形態に適用される発明の概要について説明し、その後、実施の形態の具体的な内容を説明する。
【0019】
図1は、実施の形態に適用される発明の概念図である。図1に示すように、キャッシュ管理装置では、CPU1、上位レベルメモリ2、および下位レベルメモリ3間のデータ入出力を制御する。すなわち、キャッシュ管理装置は、CPU1からのアクセス要求に応じたキャッシュ処理を制御するようにしたものである。上位レベルメモリ2は、キャッシュメモリである。また、下位レベルメモリ3は、メインメモリであってもよいし、二次キャッシュメモリであってもよい。
【0020】
上位レベルメモリ2は、CPU1に接続されている。また、上位レベルメモリ2には、タグ情報2aが設けられている。タグ情報2aには、上位レベルメモリ2に格納されている入出力単位データ毎のタグ2bが設けられ、そのタグ2bにカウンタ2cが関連づけられている。タグ2bには、対応するデータのメモリアドレス等の情報が設定される。
【0021】
カウンタ2cは、上位レベルメモリ2に格納された各データのアクセス回数を計数する。なお、アクセス回数の計数は、ブロック単位で行うことができる。ここで言うブロックは、キャッシュ処理における処理単位である。すなわち、複数のデータで構成されるブロック単位で、上位レベルメモリ2に格納される。
【0022】
下位レベルメモリ3は、CPU1と上位レベルメモリ2とに接続され、上位レベルメモリ2に格納された各データに対応するデータを格納する。すなわち、下位レベルメモリ3に格納されているデータの一部が、上位レベルメモリ2にも格納されている。なお、対応するデータとは、メモリアドレスが共通のデータである。下位レベルメモリ3にはタグ情報3aが設けられている。タグ情報3aには、下位レベルメモリ3に格納されているデータ毎のタグ3bが設けられ、そのタグ3bにアクセス回数ログ3cが関連付けられている。
【0023】
アクセス回数ログ3cは、下位レベルメモリ3に格納された各データに対応づけて設けられている。なお、アクセス回数ログ3cは、たとえば、ブロック毎に設けられる。アクセス回数ログ3cには、対応するデータへのアクセス回数が格納される。このアクセス回数は、少なくとも上位レベルメモリ2上でアクセスされた回数である。
【0024】
メモリコントローラ1aは、CPU1が出力するアクセス要求で指定されたアクセス対象データが上位レベルメモリ2にヒットすると、アクセス対象データに対応するカウンタ2cの値をカウントアップする。また、メモリコントローラ1aは、上位レベルメモリ2内の置き換え対象データを無効化したとき、置き換え対象データに対応するカウンタ2cの値を、下位レベルメモリ3内の置き換え対象データに対応するアクセス回数ログ3cに設定する。なお、上位レベルメモリ2内の置き換え対象データの無効化は、上位レベルメモリ2内に空き領域がない状態で、下位レベルメモリ3内のデータを上位レベルメモリ2に取り込む際に実行される。
【0025】
さらに、メモリコントローラ1aは、アクセス対象データが上位レベルメモリ2にミスヒットしたとき、下位レベルメモリ3内のアクセス対象データのアクセス回数ログ3cの値が所定値より大きければ、アクセス対象データを上位レベルメモリに格納する。
【0026】
このようなキャッシュ管理装置によれば、上位レベルメモリ2上で各データのアクセス回数が計数される。上位レベルメモリ2で無効化された置き換え対象データのアクセス回数は、下位レベルメモリ3のアクセス回数ログ3cに設定される。そして、上位レベルメモリ2でミスヒットした場合、アクセス対象データに対応するアクセス回数ログ3cの値が所定値より大きければ、アクセス対象データが上位レベルメモリ2に格納される。すなわち、上位レベルメモリ2でミスヒットしても、アクセス対象データに対応するアクセス回数ログ3cの値が所定値以下であれば、アクセス対象データの上位レベルメモリ2への格納は行われない。
【0027】
このように上位レベルメモリ2上でのアクセス回数をカウントし、データが上位レベルメモリ2を追い出された後は、アクセス回数が所定値より多い場合にのみ下位レベルメモリ3から上位レベルメモリ2へのキャッシングを行うようにした。そのため、再利用性の高いデータに限定したキャッシングが可能となる。すなわち、再利用性の良否をミスヒット発生時に知ることで、そのデータをキャッシュメモリに置くか否かの切り替えを動的に行うことができる。その結果、記憶資源の浪費、ブロック転送による時間の無駄を防ぐことができる。
【0028】
また、上記の処理は、データの参照(リード)のみについて適用してもよいし、データのリードとライトの双方について適用してもよい。データライトのアクセス要求に適用した場合、データライト方式の切り替えが行われることになる。すなわち、データライトのミスヒット時に上位レベルメモリ2にデータを取り込む方式(ライトアロケート方式)と、データライト時にはミスヒットしても上位レベルメモリ2にデータを取り込まない方式(ノーライトアロケート方式)とが切り替えられる。これにより、ブロックの再利用性を表すアクセス回数ログ3cの値に応じて、ライトミス時の動作としてライトアロケート方式、ノーライトアロケート方式のうちより適したものを動的に選択することが可能となる。
【0029】
また、上位レベルメモリへのデータライトの回数をカウンタで計数すれば、データの書き込み頻度を取得することができる。これを利用することで、データの聞き込み頻度に応じて、そのデータに対する書き込み時の方式としてライトスルー方式とライトバック方式のうち、より適したものを選択することができるようになる。
【0030】
さらに、下位レベルメモリ3を複数のCPUで共有するシステムにおいては、下位レベルメモリのタグに対して、各CPUに応じたアクセス回数ログを関連付けることができる。これにより、当該ブロックがどのCPUから何回参照されたかを、下位レベルメモリ3で記録できる。その結果、各データに関して、上位レベルメモリ滞在中のアクセス回数をCPU毎に知ることができる。CPU毎のアクセス回数を知ることができれば、各CPUからの再利用性の低いブロックを察知でき、キャッシングの有効性を判断できる。有効でないと判断されたときにはそのブロックのキャッシングをCPU毎に抑制することで、キャッシングに伴うブロック転送や、有効なブロックのキャッシュメモリからの追い出しを避けることができる。
【0031】
以下に、本発明の実施の形態を具体的に説明する。なお、実施の形態では、キャッシュ処理の処理単位であるブロック毎にアクセス回数をカウントするものとする。また、実施の形態に示すシステムは、CPUと主記憶装置との間に2段のキャッシュメモリ(一次キャッシュと二次キャッシュ)が設けられており、一次キャッシュと二次キャッシュとの間のデータの入出力制御に、本発明を適用する。
【0032】
[第1の実施の形態]
図2は、第1の実施の形態のシステム構成例を示す図である。この例では、2段階のキャッシュメモリを有するCPUモジュールを複数実装したコンピュータシステムの例である。各CPUモジュールは、それぞれCPU110,210,310,410を有している。ここで、CPU110の識別名を「CPU0」、CPU210の識別名を「CPU1」、CPU310の識別名を「CPU2」、CPU410の識別名を「CPU3」とする。
【0033】
CPU110には、CPU0用の一次キャッシュ120とCPU0用の二次キャッシュ130とが接続されている。CPU110には、メモリコントローラ111が内蔵されている。メモリコントローラ111は、CPU110へのデータの取り込みやデータの書き出しを制御する。CPU0用の一次キャッシュ120は、タグ情報121を有している。タグ情報121は、一次キャッシュ120内の記憶領域にブロック単位で格納されているデータを管理するための情報である。CPU0用の二次キャッシュ130は、タグ情報131を有している。タグ情報131は、二次キャッシュ130内の記憶領域にブロック単位で格納されているデータを管理するための情報である。
【0034】
CPU210には、CPU1用の一次キャッシュ220とCPU1用の二次キャッシュ230とが接続されている。CPU210はメモリコントローラ211を有している。一次キャッシュ220はタグ情報221を有している。二次キャッシュ230はタグ情報231を有している。
【0035】
CPU310には、CPU2用の一次キャッシュ320とCPU2用の二次キャッシュ330とが接続されている。CPU310はメモリコントローラ311を有している。一次キャッシュ320はタグ情報321を有している。二次キャッシュ330はタグ情報331を有している。
【0036】
CPU410には、CPU2用の一次キャッシュ420とCPU2用の二次キャッシュ430とが接続されている。CPU410はメモリコントローラ411を有している。一次キャッシュ420はタグ情報421を有している。二次キャッシュ430はタグ情報431を有している。
【0037】
各二次キャッシュ130,230,330,430は、主記憶装置10に接続されている。
なお、一次キャッシュ120,220,320,420は、二次キャッシュ130,230,330,430よりも高速にアクセス可能なメモリである。また、二次キャッシュ130,230,330,430は、主記憶装置10よりも高速にアクセス可能なメモリである。
【0038】
図3は、一次キャッシュのタグ情報のデータ構造例を示す図である。図3には、CPU0用の一次キャッシュ120のタグ情報121を代表的に示している。タグ情報121には、一次キャッシュ120内のブロック毎にタグ122a,122b,・・・が設けられている。タグ122a,122b,・・・は、対応するブロックに格納されたデータのアドレス(ブロックフレームアドレス)を示している。タグ122a,122b,・・・には、状態123a,123b,・・・とカウンタ124a,124b,・・・とが関連付けられている。
【0039】
状態123a,123b,・・・は、対応するブロックに格納されているデータの状態を示す情報である。たとえば、データが有効か否か、データの書き込みの有無等が設定される。状態123a,123b,・・・の内容は、CPU110内のメモリコントローラ111によって設定される。
【0040】
カウンタ124a,124b,・・・は、対応するブロックに格納されているデータがアクセス(参照や書き込み)された回数を示す数値(アクセス回数情報)が設定される。カウンタ124a,124b,・・・の値は、CPU110内のメモリコントローラ111によって更新される。具体的には、カウンタ124a,124b,・・・の値は、対応するブロック内のデータがアクセスされる度に1ずつ増やされる。
【0041】
図3には、CPU0用の一次キャッシュ120のタグ情報121の例を示したが、他のCPU用のタグ情報221,321,421も同様のデータ構造である。
【0042】
図4は、二次キャッシュのタグ情報のデータ構造例を示す図である。図4には、CPU0用の二次キャッシュ130のタグ情報131を代表的に示している。タグ情報131には、二次キャッシュ130内のブロック毎にタグ132a,132b,・・・が設けられている。タグ132a,132b,・・・は、対応するブロックに格納されたデータのアドレス(ブロックフレームアドレス)を示している。タグ132a,132b,・・・には、状態133a,133b,・・・とアクセス回数ログ134a,134b,・・・とが関連付けられている。
【0043】
状態133a,133b,・・・は、対応するブロックに格納されているデータの状態を示す情報である。たとえば、データが有効か否か、データの書き込みの有無等が設定される。状態133a,133b,・・・の内容は、CPU110内のメモリコントローラ111によって設定される。
【0044】
アクセス回数ログ134a,134b,・・・は、対応するブロックに格納されているデータが一次キャッシュ上でアクセスされた回数を示す数値(参照回数)が格納される。アクセス回数ログ134a,134b,・・・の値は、CPU110内のメモリコントローラ111によって更新される。具体的には、アクセス回数ログ134a,134b,・・・の値は、対応するブロック内が一次キャッシュ120から追い出されたとき、そのブロックの一次キャッシュ120におけるカウンタの値が加算される。
【0045】
図4には、CPU0用の二次キャッシュ130のタグ情報131の例を示したが、他のCPU用のタグ情報231,331,431も同様のデータ構造である。
【0046】
このようなタグ情報を用いて、メモリコントローラ111,211,311,411がデータアクセス処理を制御する。以下、アクセス要求に応じたデータアクセス処理の内容をメモリコントローラ111の例を用いて説明する。なお、以下の例では、アクセス対象のデータが二次キャッシュ130内に格納されている場合を想定している。
【0047】
図5は、第1の実施の形態に係るアクセス処理の手順を示すフローチャートである。以下、図5に示す処理をステップ番号に沿って説明する。
[ステップS11]メモリコントローラ111は、CPU110からデータ参照のアクセス要求を受け付ける。
【0048】
[ステップS12]メモリコントローラ111は、一次キャッシュ120にヒットしたか否かを判断する。すなわち、アクセス要求で指定されたアドレスが一次キャッシュ120に存在するか否かを判断する。具体的には、メモリコントローラ111はアクセス要求で指定されたアドレスのブロックフレームアドレス部分と、タグ情報121内の各タグ121a,121b,・・・とを比較する。そして、値の一致するタグがある場合には、一次キャッシュ120にヒットしたと判断する。
【0049】
一次キャッシュ120にヒットした場合には、処理がステップS13に進められる。一次キャッシュ120にヒットしなかった場合(ミスヒット)には、処理がステップS15に進められる。
【0050】
[ステップS13]メモリコントローラ111は、一次キャッシュ120からデータを読み出す。具体的には、メモリコントローラ111は、一次キャッシュ内の該当するブロックからアクセス要求で指定されているアドレスのデータを読み出す。ブロック内における該当するデータの位置は、アドレス内のブロック内オフセットアドレスの部分(アドレスからブロックフレームアドレスを除いた値)によって判別できる。読み出されたデータは、CPU110に渡される。
【0051】
[ステップS14]メモリコントローラ111は、一次キャッシュ120のアクセス対象のブロックに対応するカウンタを更新(1だけカウントアップ)する。その後、処理が終了する。
【0052】
[ステップS15]一次キャッシュ120にミスヒットした場合、メモリコントローラ111は、二次キャッシュ130の該当ブロックのアクセス回数ログの値(N2)と予め設定されている閾値(T)とを比較する。そして、アクセス回数ログの値(N2)の方が閾値(T)よりも大きければ、処理がステップS17に進められる。アクセス回数ログの値(N2)が閾値(T)以下であれば、処理がステップS16に進められる。
【0053】
[ステップS16]アクセス回数ログの値(N2)が閾値(T)以下の場合、ブロックの入れ替えが行われない。そのため、メモリコントローラ111は、二次キャッシュ130からデータを読み出し、CPU110に渡す。その後、処理が終了する。
【0054】
[ステップS17]アクセス回数ログの値(N2)が閾値(T)より大きい場合、ブロックの入れ替えが行われる。そこで、メモリコントローラ111は、まず、一次キャッシュ120の各ブロックのカウンタを参照する。
【0055】
[ステップS18]メモリコントローラ111は、一次キャッシュ120の各ブロックのカウンタのうち、最も値の小さいカウンタに対応するブロックを1つ選択し、そのブロックを追い出す。ブロックの追い出しとは、そのブロックを無効化し、他のブロックを格納できるようにすることである。たとえば、該当するブロックの状態に、無効を示す値を設定する。
【0056】
[ステップS19]メモリコントローラ111は、追い出されたブロックの二次キャッシュ130におけるタグ情報131内のアクセス回数ログに、追い出されたブロックの一次キャッシュ120におけるタグ情報121内のカウンタの値を加算する。
【0057】
[ステップS20]メモリコントローラ111は、アクセス要求で指定されたアドレスのデータを二次キャッシュ130から読み出し、CPU110に渡す。[ステップS21]メモリコントローラ111は、一次キャッシュ120へアクセスの対象となったブロックの書き込みを行う。書き込み場所は、ステップS18で追い出されたブロックが格納されていた領域である。その後、処理が終了する。
【0058】
このように、一次キャッシュ120のリードミスが発生して二次キャッシュ130へのアクセスがあったとき、二次キャッシュ130上のカウンタ値が大きければ多く参照される(参照頻度が高い)ブロックであると判断され、一次キャッシュ120に入れられる。カウンタ値が小さければあまり参照されない(参照頻度が低い)ブロックであると判断され、一次キャッシュ120に入れずに直接CPU110へデータが送られる。
【0059】
なお、従来の技術では、一次キャッシュにミスヒットした場合、LRU(Least Recently Used)テーブルを参照して、最も過去に参照されたブロックが追い出されるのが一般的である。なお、LRUテーブルには、各ブロックを示すが、最近のアクセスからの経過時間に応じて並べられている。このLRUテーブルは、一次キャッシュにヒットしたときに並べ替えられる。このように、LRUテーブルを参照した追い出し対象のブロックを判定した場合、アクセス頻度の高いブロックであっても、たまたま最近のアクセスから間が空くと追い出されてしまう。
【0060】
第1の実施の形態のように、過去のアクセス回数の少ないブロックを追い出すことで、アクセス頻度の高いブロックを一次キャッシュ内に継続して保持させることができる。
【0061】
次に、任意のブロックに関し、多くアクセスされた場合とあまりアクセスされなかった場合とのタグ情報の更新例について説明する。
図6は、一次キャッシュ上で多くアクセスされた場合のタグ情報の更新例を示す図である。この例は、カウンタが3ビット(最大7までカウント)のとき、一次キャッシュ120上での参照回数が多かった場合のタグ情報の内容の変化を時系列で示している。
【0062】
(ST1)ここで、一次キャッシュ120と二次キャッシュ130とにミスヒットしてブロック転送が発生した場合を想定する。この場合、一次キャッシュ120と二次キャッシュ130とに該当ブロックが格納される。これにより、一次キャッシュ120のタグ情報121には、格納されたブロックに対応するタグ122a,状態123a,カウンタ124aが登録される。同様に、二次キャッシュ130のタグ情報131には、格納されたブロックに対応するタグ132a,状態133a,アクセス回数ログ134aが登録される。このとき、書き込まれたブロックのカウンタ124aが0にリセットされる。その後、カウンタ124aの値は、CPU110によって参照される毎にカウントアップされる。
【0063】
(ST2)該当ブロックに対して7回以上の参照等のアクセスがあると、一次キャッシュ120のタグ情報121におけるカウント値が7(上限)になる。
(ST3)該当するブロックが一次キャッシュ120から追い出されると、二次キャッシュ130上のアクセス回数ログ134aの値が7に更新される。すなわち、追い出されたブロックの一次キャッシュ120におけるカウンタ124aの値が、該当ブロックの二次キャッシュ130におけるアクセス回数ログ134aに加算される。
【0064】
その後、一次キャッシュ120でのリードミスにより二次キャッシュ130上の当該ブロックにアクセスがあったとき、アクセス回数ログ134aが参照される。アクセス回数ログ134aの値(N2)が閾値(T)より大きければ一次キャッシュ120に載せたときの再利用性があると判断され、一次キャッシュ120へのブロック転送が許可される。その結果、アクセス要求で指定されたデータがCPU110に送られると共に、そのデータを含むブロックが一次キャッシュ120に転送される。
【0065】
図7は、一次キャッシュ上でのアクセス回数が少なかった場合のタグ情報の更新例を示す図である。この例は、カウンタが3ビット(最大7までカウント)のとき、一次キャッシュ120上でのアクセス回数が少なかった場合のタグ情報の内容の変化を時系列で示している。
【0066】
(ST11)一次キャッシュ120と二次キャッシュ130とにミスヒットしてブロック転送が発生し、一次キャッシュ120と二次キャッシュ130とにブロックが格納される。一次キャッシュ120に格納されたブロックのカウンタ124aの値は0にリセットされる。二次キャッシュ130に格納されたブロックのアクセス回数ログ134aの値は0にリセットされる。
【0067】
(ST12)該当するブロックに対してアクセスが行われない場合、カウント値は0のままである。
(ST13)該当ブロックが一次キャッシュ120から追い出されると、二次キャッシュ130上のアクセス回数ログ134aの値は変更されず「0」のままである。
【0068】
その後、一次キャッシュ120でのミスヒットにより二次キャッシュ130上の当該ブロックにアクセスがあったとき、アクセス回数ログ134aが参照される。アクセス回数ログ134aの値(N2)が閾値(T)以下であれば一次キャッシュ120に載せたときの再利用性がないと判断され、一次キャッシュ120へのブロック転送を禁じ、データが直接CPU110へ送られる。
【0069】
このように、再利用性の高いブロックのみを上位のキャッシュに格納することで、処理効率やキャッシュヒット率を向上させることができる。
すなわち、再利用性のないブロックをキャッシュに入れても、その効果は得られない。逆に、ブロックの転送に時間とバス帯域を費やし、性能の低下を招いてしまう。そこで、第1の本実施の形態に示すように、一次キャッシュに格納されたときのブロックのアクセス回数をカウントし、二次キャッシュに追い出された際にもそのアクセス回数を関連付けておくことで、二次キャッシュの中から再利用性のないブロックを判別可能となる。これにより、無駄なブロック転送を抑制し、時間とバスの使用帯域を節約することができる。
【0070】
しかも、従来の技術では、再利用性のないブロックが一次キャッシュに格納され、それと入れ替わりに再利用性のあるブロックを追い出してしまう可能性がある。第1の実施の形態では再利用性のないブロックをキャッシュに入れないため、再利用性のあるブロックを一次キャッシュ内に留めておくことができる。その結果、キャッシュヒット率が向上する。
【0071】
なお、第1の実施の形態では、ブロックへのデータリード(参照)とデータライト(書き込み)とのアクセス回数をカウントしているが、データリードのアクセス要求のみをカウントしてもよい。たとえば、データの書き込み方式としてライトスルー方式を固定的に採用している場合、あるブロックへの書き込みの頻度が高くても、参照頻度が低ければ再利用性は低いと判断できる。
【0072】
[第2の実施の形態]
次に第2の実施の形態について説明する。第2の実施の形態は、複数のCPUモジュールに個別の一次キャッシュが搭載され、別に共有の二次キャッシュが設けられた計算機の例である。
【0073】
図8は、第2の実施の形態に係るコンピュータのシステム構成例を示す図である。この例では、各CPUモジュールは、それぞれCPU610,710,810,910を有している。ここで、CPU610の識別情報を「CPU0」、CPU710の識別情報を「CPU1」、CPU810の識別情報を「CPU2」、CPU910の識別情報を「CPU3」とする。
【0074】
CPU610には、CPU0用の一次キャッシュ620が接続されている。CPU610には、メモリコントローラ611が内蔵されている。メモリコントローラ611は、CPU610へのデータの取り込みやデータの書き出しを制御する。CPU0用の一次キャッシュ620は、タグ情報621を有している。タグ情報621は、一次キャッシュ620内のブロック単位の記憶領域に格納されているデータを管理するための情報である。
【0075】
CPU710には、CPU1用の一次キャッシュ720が接続されている。CPU710はメモリコントローラ711を有している。一次キャッシュ720はタグ情報721を有している。
【0076】
CPU810には、CPU2用の一次キャッシュ820が接続されている。CPU810はメモリコントローラ811を有している。一次キャッシュ820はタグ情報821を有している。
【0077】
CPU910には、CPU3用の一次キャッシュ920が接続されている。CPU910はメモリコントローラ911を有している。一次キャッシュ920はタグ情報921を有している。
【0078】
各一次キャッシュ620,720,820,920は、二次キャッシュ20に接続されている。二次キャッシュ20は、タグ情報21を有している。二次キャッシュ20は、主記憶装置30に接続されている。
【0079】
なお、一次キャッシュ620,720,820,920は、二次キャッシュ20よりも高速にアクセス可能なメモリである。また、二次キャッシュ20は、主記憶装置30よりも高速にアクセス可能なメモリである。
【0080】
ここで、各一次キャッシュ620,720,820,920のタグ情報621,721,821,921のデータ構造は、図3に示した第1の実施の形態におけるタグ情報121と同様である。一方、二次キャッシュ20のタグ情報21には、複数の一次キャッシュ620,720,820,920における参照頻度を示すカウンタの格納領域が設けられている。
【0081】
図9は、二次キャッシュのタグ情報のデータ構造例を示す図である。タグ情報21には、二次キャッシュ20内のブロック毎にタグ22a,22b,・・・が設けられている。タグ22a,22b,・・・は、対応するブロックに格納されたデータのアドレス(ブロックフレームアドレス)を示している。タグ22aには、状態23aと複数のアクセス回数ログ24a,25a,26a,27aとが関連付けられている。同様に、タグ22bには、状態23bと複数のアクセス回数ログ24b,25b,26b,27bとが関連付けられている。
【0082】
状態23a,23b,・・・は、対応するブロックに格納されているデータの状態を示す情報である。たとえば、データが有効か否か、データの書き込みの有無等が設定される。状態23a,23b,・・・の内容は、CPU610、710,810,910内のメモリコントローラ611,711,811,911によって設定される。
【0083】
アクセス回数ログは、対応するブロックに格納されているデータがアクセスされた回数を示す数値(アクセス頻度情報)が設定される。ここで、アクセス回数ログ24a,24b,・・・は、CPU610から一次キャッシュ620と二次キャッシュ20との対応ブロックに対するアクセス回数を示す値である。アクセス回数ログ25a,25b,・・・は、CPU710から一次キャッシュ720と二次キャッシュ20との対応ブロックに対するアクセス回数を示す値である。アクセス回数ログ26a,26b,・・・は、CPU810から一次キャッシュ820と二次キャッシュ20の対応ブロックに対するアクセス回数を示す値である。アクセス回数ログ27a,27b,・・・は、CPU910から一次キャッシュ920と二次キャッシュ20との対応ブロックに対するアクセス回数を示す値である。このように、各タグには、各CPUから各ブロックへのアクセス回数が関連付けられている。
【0084】
アクセス回数ログ24a,24b,・・・の値は、CPU610内のメモリコントローラ611によって更新される。具体的には、アクセス回数ログ24a,24b,・・・の値は、対応するブロックが一次キャッシュ620から追い出されたとき、そのブロックの一次キャッシュ620におけるカウンタの値が加算される。そして、CPU610から二次キャッシュ20にアクセスされたとき、アクセスされたブロックに対応するアクセス回数ログの値がカウントアップされる。
【0085】
同様に、カウンタ25a,25b,・・・の値は、CPU710内のメモリコントローラ711によって更新される。カウンタ26a,26b,・・・の値は、CPU810内のメモリコントローラ811によって更新される。カウンタ27a,27b,・・・の値は、CPU910内のメモリコントローラ911によって更新される。
【0086】
このように、カウンタの更新は、CPU610,710,810,910からのメモリアクセスに伴って、メモリコントローラ611,711,811,911によって行われる。そのときのメモリコントローラ611,711,811,911の処理は、図5に示した第1の実施の形態の処理と同様である。
【0087】
次に、任意のブロックに関し、多くアクセスされた場合とあまりアクセスされなかった場合とのタグ情報の更新例について説明する。
図10は、一次キャッシュ上で多くアクセスされた場合のタグ情報の更新例を示す図である。この例は、カウンタが3ビット(最大7までカウント)のとき、一次キャッシュ620上でのアクセス回数が多かった場合のタグ情報の内容の変化を時系列で示している。
【0088】
(ST21)ここで、一次キャッシュ620にミスヒットしてブロック転送が発生し、一次キャッシュ620にデータが格納された場合を想定する。この場合、該当するブロックは、一次キャッシュ620に格納される。これにより、一次キャッシュ620に格納されたブロックに対応するタグ622a,状態623a,カウンタ624aがタグ情報621に登録される。同様に、二次キャッシュ20に格納されたブロックに対応するタグ22a,状態23a,カウンタ24aがタグ情報21に登録される。このとき、書き込まれたブロックのカウンタが0にリセットされる。その後、カウンタ624aの値は、CPU610によって参照される毎にカウントアップされる。
【0089】
(ST22)該当ブロックに対して、7回以上の参照等のアクセスがあると、一次キャッシュ620のタグ情報621におけるカウント値が7(上限)になる。
【0090】
(ST23)該当するブロックが一次キャッシュ620から追い出されるか、キャッシュプロトコルによって無効化されると、二次キャッシュ20上のアクセス回数ログ24aの値が7に更新される。すなわち、追い出されたブロックの一次キャッシュ620におけるカウンタ624aの値が、該当ブロックの二次キャッシュ20におけるアクセス回数ログ24aに加算される。
【0091】
(ST24)同様に他のCPU710,810,910においても該当するブロックに対して7回以上の参照等のアクセスがあり、一次キャッシュ720,820,920から追い出されるかキャッシュプロトコルによって無効化されると、二次キャッシュ20上のカウンタ25a,26a,27aの値が7に更新される。
【0092】
その後、CPU0用の一次キャッシュ620でのリードミスにより二次キャッシュ20上の当該ブロックにアクセスがあったとき、CPU0用のアクセス回数ログ24aの値が参照され、データを一次キャッシュ620に入れるか、一次キャッシュ620に入れずに直接CPU610へデータを送るかが判断される。図10の例では、アクセス回数ログ24aの値が「7」であるため一次キャッシュ620に載せたときの再利用性があると判断され、一次キャッシュ620へのブロック転送が許可される。
【0093】
図11は、一次キャッシュ上でのアクセス回数が少なかった場合のタグ情報の更新例を示す図である。この例は、カウンタが3ビット(最大7までカウント)のとき、一次キャッシュ620上でのアクセス回数が少なかった場合のタグ情報の内容の変化を時系列で示している。
【0094】
(ST31)CPU610からのリード要求に対して一次キャッシュ620にミスヒットしてブロック転送が発生し、一次キャッシュ620にブロックが格納される。該当ブロックのカウンタ624aの値は0にリセットされる。
【0095】
(ST32)CPU610から該当するブロックに対して参照等のアクセスが行われない場合、カウント値は0のままである。
(ST33)該当ブロックが一次キャッシュ620から追い出されるか、またはキャッシュプロトコルによりブロックが無効化される。この場合、二次キャッシュ20上のCPU0用のアクセス回数ログ24aの値は0のままである。
【0096】
(ST34)ここで、他のCPU710,810,910からの該当ブロックへの参照等のアクセスが多数(7回以上)あったものとする。すると、該当ブロックが各CPU710,810,910の一次キャッシュ720,820,920から追い出されたとき、または無効化されたときには、二次キャッシュ20におけるそれぞれに対応するアクセス回数ログ25a,26a,27aが更新される。この例では、アクセス回数ログ25a,26a,27aの値が全て「7」になる。
【0097】
その後、CPU610からのリード要求に対して一次キャッシュ620でのミスヒットにより二次キャッシュ20上の当該ブロックにアクセスがあったとき、アクセス回数ログ24aが参照される。アクセス回数ログ24aの値(N2)が閾値(T)以下であれば一次キャッシュ620に載せたときの再利用性がないと判断され、一次キャッシュ620へのブロック転送を禁じ、データが直接CPU610へ送られる。
【0098】
以上のように、二次キャッシュ20が共有の場合であっても、二次キャッシュ20のタグ情報21にCPU毎のアクセス回数ログを関連付けておくことで、各ブロックに対するCPU毎の参照頻度が分かる。その結果、各CPUから二次キャッシュにアクセスがあったとき、そのCPUにおける該当ブロックへの参照頻度に応じて、一次キャッシュへの格納の是非を判断することができる。
【0099】
[第3の実施の形態]
次に、第3の実施の形態について説明する。第3の実施の形態は、第1の実施の形態に示す構成に基づき、二次キャッシュにおけるブロックへのアクセス頻度をカウントするようにしたものである。
【0100】
すなわち、第1の実施の形態では、二次キャッシュ130,230,330,430のブロック毎のタグには、アクセス回数ログが関連付けられている。このアクセス回数ログは、該当ブロックが一次キャッシュから追い出されたときに更新され、二次キャッシュにアクセスがあっても更新されない。そのため、アクセス回数ログの値が小さいとき、対応するブロックが二次キャッシュから一次キャッシュへ取り込まれる機会がなくなってしまう。なお、該当ブロックが二次キャッシュからも追い出されれば、その後、該当するブロックへのアクセスは主記憶装置に対して行われ、一次キャッシュと二次キャッシュと取り込むことができる。
【0101】
そこで、第3の実施の形態では、二次キャッシュ上の各ブロックでのアクセス回数をカウントし、一次キャッシュでのアクセス回数(第1の実施の形態におけるアクセス回数ログの値)に合算する。
【0102】
第3の実施の形態におけるシステム構成は、図2に示す第1の実施の形態の構成とほぼ同じである。ただし、二次キャッシュにおけるタグ情報のデータ構造およびメモリコントローラの処理が異なる。以下、図2に示す第1の実施の形態の各要素(二次キャッシュのタグ情報を除く)の符号を用いて、CPU0用の二次キャッシュ130におけるタグ情報のデータ構造を説明する。
【0103】
図12は、第3の実施の形態における二次キャッシュのタグ情報の例を示す図である。図12には、CPU0用の二次キャッシュ130のタグ情報131aを代表的に示している。
【0104】
タグ情報131aには、二次キャッシュ130内のブロック毎にタグ132c,132d,・・・が設けられている。タグ132c,132d,・・・は、対応するブロックに格納されたデータのアドレス(ブロックフレームアドレス)を示している。タグ132c,132d,・・・には、状態133c,133d,・・・とカウンタ134c,134d,・・・とが関連付けられている。
【0105】
状態133c,133d,・・・は、対応するブロックに格納されているデータの状態を示す情報である。たとえば、データが有効か否か、データの書き込みの有無等が設定される。状態133c,133d,・・・の内容は、CPU110内のメモリコントローラ111によって設定される。
【0106】
カウンタ134c,134d,・・・は、二次キャッシュ130内の対応するブロックに格納されているデータがアクセス(参照や書き込み)された回数を示す数値(アクセス回数情報)が設定される。また、カウンタ134c,134d,・・・は、対応するブロックが一次キャッシュから追い出されたとき、そのブロックが一次キャッシュ上でアクセスされた回数を示す数値(参照回数)が加算される。このカウンタ134c,134d,・・・の値の更新は、CPU110内のメモリコントローラ111によって行われる。
【0107】
このように、第1の実施の形態において二次キャッシュ130の各ブロックに関連付けられたアクセス回数ログが、第3の実施の形態ではカウンタ134c,134dに置き換えられている。このカウンタ134c,134dの有する機能は、アクセス回数ログの機能と同様に情報の記憶機能であるが、二次キャッシュへのアクセスに応じてカウントアップされるため、カウンタと称している。
【0108】
図13は、第3の実施の形態かかるメモリコントローラのアクセス処理の手順を示すフローチャートである。このフローチャートは、図5に示す第1の実施の形態のアクセス処理とほぼ同じであるため、同じ処理には同じステップ番号を付し、説明を省略する。
【0109】
第3の実施の形態では、図5のステップS15の処理が以下の様に変更される。
[ステップS31]一次キャッシュ120にミスヒットした場合、メモリコントローラ111は、二次キャッシュ130の該当ブロックのカウンタの値(N2)と予め設定されている閾値(T)とを比較する。そして、アクセス回数ログの値(N2)の方が閾値(T)よりも大きければ、処理がステップS17に進められる。アクセス回数ログの値(N2)の方が閾値(T)以下であれば、処理がステップS16に進められる。
【0110】
また、第3の実施の形態では、二次キャッシュ130からデータを読み出した後の処理が第1の実施の形態と異なる。すなわち、第1の実施の形態では、二次キャッシュ130からデータを読み出すと処理が終了する(ステップS16)が、第3の実施の形態では、ステップS16の処置の次に以下のようなステップS31の処理が実行される。
【0111】
[ステップS32]メモリコントローラ111は、二次キャッシュのカウンタを更新する。すなわち、読み出した対象のデータが格納されているブロックに対応するカウンタの値を、1だけ増加させる。その後、処理が終了する。
【0112】
さらに、第3の実施の形態では、図5のステップS19の処理が以下の様に変更される。
[ステップS32]メモリコントローラ111は、一次キャッシュ120から追い出されたブロックのカウンタの値を、二次キャッシュ130の対応するブロックのカウンタに加算する。
【0113】
このように、第3の実施の形態では、全ての一次キャッシュと二次キャッシュのタグにはアクセス回数を記録するカウンタが含まれ、このカウント値は各キャッシュにて当該ブロックが参照される度に1ずつ増やされる。その後、一次キャッシュのリードミスが発生して二次キャッシュアクセスがあったとき、二次キャッシュ上の当該CPU用カウンタ値を見て、データを一次キャッシュに入れるか、一次キャッシュに入れずに直接CPUへデータを送るかが判断される。
【0114】
これにより、第1の実施の形態では、二次キャッシュ上で再利用性がないと判定されたブロックは二次キャッシュを出ない限りその判定を覆すことはできず、一次キャッシュに入ることができない。一方、第3の実施の形態では、一次キャッシュと同様に、二次キャッシュにアクセスがあった場合には二次キャッシュ上のカウンタを増やす。そのため、一旦再利用性がないと判定されたブロックでも、二次キャッシュ上で多くアクセスされれば、リードミス時に一次キャッシュへの転送が許されるようになる。
【0115】
[第4の実施の形態]
次に、第4実施の形態について説明する。第4の実施の形態は、第2の実施の形態に示す構成に基づき、二次キャッシュにおけるブロックへのアクセス頻度をカウントするようにしたものである。
【0116】
すなわち、第2の実施の形態では、二次キャッシュ20のブロック毎のタグには、アクセス回数ログが関連付けられている。このアクセス回数ログは、該当ブロックが一次キャッシュから追い出されたときに更新され、二次キャッシュにアクセスがあっても更新されない。そのため、アクセス回数ログの値が小さいとき、対応するブロックが二次キャッシュから一次キャッシュへ取り込まれる機会がなくなってしまう。なお、該当ブロックが二次キャッシュからも追い出されれば、その後、該当するブロックへのアクセスは主記憶装置に対して行われ、一次キャッシュと二次キャッシュと取り込むことができる。
【0117】
そこで、第4の実施の形態では、二次キャッシュ上の各ブロックでのアクセス回数を、一次キャッシュでのアクセス回数(第1の実施の形態におけるアクセス回数ログの値)に加算してカウントする。
【0118】
第4の実施の形態におけるシステム構成は、図8に示す第2の実施の形態の構成とほぼ同じである。ただし、二次キャッシュにおけるタグ情報のデータ構造およびメモリコントローラの処理が異なる。また、第4の実施の形態におけるタグ情報のデータ構造は以下の通りである。
【0119】
図14は、第4の実施の形態における二次キャッシュのタグ情報の例を示す図である。
タグ情報21aには、二次キャッシュ20内のブロック毎にタグ22c,22d,・・・が設けられている。タグ22c,22d,・・・は、対応するブロックに格納されたデータのアドレス(ブロックフレームアドレス)を示している。タグ22c,22d,・・・には、状態23c,23d,・・・とカウンタ24c,24d,・・・とが関連付けられている。
【0120】
状態23c,23d,・・・は、対応するブロックに格納されているデータの状態を示す情報である。たとえば、データが有効か否か、データの書き込みの有無等が設定される。状態23c,23d,・・・の内容は、CPU610内のメモリコントローラ611によって設定される。
【0121】
カウンタ24c,24d,・・・は、二次キャッシュ20内の対応するブロックに格納されているデータがアクセス(参照や書き込み)された回数を示す数値(アクセス頻度情報)が設定される。カウンタ24c,24d,・・・の値は、CPU610内のメモリコントローラ611によって更新される。具体的には、カウンタ24c,24d,・・・の値は、対応するブロック内のデータが参照される度に1ずつ増やされる。
【0122】
第4の実施の形態におけるメモリコントローラの処理は、図13に示す第3の実施の形態のアクセス処理と同じである。
このように、一次キャッシュ、二次キャッシュの各ブロックにそれぞれ図3、図14のようなタグを持たせる。全ての一次キャッシュと二次キャッシュのタグにはアクセス回数を記録するカウンタが含まれ、このカウント値は各キャッシュにて当該ブロックが参照される度に1ずつ増やされる。当該ブロックが一次キャッシュを追い出されるか、キャッシュプロトコルによって無効化されたときに、二次キャッシュの当該CPU用のカウンタにこの値が加算される。
【0123】
その後一次キャッシュのリードミスが発生して二次キャッシュアクセスがあったとき、二次キャッシュ上の当該CPU用カウンタ値を見て、データを一次キャッシュに入れるか、一次キャッシュに入れずに直接CPUへデータを送るかを判断する。
【0124】
第2の実施の形態では、二次キャッシュ上で再利用性がないと判定されたブロックは二次キャッシュを出ない限りその判定を覆すことはできず、一次キャッシュに入ることができない。一方、第4の実施の形態では、一次キャッシュと同様に、二次キャッシュにアクセスがあった場合には二次キャッシュ上のカウンタを増やす(例えばCPU0から要求で二次キャッシュにアクセスが来たときには、CPU0に対応するカウンタの値を増やす)ことで、一旦再利用性がないと判定されたブロックでも、二次キャッシュ上で多くアクセスされればリードミス時に一次キャッシュへの転送が許されるようになる。
【0125】
[第5の実施の形態]
次に、第5の実施の形態について説明する。第5の実施の形態は、第1の実施の形態に基づき、一次キャッシュにライトミスしたときの処理方式を一次キャッシュにおけるブロックのアクセス回数に応じて判断するようにしたものである。
【0126】
ライトミスしたときの処理方式には、たとえば、ライトアロケートとノーライトアロケートとがある。ここで、ライトアロケートとは、一次キャッシュでライトミスしたときに、二次キャッシュからブロックを一次キャッシュにロードする処理方式である。また、ノーライトアロケートとは、一次キャッシュでライトミスしたときに、二次キャッシュからデータを読み取り、該当ブロックの一次キャッシュへのロードを行わない処理方式である。
【0127】
第5の実施の形態におけるシステム構成は、図2に示す第1の実施の形態の構成とほぼ同じである。ただし、メモリコントローラのデータライト時の処理が異なる。なお、メモリコントローラのデータリード(参照)時の処理は、図5に示した第1の実施の形態と同じである。そこで、図2に示す構成を参照してメモリコントローラの処理におけるデータライト時の処理を説明する。
【0128】
図15は、第5の実施の形態に係るライト処理の手順を示すフローチャートである。以下、図15に示す処理をステップ番号に沿って説明する。
[ステップS41]メモリコントローラ111は、CPU110からのデータライトのアクセス要求を受け付ける。
【0129】
[ステップS42]メモリコントローラ111は、一次キャッシュ120にヒットしたか否かを判断する。すなわち、アクセス要求で指定されたアドレスが一次キャッシュ120に存在するか否かを判断する。一次キャッシュ120にヒットした場合には、処理がステップS43に進められる。一次キャッシュ120にヒットしなかった場合(ミスヒット)には、処理がステップS45に進められる。
【0130】
[ステップS43]メモリコントローラ111は、一次キャッシュ120からにデータを書き込む。具体的には、メモリコントローラ111は、一次キャッシュ内の該当するブロックからアクセス要求で指定されているアドレスのデータの領域へ、CPU110から送られたデータを書き込む。
【0131】
[ステップS44]メモリコントローラ111は、一次キャッシュ120のデータの書き込みが行われたブロックに対応するカウンタを更新する。すなわち、カウンタの値を1だけ増加させる。その後、処理が終了する。
【0132】
[ステップS45]一次キャッシュ120にミスヒットした場合、メモリコントローラ111は、二次キャッシュ130の該当ブロックのアクセス回数ログの値(N2)と予め設定されている閾値(T)とを比較する。そして、アクセス回数ログの値(N2)の方が閾値(T)よりも大きければ、処理がステップS47に進められる。アクセス回数ログの値(N2)が閾値(T)以下であれば、処理がステップS46に進められる。
【0133】
[ステップS46]アクセス回数ログの値(N2)が閾値(T)以下の場合、ノーライトアロケート処理が行われる。そのため、メモリコントローラ111は、二次キャッシュ130内のライト要求で指示されたアドレスに該当するデータの記憶領域へ、CPU110から送られたデータを書き込む。その後、処理が終了する。
【0134】
[ステップS47]アクセス回数ログの値(N2)が閾値(T)より大きい場合、ブロックの入れ替えが行われる。そこで、メモリコントローラ111は、まず、一次キャッシュ120の各ブロックのカウンタを参照する。
【0135】
[ステップS48]メモリコントローラ111は、一次キャッシュ120の各ブロックのカウンタのうち、最も参照頻度の小さいカウンタの1つに対応するブロックを追い出す。
【0136】
[ステップS49]メモリコントローラ111は、追い出されたブロックの二次キャッシュ130にけるタグ情報131内のアクセス回数ログに、追い出されたブロックの一次キャッシュ120におけるタグ情報121内のカウンタの値を加算する。
【0137】
[ステップS50]メモリコントローラ111は、二次キャッシュ130の該当ブロックを、一次キャッシュ120の追い出されたブロックが格納されていた領域へ書き込む。
【0138】
[ステップS51]メモリコントローラ111は、一次キャッシュ120内のライト要求で指定されたアドレスのデータの領域へ、CPU110から送られたデータを書き込む。その後、処理が終了する。
【0139】
このように、第5の実施の形態では、一次キャッシュのタグにはアクセス回数を記録するカウンタを関連付け、このカウント値は当該ブロックが参照される度に1ずつ増やされる。当該ブロックが一次キャッシュを追い出されると、二次キャッシュのカウンタにこの値が加算される。その後一次キャッシュ120のライトミスが発生して二次キャッシュ130にアクセスがあったとき、二次キャッシュ130上のアクセス回数ログの値を見て、ライトアロケートにするか、ノーライトアロケートにするかが判断される。
【0140】
このようにして、再利用性の高いブロックのみをライトアロケートにすることができる。その結果、一次キャッシュ内に再利用性の高いブロックを優先格納することができ、データアクセスの効率を向上させることができる。
【0141】
[第6の実施の形態]
次に、第6の実施の形態について説明する。第6の実施の形態は、第2の実施の形態に基づき、一次キャッシュにライトミスしたときの処理方式を一次キャッシュにおけるブロックのアクセス回数に応じて判断するようにしたものである。ライトミスしたときの処理方式には、たとえば、ライトアロケートとノーライトアロケートとがある。
【0142】
第6の実施の形態におけるシステム構成は、図8に示す第2の実施の形態の構成とほぼ同じである。ただし、メモリコントローラのデータライト時の処理が異なる。なお、メモリコントローラのデータリード(参照)時の処理は、図5に示した第1の実施の形態と同じである。また、メモリコントローラのデータライト時の処理は、図15に示した第5の実施の形態と同じである。
【0143】
これにより、全ての一次キャッシュのタグにはアクセス回数を記録するカウンタが含まれ、このカウント値は当該ブロックが参照される度に1ずつ増やされる。当該ブロックが一次キャッシュを追い出されるか、キャッシュプロトコルによって無効化されたときに、二次キャッシュの当該CPU用のカウンタにこの値が加算される。その後一次キャッシュのライトミスが発生して二次キャッシュアクセスがあったとき、二次キャッシュ上の当該CPU用カウンタ値を見て、ライトアロケートにするか、ノーライトアロケートにするかが判断される。
【0144】
[第7の実施の形態]
次に、第7の実施の形態について説明する。第7の実施の形態は、第3の実施の形態に基づき、一次キャッシュにライトミスしたときの処理方式を、一次キャッシュと二次キャッシュとにおけるブロックのアクセス回数に応じて判断するようにしたものである。ライトミスしたときの処理方式には、たとえば、ライトアロケートとノーライトアロケートとがある。
【0145】
第7の実施の形態におけるシステム構成は、図2に示す第1の実施の形態の構成とほぼ同じである。ただし、二次キャッシュのタグ情報のデータ構造は、図12に示す第3の実施の形態のタグ情報と同様である。また、メモリコントローラのデータリード(参照)時の処理は、図13に示した第3の実施の形態と同じである。また、メモリコントローラのデータライト時の処理は、図15に示した第5の実施の形態と同じである。
【0146】
これにより、全ての一次キャッシュと二次キャッシュのタグにはアクセス回数を記録するカウンタが含まれ、このカウント値は各キャッシュにて当該ブロックが参照される度に1ずつ増やされる。その後一次キャッシュのライトミスが発生して二次キャッシュアクセスがあったとき、二次キャッシュ上のカウンタ値を見て、ライトアロケートにするか、ノーライトアロケートにするかを判断する。
【0147】
第5の実施の形態では、二次キャッシュ上で再利用性がないと判定されたブロックは二次キャッシュを出ない限りその判定を覆すことはできず、一次キャッシュに入ることができない。そこで、第7の実施の形態では、一次キャッシュと同様に、二次キャッシュにアクセスがあった場合には二次キャッシュ上のカウンタを増やすようにした。これにより一旦再利用性がないと判定されたブロックでも、二次キャッシュ上で多くアクセスされれば、ライトミス時に一次キャッシュへの転送後に書き込みを行わせる(ライトアロケート方式)ことができる。
【0148】
[第8の実施の形態]
次に、第8の実施の形態について説明する。第8の実施の形態は、第4の実施の形態に基づき、一次キャッシュにライトミスしたときの処理方式を、一次キャッシュと二次キャッシュとにおけるブロックのアクセス回数に応じて判断するようにしたものである。ライトミスしたときの処理方式には、たとえば、ライトアロケートとノーライトアロケートとがある。
【0149】
第8の実施の形態におけるシステム構成は、図8に示す第2の実施の形態の構成とほぼ同じである。ただし、二次キャッシュのタグ情報のデータ構造は、図14に示す第4の実施の形態のタグ情報と同様である。また、メモリコントローラのデータリード(参照)時の処理は、図15に示した第4の実施の形態と同じである。また、メモリコントローラのデータライト時の処理は、図15に示した第5の実施の形態と同じである。
【0150】
これにより、全ての一次キャッシュと二次キャッシュのタグにはアクセス回数を記録するカウンタが含まれ、このカウント値は各キャッシュにて当該ブロックが参照等される度に1ずつ増やされる。当該ブロックが一次キャッシュを追い出されるか、キャッシュプロトコルによって無効化されたときに、二次キャッシュの当該CPU用のカウンタにこの値が加算される。その後一次キャッシュのライトミスが発生して二次キャッシュアクセスがあったとき、二次キャッシュ上の当該CPU用カウンタ値を見て、ライトアロケートにするか、ノーライトアロケートにするかを判断する。
【0151】
第6の実施の形態では、二次キャッシュ上で再利用性がないと判定されたブロックは二次キャッシュを出ない限りその判定を覆すことはできず、一次キャッシュに入ることができない。そこで、第8の実施の形態では、一次キャッシュと同様に、二次キャッシュにアクセスがあった場合には二次キャッシュ上のカウンタを増やす(たとえば、CPU610からの要求で二次キャッシュにアクセスが来たときには、CPU610に対応するカウンタの値を増やす)ことで、一旦再利用性がないと判定されたブロックでも、二次キャッシュ上で多くアクセスされればライトミス時に一次キャッシュへの転送後に書き込みを行わせる(ライトアロケート方式)ことができる。
【0152】
[第9の実施の形態]
次に、第9の実施の形態について説明する。第9の実施の形態は、第1の実施の形態に基づき、ライト要求に応じたデータの書き込み方式を一次キャッシュにおけるブロックのアクセス回数に応じて動的に切り替えるものである。
【0153】
データの書き込み方式には、たとえば、ライトバックとライトスルーとがある。ここで、ライトバックでは、ライト要求に応答して、データの書き込みを一次キャッシュのブロックに対して行う。そして、そのブロックが一次キャッシュから追い出されるとき、そのブロックのデータを二次キャッシュに書き込む。ライトスルーでは、ライト要求に応答して、一次キャッシュと二次キャッシュとの双方にデータを書き込む。
【0154】
第9の実施の形態におけるシステム構成は、図2に示す第1の実施の形態の構成とほぼ同じである。ただし、メモリコントローラのデータライト時の処理が異なる。なお、メモリコントローラのデータリード(参照)時の処理は、図5に示した第1の実施の形態とほぼ同じである。ただし、ステップS14における一次キャッシュのカウンタの更新処理は行わないものとする。すなわち、図3に示したカウンタ124a,124bは、書き込み回数のみをカウントするカウンタとして使用される。同様に、図4に示したアクセス回数ログ134a,134bには、書き込みの回数を示す値が格納される。
【0155】
そこで、図2に示す構成を参照してメモリコントローラの処理におけるデータライト時の処理を説明する。
図16は、第9の実施の形態に係るライト処理の手順を示すフローチャートである。以下、図16に示す処理をステップ番号に沿って説明する。
【0156】
[ステップS61]メモリコントローラ111は、CPU110からのデータライトのアクセス要求を受け付ける。
[ステップS62]メモリコントローラ111は、一次キャッシュ120にヒットしたか否かを判断する。すなわち、アクセス要求で指定されたアドレスが一次キャッシュ120に存在するか否かを判断する。一次キャッシュ120にヒットしなかった場合(ミスヒット)には、処理がステップS63に進められる。一次キャッシュ120にヒットした場合には、処理がステップS64に進められる。
【0157】
[ステップS63]一次キャッシュ120にミスヒットした場合、メモリコントローラ111は、二次キャッシュ130内のライト要求で指示されたアドレスに該当するデータの記憶領域へ、CPU110から送られたデータを書き込む。その後、処理が終了する。
【0158】
[ステップS64]一次キャッシュ120にヒットした場合、メモリコントローラ111は、一次キャッシュ120にデータを書き込む。具体的には、メモリコントローラ111は、一次キャッシュ内の該当するブロックからアクセス要求で指定されているアドレスのデータの領域へ、CPU110から送られたデータを書き込む。
【0159】
[ステップS65]メモリコントローラ111は、一次キャッシュ120のデータの書き込みが行われたブロックに対応するカウンタを更新する。すなわち、カウンタの値を1だけ増加させる。その後、処理が終了する。
【0160】
[ステップS66]メモリコントローラ111は、一次キャッシュ120の該当ブロックのカウンタの値(N1)と予め設定されている閾値(T1)とを比較する。そして、カウンタの値(N1)の方が閾値(T1)よりも大きければライトバック方式が採用され、処理が終了する。カウンタの値(N1)が閾値(T1)以下であればライトスルー方式が採用され、処理がステップS67に進められる。
【0161】
[ステップS67]メモリコントローラ111は、二次キャッシュ130内のライト要求で指示されたアドレスに該当するデータの記憶領域へ、CPU110から送られたデータを書き込む。その後、処理が終了する。
【0162】
このように、一次キャッシュのタグには書き込み頻度情報を記録するカウンタが含まれ、このカウント値は当該ブロックに対する書き込みを行われる度に1ずつ増やされる。当該ブロックが一次キャッシュを追い出されると、二次キャッシュのカウンタにこの値が加算される。その後、ライト要求が出され一次キャッシュにヒットした場合、カウンタの値が所定の閾値(N)より大きければ、書き込みの多いブロックであると判断できるのでライトバック方式での書き込みが行われる。そうでなければライトスルー方式での書き込みが行われる。
【0163】
このように、ライトバック方式とライトスルー方式とを、カウンタの値(N1)に応じて動的に変更することができる。アクセスが多いブロックは、ライトバック方式を採用することで、二次キャッシュへの書き込み回数を減らすことができる。その結果、平均アクセス時間が短縮される。また、アクセスが少ないブロックは、ライトスルー方式を採用することで、一次キャッシュと二次キャッシュとの一貫性を維持することができる。
【0164】
なお、第9の実施の形態では、データ書き込みの回数をカウントするためにカウンタを用いるものとして説明したが、一次キャッシュ120のタグ情報121に、書き込み用のカウンタと参照用のカウンタとを設けることもできる。その場合、二次キャッシュ130のタグ情報131には、書き込み用のアクセス回数ログと参照用のアクセス回数ログとを設ける。これにより、1つのシステム内で、書き込み回数に応じた書き込み方式の判断と、アクセス回数に応じた一次キャッシュへの書き込み要否判断とを行うことができる。
【0165】
なお、第9の実施の形態の説明では、メモリコントローラのデータリード(参照)時の処理は、図5に示した第1の実施の形態とほぼ同じであるとしている。したがって、一次キャッシュからブロックが追い出されると、そのブロックのカウンタ値が二次キャッシュの対応するブロックのアクセス回数ログに加算される。そこで、ブロックを一次キャッシュに読み込む際に、アクセス回数ログの値に応じて書き込み方式を決定することもできる。この場合、アクセス回数ログの値が所定の閾値より大きければ、一次キャッシュに読み込んだ該当ブロックへのデータライトに関して、ライトバック方式を採用する。一方、アクセス回数ログの値が所定の閾値以下であれば、一次キャッシュに読み込んだ該当ブロックへのデータライトに関して、ライトスルー方式を採用する。
【0166】
また、一次キャッシュに新たなブロックを取り込んだとき、そのブロックに対する書き込み方式の初期設定として、ライトスルー方式を採用することとしてもよい。参照頻度の多いブロックであれば、カウンタ数が閾値を超えることでライトバック方式に切り替えられる。
【0167】
[第10の実施の形態]
次に、第10の実施の形態について説明する。第10の実施形態は、二次キャッシュから一次キャッシュにブロックを取り込むか否かの判定を、追い出されるブロックのカウンタ値を用いて行うものである。具体的には、一次キャッシュ上で最もカウンタ値の小さなブロックのカウンタ値と、二次キャッシュ上の取り込み対象ブロックのアクセス回数ログの値とを比較する。そして、二次キャッシュ上の取り込み対象ブロックのアクセス回数ログの値の方が大きければ、そのブロックを一次キャッシュに取り込む。
【0168】
図17は、第10の実施の形態に係るアクセス処理の手順を示すフローチャートである。なお、図17に示す処理のうちステップS71,S72以外の処理は図5に示した第1の実施の形態におけるアクセス処理を同じであるため同じステップ番号を付し説明を省略する。
【0169】
[ステップS71]メモリコントローラ111は、一次キャッシュ120の各ブロックのカウンタを参照する。
[ステップS72]そして、メモリコントローラ111は、一次キャッシュ120の各ブロックのうち、カウンタ値が最も小さなブロックを追い出し対象ブロックとする。そして、そのブロックのカウンタ値(N1)と、二次キャッシュ130内のアクセス対象のブロックのアクセス回数ログの値(N2)との大小を比較する。追い出し対象ブロックのカウンタ値(N1)の方が大きければブロックの入れ替えが不要と判断され、処理がステップS16に進められる。追い出し対象ブロックのカウンタ値(N1)が、アクセス対象のブロックのアクセス回数ログの値(N2)以下であれば、ブロックの入れ替えが必要と判断され、処理がステップS18に進められる。
【0170】
このように、一次キャッシュの最小のカウンタ値よりも大きなアクセス回数ログを有するブロックのみを一次キャッシュに格納することで、アクセス頻度の高いブロックのみを一次キャッシュに取り込むことができる。
【0171】
なお、上記の各実施の形態では、キャッシュメモリ制御における記憶対象の最小単位であるブロック毎にカウンタを設けているが、このブロックの大きさは任意に設定することができる。従って、ブロックのサイズを、CPUに対するデータ入出力のデータ長と同じにすることもできる。一般に、ブロックサイズはメモリアクセス処理における平均アクセス時間が最短になるような値に設定される。
【0172】
従来の技術のように、再利用性のないブロックをキャッシュに入れても、ヒット率上昇の効果は得られず、逆に、ブロックの転送に時間とバス帯域を費し、性能の低下を招いてしまう。一方、本実施の形態では再利用性のないブロックを察知することで無駄なブロック転送を抑制し、時間とバスの使用帯域を節約することができる。
【0173】
また、再利用性のないブロックをキャッシュに入れると、それと入れ替わりに、再利用性のあるブロックを追い出してしまう可能性がある。上記実施の形態では再利用性のないブロックをキャッシュに入れないため、そのようなことは生じない。
【0174】
また、キャッシュへの書き込み方式には大きく分けてライトスルー方式とライトバック方式がある。従来はこの二つは切り替えることができないが、上記実施の形態ではこの二つを切り替えることで、書き込みの多いブロックや、書き込みの少ないブロックや、時間によって両方の性質を示すブロックも柔軟に扱うことができる。
【0175】
(付記1) CPUからのアクセス要求に応じたキャッシュ処理を制御するキャッシュ管理装置において、
前記CPUに接続された上位レベルメモリと、
前記上位レベルメモリに格納された各データのアクセス回数を計数するカウンタと、
前記CPUと前記上位レベルメモリとに接続され、前記上位レベルメモリに格納された各データに対応するデータを格納する下位レベルメモリと、
前記下位レベルメモリに格納された各データに対応づけて設けられたアクセス回数ログと、
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップし、前記上位レベルメモリ内の置き換え対象データを無効化したとき、前記置き換え対象データに対応する前記カウンタの値を、前記下位レベルメモリ内の前記置き換え対象データに対応する前記アクセス回数ログに設定し、前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納するメモリコントローラと、
を有することを特徴とするキャッシュ管理装置。
【0176】
(付記2) 前記カウンタは、前記上位レベルメモリの記憶管理の最小単位であるブロック毎にアクセス回数をカウントすることを特徴とする付記1記載のキャッシュメモリ装置。
【0177】
(付記3) 前記CPUが複数ある場合、前記CPUそれぞれに対応する前記上位レベルメモリ、前記カウンタ、前記下位レベルメモリ、前記アクセス回数ログ、および前記メモリコントローラを有することを特徴とする付記1記載のキャッシュメモリ装置。
【0178】
(付記4) 前記CPUが複数ある場合、前記CPUそれぞれに対応する前記上位レベルメモリ、前記カウンタ、前記アクセス回数ログ、および前記メモリコントローラを有し、複数の前記CPUにより前記下位レベルメモリを共有することを特徴とする付記1記載のキャッシュメモリ装置。
【0179】
(付記5) 前記メモリコントローラは、前記下位レベルメモリに格納された各データのアクセス回数を計数し、前記アクセス回数ログに合算することを特徴とする付記1記載のキャッシュ管理装置。
【0180】
(付記6) 前記メモリコントローラは、前記アクセス要求がライト要求である場合、前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納することを特徴とする付記1記載のキャッシュ管理装置。
【0181】
(付記7) 前記メモリコントローラは、前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が、前記上位レベルメモリ内で置き換えられるデータに対応するカウンタの値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納することを特徴とする付記1記載のキャッシュ管理装置。
【0182】
(付記8) CPUからのアクセス要求に応じたキャッシュ処理を制御するキャッシュ管理装置において、
前記CPUに接続された上位レベルメモリと、
前記上位レベルメモリに格納された各データのアクセス回数を計数するカウンタと、
前記CPUと前記上位レベルメモリとに接続され、前記上位レベルメモリに格納された各データに対応するデータを格納する下位レベルメモリと、
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップするとともに、前記アクセス要求がデータライト要求である場合、前記上位レベルメモリへデータの書き込みを行い、前記アクセス要求がデータライト要求であり、且つ前記アクセス対象データの前記カウンタの値が前記所定値以下である場合、前記下位レベルメモリへもデータの書き込みを行うメモリコントローラと、
を有することを特徴とするキャッシュ管理装置。
【0183】
(付記9) 上位レベルメモリと、前記上位レベルメモリに格納されたデータに対応するデータを格納する下位レベルメモリとへのCPUからのアクセス要求に応じたキャッシュ処理を制御するためのキャッシュメモリ管理方法において、前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応するカウンタの値をカウントアップし、
前記上位レベルメモリ内の置き換え対象データを無効化したとき、前記置き換え対象データに対応する前記カウンタの値を、前記下位レベルメモリ内の前記置き換え対象データに対応するアクセス回数ログに設定し、
前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納する、
ことを特徴とするキャッシュメモリ管理方法。
【0184】
(付記10) 上位レベルメモリと、前記上位レベルメモリに格納されたデータに対応するデータを格納する下位レベルメモリとへのCPUからのアクセス要求に応じたキャッシュ処理を制御するためのキャッシュメモリ管理方法において、
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップし、
前記アクセス要求がデータライト要求である場合、前記上位レベルメモリへデータの書き込みを行い、
前記アクセス要求がデータライト要求であり、且つ前記アクセス対象データの前記カウンタの値が前記所定値以下である場合、前記下位レベルメモリへもデータの書き込みを行う、
ことを特徴とするキャッシュメモリ管理方法。
【0185】
【発明の効果】
以上説明したように本発明では、上位レベルメモリでのアクセス回数をカウントし、データが上位レベルメモリを追い出された後は、アクセス回数が所定値より多い場合にのみ下位レベルメモリから上位レベルメモリへのキャッシングを行うようにしたため、再利用性の高いデータに限定したキャッシングが可能となる。
【0186】
また、別の発明では、上位レベルメモリでのアクセス回数をカウントし、データライト要求が出された際、アクセス回数が所定値以下の場合にのみ下位レベルメモリへの書き込みを行うようにしたため、再利用性の高いデータに関してはライトバック方式による高速のアクセスが可能となる。
【図面の簡単な説明】
【図1】実施の形態に適用される発明の概念図である。
【図2】第1の実施の形態のシステム構成例を示す図である。
【図3】一次キャッシュのタグ情報のデータ構造例を示す図である。
【図4】二次キャッシュのタグ情報のデータ構造例を示す図である。
【図5】第1の実施の形態に係るアクセス処理の手順を示すフローチャートである。
【図6】一次キャッシュ上で多くアクセスされた場合のタグ情報の更新例を示す図である。
【図7】一次キャッシュ上でのアクセス回数が少なかった場合のタグ情報の更新例を示す図である。
【図8】第2の実施の形態に係るコンピュータのシステム構成例を示す図である。
【図9】二次キャッシュのタグ情報のデータ構造例を示す図である。
【図10】一次キャッシュ上で多くアクセスされた場合のタグ情報の更新例を示す図である。
【図11】一次キャッシュ上でのアクセス回数が少なかった場合のタグ情報の更新例を示す図である。
【図12】第3の実施の形態における二次キャッシュのタグ情報の例を示す図である。
【図13】第3の実施の形態かかるメモリコントローラのアクセス処理の手順を示すフローチャートである。
【図14】第4の実施の形態における二次キャッシュのタグ情報の例を示す図である。
【図15】第5の実施の形態に係るライト処理の手順を示すフローチャートである。
【図16】第9の実施の形態に係るライト処理の手順を示すフローチャートである。
【図17】第10の実施の形態に係るアクセス処理の手順を示すフローチャートである。
【符号の説明】
1 CPU
1a メモリコントローラ
2 上位レベルメモリ
2a タグ情報
2b タグ
2c カウンタ
3 下位レベルメモリ
3a タグ情報
3b タグ
3c アクセス回数ログ
10 主記憶装置
110,210,310,410 CPU
111,211,311,411 メモリコントローラ
120,220,320,420 一次キャッシュ
121,221,321,421 タグ情報
130,230,330,430 二次キャッシュ
131,231,331,431 タグ情報[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a cache management device and a cache memory management method, and more particularly to a cache management device and a cache memory management method capable of storing frequently used data in an upper level memory.
[0002]
[Prior art]
Generally, a cache memory is used for speeding up a computer system. The cache memory is arranged between the CPU and the main storage device. As the cache memory, a memory faster than the memory used for the main storage device is used. Therefore, the CPU can access the data stored in the cache memory at high speed. The cache memory is managed by being divided into areas in units of blocks, and processes such as data writing and writing are performed in units of blocks.
[0003]
By the way, data caching is performed not only when reading data (read cache) but also when writing data (write cache).
There are a write-through method and a write-back method for writing data to the main storage device. In the write-through method, when the CPU writes data, the data is written to the main memory at the same time as the data is written to the cache memory. On the other hand, in the write-back method, when the CPU writes data, the writing is performed to the cache memory. Then, the data written in the cache memory is written to the main storage device at an arbitrary timing. It is also possible to select a write-through method and a write-back method as appropriate, and to write data according to the selected method (for example, see
[0004]
[Patent Document 1]
U.S. Pat. No. 5,469,555
[Patent Document 2]
U.S. Pat. No. 5,522,057
[0005]
[Problems to be solved by the invention]
However, in the related art, when a cache miss occurs, all blocks including data to be accessed are cached indiscriminately. Therefore, even if the cache is cached, a block that is evicted without being referred to is also stored in the cache memory. Putting such non-reusable blocks into the cache memory has the following disadvantages.
[0006]
-By storing data that is hardly referred to in the cache memory, data that is more frequently referred to than that data is evicted, and the chance of gaining the benefit of improved access speed is reduced.
[0007]
-The time and the bandwidth used by the bus are used for transferring blocks that do not contribute to a reduction in the average access time, thereby lowering the processing efficiency of the system.
Note that it is possible for a programmer to intentionally specify not to cache data that is known not to be reusable at the stage of building a program. However, the reusability of a cache block depends on the cache capacity, data size, and the like, and in many cases, it cannot be ascertained except during execution.
[0008]
As described above, writing data that is rarely used to the cache memory adversely affects the performance of the computer system. Therefore, there is a demand for a system that can write data (or a block including the data) to a cache memory only when accessing data that has been frequently used in the past.
[0009]
In the techniques described in
[0010]
The present invention has been made in view of such a point, and an object of the present invention is to provide a cache management device and a cache memory management method that can determine whether or not caching is necessary according to the past use frequency of data.
[0011]
[Means for Solving the Problems]
In the present invention, in order to solve the above problems, a cache management device as shown in FIG. 1 is provided. The cache management device according to the present invention controls a cache process in response to an access request from the
[0012]
The
[0013]
According to such a cache management device, the number of times of accessing each data in the
[0014]
According to another aspect of the present invention, there is provided a cache management device for controlling a cache process in response to an access request from a CPU, comprising: an upper level memory connected to the CPU; A counter for counting the number of accesses, a lower level memory connected to the CPU and the upper level memory for storing data corresponding to each data stored in the upper level memory, and an access request output by the CPU. When the specified access target data hits the upper level memory, the value of the counter corresponding to the access target data is counted up, and when the access request is a data write request, the data is transferred to the upper level memory. Write, and the access request is a data write And a memory controller for writing data to the lower-level memory when the value of the counter of the access target data is equal to or smaller than the predetermined value. Is done.
[0015]
According to such a cache management device, when the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up. When the access request is a data write request, data is written to the upper level memory. Further, when the access request is a data write request and the value of the counter of the data to be accessed is equal to or smaller than a predetermined value, data is written to the lower-level memory.
[0016]
Further, in order to solve the above-described problem, a cache process is controlled in response to an access request from a CPU to an upper-level memory and a lower-level memory that stores data corresponding to data stored in the upper-level memory. A cache memory management method, when an access target data specified by an access request output by the CPU hits the upper level memory, increments a counter value corresponding to the access target data, and When the data to be replaced in is invalidated, the value of the counter corresponding to the data to be replaced is set in an access count log corresponding to the data to be replaced in the lower level memory, and the data to be accessed is When a miss occurs in the upper level memory, the lower If the value of the access count log of the access target data within the bell memory is greater than a predetermined value, storing the access target data to the upper level memory, the cache memory management method, characterized in that there is provided.
[0017]
According to such a cache memory management method, the number of accesses to each data is counted in the upper level memory. The access count of the replacement target data invalidated in the upper level memory is set in the access count log of the lower level memory. When a miss occurs in the upper-level memory, if the value of the access count log corresponding to the access target data is equal to or more than a predetermined value, the access target data is stored in the upper-level memory.
[0018]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
First, an outline of the invention applied to the embodiment will be described, and then, specific contents of the embodiment will be described.
[0019]
FIG. 1 is a conceptual diagram of the invention applied to the embodiment. As shown in FIG. 1, the cache management device controls data input / output between the
[0020]
The
[0021]
The
[0022]
The lower-
[0023]
The
[0024]
When the access target data specified by the access request output from the
[0025]
Further, when the data to be accessed mis-hits the
[0026]
According to such a cache management device, the number of times of accessing each data in the
[0027]
In this way, the number of accesses on the
[0028]
The above processing may be applied only to data reference (read), or may be applied to both data read and write. When applied to a data write access request, the data write mode is switched. That is, a method of taking data into the
[0029]
Also, if the number of times of data writing to the upper level memory is counted by a counter, the frequency of data writing can be obtained. By utilizing this, it is possible to select a more appropriate one of the write-through method and the write-back method as a method at the time of writing to the data, according to the data listening frequency.
[0030]
Further, in a system in which the lower-
[0031]
Hereinafter, embodiments of the present invention will be specifically described. In the embodiment, the number of accesses is counted for each block which is a processing unit of the cache processing. In the system described in the embodiment, a two-stage cache memory (a primary cache and a secondary cache) is provided between the CPU and the main storage device, and data between the primary cache and the secondary cache is stored. The present invention is applied to input / output control.
[0032]
[First Embodiment]
FIG. 2 is a diagram illustrating an example of a system configuration according to the first embodiment. This example is an example of a computer system in which a plurality of CPU modules each having a two-stage cache memory are mounted. Each CPU module has a
[0033]
A
[0034]
The
[0035]
A
[0036]
A
[0037]
Each of the
The
[0038]
FIG. 3 is a diagram illustrating a data structure example of tag information of the primary cache. FIG. 3 representatively shows
[0039]
The
[0040]
Each of the
[0041]
FIG. 3 shows an example of the
[0042]
FIG. 4 is a diagram illustrating a data structure example of tag information of the secondary cache. FIG. 4 representatively shows
[0043]
The
[0044]
Each of the
[0045]
FIG. 4 shows an example of the
[0046]
Using such tag information, the
[0047]
FIG. 5 is a flowchart illustrating a procedure of an access process according to the first embodiment. Hereinafter, the processing illustrated in FIG. 5 will be described along with step numbers.
[Step S11] The
[0048]
[Step S12] The
[0049]
If the
[0050]
[Step S13] The
[0051]
[Step S14] The
[0052]
[Step S15] When there is a mishit in the
[0053]
[Step S16] If the value (N2) of the access count log is equal to or smaller than the threshold (T), the blocks are not replaced. Therefore, the
[0054]
[Step S17] If the value (N2) of the access count log is larger than the threshold (T), the blocks are replaced. Therefore, the
[0055]
[Step S18] The
[0056]
[Step S19] The
[0057]
[Step S20] The
[0058]
As described above, when a read miss occurs in the
[0059]
In the related art, when a miss occurs in the primary cache, it is general that the least recently referenced block is evicted by referring to an LRU (Least Recently Used) table. Each block is shown in the LRU table, and is arranged according to the elapsed time since the most recent access. This LRU table is rearranged when the primary cache is hit. As described above, when the block to be evicted is determined with reference to the LRU table, even if the block has a high access frequency, the block is accidentally evicted if there is enough space from the most recent access.
[0060]
As in the first embodiment, a block with a low access frequency in the past is evicted, so that a block with a high access frequency can be continuously held in the primary cache.
[0061]
Next, a description will be given of an example of updating tag information in a case where a large number of accesses have been made to an arbitrary block and in a case where the block information has not been frequently accessed.
FIG. 6 is a diagram illustrating an example of updating tag information when many accesses are made on the primary cache. In this example, when the counter is 3 bits (counts up to a maximum of 7), the change of the content of the tag information when the number of times of reference on the
[0062]
(ST1) Here, it is assumed that the
[0063]
(ST2) If the corresponding block is accessed seven times or more, the count value in the
(ST3) When the corresponding block is evicted from the
[0064]
Thereafter, when the block in the
[0065]
FIG. 7 is a diagram illustrating an example of updating tag information when the number of accesses on the primary cache is small. In this example, when the counter is 3 bits (counts up to a maximum of 7), the change of the content of the tag information when the number of accesses on the
[0066]
(ST11) A block transfer occurs due to a mishit in the
[0067]
(ST12) When the corresponding block is not accessed, the count value remains 0.
(ST13) When the relevant block is evicted from the
[0068]
Thereafter, when the block in the
[0069]
In this way, by storing only the blocks having high reusability in the upper cache, the processing efficiency and the cache hit rate can be improved.
That is, even if a non-reusable block is put in the cache, the effect cannot be obtained. Conversely, it takes time and bus bandwidth to transfer blocks, resulting in performance degradation. Therefore, as shown in the first embodiment, by counting the number of times a block is accessed when stored in the primary cache and associating the number of accesses even when the block is evicted from the secondary cache, Blocks having no reusability can be determined from the secondary cache. As a result, useless block transfer can be suppressed, and time and bus usage bandwidth can be saved.
[0070]
In addition, in the conventional technique, a block having no reusability is stored in the primary cache, and a block having reusability may be expelled instead. In the first embodiment, since blocks without reusability are not put in the cache, blocks with reusability can be kept in the primary cache. As a result, the cache hit rate is improved.
[0071]
In the first embodiment, the number of times of data read (reference) and data write (write) access to a block is counted, but only the data read access request may be counted. For example, when the write-through method is fixedly adopted as the data writing method, it can be determined that the reusability is low if the frequency of reference to the block is low, even if the frequency of writing to a certain block is high.
[0072]
[Second embodiment]
Next, a second embodiment will be described. The second embodiment is an example of a computer in which individual primary caches are mounted on a plurality of CPU modules and a shared secondary cache is separately provided.
[0073]
FIG. 8 is a diagram illustrating an example of a system configuration of a computer according to the second embodiment. In this example, each CPU module has a
[0074]
The
[0075]
A
[0076]
A
[0077]
A
[0078]
Each of the
[0079]
The
[0080]
Here, the data structure of the
[0081]
FIG. 9 is a diagram illustrating a data structure example of tag information of the secondary cache. In the
[0082]
The
[0083]
In the access count log, a numerical value (access frequency information) indicating the number of times data stored in the corresponding block has been accessed is set. Here, the
[0084]
The values of the
[0085]
Similarly, the values of the
[0086]
As described above, the updating of the counter is performed by the
[0087]
Next, a description will be given of an example of updating tag information in a case where a large number of accesses have been made to an arbitrary block and in a case where the block information has not been frequently accessed.
FIG. 10 is a diagram illustrating an example of updating tag information when many accesses are made on the primary cache. In this example, when the counter is 3 bits (counts up to a maximum of 7), a change in the contents of the tag information when the number of accesses on the
[0088]
(ST21) Here, it is assumed that a mishit occurs in the
[0089]
(ST22) If the block is accessed seven times or more for reference, the count value in the
[0090]
(ST23) When the corresponding block is evicted from the
[0091]
(ST24) Similarly, in the
[0092]
Thereafter, when the block in the
[0093]
FIG. 11 is a diagram illustrating an example of updating tag information when the number of accesses on the primary cache is small. In this example, when the counter is 3 bits (counts up to a maximum of 7), the change of the content of the tag information when the number of accesses on the
[0094]
(ST31) In response to a read request from the
[0095]
(ST32) When the
(ST33) The corresponding block is evicted from the
[0096]
(ST34) Here, it is assumed that there have been many (seven or more) accesses from
[0097]
Thereafter, when there is an access to the block on the
[0098]
As described above, even when the
[0099]
[Third Embodiment]
Next, a third embodiment will be described. The third embodiment is based on the configuration shown in the first embodiment, and counts the frequency of access to blocks in the secondary cache.
[0100]
That is, in the first embodiment, the access count log is associated with the tag for each block of the
[0101]
Therefore, in the third embodiment, the number of accesses in each block on the secondary cache is counted and added to the number of accesses in the primary cache (the value of the access count log in the first embodiment).
[0102]
The system configuration according to the third embodiment is substantially the same as the configuration according to the first embodiment shown in FIG. However, the data structure of the tag information in the secondary cache and the processing of the memory controller are different. Hereinafter, the data structure of the tag information in the
[0103]
FIG. 12 is a diagram illustrating an example of tag information of the secondary cache according to the third embodiment. FIG. 12 representatively shows the
[0104]
In the
[0105]
The
[0106]
Each of the
[0107]
As described above, the access count log associated with each block of the
[0108]
FIG. 13 is a flowchart illustrating a procedure of an access process of the memory controller according to the third embodiment. Since this flowchart is almost the same as the access processing of the first embodiment shown in FIG. 5, the same processing is denoted by the same step number, and the description is omitted.
[0109]
In the third embodiment, the process of step S15 in FIG. 5 is changed as follows.
[Step S31] When a miss occurs in the
[0110]
Further, in the third embodiment, processing after reading data from the
[0111]
[Step S32] The
[0112]
Further, in the third embodiment, the process of step S19 in FIG. 5 is changed as follows.
[Step S32] The
[0113]
As described above, in the third embodiment, all of the tags of the primary cache and the secondary cache include the counter for recording the number of accesses, and this count value is set each time the cache is referred to in each cache. Increased by one. Thereafter, when a secondary cache access occurs due to a primary cache read miss, the CPU counter value on the secondary cache is looked at, and the data is placed in the primary cache or directly to the CPU without entering the primary cache. It is determined whether to send data.
[0114]
As a result, in the first embodiment, a block that has been determined not to be reusable on the secondary cache cannot be reversed without leaving the secondary cache and cannot enter the primary cache. . On the other hand, in the third embodiment, similarly to the primary cache, when the secondary cache is accessed, the counter on the secondary cache is increased. Therefore, even if a block is determined to have no reusability, if it is accessed a lot on the secondary cache, it can be transferred to the primary cache when a read miss occurs.
[0115]
[Fourth Embodiment]
Next, a fourth embodiment will be described. The fourth embodiment is based on the configuration shown in the second embodiment, and counts the frequency of access to blocks in the secondary cache.
[0116]
That is, in the second embodiment, the access count log is associated with the tag of each block of the
[0117]
Therefore, in the fourth embodiment, the number of accesses in each block on the secondary cache is added to the number of accesses in the primary cache (the value of the access count log in the first embodiment) and counted.
[0118]
The system configuration of the fourth embodiment is almost the same as the configuration of the second embodiment shown in FIG. However, the data structure of the tag information in the secondary cache and the processing of the memory controller are different. The data structure of the tag information in the fourth embodiment is as follows.
[0119]
FIG. 14 is a diagram illustrating an example of tag information of the secondary cache according to the fourth embodiment.
In the
[0120]
The
[0121]
Each of the
[0122]
The processing of the memory controller according to the fourth embodiment is the same as the access processing according to the third embodiment shown in FIG.
As described above, each block of the primary cache and the secondary cache has a tag as shown in FIGS. 3 and 14, respectively. All primary cache and secondary cache tags include a counter that records the number of accesses, and this count value is incremented by one each time the block is referenced in each cache. When the block is evicted from the primary cache or invalidated by the cache protocol, this value is added to the counter for the CPU in the secondary cache.
[0123]
Then, when a secondary cache access occurs due to a primary cache read miss, the CPU counter value on the secondary cache is checked and the data is placed in the primary cache or the data is directly sent to the CPU without entering the primary cache. Judge whether to send.
[0124]
In the second embodiment, a block determined to be non-reusable on the secondary cache cannot be reversed unless leaving the secondary cache, and cannot enter the primary cache. On the other hand, in the fourth embodiment, similarly to the primary cache, when the secondary cache is accessed, the counter on the secondary cache is increased (for example, when the secondary cache is accessed by a request from CPU 0). By increasing the value of the counter corresponding to CPU0), even if a block is determined to have no reusability, it can be transferred to the primary cache upon a read miss if a large number of accesses are made on the secondary cache. .
[0125]
[Fifth Embodiment]
Next, a fifth embodiment will be described. In the fifth embodiment, based on the first embodiment, a processing method when a write miss occurs in the primary cache is determined according to the number of block accesses in the primary cache.
[0126]
The processing method when a write miss occurs includes, for example, a write allocate and a no write allocate. Here, the write allocate is a processing method for loading a block from the secondary cache into the primary cache when a write miss occurs in the primary cache. The no-write allocate is a processing method in which when a write miss occurs in the primary cache, data is read from the secondary cache and the corresponding block is not loaded into the primary cache.
[0127]
The system configuration of the fifth embodiment is almost the same as the configuration of the first embodiment shown in FIG. However, the data write process of the memory controller is different. Note that the processing at the time of data reading (referencing) of the memory controller is the same as that of the first embodiment shown in FIG. Therefore, the processing at the time of data writing in the processing of the memory controller will be described with reference to the configuration shown in FIG.
[0128]
FIG. 15 is a flowchart illustrating a procedure of a write process according to the fifth embodiment. Hereinafter, the processing illustrated in FIG. 15 will be described along the step numbers.
[Step S41] The
[0129]
[Step S42] The
[0130]
[Step S43] The
[0131]
[Step S44] The
[0132]
[Step S45] When there is a mishit in the
[0133]
[Step S46] If the value (N2) of the access count log is equal to or smaller than the threshold (T), a no-write allocate process is performed. Therefore, the
[0134]
[Step S47] If the value (N2) of the access count log is larger than the threshold (T), the blocks are replaced. Therefore, the
[0135]
[Step S48] The
[0136]
[Step S49] The
[0137]
[Step S50] The
[0138]
[Step S51] The
[0139]
As described above, in the fifth embodiment, the counter for recording the number of accesses is associated with the tag of the primary cache, and the count value is incremented by one each time the block is referred to. When the block is evicted from the primary cache, this value is added to the counter of the secondary cache. Thereafter, when a write miss occurs in the
[0140]
In this way, only blocks having high reusability can be write-allocated. As a result, blocks with high reusability can be preferentially stored in the primary cache, and data access efficiency can be improved.
[0141]
[Sixth Embodiment]
Next, a sixth embodiment will be described. In the sixth embodiment, based on the second embodiment, a processing method when a write miss occurs in the primary cache is determined according to the number of block accesses in the primary cache. The processing method when a write miss occurs includes, for example, a write allocate and a no write allocate.
[0142]
The system configuration according to the sixth embodiment is substantially the same as the configuration according to the second embodiment shown in FIG. However, the data write process of the memory controller is different. Note that the processing at the time of data reading (referencing) of the memory controller is the same as that of the first embodiment shown in FIG. The processing at the time of data writing of the memory controller is the same as that of the fifth embodiment shown in FIG.
[0143]
As a result, all the primary cache tags include a counter that records the number of accesses, and this count value is incremented by one each time the block is referenced. When the block is evicted from the primary cache or invalidated by the cache protocol, this value is added to the counter for the CPU in the secondary cache. Thereafter, when a write miss occurs in the primary cache and there is a secondary cache access, the CPU counter value in the secondary cache is checked to determine whether to perform write allocate or no-write allocate.
[0144]
[Seventh Embodiment]
Next, a seventh embodiment will be described. The seventh embodiment is based on the third embodiment, and determines a processing method when a write miss occurs in the primary cache according to the number of block accesses in the primary cache and the secondary cache. It is. The processing method when a write miss occurs includes, for example, a write allocate and a no write allocate.
[0145]
The system configuration of the seventh embodiment is almost the same as the configuration of the first embodiment shown in FIG. However, the data structure of the tag information of the secondary cache is the same as the tag information of the third embodiment shown in FIG. The processing at the time of data reading (reference) of the memory controller is the same as that of the third embodiment shown in FIG. The processing at the time of data writing of the memory controller is the same as that of the fifth embodiment shown in FIG.
[0146]
Thus, all the primary cache and secondary cache tags include a counter for recording the number of accesses, and this count value is incremented by one each time the cache refers to the block. Thereafter, when a write miss occurs in the primary cache and the secondary cache is accessed, the counter value on the secondary cache is checked to determine whether to perform write allocate or no-write allocate.
[0147]
In the fifth embodiment, a block that has been determined not to be reusable on the secondary cache cannot reverse its determination unless it leaves the secondary cache, and cannot enter the primary cache. Therefore, in the seventh embodiment, similarly to the primary cache, when the secondary cache is accessed, the counter on the secondary cache is increased. As a result, even if a block once determined to have no reusability is accessed a lot on the secondary cache, writing can be performed after transfer to the primary cache at the time of a write miss (write allocate method).
[0148]
[Eighth Embodiment]
Next, an eighth embodiment will be described. In the eighth embodiment, based on the fourth embodiment, a processing method when a write miss occurs in the primary cache is determined according to the number of block accesses in the primary cache and the secondary cache. It is. The processing method when a write miss occurs includes, for example, a write allocate and a no write allocate.
[0149]
The system configuration of the eighth embodiment is almost the same as the configuration of the second embodiment shown in FIG. However, the data structure of the tag information of the secondary cache is the same as the tag information of the fourth embodiment shown in FIG. The processing at the time of data reading (reference) of the memory controller is the same as that of the fourth embodiment shown in FIG. The processing at the time of data writing of the memory controller is the same as that of the fifth embodiment shown in FIG.
[0150]
Thus, all the primary cache and secondary cache tags include a counter for recording the number of accesses, and this count value is incremented by one each time the block is referenced in each cache. When the block is evicted from the primary cache or invalidated by the cache protocol, this value is added to the counter for the CPU in the secondary cache. Thereafter, when a write miss occurs in the primary cache and a secondary cache access occurs, the CPU counter value on the secondary cache is checked to determine whether to perform write allocate or no-write allocate.
[0151]
In the sixth embodiment, a block that has been determined not to be reusable on the secondary cache cannot be reversed unless leaving the secondary cache, and cannot enter the primary cache. Therefore, in the eighth embodiment, similarly to the primary cache, when the secondary cache is accessed, the counter on the secondary cache is increased (for example, the access to the secondary cache is made by a request from the CPU 610). In this case, the value of the counter corresponding to the
[0152]
[Ninth embodiment]
Next, a ninth embodiment will be described. The ninth embodiment is based on the first embodiment, and dynamically switches a data writing method according to a write request in accordance with the number of block accesses in the primary cache.
[0153]
Data writing methods include, for example, write-back and write-through. Here, in the write-back, data is written to a block of the primary cache in response to a write request. Then, when the block is evicted from the primary cache, the data of the block is written to the secondary cache. In write-through, data is written to both the primary cache and the secondary cache in response to a write request.
[0154]
The system configuration of the ninth embodiment is almost the same as the configuration of the first embodiment shown in FIG. However, the data write process of the memory controller is different. Note that the processing at the time of data reading (referencing) of the memory controller is substantially the same as that of the first embodiment shown in FIG. However, the update process of the primary cache counter in step S14 is not performed. That is, the
[0155]
Therefore, the processing at the time of data writing in the processing of the memory controller will be described with reference to the configuration shown in FIG.
FIG. 16 is a flowchart illustrating the procedure of the write process according to the ninth embodiment. Hereinafter, the processing illustrated in FIG. 16 will be described along with step numbers.
[0156]
[Step S61] The
[Step S62] The
[0157]
[Step S63] If there is a mishit in the
[0158]
[Step S64] When a hit occurs in the
[0159]
[Step S65] The
[0160]
[Step S66] The
[0161]
[Step S67] The
[0162]
As described above, the tag of the primary cache includes the counter for recording the write frequency information, and this count value is incremented by one each time a write is performed on the block. When the block is evicted from the primary cache, this value is added to the counter of the secondary cache. Thereafter, when a write request is issued and the primary cache is hit, if the value of the counter is larger than a predetermined threshold value (N), it can be determined that the block is a block to which writing is frequently performed, and writing is performed by a write-back method. Otherwise, writing by the write-through method is performed.
[0163]
As described above, the write-back method and the write-through method can be dynamically changed according to the value (N1) of the counter. For a block that is frequently accessed, the number of times of writing to the secondary cache can be reduced by adopting the write-back method. As a result, the average access time is reduced. In addition, for a block with few accesses, the write-through method can be used to maintain consistency between the primary cache and the secondary cache.
[0164]
In the ninth embodiment, a counter is used to count the number of times of writing data. However, a tag for writing and a counter for reference are provided in the
[0165]
In the description of the ninth embodiment, it is assumed that the process at the time of data read (reference) of the memory controller is substantially the same as that of the first embodiment shown in FIG. Therefore, when a block is evicted from the primary cache, the counter value of that block is added to the access count log of the corresponding block in the secondary cache. Therefore, when a block is read into the primary cache, the writing method can be determined according to the value of the access count log. In this case, if the value of the access count log is larger than a predetermined threshold, a write-back method is adopted for writing data to the corresponding block read into the primary cache. On the other hand, if the value of the access count log is equal to or smaller than the predetermined threshold, a write-through method is adopted for writing data to the corresponding block read into the primary cache.
[0166]
When a new block is fetched into the primary cache, a write-through method may be adopted as an initial setting of a writing method for the block. If the block has a high frequency of reference, it can be switched to the write-back method when the number of counters exceeds the threshold value.
[0167]
[Tenth embodiment]
Next, a tenth embodiment will be described. In the tenth embodiment, whether or not a block is fetched from the secondary cache into the primary cache is determined using the counter value of the block to be evicted. Specifically, the counter value of the block having the smallest counter value on the primary cache is compared with the value of the access count log of the block to be fetched on the secondary cache. If the value of the access count log of the fetch target block on the secondary cache is larger, the block is fetched into the primary cache.
[0168]
FIG. 17 is a flowchart illustrating a procedure of an access process according to the tenth embodiment. Note that among the processing shown in FIG. 17, processing other than steps S71 and S72 is the same as the access processing in the first embodiment shown in FIG. 5, and thus the same step numbers are assigned and description thereof is omitted.
[0169]
[Step S71] The
[Step S72] Then, the
[0170]
In this way, by storing only the blocks having the access count log larger than the minimum counter value of the primary cache in the primary cache, it is possible to take only the blocks with a high access frequency into the primary cache.
[0171]
In each of the above embodiments, the counter is provided for each block which is the minimum unit to be stored in the cache memory control, but the size of this block can be set arbitrarily. Therefore, the size of the block can be made equal to the data length of data input / output to / from the CPU. Generally, the block size is set to a value that minimizes the average access time in the memory access processing.
[0172]
Even if a non-reusable block is cached as in the conventional technology, the effect of increasing the hit ratio cannot be obtained, and conversely, time and bus bandwidth are spent for block transfer, resulting in a decrease in performance. I will. On the other hand, in the present embodiment, useless block transfer can be suppressed by detecting a block having no reusability, and time and the bandwidth used by the bus can be saved.
[0173]
If a non-reusable block is put in the cache, the reusable block may be evicted instead. In the above embodiment, such a case does not occur because a block having no reusability is not cached.
[0174]
The cache writing method is roughly classified into a write-through method and a write-back method. Conventionally, the two cannot be switched, but in the above embodiment, the two can be switched to flexibly handle blocks with many writes, blocks with few writes, and blocks that show both properties depending on time. Can be.
[0175]
(Supplementary Note 1) In a cache management device that controls a cache process according to an access request from a CPU,
An upper level memory connected to the CPU;
A counter for counting the number of accesses to each data stored in the upper level memory;
A lower-level memory connected to the CPU and the upper-level memory and storing data corresponding to each data stored in the upper-level memory;
An access count log provided in association with each data stored in the lower level memory,
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up, and the replacement target data in the upper level memory is invalidated. When the data is replaced, the value of the counter corresponding to the data to be replaced is set in the access count log corresponding to the data to be replaced in the lower level memory, and the data to be accessed misses the upper level memory. If the value of the access count log of the access target data in the lower level memory is larger than a predetermined value, a memory controller that stores the access target data in the upper level memory;
A cache management device comprising:
[0176]
(Supplementary note 2) The cache memory device according to
[0177]
(Supplementary Note 3) The
[0178]
(Supplementary Note 4) When there are a plurality of CPUs, the CPU includes the upper-level memory, the counter, the access count log, and the memory controller corresponding to each of the CPUs, and the lower-level memory is shared by the plurality of CPUs. 3. The cache memory device according to
[0179]
(Supplementary Note 5) The cache management device according to
[0180]
(Supplementary Note 6) When the access request is a write request, the memory controller determines that the number of accesses of the access target data in the lower level memory is a predetermined number when the access target data miss-hits the upper level memory. 2. The cache management device according to
[0181]
(Supplementary Note 7) The memory controller replaces the value of the access count log of the access target data in the lower level memory in the upper level memory when the access target data misses the upper level memory. 2. The cache management device according to
[0182]
(Supplementary Note 8) In a cache management device that controls a cache process according to an access request from a CPU,
An upper level memory connected to the CPU;
A counter for counting the number of accesses to each data stored in the upper level memory;
A lower-level memory connected to the CPU and the upper-level memory and storing data corresponding to each data stored in the upper-level memory;
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up, and the access request is a data write request. Writing data to the upper-level memory, and writing the data to the lower-level memory if the access request is a data write request and the value of the counter of the access target data is equal to or smaller than the predetermined value. A memory controller that performs
A cache management device comprising:
[0183]
(Supplementary Note 9) A cache memory management method for controlling a cache process in response to an access request from a CPU to an upper-level memory and a lower-level memory that stores data corresponding to data stored in the upper-level memory In the above, when the access target data specified by the access request output by the CPU hits the upper level memory, the value of a counter corresponding to the access target data is counted up,
When the replacement target data in the upper level memory is invalidated, the value of the counter corresponding to the replacement target data is set in an access count log corresponding to the replacement target data in the lower level memory,
When the access target data miss-hits the upper level memory, if the value of the access count log of the access target data in the lower level memory is larger than a predetermined value, the access target data is stored in the upper level memory. Do
A cache memory management method, characterized in that:
[0184]
(Supplementary Note 10) A cache memory management method for controlling cache processing in response to an access request from a CPU to an upper-level memory and a lower-level memory that stores data corresponding to data stored in the upper-level memory At
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up,
If the access request is a data write request, write data to the upper level memory;
If the access request is a data write request, and the value of the counter of the data to be accessed is equal to or less than the predetermined value, data is also written to the lower-level memory.
A cache memory management method, characterized in that:
[0185]
【The invention's effect】
As described above, in the present invention, the number of accesses in the upper-level memory is counted, and after the data is evicted from the upper-level memory, the data is transferred from the lower-level memory to the upper-level memory only when the number of accesses is larger than a predetermined value. Is performed, so that caching limited to highly reusable data can be performed.
[0186]
In another invention, the number of accesses to the upper level memory is counted, and when a data write request is issued, writing to the lower level memory is performed only when the number of accesses is equal to or less than a predetermined value. For highly usable data, high-speed access by the write-back method becomes possible.
[Brief description of the drawings]
FIG. 1 is a conceptual diagram of the invention applied to an embodiment.
FIG. 2 is a diagram illustrating a system configuration example according to the first embodiment;
FIG. 3 is a diagram illustrating an example of a data structure of tag information of a primary cache.
FIG. 4 is a diagram illustrating an example of a data structure of tag information of a secondary cache.
FIG. 5 is a flowchart illustrating a procedure of an access process according to the first embodiment.
FIG. 6 is a diagram illustrating an example of updating tag information when many accesses are made on the primary cache;
FIG. 7 is a diagram illustrating an example of updating tag information when the number of accesses on the primary cache is small.
FIG. 8 is a diagram illustrating an example of a system configuration of a computer according to a second embodiment.
FIG. 9 is a diagram illustrating an example of a data structure of tag information of a secondary cache.
FIG. 10 is a diagram showing an example of updating tag information when many accesses are made on the primary cache.
FIG. 11 is a diagram illustrating an example of updating tag information when the number of accesses on the primary cache is small.
FIG. 12 is a diagram illustrating an example of tag information of a secondary cache according to the third embodiment.
FIG. 13 is a flowchart illustrating a procedure of an access process of the memory controller according to the third embodiment;
FIG. 14 is a diagram illustrating an example of tag information of a secondary cache according to the fourth embodiment.
FIG. 15 is a flowchart illustrating a procedure of a write process according to a fifth embodiment.
FIG. 16 is a flowchart illustrating a procedure of a write process according to a ninth embodiment;
FIG. 17 is a flowchart illustrating a procedure of an access process according to the tenth embodiment.
[Explanation of symbols]
1 CPU
1a Memory controller
2 Upper level memory
2a Tag information
2b tag
2c counter
3 Lower level memory
3a Tag information
3b tag
3c Access count log
10 Main storage device
110, 210, 310, 410 CPU
111, 211, 311, 411 Memory controller
120, 220, 320, 420 Primary cache
121,221,321,421 Tag information
130, 230, 330, 430 Secondary cache
131, 231, 331, 431 Tag information
Claims (5)
前記CPUに接続された上位レベルメモリと、
前記上位レベルメモリに格納された各データのアクセス回数を計数するカウンタと、
前記CPUと前記上位レベルメモリとに接続され、前記上位レベルメモリに格納された各データに対応するデータを格納する下位レベルメモリと、
前記下位レベルメモリに格納された各データに対応づけて設けられたアクセス回数ログと、
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップし、前記上位レベルメモリ内の置き換え対象データを無効化したとき、前記置き換え対象データに対応する前記カウンタの値を、前記下位レベルメモリ内の前記置き換え対象データに対応する前記アクセス回数ログに設定し、前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納するメモリコントローラと、
を有することを特徴とするキャッシュ管理装置。In a cache management device that controls cache processing according to an access request from a CPU,
An upper level memory connected to the CPU;
A counter for counting the number of accesses to each data stored in the upper level memory;
A lower-level memory connected to the CPU and the upper-level memory and storing data corresponding to each data stored in the upper-level memory;
An access count log provided in association with each data stored in the lower level memory,
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up, and the replacement target data in the upper level memory is invalidated. When the data is replaced, the value of the counter corresponding to the data to be replaced is set in the access count log corresponding to the data to be replaced in the lower level memory, and the data to be accessed misses the upper level memory. If the value of the access count log of the access target data in the lower level memory is larger than a predetermined value, a memory controller that stores the access target data in the upper level memory;
A cache management device comprising:
前記CPUに接続された上位レベルメモリと、
前記上位レベルメモリに格納された各データのアクセス回数を計数するカウンタと、
前記CPUと前記上位レベルメモリとに接続され、前記上位レベルメモリに格納された各データに対応するデータを格納する下位レベルメモリと、
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応する前記カウンタの値をカウントアップするとともに、前記アクセス要求がデータライト要求である場合、前記上位レベルメモリへデータの書き込みを行い、前記アクセス要求がデータライト要求であり、且つ前記アクセス対象データの前記カウンタの値が前記所定値以下である場合、前記下位レベルメモリへもデータの書き込みを行うメモリコントローラと、
を有することを特徴とするキャッシュ管理装置。In a cache management device that controls cache processing according to an access request from a CPU,
An upper level memory connected to the CPU;
A counter for counting the number of accesses to each data stored in the upper level memory;
A lower-level memory connected to the CPU and the upper-level memory and storing data corresponding to each data stored in the upper-level memory;
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of the counter corresponding to the access target data is counted up, and the access request is a data write request. Writing data to the upper-level memory, and writing the data to the lower-level memory if the access request is a data write request and the value of the counter of the access target data is equal to or smaller than the predetermined value. A memory controller that performs
A cache management device comprising:
前記CPUが出力するアクセス要求で指定されたアクセス対象データが前記上位レベルメモリにヒットすると、前記アクセス対象データに対応するカウンタの値をカウントアップし、
前記上位レベルメモリ内の置き換え対象データを無効化したとき、前記置き換え対象データに対応する前記カウンタの値を、前記下位レベルメモリ内の前記置き換え対象データに対応するアクセス回数ログに設定し、
前記アクセス対象データが前記上位レベルメモリにミスヒットしたとき、前記下位レベルメモリ内の前記アクセス対象データの前記アクセス回数ログの値が所定値より大きければ、前記アクセス対象データを前記上位レベルメモリに格納する、
ことを特徴とするキャッシュメモリ管理方法。A cache memory management method for controlling a cache process in response to an access request from a CPU to an upper-level memory and a lower-level memory that stores data corresponding to data stored in the upper-level memory,
When the access target data specified by the access request output by the CPU hits the upper level memory, the value of a counter corresponding to the access target data is counted up,
When the replacement target data in the upper level memory is invalidated, the value of the counter corresponding to the replacement target data is set in an access count log corresponding to the replacement target data in the lower level memory,
When the access target data miss-hits the upper level memory, if the value of the access count log of the access target data in the lower level memory is larger than a predetermined value, the access target data is stored in the upper level memory. Do
A cache memory management method, characterized in that:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003152762A JP2004355365A (en) | 2003-05-29 | 2003-05-29 | Cache management device and cache memory management method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003152762A JP2004355365A (en) | 2003-05-29 | 2003-05-29 | Cache management device and cache memory management method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2004355365A true JP2004355365A (en) | 2004-12-16 |
Family
ID=34047889
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003152762A Withdrawn JP2004355365A (en) | 2003-05-29 | 2003-05-29 | Cache management device and cache memory management method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2004355365A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011078014A1 (en) * | 2009-12-21 | 2011-06-30 | ソニー株式会社 | Cache memory and cache memory control device |
JP2011204060A (en) * | 2010-03-26 | 2011-10-13 | Nec Corp | Disk device |
WO2013064935A1 (en) * | 2011-10-31 | 2013-05-10 | International Business Machines Corporation | Dynamically adjusted threshold for population of secondary cache |
JP2013174997A (en) * | 2012-02-24 | 2013-09-05 | Mitsubishi Electric Corp | Cache control device and cache control method |
JP2015516613A (en) * | 2012-03-05 | 2015-06-11 | インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation | Method, computer program, and system for managing data |
JP2017058951A (en) * | 2015-09-16 | 2017-03-23 | 株式会社東芝 | Memory system |
-
2003
- 2003-05-29 JP JP2003152762A patent/JP2004355365A/en not_active Withdrawn
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011078014A1 (en) * | 2009-12-21 | 2011-06-30 | ソニー株式会社 | Cache memory and cache memory control device |
CN102667737A (en) * | 2009-12-21 | 2012-09-12 | 索尼公司 | Cache memory and cache memory control device |
US10102132B2 (en) | 2009-12-21 | 2018-10-16 | Sony Corporation | Data transfer in a multiprocessor using a shared cache memory |
US9535841B2 (en) | 2009-12-21 | 2017-01-03 | Sony Corporation | Cache memory and cache memory control unit |
JP2011204060A (en) * | 2010-03-26 | 2011-10-13 | Nec Corp | Disk device |
JP2014535106A (en) * | 2011-10-31 | 2014-12-25 | インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation | Method, controller and program for populating data in a secondary cache of a storage system |
GB2513741A (en) * | 2011-10-31 | 2014-11-05 | Ibm | Dynamically adjusted threshold for population of secondary cache |
US8972662B2 (en) | 2011-10-31 | 2015-03-03 | International Business Machines Corporation | Dynamically adjusted threshold for population of secondary cache |
US8972661B2 (en) | 2011-10-31 | 2015-03-03 | International Business Machines Corporation | Dynamically adjusted threshold for population of secondary cache |
GB2513741B (en) * | 2011-10-31 | 2016-11-02 | Ibm | Dynamically adjusted threshold for population of secondary cache |
WO2013064935A1 (en) * | 2011-10-31 | 2013-05-10 | International Business Machines Corporation | Dynamically adjusted threshold for population of secondary cache |
JP2013174997A (en) * | 2012-02-24 | 2013-09-05 | Mitsubishi Electric Corp | Cache control device and cache control method |
JP2015516613A (en) * | 2012-03-05 | 2015-06-11 | インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation | Method, computer program, and system for managing data |
JP2017058951A (en) * | 2015-09-16 | 2017-03-23 | 株式会社東芝 | Memory system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7711902B2 (en) | Area effective cache with pseudo associative memory | |
US7698508B2 (en) | System and method for reducing unnecessary cache operations | |
US6957304B2 (en) | Runahead allocation protection (RAP) | |
EP0780769B1 (en) | Hybrid numa coma caching system and methods for selecting between the caching modes | |
JP5328748B2 (en) | Cache line replacement in cache memory | |
EP1654660B1 (en) | A method of data caching | |
US7380065B2 (en) | Performance of a cache by detecting cache lines that have been reused | |
US6295582B1 (en) | System and method for managing data in an asynchronous I/O cache memory to maintain a predetermined amount of storage space that is readily available | |
US7281092B2 (en) | System and method of managing cache hierarchies with adaptive mechanisms | |
EP0780770A1 (en) | Hybrid numa coma caching system and methods for selecting between the caching modes | |
JP4298800B2 (en) | Prefetch management in cache memory | |
US10725923B1 (en) | Cache access detection and prediction | |
US20060184743A1 (en) | Cache memory direct intervention | |
WO2002001366A2 (en) | Cache line pre-load and pre-own based on cache coherence speculation | |
WO2002073417A1 (en) | State-based allocation and replacement for improved hit ratio in directory caches | |
US20020169935A1 (en) | System of and method for memory arbitration using multiple queues | |
JP2002073415A (en) | Computer cache system made delay invalid | |
EP1980945B1 (en) | Memory access control apparatus and memory access control method | |
JP2003186743A (en) | Method and device for locking and unlocking of adaptive cache frame | |
JP2004355365A (en) | Cache management device and cache memory management method | |
US6240491B1 (en) | Process and system for switching between an update and invalidate mode for each cache block | |
US20090157968A1 (en) | Cache Memory with Extended Set-associativity of Partner Sets | |
CN113778693B (en) | Cache operation method, cache operation device, electronic equipment and processor | |
JPH11143774A (en) | Cache control mechanism |
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: 20060801 |