Slide 1On the DesignSlide 3TodayStyle for Figure LabelsStyle for CodeStyle for Code and Alternative CodeStyle for Assembly Code: Version IStyle for Assembly Code: Version IILinux Command PromptStack and RegistersBar PlotTablesColor PaletteCarnegie Mellon1About the New Slides forIntroduction to Computer Systems15-213/18-243: Introduction to Computer Systems0th Lecture, Aug. 24, 2010Markus PüschelElectrical and Computer Engineering(with small contributions by Dave O’Hallaron)Carnegie Mellon2On the DesignAll slides are in Powerpoint 2007 (mix of PC and Mac versions)Probably could be edited using Powerpoint 2003 plusFile format pluginCalibri fontI would still recommend to use 2007 for editingDesign is suitable for printing out slidesOnly light colors, in particular for boxesSome slides have covered areas (that disappear later) suitable for quizzing in classThe design follows the Small Guide to Giving PresentationsNext slides: Color/format conventionsCarnegie Mellon3System-Level I/O15-213/18-243: Introduction to Computer Systems14th Lecture, Oct. 12, 2010Instructors: Randy Bryant and Dave O’HallaronStyle for title slidesCarnegie Mellon4TodayUnix I/ORIO (robust I/O) packageMetadata, sharing, and redirectionStandard I/OConclusions and examplesStyle for outliningCarnegie Mellon5Style for Figure LabelsCapitalize only the first word in each figure labelE.g., “Payload and padding”, not “Payload and Padding”, or “payload and padding”This is the same style convention that we used in CS:APP2e.SizeFormat ofallocated andfree blocksPayload andpaddinga = 1: Allocated block a = 0: Free blockSize: Total block sizePayload: Application data(allocated blocks only)aSize aBoundary tag(footer)HeaderCarnegie Mellon6Style for Code/* * hello.c - Pthreads "hello, world" program */#include "csapp.h"void *thread(void *vargp);int main() { pthread_t tid; Pthread_create(&tid, NULL, thread, NULL); Pthread_join(tid, NULL); exit(0);}/* thread routine */void *thread(void *vargp) { printf("Hello, world!\n"); return NULL;}Carnegie Mellon7Style for Code and Alternative CodeC Codeint fact_do(int x){ int result = 1; do { result *= x; x = x-1; } while (x > 1); return result;}Goto Versionint fact_goto(int x){ int result = 1;loop: result *= x; x = x-1; if (x > 1) goto loop; return result;}Carnegie Mellon8Style for Assembly Code: Version Iint absdiff(int x, int y){ int result; if (x > y) { result = x-y; } else { result = y-x; } return result;}absdiff:pushl %ebpmovl %esp, %ebpmovl 8(%ebp), %edxmovl 12(%ebp), %eaxcmpl %eax, %edxjle .L7subl %eax, %edxmovl %edx, %eax.L8:leaveret.L7:subl %edx, %eaxjmp .L8Body1SetupFinishBody2Carnegie Mellon9Style for Assembly Code: Version IIstruct rec { int i; int a[3]; int *p;}; # %edx = rmovl (%edx),%ecx # r->ileal 0(,%ecx,4),%eax # 4*(r->i)leal 4(%edx,%eax),%eax # r+4+4*(r->i)movl %eax,16(%edx) # Update r->pvoid set_p(struct rec *r){ r->p = &r->a[r->i];}Carnegie Mellon10Linux Command Promptlinux> ./badcntBOOM! cnt=198841183linux> ./badcntBOOM! cnt=198261801linux> ./badcntBOOM! cnt=198269672Carnegie Mellon11Stack and RegistersReturn addrSavedregisters+LocalvariablesArgumentbuildOld %ebpArgumentsCallerFrame%ebp%esp%eax%edx%ecx%ebx%esi%edi%esp%ebpCaller-saveCallee-saveSpecialCarnegie Mellon12Bar Plot2565121k2k4k8k16k32k64k128k256k00000.010.11101001000lower1 lower2CPU SecondsString LengthCarnegie Mellon13TablesMachine Nocona Core 2rfact 15.5 6.0fact 10.0 3.0Cycles per element (or per mult)Method Int (add/mult) Float (add/mult)combine4 2.2 10.0 5.0 7.0unroll2 1.5 10.0 5.0 7.0unroll2-ra 1.56 5.0 2.75 3.62bound 1.0 1.0 2.0 2.0Some instructions take > 1 cycle, but can be pipelinedInstruction Latency Cycles/IssueLoad / Store5 1Integer Multiply 10 1Integer/Long Divide 36/106 36/106Single/Double FP Multiply 7 2Single/Double FP Add 5 2Single/Double FP Divide 32/46 32/46Carnegie Mellon14Color PaletteBoxes/areas:Assembly, memory, …Linux, memory, …Code, …Code, registers, …Registers, …Memory, …Memory, …Occasionally I use darker versions of the colors aboveText:Emphasizing something in the textComments inside yellow code
View Full Document