SlideShare a Scribd company logo
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Objectives


                In this session, you will learn to:
                   Identify time and space complexity
                   Optimize programming constructs
                   Identify performance libraries for optimization




     Ver. 1.0                                                        Slide 1 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Examining Algorithms


                An algorithm is a set of finite steps that accomplish a
                specific task.
                The efficiency of an algorithm is measured in terms of the
                processor time and the memory space that the algorithm
                utilizes.
                It is necessary to tune the algorithm to make optimal use of
                available resources, such as processor time and memory.
                To analyze algorithmic complexity, it is important to
                understand the time and space aspects of complexity.




     Ver. 1.0                                                        Slide 2 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Time Complexity


                The time taken to compute the steps involved in an
                algorithm is called the time complexity of that algorithm.
                The time taken to execute all the steps for a worst-case
                scenario is the time complexity of the entire algorithm.
                The execution of steps in an algorithm depends on the
                conditions specified in it. As a result, the time complexity of
                an algorithm is measurable with reference to the conditions
                involved in the algorithm.




     Ver. 1.0                                                           Slide 3 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Time Complexity (Contd.)


                Computing the nth number of the fibonacci series:
                Step   1: start
                Step   2: input the value of n
                Step   3:        if (n < = 1) then go to step 14
                Step   4:                  x = 0
                Step   5:                  y = 1
                Step   6:            write (x + “ “ + y)
                Step   7:        for (i = 0 to n-1)
                Step   8:                  {f = y + x
                Step   9:                   x = y
                Step   10:                  y = f
                Step   11:                 i = i + 1
                Step   12: write (f) }
                Step   13: go to step 15
                Step   14: write (n)
                Step   15: stop




     Ver. 1.0                                                       Slide 4 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Time Complexity (Contd.)


                Based on the value of n, two cases can exist in the
                preceding algorithm.
                If the value of n is less than or equal to 1, time complexity is
                constant and does not depend on input, which is n, as
                shown in the following table.

                  Statements                                Frequency of Execution
                  Step 2: input the value of n              1
                  Step 3: if (n < = 1) then go to step 14   1

                  Step 14: write (n)                        1
                  Total Number of instructions executed     3




     Ver. 1.0                                                                        Slide 5 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Time Complexity (Contd.)


                If the value of n is greater than 1, time complexity is 4n-2.
                This is shown in the following table.
                 Statements                                     Frequency of Execution

                 Step 2: input the value of n                   1

                 Step 3: if (n < = 1) then go to step 13        1


                 Step 4: x = 0                                  1

                 Step 5: y = 1                                  1

                 Step 6: for i= 2 to n-1 repeat steps 7 to 10   1

                 Step 7: f = y + x                              n-2

                 Step 8: x = y                                  n-2

                 Step 9: y = f                                  n-2

                 Step 10: i = i + 1                             n-2

                 Step 11: write (f)                             1

                 Total number of instructions executed          4n-2




     Ver. 1.0                                                                            Slide 6 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Just a minute


                What do you mean by the time complexity of an algorithm?




                Answer:
                   The time taken to compute the steps involved in an algorithm
                   is called the time complexity of that algorithm.



     Ver. 1.0                                                           Slide 7 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Space Complexity


                Space complexity is the amount of memory that a program
                requires to accomplish a task.
                Space complexity is a criterion to measure the efficiency of
                a program.
                For example, consider the following expression:
                Return [a + b + b * c + (a +b – c) / (a + b) + 4.0]
                   If variables b and c are each of 2 bits, the storage requirements
                   for the preceding instruction will be constant.
                   If the values of a, b, and c are taken from user input, the
                   storage space required will vary.




     Ver. 1.0                                                               Slide 8 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying Space Complexity (Contd.)


                Refer to the following algorithm:
                Step   1: start
                Step   2: function Add (k, m)
                Step   3:        l = 0
                Step   4:        for j= 1 to m repeat step 5
                Step   5:                  l = l + k[j]
                Step   6:        return the value of l
                Step   7: stop

                For the preceding algorithm:
                   The space taken by the k array is m units.
                   The other variables, m, j, and l will take only one unit of space
                   each.
                   As a result, you can obtain the space complexity of this
                   algorithm by adding the space utilized by all the variables.




     Ver. 1.0                                                                Slide 9 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Examining Programming Constructs


                An application developed in any programming language,
                such as C, C++, C#, or Java, is based on an algorithm.
                Each algorithm consists of several programming constructs,
                such as loops, decisions, and functions.
                The performance of an application is related to the
                programming constructs used in the application.
                To achieve the desired level of optimization, it is important
                to examine the loops, branching statements, and function
                calls used in the program.




     Ver. 1.0                                                        Slide 10 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Examining Loops


                Loops can be optimized by:
                ►   Removing unwanted parts of loops   In this technique, you need to
                                                       first identify the
                ►   Combining loops                    When multiple loops work on
                                                       decision-making steps present
                                                       the same variables, you may
                ►   Using unrolling                    inside a loop. to the
                                                       Unrolling refers
                                                       combine the loops.
                                                       Aftervaluesbreaking compact
                                                       process of
                ►   Reducing work inside loops         The identifying these steps,
                                                                     of some
                                                       This helpssimpler statements.
                                                       loops into reduce
                                                       you need to decide whether the
                                                       expressions, time because
                                                       computation variables, or
                ►   Using sentinel values              loop affects the steps in any
                                                       A sentinel do notis a value
                                                       constants value of
                                                       the total number change
                                                       way.is the loop and end of a
                                                       that placed at the
                ►   Looking at the order of loops      inside improve the
                                                       You can
                                                       instructions executed
                                                       search range. not affect
                                                       If the loop of a consumeby the
                                                       reduces. does
                                                       unnecessarily program
                                                       efficiency
                ►   Looking at operators               steps, remove prevents you
                                                       Sentinel value the unaffected
                                                       In terms oftime.
                                                       processor efficiency,
                                                       changing the order of loops.
                                                       stepsperforming theapproach
                                                       from from a better additional
                                                       Therefore, the loop.
                                                       operations such as
                                                       task of checkingoutside the
                                                       is to bring them the end of
                                                       multiplication and division are
                                                       the input search than
                                                       more expensive string.
                                                       loop.
                                                       operations such as addition.
                                                       You should try to convert all
                                                       expensive operations with
                                                       cheaper ones.




     Ver. 1.0                                                             Slide 11 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Examining Functions


                As the frequency of calling a function increases, program
                execution time increases.
                Examining functions is important for performance
                optimization.
                Functions can be optimized by:
                ►   Using faster functions                 Try to use only fast functions.
                ►   Identifying mathematical functions    You need identify fast
                                                           You can to be selective
                                                          about mathematical the time
                                                           functions by knowing
                ►   Identifying standard functions         complexity associated with
                                                          Use standard mathematical
                                                          functions, such as square
                                                          root, function.a program.
                                                           the used in
                                                          approaches to compute a
                ►   Declaring local functions as static   Using static functions,
                                                          result that uses complex
                                                          You can sequence and
                                                          evaluation is faster
                                                          calculations. functions based
                                                          mathematical
                                                          efficiency is improved.
                                                          This enables you to solve a
                                                          on execution time.
                                                          problem more efficiently.




     Ver. 1.0                                                                  Slide 12 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Examining Branching


                Transferring control from one part of code to another is
                achieved through branching.
                Various techniques can be adopted to make the process of
                branching effective and improve the efficiency of code.
                Branches can be examined by:
                ►   Removing the else clause             Using an else clause with
                                                         every if loop leads to
                ►   Using effective case statements      You should use effective
                                                         ineffective branching.
                                                         case statements in such a
                ►   Replacing conditional computations   Therefore, youcomputational
                                                         You can save should try to
                                                         way so the order of options is
                                                         remove replacingclause, if
                                                         time by the else conditional
                                                         defined based on the
                                                         possible.
                                                         computation with equivalent
                                                         frequency of using the
                                                         arithmetic expressions.
                                                         options.




     Ver. 1.0                                                             Slide 13 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

