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

Similar documents
M2 Instruction Set Architecture

Lecture 3: C Programm

Lecture 3: Instruction Set Architecture

CSC 1600 Memory Layout for Unix Processes"

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

Lecture 2: C Programm

Introduction to Computer Systems

PROGRAM COMPILATION MAKEFILES. Problem Solving with Computers-I

ENCE Computer Organization and Architecture. Chapter 1. Software Perspective

Introduction to Computer Systems

Introduction to Computer Systems

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory

Chris Riesbeck, Fall Introduction to Computer Systems

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

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

TDDB68 Concurrent Programming and Operating Systems. Lecture 2: Introduction to C programming

Lectures 5-6: Introduction to C

Memory and C/C++ modules

Introduction Presentation A

Programming refresher and intro to C programming

Programming. Data Structure

Computer Systems A Programmer s Perspective 1 (Beta Draft)

CS 61C: Great Ideas in Computer Architecture Introduction to C

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

Executables and Linking. CS449 Spring 2016

Hardware Address Binding Memory Allocation References. Physical Memory. Daniel Bosk 1

Introduction to Supercomputing

Topic 6: A Quick Intro To C

ABSTRACTION ISN T THE ENTIRE STORY

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

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Computer Systems Organization

CS240: Programming in C. Lecture 2: Overview

Bilgisayar Sistemlerine Genel Bakış

Lecture 03 Bits, Bytes and Data Types

PRINCIPLES OF OPERATING SYSTEMS

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

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder

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

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

Kampala August, Agner Fog

Under the Hood: Data Representations, Memory and Bit Operations. Computer Science 104 Lecture 3

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

CSE 12 Spring 2016 Week One, Lecture Two

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

CS Programming In C

CO200 Computer Organization and Architecture

Outline. Unresolved references

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

Lecture 1: Course Overview

Introduction to Supercomputing

Final CSE 131B Spring 2004

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers

Course Information and Introduction

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Week 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals. Alvin Valera. School of Engineering and Computer Science Victoria University of Wellington

Compilation, Disassembly, and Profiling (in Linux)

LAB 6 (2017 June 22/27) Array of pointers. Dynamic memory allocation.

Run-time Environments - 3

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

Lectures 5-6: Introduction to C

Technical Questions. Q 1) What are the key features in C programming language?

High Performance Computing and Programming, Lecture 3

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

CSE 12 Spring 2018 Week One, Lecture Two

Class Information ANNOUCEMENTS

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

... Lecture 10. Concepts of Mobile Operating Systems. Mobile Business I (WS 2017/18) Prof. Dr. Kai Rannenberg

Memory and C++ Pointers

A Simplistic Program Translation Scheme

Executables and Linking. CS449 Fall 2017

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

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Page 1. Agenda. Programming Languages. C Compilation Process

Lecture 8: linking CS 140. Dawson Engler Stanford CS department

CMPE-013/L. Introduction to C Programming

COMPILING OBJECTS AND OTHER LANGUAGE IMPLEMENTATION ISSUES. Credit: Mostly Bryant & O Hallaron

EC 413 Computer Organization

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 6

Run Time Environment

Department of Computer Science and Engineering Yonghong Yan

ECEN 449 Microprocessor System Design. Review of C Programming

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

Dynamic Memory Allocation and Command-line Arguments

Processes. Johan Montelius KTH

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

#include <stdio.h> int main() { printf ("hello class\n"); return 0; }

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

A process. the stack

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2

Plan of the lecture. Quick-Sort. Partition of lists (or using extra workspace) Quick-Sort ( 10.2) Quick-Sort Tree. Partitioning arrays

COS 318: Operating Systems

CS2141 Software Development using C/C++ Debugging

Programming Languages

Machine-Level Programming V: Unions and Memory layout

Introduction Slide 1/20. Introduction. Fall Semester. Parallel Computing

Transcription:

High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science

Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation (4) 2. Computer organization: Memory, Registers, Instruction set architecture, Instruction processing (6) 3. Virtual memory: Address translation, Paging (4) 4. Operating system: Processes, System calls, Process management (6) 5. Pipelined processors: Structural, data and control hazards, impact on programming (4) 6. Cache memory: Organization, impact on programming (5) 7. Program profiling (2) 8. File systems: Disk management, Name management, Protection (4) 9. Parallel programming: Inter-process communication, Synchronization, Mutual exclusion, Parallel architecture, Programming with message passing using MPI (5) 2

Reference Material Patterson and Hennessy, Computer Organization and Design: The Hardware/Software Interface, 4 th Edition ARM Edition, Morgan Kaufman Publishers, 2010. Silberschatz, Galvin and Gagne, Operating System Concepts, 8 th Edition, John Wiley & Sons, Inc, 2008. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Addison Wesley, 2002. 3

Course Objective To understand what happens on a computer system during program execution Why? In order to improve the quality of the programs that you write 4

What is a Computer Program? Description of algorithms and data structures to achieve a specific objective Could be done in any language, even a natural language like English Programming language: A Standard notation for writing programs Examples: C, Java, Intel assembly language An extreme example: Machine language Hence the need for program translators Example: gcc 5

