1 / 34

Carnegie Mellon

Carnegie Mellon. Course Overview CSCi 2021 : Machine Architecture and Organization. Instructor: Prof. Jon Weissman Chapter 1 . Carnegie Mellon. Today. “Hello world” lecture Course theme and coverage Administrivia Gentle lead in: Chapter 1 (read this week).

katy
Télécharger la présentation

Carnegie Mellon

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Carnegie Mellon Course OverviewCSCi 2021: Machine Architecture and Organization Instructor: Prof. Jon Weissman Chapter 1

  2. Carnegie Mellon Today • “Hello world” lecture • Course theme and coverage • Administrivia • Gentle lead in: Chapter 1 (read this week)

  3. My Research/Teaching Interests? • Operating Systems – CSCi 4061 • Distributed Systems • High Performance Computing Like to build things, like to understand how things work Have varied interests, “east-coast” sense of humah Never taught 2021, but asked to teach it, bear with me …

  4. Acknowledgements • Antonia Zhai (UMn) • Chris Dovolis (UMn) • Randy Bryant, Dave O’Hallaron (CMU) • Provided some course content, slides, etc.

  5. 1902: Basic programming in Java class HelloWorldApp {      public static void main(String[]args){          System.out.println("Hello World!");     } } How to edit, compile, run, debug basic programs on a Linux system Basic program constructs and problem-solving Expect you to know about types, data-structures, control, procedure calls, library calls, basic I/O, algorithms

  6. Why 2021? • How does a program actually run on a computer? • Why is my program slow/fast, reliable/unreliable, secure/insecure, power efficient/inefficient? • performance: O(N) is only part of the story • Need to go deeper to answer these questions • Why do I need to learn C let alone some x86 assembly? • What is the Java interpreter written in? • How does my cell phone s/w interact with the camera, radio, speaker?

  7. Carnegie Mellon Memory (i.e. pointers) and C • C and C++ do not provide any memory protection • Out of bounds array references • Invalid pointer values • Allows one to write fast, compact, code • Can lead to nasty bugs • Whether or not bug has any effect depends on system and compiler • Action at a distance • Corrupted object logically unrelated to one being accessed • Effect of bug may be first observed long after it is generated • How can I deal with this? • Program in Java • Use or develop tools to detect referencing errors • Understand what possible interactions may occur

  8. OK, But why do I need to understand assembly? • Chances are, you’ll never write programs in assembly • Compilers are much better & more patient than you are • But: Understanding assembly is key to machine-level execution model • Behavior of programs in presence of bugs • High-level language models break down • Tuning program performance • Understand optimizations done / not done by the compiler • Understanding sources of program inefficiency • Creating / fighting malware • x86 assembly is the language of choice! • k % may want to do work in architecture …

  9. Carnegie Mellon Assembly Code Example • Time Stamp Counter • Special 64-bit register in Intel-compatible machines • Incremented every clock cycle • Read with rdtsc instruction • Application • Measure time (in clock cycles) required by procedure double t; start_counter(); P(); t = get_counter(); printf("P required %f clock cycles\n", t);

  10. Carnegie Mellon Code to Read Counter • Write small amount of assembly code using GCC’s asm facility • Inserts assembly code into machine code generated by compiler static unsigned cyc_hi = 0; static unsigned cyc_lo = 0; /* Set *hi and *lo to the high and low order bits of the cycle counter. */ void access_counter(unsigned *hi, unsigned *lo) { asm("rdtsc; movl %%edx,%0; movl %%eax,%1" : "=r" (*hi), "=r" (*lo) : : "%edx", "%eax"); }

  11. printf.o Course Goals Pre- processor (cpp) Compiler (cc1) Assembler (as) Linker (ld) hello.c hello.i hello.s hello.o hello Source program (text) Assembly program (text) Modified source program (text) Relocatable object programs (binary) Executable object program (binary) • De-mystify the inner workings of a computer and tools • grounded in computer architecture concepts • “cocktail party” • Understand the factors that impact performance, reliability, security, and other resource consumption (e.g. power) • Develop beginning competence in the systems programming language C • needed for a range of other courses: OS, networking

  12. What is this? Memory invisible to user code Kernel virtual memory User stack (created at runtime) Memory mapped region for shared libraries printffunction Run-time heap (created by malloc) Read/write data Loaded from the hello executable file Read-only code and data 0x08048000 (32) 0x00400000 (64) 0

  13. Busy, busy, busy • We’ll be busy (all of us) • Book reading, homeworks, projects, exams, keep coming, … • Time management will be key • Stay on top of things! • Form study groups as needed • Don’t stew • Ask questions, use the class forum (monitored by students and TAs) • Can’t do it all unless committed

  14. CPU Register file ALU PC System bus Memory bus Main memory Bus interface I/O bridge I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk hello executable stored on disk

  15. Administrivia

  16. Course Resources • Myself • Office hours: Fri (10:30-11:30) KH 4-225F • TAs (see website) • Marie • Emery • Class Website: http://www-users.cselabs.umn.edu/classes/Spring-2011/csci2021 Read for all policy information, schedule, and so on • Forum

  17. Carnegie Mellon Textbooks • Randal E. Bryant and David R. O’Hallaron, • “Computer Systems: A Programmer’s Perspective, Second Edition” Prentice Hall, 2011 • http://csapp.cs.cmu.edu • This book really matters for the course! • How to solve labs • Practice problems typical of exam problems • Some other C book as needed … • “The C Programming Language, Second Edition”, Prentice Hall, 1988 • Many others

  18. Carnegie Mellon Things to Avoid • Cheating • Sharing code: by copying, retyping, looking at, or supplying a file • Coaching: helping your friend to write a lab, line by line • Copying code from previous course or from elsewhere on WWW • High-level discussion is fine • Deal with harshly • Rudeness in class • Disruptive or distracting behavior to me or your classmates

  19. Lecture/Recitation Lecture: • Follow the book (more or less) • Take periodic “breaks” for in-class exercises • Create incentives for attendance Recitation: • Strongly recommend you go • C programming, Go over homeworks, Lab discussion

  20. Other Course Components • Written homework • problems from the book; good practice for exams • ~ 1 week (done alone) – 4 of them • Labs • Programming exercises – put ideas into practice “hands-on”; shows you are developing C programming skill with an eye towards performance, reliability, security, or other lower-level concerns • ~ 2 weeks (done alone or in groups) – 5 of them • Exams • Mix of conceptual and “nitty gritty” questions; shows that you have absorbed the important concepts in the course – 3 of them

  21. Carnegie Mellon Policies: Grading • Exams (30%): weighted 15%, 15%, 15% • Homework: weighted 20% • Labs (50%): weighted according to effort • Absolute scale along the lines: • > 90%: A • > 80%: B • > 70%: C • Late work/regrading policy on website – READ THEM

  22. Carnegie Mellon Programs and Data • Topics • Bits operations, arithmetic, C/assembly language programs (2+ weeks) • Representation of control and data structures (3 weeks) • Includes aspects of architecture and compilers • Assignments • L0 (C basics): Something simple • L1 (datalab): Manipulating bits • L2 (bomblab): Defusing a binary bomb

  23. Microarchitecture • Topics • Boolean Logic (.5 week) • ISA (1.5 weeks)

  24. Carnegie Mellon Performance • Topics • Co-optimization (control and data), measuring time on a computer (~ 2 weeks) • Includes aspects of architecture, compilers, and OS • Assignments • L3 (performance: bare metal or microarchitecture): TBD

  25. Carnegie Mellon The Memory Hierarchy + Virtual Memory • Topics • Memory technology, memory hierarchy, caches, disks, locality (1 week) • Virtual memory, address translation, dynamic storage allocation (1 week) • Includes aspects of architecture and OS • Assignments • L4 (memory): TBD

  26. Carnegie Mellon Miscellaneous • Topics • Exceptions (.5 week) • Linker, loader (1 week) • Advanced topic (.5 lecture) • Material > 1 week out is in flux

  27. Questions on Adminstrivia?

  28. Getting Started … Fundamentals • Computer System Concepts • Abstraction • What is it? Examples? • Hierarchy • What is it? Examples? • OS role • What is the role of the OS? • Locality • What is it? Examples? • Binary/Ascii

  29. Abstractions at the program level • Data-structures, types, control constructs • Make life easy, but … in most cases they are approximations of reality (inside the machine) • Numerics (int, float abstractions) • int is not an integer; float is not a real • finite precision

  30. Carnegie Mellon Example • Is x2 ≥ 0? • Float’s: Yes! • Int’s (32 bits): • 40000 * 40000 = 1600000000 • 50000 * 50000 = 2500000000 ??? • Cannot assume all mathematical properties • Commutativity, associativity, distributivity, and so on

  31. Carnegie Mellon RAM Abstraction • Finiteness: Memory is not unbounded • It must be allocated and managed • Memory referencing bugs especially pernicious • Effects are distant in both time and space! • Hierarchy: Memory performance is not uniform • Cache and virtual memory effects can greatly affect program performance • Adapting program to characteristics of memory system can lead to major speed improvements

  32. Carnegie Mellon Memory System Performance Example • Hierarchical memory organization • Performance depends on access patterns • Including how step through multi-dimensional array 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]; } 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]; } 21 times slower(Pentium 4)

  33. Next Time • How is information represented inside a computer? • Start reading Chapter 1, 2.1

  34. Welcome and Enjoy!

More Related