final review
play

Final Review CS304 Introduc2on to C Why C? Difference - PowerPoint PPT Presentation

Final Review CS304 Introduc2on to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is


  1. Final ¡Review ¡ CS304 ¡

  2. Introduc2on ¡to ¡C ¡ • Why ¡C? ¡ • Difference ¡between ¡Python ¡and ¡C ¡ • C ¡compiler ¡stages ¡ • Basic ¡syntax ¡in ¡C ¡

  3. Pointers ¡ • What ¡is ¡a ¡pointer? ¡ – declara@on, ¡&, ¡dereference ¡... ¡ • Pointer ¡& ¡dynamic ¡memory ¡alloca@on ¡ – Virtual ¡memory ¡ • Pointer ¡& ¡arrays ¡ – Rela@onship ¡between ¡pointer ¡and ¡array ¡name ¡ – sizeof, ¡strlen... ¡ • Pointer ¡arithme@c ¡ – *(array_ptr++) ¡and ¡(*array_ptr)++ ¡ ¡ – [] ¡and ¡* ¡ – pointers ¡to ¡arrays ¡and ¡array ¡of ¡pointers ¡

  4. Pointers ¡ • Pointer ¡& ¡func@ons ¡ – passing ¡by ¡value ¡& ¡passing ¡by ¡reference ¡ – func@on ¡pointers ¡ • Pointer ¡& ¡structures ¡ • Struct ¡declara@on ¡and ¡defini@on ¡ – #define ¡and ¡typedef ¡ – access ¡struct ¡with ¡pointers ¡ – offsetof ¡ ¡

  5. Introduc2on ¡to ¡Computer ¡Organiza2on ¡ • Three ¡layers ¡in ¡computer ¡system ¡ – soTware/os/hardware ¡ • Hardware ¡organiza@on ¡ – Von ¡Neumann ¡Architecture ¡ – virtual ¡memory ¡and ¡cache ¡hierarchy ¡ • What ¡will ¡happen ¡if ¡we ¡type ¡a ¡linux ¡command ¡ in ¡command ¡line? ¡

  6. Informa2on ¡Representa2on ¡ • Number ¡systems ¡ – Decimal, ¡Binary, ¡Hexadecimal, ¡Octal, ¡base-­‑10 ¡ • Two ¡important ¡limita@ons ¡ – Overflow, ¡accuracy ¡ • Informa@on ¡storage ¡and ¡byte ¡order ¡ – interpreta@on ¡is ¡important ¡ – word ¡size ¡ – byte ¡ – big ¡endian ¡and ¡li^le ¡endian ¡

  7. Integers ¡ • Why ¡low ¡level ¡representa@on? ¡ • B2U, ¡B2T, ¡B2O, ¡B2S ¡ – range ¡& ¡min, ¡max ¡ • Signed ¡vs. ¡unsigned ¡ • Integer ¡opera@ons ¡ – sign ¡extend, ¡trunca@on, ¡addi@on, ¡nega@on, ¡ mul@plica@on, ¡division ¡ – overflow, ¡mul@plica@on ¡by ¡constant, ¡division ¡by ¡power ¡ of ¡2, ¡rounding ¡ – shiT ¡and ¡bit ¡opera@ons ¡

  8. Floa2ng ¡Point ¡Numbers ¡ • Binary ¡floa@ng ¡point ¡ ¡ • IEEE-­‑754 ¡format ¡ – single ¡precision: ¡ ¡ • 1[31]-­‑sign, ¡8[30-­‑23]-­‑exponent, ¡23[22-­‑0]-­‑frac@on, ¡127-­‑bias ¡ ¡ • Normalized ¡& ¡special ¡values ¡ – 0, ¡subnormal ¡(de-­‑normalized), ¡+/-­‑infinity, ¡NaN ¡ – bias, ¡hidden ¡bit ¡ • Range ¡and ¡precision ¡ • Rounding, ¡cas@ng, ¡special ¡opera@ons ¡

  9. Assembly ¡Programming: ¡Y86 ¡ • Introduc@on ¡to ¡assembly ¡programming ¡ – Why ¡assembly ¡code? ¡ – Opera@ons ¡and ¡visible ¡states ¡in ¡assembly ¡ programming ¡ – Concept ¡of ¡ISA ¡and ¡CPU ¡cycle ¡ • Introduc@on ¡to ¡Y86 ¡ – Visible ¡states ¡in ¡Y86, ¡registers, ¡memory, ¡cc, ¡PC, ¡ program ¡status ¡

  10. Assembly ¡Programming: ¡Y86 ¡ • Y86 ¡instruc@ons ¡ – assembler ¡direc@ves ¡ – status ¡condi@ons ¡and ¡excep@ons ¡ ¡ – instruc@ons ¡(opera@ons, ¡branches, ¡and ¡moves) ¡ – stack ¡opera@ons ¡ – subrou@ne ¡call/return ¡ • Y86 ¡encoding ¡ • Y86 ¡instruc@on ¡execu@on ¡

  11. Assembly ¡Programming: ¡IA32 ¡ • Introduc@on ¡to ¡IA32 ¡ – RISC ¡and ¡CISC ¡(Y86 ¡R ¡or ¡C, ¡IA32 ¡R ¡or ¡C?) ¡ ¡ – IA32 ¡visible ¡states ¡ • IA32 ¡opera@ons ¡ – Data ¡movement ¡ ¡ • addressing ¡modes: ¡absolute, ¡indirect, ¡base+displacement, ¡and ¡indexed ¡ • suffix: ¡extend ¡and ¡truncate ¡ – Stack ¡and ¡func@on ¡opera@ons ¡ • basic ¡stack ¡push ¡and ¡pop; ¡func@on ¡call ¡and ¡return ¡ • how ¡to ¡maintain ¡the ¡stack ¡frame ¡for ¡procedure ¡calls ¡ • register ¡usage ¡conven@ons ¡ • recursive ¡procedures ¡

  12. Assembly ¡Programming: ¡IA32 ¡ • IA32 ¡opera@ons ¡(con@nue) ¡ – Arithme@c ¡and ¡logic ¡opera@ons ¡ • LEA! ¡ – Compare ¡and ¡jump ¡ • control ¡flow ¡and ¡data ¡flow ¡ • cc ¡and ¡how ¡to ¡set ¡cc: ¡cmp ¡and ¡test ¡ • how ¡to ¡use ¡cc: ¡set, ¡jmp ¡and ¡cmov ¡ • control ¡structures: ¡select, ¡loop, ¡switch ¡(jump ¡table) ¡ ¡

  13. Assembly ¡Programming: ¡IA32 ¡ • IA32 ¡instruc@on ¡encoding ¡ – general ¡format ¡ – ModR/M ¡ – SIB ¡part ¡(no@ce ¡the ¡endian ¡problem) ¡ • Array ¡and ¡structures ¡alloca@on ¡and ¡access ¡ – rela@onship/conversion ¡between ¡c ¡and ¡IA32 ¡ – Data ¡alignment ¡issue ¡

  14. Cache ¡ • Concept ¡of ¡memory ¡hierarchy ¡ – Why ¡we ¡design ¡memory ¡hierarchy? ¡ – Data ¡locality: ¡spa@al ¡and ¡temporal ¡ • Concept ¡of ¡cache ¡ – mapping ¡and ¡replacement ¡ – cache ¡hit ¡and ¡cache ¡miss ¡ • cold ¡miss, ¡conflict ¡miss ¡and ¡capacity ¡miss ¡ – loca@on ¡of ¡the ¡cache ¡in ¡the ¡computer ¡organiza@on ¡

  15. Cache ¡ • Cache ¡organiza@on ¡ – C ¡= ¡S ¡* ¡E ¡* ¡B ¡ – tag/set/block ¡ – direct-­‑mapped ¡and ¡E-­‑way ¡set ¡associa@ve ¡cache ¡ • Cache ¡write ¡ – write-­‑through ¡+ ¡no-­‑write-­‑allocate ¡ – write-­‑back ¡+ ¡write-­‑allocate ¡ • Trade-­‑offs ¡in ¡cache ¡design ¡ – cache ¡size, ¡block ¡size, ¡set ¡associa@ve, ¡and ¡write ¡polity ¡ • Cache ¡performance ¡metrics ¡ – Miss ¡rate, ¡hit ¡@me, ¡miss ¡penalty ¡

  16. Cache ¡ • Cache ¡and ¡code ¡op@miza@on ¡ – focus ¡on ¡the ¡kernel, ¡especially ¡inner-­‑loop ¡of ¡the ¡kernel ¡ – improve ¡temporal ¡locality ¡and ¡spa@al ¡locality ¡ • memory ¡mountain ¡ – read ¡throughput/bandwidth ¡ – stride ¡ à ¡spa@al ¡locality ¡ – size ¡ à ¡temporal ¡locality ¡ • matrix ¡mul@plica@on ¡ – loop ¡interchange/permuta@on/rearranging ¡ à ¡spa@al ¡ locality ¡ – matrix ¡blocking/@ling ¡ à ¡temporal ¡locality ¡

  17. Exam ¡format ¡ • True ¡or ¡false ¡(10 ¡pts) ¡ – Ex. ¡IA32 ¡belongs ¡to ¡CISC ¡ • Mul@ple ¡choice ¡(10 ¡pts) ¡ – basic ¡concepts ¡ • Short ¡answer ¡(20 ¡pts) ¡ – instruc@on ¡encoding ¡and ¡instruc@on ¡execu@on ¡ – code ¡reading/wri@ng ¡ • Code ¡evalua@on ¡(60 ¡pts) ¡ – code ¡reading, ¡explain ¡and ¡fill ¡in ¡blanks ¡ – conversion ¡between ¡C ¡and ¡Y86 ¡(or ¡IA32) ¡ – cache ¡impact ¡on ¡program ¡performance ¡ • Extra ¡bonus ¡(10 ¡pts) ¡ – code ¡op@miza@ons ¡with ¡computer ¡organiza@on ¡knowledge ¡

  18. Sugges2ons ¡ • slides! ¡ • textbook! ¡ • Labs ¡& ¡HWs! ¡ • “reading ¡assignments” ¡and ¡“self-­‑study” ¡contents ¡on ¡ our ¡website ¡ • Prac@ce ¡problems ¡on ¡our ¡website ¡ • Don’t ¡forget ¡to ¡prepare ¡for ¡a ¡le^er-­‑size ¡double-­‑side ¡ cheat ¡sheet ¡(must ¡contain: ¡Y86/IA32 ¡encoding) ¡ • Please ¡take ¡our ¡course ¡evalua@on ¡whenever ¡you ¡ have ¡@me ¡before ¡April ¡28 th . ¡

  19. Thanks ¡for ¡taking ¡this ¡class, ¡and ¡good ¡ luck ¡with ¡all ¡your ¡finals! ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend