当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

复旦大学:《计算机原理 Computer System》课程PPT课件_Cache Memory(• Cache mountain • Matrix multiplication)

资源类别:文库,文档格式:PPT,文档页数:38,文件大小:342.5KB,团购合买
• Cache mountain • Matrix multiplication • Suggested Reading
点击下载完整版文档(PPT)

Cache Memory

1 Cache Memory

Outline Cache mountain Matrix multiplication Suggested Reading: 6.6, 6.7

2 Outline • Cache mountain • Matrix multiplication • Suggested Reading: 6.6, 6.7

6.6 Putting it Together: The Impact of Caches on Program Performance 6.6.1 The Memory Mountain

3 6.6 Putting it Together: The Impact of Caches on Program Performance 6.6.1 The Memory Mountain

The memory Mountain P512 Read throughput (read bandwidth) The rate that a program reads data from the memory system Memory mountain A two-dimensional function of read bandwidth versus temporal and spatial locality Characterizes the capabilities of the memory system for each computer

4 The Memory Mountain P512 • Read throughput (read bandwidth) – The rate that a program reads data from the memory system • Memory mountain – A two-dimensional function of read bandwidth versus temporal and spatial locality – Characterizes the capabilities of the memory system for each computer

Memory mountain main routine Figure 6.41 P513 / mountain c- Generate the memory mountain. #define minbytes(1 <<10)/working set size ranges from 1 KB*/ #define maxbYtes (1 < 23)/...up to 8 MB*/ #define maxstride 16 / strides range from 1 to 16*/ #define maXelems maXbytes/sizeof(int) int data MAXELEMSI: The array well be traversing

5 Memory mountain main routine Figure 6.41 P513 /* mountain.c - Generate the memory mountain. */ #define MINBYTES (1 << 10) /* Working set size ranges from 1 KB */ #define MAXBYTES (1 << 23) /* ... up to 8 MB */ #define MAXSTRIDE 16 /* Strides range from 1 to 16 */ #define MAXELEMS MAXBYTES/sizeof(int) int data[MAXELEMS]; /* The array we'll be traversing */

Memory mountain main routine int maino int size, / Working set size(in bytes)*/ int stride: / Stride (in array elements)*/ double mhz; / Clock frequency * init data(data, MAXELEMS); /Initialize each element in data to 1 */ Mhz=mhz) / Estimate the clock frequency x

6 Memory mountain main routine int main() { int size; /* Working set size (in bytes) */ int stride; /* Stride (in array elements) */ double Mhz; /* Clock frequency */ init_data(data, MAXELEMS); /* Initialize each element in data to 1 */ Mhz = mhz(0); /* Estimate the clock frequency */

Memory mountain main routine for(size= MAXBYTES; size > MINBYTES; size >>=1)t for(stride= 1; stride<= MAXSTRIDE; stride++) printf( o.Ift",run(size, stride, Mhz)) printf("n; exit(0);

7 Memory mountain main routine for (size = MAXBYTES; size >= MINBYTES; size >>= 1) { for (stride = 1; stride <= MAXSTRIDE; stride++) printf("%.1f\t", run(size, stride, Mhz)); printf("\n"); } exit(0); }

Memory mountain test function Figure 6.40 P512 / The test function * void test (int elems, int stride)i inti result=0 volatile int sink: for(i=0; i< elems; i+= stride) result += datai; sink= result: /*So compiler doesn't optimize away the loop

8 Memory mountain test function Figure 6.40 P512 /* The test function */ void test (int elems, int stride) { int i, result = 0; volatile int sink; for (i = 0; i < elems; i += stride) result += data[i]; sink = result; /* So compiler doesn't optimize away the loop */ }

Memory mountain test function /*Run test(elems, stride) and return read throughput MB/s)*/ double run (int size, int stride, double mhz) double cycles; int elems= size/ sizeof(int) test(elems, stride); / warm up the cache * cycles= fcyc2(test, elems, stride, 0); /*call test(elems, stride)*/ return(size/stride)/(cycles /Mhz); /*convert cycles to MB/s*/

9 Memory mountain test function /* Run test (elems, stride) and return read throughput (MB/s) */ double run (int size, int stride, double Mhz) { double cycles; int elems = size / sizeof(int); test (elems, stride); /* warm up the cache */ cycles = fcyc2(test, elems, stride, 0); /* call test (elems,stride) */ return (size / stride) / (cycles / Mhz); /* convert cycles to MB/s */ }

The memory Mountain Data Size MAXByTES(8M)bytes or MAXELEMS(2M)words Partially accessed Working set: from 8MB to 1KB Stride: from 1 to 16

10 The Memory Mountain • Data – Size • MAXBYTES(8M) bytes or MAXELEMS(2M) words – Partially accessed • Working set: from 8MB to 1KB • Stride: from 1 to 16

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共38页,可试读13页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有