General Guidelines for Optimization


                Some guidelines to follow when writing code are:
                   Identify optimization areas
                   Identify the depth of optimization
                   Identify correct alternatives
                   Identify what is being asked




     Ver. 1.0                                                      Slide 14 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Common Misconceptions About Optimization


                Some of the common misconceptions about code and their
                optimization are:
                   To think a program doesn’t require optimization because it
                   appears to be quite fast.
                   To think that only the optimization performed by the compiler is
                   enough.
                   To believe that short code is efficient.
                   To think a specific solution will be effective without verifying
                   performance results.
                   To think optimizing while programming is good practice.




     Ver. 1.0                                                             Slide 15 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Just a minute


                What is unrolling?
                What is sentinel value?




                Answer:
                   Breaking compact loops into simpler statements is called
                   unrolling.
                   A sentinel value is a value that is placed at the end of a search
                   range. This assures the termination of the search.

     Ver. 1.0                                                              Slide 16 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Using Performance Libraries For Applications


                Each software developer has an individualistic style of
                writing code. It is possible that the written code will not be
                efficient.
                Sections of software, such as the menu bar, remain
                common in most software.
                Writing these sections of codes repeatedly makes the
                process time-consuming and error-prone.
                In such situations, you might prefer to use existing code,
                which is called a performance library.
                This piece of code is already checked for errors. In addition,
                this code attains a high level of optimization over a period.




     Ver. 1.0                                                         Slide 17 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Using Performance Libraries For Applications (Contd.)


                The advantages of using performance libraries are the
                following:
                    Enable programmers to develop code in less time
                    Offer error free codes
                    Enables best use of resources
                    Help in performance improvement
                    Add to stability of the functioning software application




     Ver. 1.0                                                                  Slide 18 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Identifying the Types of Performance Libraries


                Based on these tasks, performance libraries can be
                categorized as:
                ►   Engineering and science libraries   These libraries are mainly
                                                        used in scientific and
                ►   Math libraries                      These libraries deal with the
                                                        engineering applications.
                                                        evaluation of complex
                ►   Graphic libraries                   These libraries help draw
                                                                         may include
                                                        mathematical functions, such
                                                        graphics, pie for searching,
                                                        functionalitiescharts, graphs,
                ►   Audio/Video libraries               as vector and matrixoptimize
                                                        These libraries help
                                                        and bar diagrams correctly
                                                        sorting, and evaluating
                                                        calculations.
                ►   Image processing libraries          various functions related to
                                                        and accurately.
                                                        variouslibraries help process
                                                        These expressions.
                                                        audio-visual data.
                                                        images faster. may include
                ►   Other libraries                     Other libraries
                                                        functionalities for performing
                                                        various tasks, such as
                                                        speech recognition, signal
                                                        processing, and
                                                        cryptography.




     Ver. 1.0                                                             Slide 19 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Just a minute


                Which libraries may include functionalities for searching,
                sorting, and evaluating various expressions?




                Answer:
                   Engineering and science libraries




     Ver. 1.0                                                         Slide 20 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Summary


                In this session, you learned that:
                   Time complexity is the time taken by the steps of an algorithm
                   to execute.
                   Space complexity is the measurement of the space utilized by
                   the components of an algorithm.
                   Identifying the data structures used in an algorithm and then
                   adding them can measure space complexity.
                   Loops are generally the most time-consuming constructs of a
                   program.
                   Some of the techniques to optimize loops are:
                           Removing unwanted parts of loops
                           Combining loops
                           Using Unrolling
                           Reducing work inside loops


     Ver. 1.0                                                            Slide 21 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Summary (Contd.)


                       Using Sentinel Values
                       Looking at the order of loops
                       Looking at operators
                – Some of the techniques to optimize functions are:
                       Using faster functions
                       Identifying mathematical functions
                       Identifying standard functions
                       Declaring local functions as static
                  Transferring control from one part of a code to another is
                  achieved through branching.




     Ver. 1.0                                                             Slide 22 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Summary (Contd.)


                Some of the techniques to make the process of branching
                effective are:
                    – Removing the else clause
                    – Using Effective Case Statements
                    – Replacing Conditional Computation
                You should keep the following optimization guidelines in mind
                when writing codes:
                    – Identify optimization areas
                    – Identify the depth of optimization
                    – Identify correct alternatives
                    – Identify what is being asked




     Ver. 1.0                                                         Slide 23 of 24
