Intro C
Intro C
(CS541)
Arijit Mondal
CS541 1
Syllabus
CS541 2
Books to be followed
CS541 3
Evaluation policy
• Midsem: 30%
• Endsem: 50%
• Assignments/Quiz: 20%
CS541 4
Introduction
CS541 5
Abstraction of computing systems
Application
Physics
CS541 6
Abstraction of computing systems
Application
Algorithms
Physics
CS541 7
Abstraction of computing systems
Application
Algorithms
Programming language
Physics
CS541 8
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Physics
CS541 9
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Physics
CS541 10
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Microarchitecture
Physics
CS541 11
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Microarchitecture
Physics
CS541 12
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Microarchitecture
Gates
Physics
CS541 13
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Microarchitecture
Gates
Circuits
Physics
CS541 14
Abstraction of computing systems
Application
Algorithms
Programming language
Operating systems
Instruction set architecture
Microarchitecture
Gates
Circuits
Physics
CS541 15
Abstraction of computing systems
Application
CS541 16
Abstraction
CS541 17
Architecture vs Microarchitecture
CS541 18
Levels of Program Code
• High level language
g = h * i ;
Easy to code & debug
k = j + i ;
Close to problem domain g = h[1] ;
Provides productivity
CS541 19
Levels of Program Code
• High level language
g = h * i ;
Easy to code & debug
k = j + i ;
Close to problem domain g = h[1] ;
Provides productivity
compiler
CS541 19
Levels of Program Code
• High level language
g = h * i ;
Easy to code & debug
k = j + i ;
Close to problem domain g = h[1] ;
Provides productivity
compiler
CS541 19
Levels of Program Code
• High level language
g = h * i ;
Easy to code & debug
k = j + i ;
Close to problem domain g = h[1] ;
Provides productivity
compiler
CS541 19
Levels of Program Code
• High level language
g = h * i ;
Easy to code & debug
k = j + i ;
Close to problem domain g = h[1] ;
Provides productivity
compiler
CS541 19
Components of a Computer
CS541 20
Components of a Computer
CS541 20
Components of a Computer
CS541 20
Components of a Computer
CS541 20
Components of a Computer
CS541 20
IAS Computer
Arithmetic Logic
Unit
CS541 21
IAS Computer
Arithmetic Logic
Unit
Program control
Unit
CS541 22
IAS Computer
Arithmetic Logic
Unit
Main
Memory
Program control
Unit
CS541 23
IAS Computer
Arithmetic Logic
Unit
Main Input
Memory Output
Program control
Unit
CS541 24
IAS Computer
Arithmetic Logic
Unit
Main Input
Memory Output
Program control
Unit
CS541 25
Expanded structure of IAS Computer
Arithmatic logic unit (ALU)
AC MQ Input
Output
equipment
Arithmatic logic circuit
MBR
IBR PC
Main
Memory
IR MAR
Control Control
Circuits signals
CS541 26
Top level view of computer
CPU Main memory
Instruction
PC MBR Instruction
IR MAR
IOAR Data
Execution Data
Unit
IOBR Data
I/O Module
Buffers
CS541 27
Basic instruction cycle
CS541 28
Machine Model
Stack Accumulator Reg−Mem Reg−Reg
Processor
Processor
Processor
Processor
Memory
Memory
Memory
Memory
push A load A load r1, A load r1,A
push B add B add r3,r1, B load r2,B
add store C store r3, C add r3,r2,r1
pop C store r3,c
CS541 29
Understanding Performance
• Algorithms
Determines number of operation executed
• Programing language, compiler, architecture
Determine number of machine instructions is executed per operation
• Processor and memory systems
Determines how fast instructions are executed
• I/O systems
Determines how fast I/O operations are performed
CS541 30
Performance
• Response time
How long it takes to finish a task
• Throughput
Total workdone per unit time (eg. task/transaction/per hour)
• Dependency of response time and throughput
Replacing the processor with a faster version?
Adding more processors?
CS541 31
Relative performance
CS541 32
Measuring performance
CS541 33
CPU clocking
CS541 34
CPU Time
CS541 35
Example
CS541 36
Instruction count and CPI
CS541 37
CPI example
CS541 38
CPI in more detail
CS541 39
CPI example
Instruction A B C
CPI for instruction 1 2 3
IC in Sequence 1 2 1 2
IC in Sequence 2 4 1 1
CS541 40
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance summary
CS541 41
Performance: Power
CS541 42
MIPS as performance metric
CS541 43
Multiprocessors
• Multicore multiprocessors
More than one processor per chip
• Requires explicit parallel programming
Instruction level parallelism
◦ Hardware executes multiple instructions simultaneously
◦ Hidden from programmer
Hard to do
◦ Programming for performance
◦ Load balancing
◦ Optimizing communication and synchronization
CS541 44
Conclusion
• Cost/performance is improving
Due to underlying technology development
• Hierarchical layer of abstraction
In both hardware and software
• Instruction set architecture
The Hardware/Software interface
• Execution time – measure of performance
• Power is a limiting factor
Use parallelism to improve performance
CS541 45