Lecture 1: Course Overview

Similar documents
Course Overview CSCE 312. Instructor: Daniel A. Jiménez. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

ABSTRACTION ISN T THE ENTIRE STORY

Great Reality #2: You ve Got to Know Assembly Does not generate random values Arithmetic operations have important mathematical properties

Course Overview. Jo, Heeseung

Digital Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to Computer Systems: Semester 1 Computer Architecture

Introduction to Computer Systems

Introduction to Computer Systems

Computer Organization - Overview

Introduction Presentation A

Course Overview. CSCI 224 / ECE 317: Computer Architecture. Instructors: Prof. Jason Fritts. Slides adapted from Bryant & O Hallaron s slides

Introduction to Computer Systems /18 243, Spring st Lecture, Aug. 25 th. The course that gives CMU its Zip!

Overview. Course Overview and Introduction

The Hardware/Software Interface CSE351 Spring 2013 (spring has sprung!)

Overview of the ECE Computer Software Curriculum. David O Hallaron Associate Professor of ECE and CS Carnegie Mellon University

Memory Hierarchy. Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3. Instructor: Joanna Klukowska

Memory Hierarchy. Cache Memory Organization and Access. General Cache Concept. Example Memory Hierarchy Smaller, faster,

Introduction to Computer Architecture. Meet your Colleagues. Course Theme CISC Michela Taufer September 4, 2008

Dynamic Memory Allocation

CS241 Computer Organization Spring

Systems Programming and Computer Architecture ( )

: Computer Architecture

Memory hierarchies: caches and their impact on the running time

The Hardware/Software Interface CSE351 Spring 2015

Floating Point Numbers

Floating Point Numbers

Introduction to Computer Systems

Most of the slides in this lecture are either from or adapted from slides provided by the authors of the textbook Computer Systems: A Programmer s

Systems Programming and Computer Architecture ( )

Read-only memory (ROM): programmed during production Programmable ROM (PROM): can be programmed once SRAM (Static RAM)

VM as a cache for disk

Chris Riesbeck, Fall Introduction to Computer Systems

Introduction to Computer Systems

Introduction to Computer Systems

Bits, Bytes and Integers

Machine Level Programming: Arrays, Structures and More

Introduction to System Programming Course 2015 Spring Euiseong Seo

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Machine Level Programming: Control

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Fundamentals of Programming Session 12

Machine Level Programming: Basics

User Defined Functions

Introduction to Computer Systems

Dynamic Memory Allocation I

Machine Level Programming: Basics

Chapter 11 Introduction to Programming in C

Course Overview Computer Science 104: Machine Organiza;on and Programming. Overview 1/12/11

AMCAT Automata Coding Sample Questions And Answers

Cost of Your Programs

HW1 due Monday by 9:30am Assignment online, submission details to come

LC-3 Assembly Language

Introduction to Computer Systems

Chapter 11 Introduction to Programming in C

Lecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings

COS 318: Operating Systems

Many of the following slides are taken with permission from. The book is used explicitly in CS 2505 and CS 3214 and as a reference in CS 2506.

Kampala August, Agner Fog

o Code, executable, and process o Main memory vs. virtual memory

COMP26120: Pointers in C (2018/19) Lucas Cordeiro

ESC101N: Fundamentals of Computing End-sem st semester

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Hacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019

Chapter 11 Introduction to Programming in C

CS 3330 Introduction. Daniel and Charles. CS 3330 Computer Architecture 1

X86 64 Assembly Language Programming With Ubuntu Unlv

Project 0: Implementing a Hash Table

Chapter 11 Introduction to Programming in C

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

Computer Systems A Programmer s Perspective 1 (Beta Draft)

What s next. Computer Systems A Programmer s Perspective

Code Optimization & Performance. CS528 Serial Code Optimization. Great Reality There s more to performance than asymptotic complexity

Review! Lecture 5 C Memory Management !

CS61C : Machine Structures

COS 318: Operating Systems

Arrays in C C Programming and Software Tools. N.C. State Department of Computer Science

Lecture 5-6: Bits, Bytes, and Integers

Syllabus of ENPM 691: Secure Programming in C

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

CS Prof J.P.Morrison

Profilers and Debuggers. Introductory Material. One-Slide Summary

CSCI-UA /2. Computer Systems Organization Lecture 19: Dynamic Memory Allocation: Basics

Introduction to Computer Systems

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Chapter 11 Introduction to Programming in C

Lecture 19: Virtual Memory: Concepts

Code Optimization September 27, 2001

CSE 4/521 Introduction to Operating Systems

Chapter 11 Introduction to Programming in C

! Must optimize at multiple levels: ! How programs are compiled and executed , F 02

Welcome to... CS113: Introduction to C

CS61C : Machine Structures

COMP 321: Introduction to Computer Systems

Great Reality #4. Code Optimization September 27, Optimizing Compilers. Limitations of Optimizing Compilers

Pointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables

Nested Loops. A loop can be nested inside another loop.

CS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers

Pointers (continued), arrays and strings

Chapter 11 Introduction to Programming in C

Transcription:

Lecture 1: Course Overview Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran (NYU)

Well, not that kind of organization

Abstraction is good, but... Most CS and CE courses emphasize abstraction Abstract data types Asymptotic analysis (like the Big-O notation) These abstractions have limits Especially in the presence of bugs Need to understand details of underlying implementations Useful outcomes from taking CS201 Become more effective programmers Able to find and eliminate bugs efficiently Able to understand and tune for program performance Prepare for later systems classes in CS Compilers, Operating Systems, Networks, Computer Architecture, Embedded Systems, etc.

This class adds to your CV: C programming Unix / Linux familiarity X86-64 assembly Low level debugging Reverse engineering Understanding of computer systems...

Programmers' Reality #1: ints are not integers, floats/doubles are not real numbers Is x 2 >= 0? in a math class: YES (when x is an integer or a real number) on a computer: IT DEPENDS on x for example: when x is an int 30,000 * 30,000 = 900,000,000 50,000 * 50,000 =??? Is (x+y) + z = x + (y+z)? in math class: YES (when x is an integer or a real number) on a computer: IT DEPENDS on x, y, z for example: when x, y, z are of type float (1e20 + -1e20) + 3.14 = 3.14 1e20 + ( -1e20 + 3.14) =???

32,767 + 1 = -32,766

Programmers' Reality #2: you need to know 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 Debugging Performance tuning Writing system software (e.g. compilers, OS) Reverse engineering software Creating / fighting malware

Programmers' Reality #3: memory matters Memory is not unbounded It must be allocated and managed All running applications and data have to be in memory, all applications can address lots of memory. Where does it all go? Memory referencing bugs especially wicked Effects are distant in both time and space (i.e., may not happen until much later or in a different part of the program or data structure) Memory performance is not uniform Cache and virtual memory effects can greatly affect program's performance Adapting program to characteristics of memory system can lead to major speed improvements

Example: Array access #include <stdio.h> int main ( ) { int d = 3; printf("d = %d\n", d); int a[1]; int i; for (i = 0; i < 5; i ++ ) { a[i] = 214748364; } printf("d = %d\n", d); } OUTPUT (one possibility): d = 3 d = 214748364

Memory referencing errors C and C++ do not provide any memory protection Out of bounds array references Invalid pointer values Abuses of malloc/free 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, Ruby, Python, ML, Understand what possible interactions may occur Use or develop tools to detect referencing errors (e.g. Valgrind)

Programmers' Reality #4: there is more to performance than asymptotic analysis (But do not tell your teachers in Data Structures and Algorithms courses that I said that!) Constant factors matter too! Optimization has to happen at multiple levels: algorithm, data representation, details of implementation. Optimizing implementation requires understanding of the underlying system. How programs are compiled and executed How to measure program's performance and identify bottlenecks How to improve performance without destroying code modularity and generality

Example: What is Big-O notation of these two programs? 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]; } About 7 times faster on Intel Core i7-3930k CPU @ 3.20GHz 12. WHY?

Programmers' Reality #5: computers do more than execute programs They need to get data in and out I/O system critical to program reliability and performance They communicate with each other over networks Many system-level issues arise in presence of network