Code Optimization and Performance Tuning Using Intel VTune
Installing Windows XP Professional Using Attended Installation

Summary (Contd.)


                  Some of the common misconceptions about optimization are:
                     – A fast program does not require optimization
                     – Optimization performed by the compiler is enough
                     – A short code is efficient
                     – Optimizing while programming is good practice
                – Performance libraries can improve the performance of an
                  application to a large extent.
                – A variety of performance libraries are available for different
                  purposes, such as mathematical, graphical, and task-based
                  functions.




     Ver. 1.0                                                            Slide 24 of 24

More Related Content

What's hot

Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
amanabr
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
Self-Employed
 
Inter thread communication &amp; runnable interface
Inter thread communication &amp; runnable interfaceInter thread communication &amp; runnable interface
Inter thread communication &amp; runnable interface
keval_thummar
 
High-Level Synthesis with GAUT
High-Level Synthesis with GAUTHigh-Level Synthesis with GAUT
High-Level Synthesis with GAUT
AdaCore
 
Lp2520162020
Lp2520162020Lp2520162020
Lp2520162020
IJERA Editor
 
Use of an Oscilloscope - maXbox Starter33
Use of an Oscilloscope - maXbox Starter33Use of an Oscilloscope - maXbox Starter33
Use of an Oscilloscope - maXbox Starter33
Max Kleiner
 