What does gcc do for you? % gcc hello.c hello.c gcc a.out source : Program that you wrote in the C language and typed into the file hello.c object : File generated by gcc. The a.out file contains an equivalent program in machine language that can be executed on a computer system 6

Steps in gcc cpp, cc1, as, ld Temporary files are generated in between for use by the next step 7

Steps in gcc. hello.c cpp cc1 hello.s as hello.o ld Library files e.g., math.o, the math library a.out 8

Steps in gcc.. The a.out file has a well defined format i.e., you can open an a.out file and find specific information or data at specified places What does the a.out file contain? Program code (machine instructions) Data values (values, size of arrays) Other information that is needed for execution debugging Debugging: A stage in program development where you are identifying the mistakes ( bugs ) in your program 9

Example #include <stdio.h> #include <math.h> float arr[100]; int size=100; void main() { int i; float sum; for (i=0, sum=0.0; i<size; i++) { arr[i] = sqrt(arr[i]); sum += arr[i]; } printf ("sum is %f\n",sum); } 10

Object file format Header Info Machine Code Initialized Data Symbol Table Relocation Info 11

Format of the Object File Header Info. 0 4 94 4 Machine Code Size Initialized Data size 8 400 Uninitialized Data size 12 60 Symbol Table 16?? Relocation Info Machine Code 20?? Start of main; Code for first instruction 66?? code for call sqrt 12

Format of the Object File Init. Data 114 100 -- Initialized Data 118 XX size Name of symbol size and its address 130 YY arr Name of symbol arr and its address Symbol Table 142 ZZ main Name of symbol main & its address 154?? Sqrt Name of symbol sqrt and its address 166?? printf Name of symbol printf & its address Relocation Info 178?? Info. on offsets at which external variables are called 13

Steps in gcc. hello.c cpp cc1 hello.s as hello.o ld Library files e.g., math.o, the math library a.out 14

Steps in gcc. hello.c cpp cc1 hello.s as hello.o ld Library files e.g., math.o, the math library ld Linkage editor a.out Merges 2 or more object files into one 15

Linking Multiple Modules Header Info Compute(){ call MatMul() } Data Symbol Table Reloc Info Header Info MatMul(){ } Data Symbol Table Reloc Info 16

Linking Multiple Modules Header Info Compute(){ call MatMul } Data Symbol Table Relocation Info Header Info MatMul(){ } Combined Header Info Compute() MatMul() Combined Data Symbol Table Reloc Info Data Symbol Table Relocation Info 17

Program = Instructions + Data We will next learn more about data 18

There are different kinds of data How does one piece of data differ from another? Constant vs variable Basic vs structured Of different types Character Integer (unsigned, signed) Real Others (boolean, complex, ) 19

Data differing in their lifetimes Lifetime: Interval between time of creation and end of existence How long can the lifetime of a datum be? We will consider 3 possible lifetimes 20

Program Data: Different Lifetimes. 1. Lifetime = Execution time of program Initialized/uninitialized data Must be indicated in executable file The space for all of this data can be assigned when program execution starts (Static Allocation) 21

Program Data: Different Lifetimes. 1. Lifetime = Execution time of program 2. Lifetime = Time between explicit creation of data & explicit deletion of data Dynamic memory allocation In C you create new data using a function like malloc() The space for this data is managed dynamically when the malloc/free is executed (Heap allocation) 22

Program Data: Different Lifetimes.. 1. Lifetime = Execution time of program 2. Lifetime = Time between explicit creation of data & explicit deletion of data 3. Lifetime = During execution of a function (i.e., time between function call and return) Local variables, parameters of the function The space for this data is assigned when the function is called and reclaimed on return from the function (Stack allocation) Stack: Like a pile of books on a table 23

Stack allocated: Function Local Variables When the program starts executing Local Variables of main Top of Stack Pointer What if main() then calls function func1()? 24

Stack allocated: Function Local Variables. While executing in function func1() Local variables of func1 Top of Stack Pointer Other info about function call Local Local Variables of of main What happens on return from the call to func1()? 25

Stack allocated: Function Local Variables.. Executing in main() once again Local Variables of main Top of Stack Pointer 26

During program execution Code (machine language program) Data (initialized and uninitialized) Code and Data don t change in size while the program is executing Heap (for dynamically allocated data) Stack (for function local variables) Heap and Stack change in size as program executes Code Initialized Uninitialized Heap Stack 27

How is Data Represented? On a digital computer Binary Base 2 number system Two values: 0 and 1 Bit (Notation: b); Byte (Notation: B) 8 bits Other notation: K, M, G, T, P etc K: 2 10, M: 2 20, G: 230, etc 2 GB of RAM, 1 TB hard disk drive 28

Character Data Typically represented using the ASCII code ASCII: American Standard Code for Information Interchange Each character is represented by a unique 8 bit ASCII code word Example: a is represented by 01100001, 1 is represented by 00110001 29

How is Data Represented? Character data: ASCII code Integer data 30