Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Systems Class 01 15-213 “The Class That Gives CMU Its Zip!” Randal E. Bryant August 30, 2005.

Similar presentations


Presentation on theme: "Introduction to Computer Systems Class 01 15-213 “The Class That Gives CMU Its Zip!” Randal E. Bryant August 30, 2005."— Presentation transcript:

1 Introduction to Computer Systems Class 01 15-213 “The Class That Gives CMU Its Zip!” Randal E. Bryant August 30, 2005

2 – 2 – 15-213, F’05 refbug _fun: pushl%ebp movl$1073741824, %edx movl%esp, %ebp subl$16, %esp movl8(%ebp), %eax fldlLC0 fstpl-8(%ebp) movl%edx, -16(%ebp,%eax,4) fldl-8(%ebp) leave ret double fun(int i) { volatile double d[1] = {3.14}; volatile long int a[2]; a[i] = 1073741824; /* Possibly out of bounds */ return d[0]; }

3 – 3 – 15-213, F’05 copyij & copyji void copyji(int src[2048][2048], int dst[2048][2048]) { int i,j; for (j = 0; j < 2048; j++) for (i = 0; i < 2048; i++) dst[i][j] = src[i][j]; } void copyij(int src[2048][2048], int dst[2048][2048]) { int i,j; for (i = 0; i < 2048; i++) for (j = 0; j < 2048; j++) dst[i][j] = src[i][j]; }

4 – 4 – 15-213, F’05 The Memory Mountain 0 200 400 600 800 1000 1200 Read throughput (MB/s) Stride (words) Working set size (bytes) Pentium III Xeon 550 MHz 16 KB on-chip L1 d-cache 16 KB on-chip L1 i-cache 512 KB off-chip unified L2 cache L1 L2 Mem xe copyij copyji

5 – 5 – 15-213, F’05 abs_combine L21: movl%ebx, 4(%esp) leal-16(%ebp), %eax incl%ebx movl%eax, 8(%esp) movl%edi, (%esp) call_get_vec_element movl-16(%ebp), %eax movl(%esi), %edx imull%edx, %eax movl%eax, (%esi) movl%edi, (%esp) call_vec_length cmpl%ebx, %eax jgL21 void abs_combine(vec_ptr v, long int *dest) { int i; *dest = 1; for (i = 0; i < vec_length(v); i++) { long int val; get_vec_element(v, i, &val); *dest = *dest * val; }

6 – 6 – 15-213, F’05 direct_combine L30: movl(%eax,%edx,4), %ebx incl%edx imull%ebx, %ecx cmpl%esi, %edx jlL30 void direct_combine(vec_ptr v, long int *dest) { int i; int length = vec_length(v); long int *data = get_vec_start(v); long int x = 1; for (i = 0; i < length; i++) { x = x * data[i]; } *dest = x; }

7 – 7 – 15-213, F’05 void parallel_combine(vec_ptr v, long int *dest) { int length = vec_length(v); int limit = length-7; long int *data = get_vec_start(v); long int x = 1; int i; /* Combine 8 elements at a time */ for (i = 0; i < limit; i+=8) { long int t1 = data[i] * data[i+1]; long int t2 = data[i+2] * data[i+3]; long int u1 = t1 * t2; long int t3 = data[i+4] * data[i+5]; long int t4 = data[i+6] * data[i+7]; long int u2 = t3 * t4; x = x * (u1 * u2); } /* Finish any remaining elements */ for (; i < length; i++) { x = x * data[i]; } *dest = x; } parallel_combine

8 – 8 – 15-213, F’05 Role within Curriculum CS 211 Fundamental Structures CS 213 Systems CS 412 Operating Systems CS 411 Compilers Processes Mem. Mgmt Machine Code Optimization Data Structures Applications Programming CS 212 Execution Models CS 441 Networks Network Protocols ECE 447 Architecture ECE 349 Embedded Systems Exec. Model Memory System CS 113 C Programming


Download ppt "Introduction to Computer Systems Class 01 15-213 “The Class That Gives CMU Its Zip!” Randal E. Bryant August 30, 2005."

Similar presentations


Ads by Google