Univ of va intentional introduction 2013 01-31
Univ of va intentional introduction 2013 01-31Univ of va intentional introduction 2013 01-31
Univ of va intentional introduction 2013 01-31
Magnus Christerson
 
Multivariable Control System Design for Quadruple Tank Process using Quantita...
Multivariable Control System Design for Quadruple Tank Process using Quantita...Multivariable Control System Design for Quadruple Tank Process using Quantita...
Multivariable Control System Design for Quadruple Tank Process using Quantita...
IDES Editor
 
ASE02.ppt
ASE02.pptASE02.ppt
ASE02.ppt
Ptidej Team
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
Frank Nielsen
 
Gonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlabGonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlab
urmia university of technology
 
Methods
MethodsMethods

What's hot (12)

Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Inter thread communication &amp; runnable interface
Inter thread communication &amp; runnable interfaceInter thread communication &amp; runnable interface
Inter thread communication &amp; runnable interface
 
High-Level Synthesis with GAUT
High-Level Synthesis with GAUTHigh-Level Synthesis with GAUT
High-Level Synthesis with GAUT
 
Lp2520162020
Lp2520162020Lp2520162020
Lp2520162020
 
Use of an Oscilloscope - maXbox Starter33
Use of an Oscilloscope - maXbox Starter33Use of an Oscilloscope - maXbox Starter33
Use of an Oscilloscope - maXbox Starter33
 
Univ of va intentional introduction 2013 01-31
Univ of va intentional introduction 2013 01-31Univ of va intentional introduction 2013 01-31
Univ of va intentional introduction 2013 01-31
 
Multivariable Control System Design for Quadruple Tank Process using Quantita...
Multivariable Control System Design for Quadruple Tank Process using Quantita...Multivariable Control System Design for Quadruple Tank Process using Quantita...
Multivariable Control System Design for Quadruple Tank Process using Quantita...
 
ASE02.ppt
ASE02.pptASE02.ppt
ASE02.ppt
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
 
Gonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlabGonzalez, rafael,c.digitalimageprocessingusing matlab
Gonzalez, rafael,c.digitalimageprocessingusing matlab
 
Methods
MethodsMethods
Methods
 

Similar to 02 intel v_tune_session_02

02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
Vivek chan
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
Haitham El-Ghareeb
 
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
Naveen Kumar
 
05 intel v_tune_session_07
05 intel v_tune_session_0705 intel v_tune_session_07
05 intel v_tune_session_07
Niit Care
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
AjayBahoriya
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
Stefan Marr
 
Aspect-Oriented Technologies
Aspect-Oriented TechnologiesAspect-Oriented Technologies
Aspect-Oriented Technologies
Esteban Abait
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
Vivek Singh
 
Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )
Ziyauddin Shaik
 
CSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docxCSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docx
mydrynan
 
Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0
Jonathan Schemoul
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
Oswald Campesato
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
Niit Care
 
01 iec t1_s1_plt_session_01
01 iec t1_s1_plt_session_0101 iec t1_s1_plt_session_01
01 iec t1_s1_plt_session_01
Niit Care
 
關於測試,我說的其實是......
關於測試,我說的其實是......關於測試,我說的其實是......
關於測試,我說的其實是......
hugo lu
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
Ganesan Narayanasamy
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
C.U
 
parallel
parallelparallel
Introtodotnet
IntrotodotnetIntrotodotnet
Introtodotnet
rashmix
 
IntroToDotNetTech
IntroToDotNetTechIntroToDotNetTech
IntroToDotNetTech
rashmix
 

