Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プログラムで(C ++を使用して)Ubuntuでキャッシュブロックサイズを見つけるにはどうすればよいですか?
あなたはそれを見つけることができます/proc/cpuinfo; cache size合計サイズとcache_alignmentブロックサイズ。
/proc/cpuinfo
cache size
cache_alignment
1つの方法は、std::vectorまたは単なる配列にランダムな値を入力し、ループ内の各要素を2乗するなどの簡単な操作を行うことです。次に、ベクトルの長さの関数として実行時間を測定します。ベクトルがキャッシュに収まらない場合は、実行時間の急増が非常にはっきりとわかります。
std::vector