Course: Software analysis and optimization

18
Course: Software analysis and optimization Course: Software analysis and optimization Peng-Sheng Chen

Transcript of Course: Software analysis and optimization

Course: Software analysis and optimization

Course: Software analysis and optimization

Peng-Sheng Chen

2

IntroductionIntroduction

• 課程名稱:軟體分析與最佳化

• 科目代碼:4105813

• 時間:遠距教學 (非同步/同步)

Tuesday (C, D) 10:15~13:00

• 教室:創新大樓322

3

TargetTarget

• Use performance tools to analyze applications and

improve their performance

• Determine which portions of an application should

be given higher priority for optimizations

• Identify the reasons that certain portions of your

application are slower than they should be

4

TopicsTopics

• Performance tool

VTune, Gprof, Valgrind, Intel C/C++ compiler, GCC, …

• Performance issues

Branching / Memory

Loops

Slow operations / Floating point

SIMD

Multithreading / OpenMP / Thread-level speculation

• Workload analyses

Design for performance / Putting it together

Case study

• Theoretical study

Data-flow analysis

Dependence analysis / Pointer analysis / …

Intel VTune AmplifierIntel VTune Amplifier

5

Intel VTune AmplifierIntel VTune Amplifier

6

gprof(gprof2dot )gprof(gprof2dot )

7

8

Callgrind / KCachegrind

9

Reference BookReference Book

• Lecture notes by the instructor

• The Software Optimization Cookbook: High-

performance Recipes for IA-32 Platform

By Richard Gerber, Aart J.C. Bik, Kevin B . Smith, and

Xinmin Tian

ISBN: 0-9764832-1-1

Intel Press

Class MethodClass Method

• Part 1 (非同步教學)

Performance tools

Performance issues

Workload analyses

• Part 2 (面授 / 同步教學)

期中考試 (暫定)

Practice: workload analysis

分組報告

10

11

GradingGrading

• Midterm: 15%

• Homework: 25%

• Final project: workload analysis (55%)

Use performance tools to analyze and optimize

applications

Presentation: 20%

Implementation & report: 35%

• Class attendance, active participation: 5%

Introduction (1)Introduction (1)

• PC with Intel 8088, 4.77MHz, in 1981

• PC with Intel dual-core Pentium processor, 3.46GHz, in 2006

12

Speed increase: over 600 times

Something run

- 10 minutes in 1981

- < 1 second in 2006

Why do we still need software optimization?

Introduction (2)Introduction (2)

• Today’s software is more complex and is packed

with more features

Use more computing resources

Ex: games, database, OS, …

• Software performance can vary dramatically

depending upon how the programmer chooses to

solve a problem or implement a feature.

• A combination of using efficient algorithms and well-

designed implementations leads to great high

performance applications.

13

14

Overview: Optimization Pitfalls (1)Overview: Optimization Pitfalls (1)

• Application performance cannot be improved before it runs

• Build the application then see what machine it runs

• Optimize by removing features, if they run too slowly

Ex: game

Spend the time optimizing the program vs. adding another button to turn more features off

15

Overview: Optimization Pitfalls (2)Overview: Optimization Pitfalls (2)

• Runs great on my computer

Developers typically have fast new computers that do not exhibit the same performance characteristics as their customers

• Debug versus release builds

An optimizing compiler with the optimization switches turned on should be used throughout the application development process

Identify performance issues early

16

Overview: Optimization Pitfalls (3)Overview: Optimization Pitfalls (3)

• Performance requires assembly language

programming

Try to get the compiler to generate better code first

Readability / portability

• Code features first then optimize if there is time

leftover

Optimizing performance throughout the application

development process takes less time and produces

better results than waiting until the end.

• Optimizations require a processor architect

17

The Software Optimization ProcessThe Software Optimization Process

Create the

benchmarkFind hotspots Investigate causes

Modify

application

Retest using

benchmark

- Slow memory accesses

- Inefficient algorithms

- High loop counts

- Branch prediction problem

- …

18

Key PointKey Point

• Software optimization is an ongoing process that

starts at the design stage and continues all the way

through development.

• Do not resort to assembly language programming

right away. Always try to get the compiler to

generate better code first.