Similar to 02 intel v_tune_session_02 (20)

02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
 
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
 
05 intel v_tune_session_07
05 intel v_tune_session_0705 intel v_tune_session_07
05 intel v_tune_session_07
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
Aspect-Oriented Technologies
Aspect-Oriented TechnologiesAspect-Oriented Technologies
Aspect-Oriented Technologies
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
 
Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )
 
CSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docxCSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docx
 
Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
 
01 iec t1_s1_plt_session_01
01 iec t1_s1_plt_session_0101 iec t1_s1_plt_session_01
01 iec t1_s1_plt_session_01
 
關於測試,我說的其實是......
關於測試,我說的其實是......關於測試,我說的其實是......
關於測試,我說的其實是......
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
parallel
parallelparallel
parallel
 
Introtodotnet
IntrotodotnetIntrotodotnet
Introtodotnet
 
IntroToDotNetTech
IntroToDotNetTechIntroToDotNetTech
IntroToDotNetTech
 

More from Niit Care

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
Niit Care
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
Niit Care
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
Niit Care
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
Niit Care
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
Niit Care
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
Niit Care
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
Niit Care
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
Niit Care
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
Niit Care
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
Niit Care
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
Niit Care
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
Niit Care
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
Niit Care
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
Niit Care
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
Niit Care
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
Niit Care
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
Niit Care
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
Niit Care
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
Niit Care
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
Niit Care
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 

Recently uploaded (20)

Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 

