Slide 1Brief SummaryOn the DesignStyle for CodeStyle for Code and Alternative CodeStyle for Assembly Code: Version IStyle for Assembly Code: Version IILinux Command PromptStack and RegistersBar PlotTablesColor PaletteCarnegie MellonAbout the New Slides forIntroduction to Computer Systems15-213/18-243, spring 2009Markus PüschelElectrical and Computer EngineeringCarnegie MellonBrief SummaryIn spring 2009 I redesigned and unified almost the entire slide setCourse website: http://www.cs.cmu.edu/afs/cs/academic/class/15213-s09/www/Exceptions (see above website):Lecture 2: bits and bytesLecture 24: web servicesLecture 25: concurrencyLecture 27: Multi core architecturesSome slides that are in the ppt but were hidden for that termSome parts where updated and some material addedmostly program optimizations/floating point parts: lectures 9-12The website has also scanned notesincludes a few new visualizationsDo: ls *notes* in the lectures directoryCarnegie MellonOn the DesignAll slides are in Powerpoint 2007 (PC version)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 MellonStyle 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 MellonStyle 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 MellonStyle 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 MellonStyle 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 MellonLinux Command Promptlinux> ./badcntBOOM! cnt=198841183linux> ./badcntBOOM! cnt=198261801linux> ./badcntBOOM! cnt=198269672Carnegie MellonStack and RegistersReturn AddrSavedRegisters+LocalVariablesArgumentBuildOld %ebpArgumentsCallerFrame%ebp%esp%eax%edx%ecx%ebx%esi%edi%esp%ebpCaller-SaveCallee-SaveSpecialCarnegie MellonBar Plot2565121k2k4k8k16k32k64k128k256k00000.010.11101001000lower1 lower2CPU SecondsString LengthCarnegie MellonTablesMachine 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 Late ncy 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 MellonColor 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