02 intel v_tune_session_02

  • 1. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Objectives In this session, you will learn to: Identify time and space complexity Optimize programming constructs Identify performance libraries for optimization Ver. 1.0 Slide 1 of 24
  • 2. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Examining Algorithms An algorithm is a set of finite steps that accomplish a specific task. The efficiency of an algorithm is measured in terms of the processor time and the memory space that the algorithm utilizes. It is necessary to tune the algorithm to make optimal use of available resources, such as processor time and memory. To analyze algorithmic complexity, it is important to understand the time and space aspects of complexity. Ver. 1.0 Slide 2 of 24
  • 3. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Time Complexity The time taken to compute the steps involved in an algorithm is called the time complexity of that algorithm. The time taken to execute all the steps for a worst-case scenario is the time complexity of the entire algorithm. The execution of steps in an algorithm depends on the conditions specified in it. As a result, the time complexity of an algorithm is measurable with reference to the conditions involved in the algorithm. Ver. 1.0 Slide 3 of 24
  • 4. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Time Complexity (Contd.) Computing the nth number of the fibonacci series: Step 1: start Step 2: input the value of n Step 3: if (n < = 1) then go to step 14 Step 4: x = 0 Step 5: y = 1 Step 6: write (x + “ “ + y) Step 7: for (i = 0 to n-1) Step 8: {f = y + x Step 9: x = y Step 10: y = f Step 11: i = i + 1 Step 12: write (f) } Step 13: go to step 15 Step 14: write (n) Step 15: stop Ver. 1.0 Slide 4 of 24
  • 5. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Time Complexity (Contd.) Based on the value of n, two cases can exist in the preceding algorithm. If the value of n is less than or equal to 1, time complexity is constant and does not depend on input, which is n, as shown in the following table. Statements Frequency of Execution Step 2: input the value of n 1 Step 3: if (n < = 1) then go to step 14 1 Step 14: write (n) 1 Total Number of instructions executed 3 Ver. 1.0 Slide 5 of 24
  • 6. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Time Complexity (Contd.) If the value of n is greater than 1, time complexity is 4n-2. This is shown in the following table. Statements Frequency of Execution Step 2: input the value of n 1 Step 3: if (n < = 1) then go to step 13 1 Step 4: x = 0 1 Step 5: y = 1 1 Step 6: for i= 2 to n-1 repeat steps 7 to 10 1 Step 7: f = y + x n-2 Step 8: x = y n-2 Step 9: y = f n-2 Step 10: i = i + 1 n-2 Step 11: write (f) 1 Total number of instructions executed 4n-2 Ver. 1.0 Slide 6 of 24
  • 7. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Just a minute What do you mean by the time complexity of an algorithm? Answer: The time taken to compute the steps involved in an algorithm is called the time complexity of that algorithm. Ver. 1.0 Slide 7 of 24
  • 8. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Space Complexity Space complexity is the amount of memory that a program requires to accomplish a task. Space complexity is a criterion to measure the efficiency of a program. For example, consider the following expression: Return [a + b + b * c + (a +b – c) / (a + b) + 4.0] If variables b and c are each of 2 bits, the storage requirements for the preceding instruction will be constant. If the values of a, b, and c are taken from user input, the storage space required will vary. Ver. 1.0 Slide 8 of 24
  • 9. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying Space Complexity (Contd.) Refer to the following algorithm: Step 1: start Step 2: function Add (k, m) Step 3: l = 0 Step 4: for j= 1 to m repeat step 5 Step 5: l = l + k[j] Step 6: return the value of l Step 7: stop For the preceding algorithm: The space taken by the k array is m units. The other variables, m, j, and l will take only one unit of space each. As a result, you can obtain the space complexity of this algorithm by adding the space utilized by all the variables. Ver. 1.0 Slide 9 of 24
  • 10. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Examining Programming Constructs An application developed in any programming language, such as C, C++, C#, or Java, is based on an algorithm. Each algorithm consists of several programming constructs, such as loops, decisions, and functions. The performance of an application is related to the programming constructs used in the application. To achieve the desired level of optimization, it is important to examine the loops, branching statements, and function calls used in the program. Ver. 1.0 Slide 10 of 24
  • 11. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Examining Loops Loops can be optimized by: ► Removing unwanted parts of loops In this technique, you need to first identify the ► Combining loops When multiple loops work on decision-making steps present the same variables, you may ► Using unrolling inside a loop. to the Unrolling refers combine the loops. Aftervaluesbreaking compact process of ► Reducing work inside loops The identifying these steps, of some This helpssimpler statements. loops into reduce you need to decide whether the expressions, time because computation variables, or ► Using sentinel values loop affects the steps in any A sentinel do notis a value constants value of the total number change way.is the loop and end of a that placed at the ► Looking at the order of loops inside improve the You can instructions executed search range. not affect If the loop of a consumeby the reduces. does unnecessarily program efficiency ► Looking at operators steps, remove prevents you Sentinel value the unaffected In terms oftime. processor efficiency, changing the order of loops. stepsperforming theapproach from from a better additional Therefore, the loop. operations such as task of checkingoutside the is to bring them the end of multiplication and division are the input search than more expensive string. loop. operations such as addition. You should try to convert all expensive operations with cheaper ones. Ver. 1.0 Slide 11 of 24
  • 12. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Examining Functions As the frequency of calling a function increases, program execution time increases. Examining functions is important for performance optimization. Functions can be optimized by: ► Using faster functions Try to use only fast functions. ► Identifying mathematical functions You need identify fast You can to be selective about mathematical the time functions by knowing ► Identifying standard functions complexity associated with Use standard mathematical functions, such as square root, function.a program. the used in approaches to compute a ► Declaring local functions as static Using static functions, result that uses complex You can sequence and evaluation is faster calculations. functions based mathematical efficiency is improved. This enables you to solve a on execution time. problem more efficiently. Ver. 1.0 Slide 12 of 24
  • 13. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Examining Branching Transferring control from one part of code to another is achieved through branching. Various techniques can be adopted to make the process of branching effective and improve the efficiency of code. Branches can be examined by: ► Removing the else clause Using an else clause with every if loop leads to ► Using effective case statements You should use effective ineffective branching. case statements in such a ► Replacing conditional computations Therefore, youcomputational You can save should try to way so the order of options is remove replacingclause, if time by the else conditional defined based on the possible. computation with equivalent frequency of using the arithmetic expressions. options. Ver. 1.0 Slide 13 of 24
  • 14. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation General Guidelines for Optimization Some guidelines to follow when writing code are: Identify optimization areas Identify the depth of optimization Identify correct alternatives Identify what is being asked Ver. 1.0 Slide 14 of 24
  • 15. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Common Misconceptions About Optimization Some of the common misconceptions about code and their optimization are: To think a program doesn’t require optimization because it appears to be quite fast. To think that only the optimization performed by the compiler is enough. To believe that short code is efficient. To think a specific solution will be effective without verifying performance results. To think optimizing while programming is good practice. Ver. 1.0 Slide 15 of 24
  • 16. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Just a minute What is unrolling? What is sentinel value? Answer: Breaking compact loops into simpler statements is called unrolling. A sentinel value is a value that is placed at the end of a search range. This assures the termination of the search. Ver. 1.0 Slide 16 of 24
  • 17. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Using Performance Libraries For Applications Each software developer has an individualistic style of writing code. It is possible that the written code will not be efficient. Sections of software, such as the menu bar, remain common in most software. Writing these sections of codes repeatedly makes the process time-consuming and error-prone. In such situations, you might prefer to use existing code, which is called a performance library. This piece of code is already checked for errors. In addition, this code attains a high level of optimization over a period. Ver. 1.0 Slide 17 of 24
  • 18. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Using Performance Libraries For Applications (Contd.) The advantages of using performance libraries are the following: Enable programmers to develop code in less time Offer error free codes Enables best use of resources Help in performance improvement Add to stability of the functioning software application Ver. 1.0 Slide 18 of 24
  • 19. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Identifying the Types of Performance Libraries Based on these tasks, performance libraries can be categorized as: ► Engineering and science libraries These libraries are mainly used in scientific and ► Math libraries These libraries deal with the engineering applications. evaluation of complex ► Graphic libraries These libraries help draw may include mathematical functions, such graphics, pie for searching, functionalitiescharts, graphs, ► Audio/Video libraries as vector and matrixoptimize These libraries help and bar diagrams correctly sorting, and evaluating calculations. ► Image processing libraries various functions related to and accurately. variouslibraries help process These expressions. audio-visual data. images faster. may include ► Other libraries Other libraries functionalities for performing various tasks, such as speech recognition, signal processing, and cryptography. Ver. 1.0 Slide 19 of 24
  • 20. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Just a minute Which libraries may include functionalities for searching, sorting, and evaluating various expressions? Answer: Engineering and science libraries Ver. 1.0 Slide 20 of 24
  • 21. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Summary In this session, you learned that: Time complexity is the time taken by the steps of an algorithm to execute. Space complexity is the measurement of the space utilized by the components of an algorithm. Identifying the data structures used in an algorithm and then adding them can measure space complexity. Loops are generally the most time-consuming constructs of a program. Some of the techniques to optimize loops are: Removing unwanted parts of loops Combining loops Using Unrolling Reducing work inside loops Ver. 1.0 Slide 21 of 24
  • 22. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Summary (Contd.) Using Sentinel Values Looking at the order of loops Looking at operators – Some of the techniques to optimize functions are: Using faster functions Identifying mathematical functions Identifying standard functions Declaring local functions as static Transferring control from one part of a code to another is achieved through branching. Ver. 1.0 Slide 22 of 24
  • 23. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Summary (Contd.) Some of the techniques to make the process of branching effective are: – Removing the else clause – Using Effective Case Statements – Replacing Conditional Computation You should keep the following optimization guidelines in mind when writing codes: – Identify optimization areas – Identify the depth of optimization – Identify correct alternatives – Identify what is being asked Ver. 1.0 Slide 23 of 24
  • 24. Code Optimization and Performance Tuning Using Intel VTune Installing Windows XP Professional Using Attended Installation Summary (Contd.) Some of the common misconceptions about optimization are: – A fast program does not require optimization – Optimization performed by the compiler is enough – A short code is efficient – Optimizing while programming is good practice – Performance libraries can improve the performance of an application to a large extent. – A variety of performance libraries are available for different purposes, such as mathematical, graphical, and task-based functions. Ver. 1.0 Slide 24 of 24

Editor's Notes

  1. Initiate the discussion by asking the students the components of a program, such as loops, branches constituting application design. Also ask the students how the application design affects performance issues. Explain why design of an application is crucial for determining its performance. Sometimes, even minor mistakes in application design might cause serious performance issues. Therefore, it is important to know, analyze, identify, and fix application-design issues to obtain optimal application performance.
  2. Ask the students what is algorithm. Collate the answers and initiate a discussion on how same task can be performed using different algorithms. Algorithm is a formula or set of steps for solving a particular problem. The set of rules must be unambiguous and have a clear stopping point. Algorithms can be expressed in any language , from natural languages like English or French to programming languages like FORTRAN . Most programs , exception some artificial intelligence applications , consist of algorithms. Creating algorithms that are simple and efficient is one of the principal challenges in programming .
  3. Ask students what is time complexity? Explain that time complexity is an indication of time taken for execution... Sometimes the time taken by a particular algorithm can depend on a set of conditions. For example, in case of linear search of n values, if the required data is found at first location the execution will be faster as compared to the case when the required data is found at nth location. Ask the following questions: What is the time complexity of a linear search algorithm Ans: For N values the time complexity is N What is the time complexity of binary search algorithm Ans: For N values the time complexity is log N. Thus explain that binary search is better than linear search. Note that binary search can only be performed with sorted data. After explaining these concepts ask the students to find time complexity for the following algorithm: Float * loop ( float * date 1, float * date 2 ) { float Pi = 3.14, * ans; ans = ( float * ) malloc ( Max * size of (float)); for (I = 1, I &lt; MAX, I++) { ans [I] = date 1 [I] + Pi * date 2 []; } return ans; } Ans: The time complexity is of the order of MAX. Note that in terms of time complexity MAX is same as MAX +1 or MAX-3 or MAX +/- any constant number. But, MAX *MAX is different from MAX.
  4. Ask the students the time complexity of this algorithm. Discuss the result and ensure that students are familiar with the method of calculating time complexity. Again note that the solution is 4n-2, which is same as 4n.
  5. Explain that If the value of n&lt;= 1 the time complexity is constant.
  6. Explain that If the value of n&gt; 1 the time complexity is 4n-2. Next, ask the students to find the time complexity for an algorithm that computes the sum of two m*n matrices. Encourage the students to solve on their own without referring to the SG. Explain how interchanging the loops improve the time complexity of the algorithm.
  7. Ask students what is meant by space complexity. Explain that space complexity is the measurement of space utilized by the components of an algorithm.
  8. Explain the concept of space complexity. Also explain how space complexity can affect the performance of an application. Explain the steps to calculate space complexity.
  9. Explain that an algorithm has a very significant role in application performance. Most of the times an n inefficient algorithm can retard the application performance. For example, you can ask the students to write an algorithm that prints all the prime numbers from 1 to n. Enable the stude4nts to appreciate how different algorithm have different performance
  10. Explain the difference between optimized and unoptimized code and how optimized code performs better than the unoptimized code. Explain that loops are the most time consuming techniques to optimize loops. Ask the students the various techniques that can be used to optimize loops in an algorithm. Explain in detail the various techniques, such as removing unwanted parts of loops, combining loops, unrolling, reducing work inside loops, using sentinel values with the help of examples.
  11. Ask students the need to optimize functions in a program. Also, ask them various techniques that can be used to optimize functions. Explain in detail the optimization techniques, such as identifying Mathematical functions and using faster functions to speed up the execution of a program. Explain the need to use standard mathematical approach for complex calculations instead of using long unwanted steps. State the example of using exponent functions to compute nth Fibonacci number instead of using n Fibonacci number and then printing the desired number. Explain the need to declare local functions as static for faster evaluation. Explain using an example of an optimized and unoptimized code.
  12. Ask students the various techniques that can be used to make the process of branching in a program effective. Explain using the example of codes the affect on the performance after the techniques, such as removing the else clause and using effective case statements.
  13. Ask students to identify the certain guidelines that they can follow for optimization when writing a code.
  14. Explain in detail the various misconceptions that lead to ineffective optimization of programs.
  15. Explain that unrolling refers to breaking compact loops into simpler statements. Sentinel value is a value placed at the end of a search range to assure the rumination of search.
  16. Tell the students that p erformance libraries are: 1. Code snippets that serve a definite purpose, such as matrix operations. 2. Functions written to increase application performance for a specific platform. Ask students what they understand by the term Performance Library. Explain that while writing a code it is possible that the code written is time consuming and error prone. The code which is already checked for errors is called as a performance library. Explain that unrolling refers to breaking compact loops into simpler statements.
  17. Tell the students that performance libraries enable programmers to focus on the areas of coding. Ask students the advantages of using Performance Libraries Explain the advantages that performance libraries, such as less time needed to develop a code, best possible utilization of resources and increase in the efficiency and stability of the software application.
  18. Ask students to identify the various tasks where you can use the performance libraries. Also, ask students to categorize the performance libraries based on the various software tasks.
  19. Engineering and Science Libraries are used to include functionalities for searching, sorting, and evaluating expressions.
  20. Summarize the session.
  21. Summarize the session.
  22. Summarize the session.
  23. Summarize the session.