首页 > 代码库 > Intel 寻找热点

Intel 寻找热点

            

 

 

 

 

 

Lab 1: Finding Hotspots

___________________________________________________________________

 

Developer Product Division

 

寻找热点

 





                                                                                                        

 

 

 

                                        

Disclaimer

The information contained in this document is provided for informational purposes only and represents the current view of Intel Corporation ("Intel") and its contributors ("Contributors") on, as of the date of publication. Intel and the Contributors make no commitment to update the information contained in this document, and Intel reserves the right to make changes at any time, without notice.

DISCLAIMER. THIS DOCUMENT, IS PROVIDED "AS IS." NEITHER INTEL, NOR THE CONTRIBUTORS MAKE ANY REPRESENTATIONS OF ANY KIND WITH RESPECT TO PRODUCTS REFERENCED HEREIN, WHETHER SUCH PRODUCTS ARE THOSE OF INTEL, THE CONTRIBUTORS, OR THIRD PARTIES. INTEL, AND ITS CONTRIBUTORS EXPRESSLY DISCLAIM ANY AND ALL WARRANTIES, IMPLIED OR EXPRESS, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT, AND ANY WARRANTY ARISING OUT OF THE INFORMATION CONTAINED HEREIN, INCLUDING WITHOUT LIMITATION, ANY PRODUCTS, SPECIFICATIONS, OR OTHER MATERIALS REFERENCED HEREIN. INTEL, AND ITS CONTRIBUTORS DO NOT WARRANT THAT THIS DOCUMENT IS FREE FROM ERRORS, OR THAT ANY PRODUCTS OR OTHER TECHNOLOGY DEVELOPED IN CONFORMANCE WITH THIS DOCUMENT WILL PERFORM IN THE INTENDED MANNER, OR WILL BE FREE FROM INFRINGEMENT OF THIRD PARTY PROPRIETARY RIGHTS, AND INTEL, AND ITS CONTRIBUTORS DISCLAIM ALL LIABILITY THEREFOR. INTEL, AND ITS CONTRIBUTORS DO NOT WARRANT THAT ANY PRODUCT REFERENCED HEREIN OR ANY PRODUCT OR TECHNOLOGY DEVELOPED IN RELIANCE UPON THIS DOCUMENT, IN WHOLE OR IN PART, WILL BE SUFFICIENT, ACCURATE, RELIABLE, COMPLETE, FREE FROM DEFECTS OR SAFE FOR ITS INTENDED PURPOSE, AND HEREBY DISCLAIM ALL LIABILITIES THEREFOR. ANY PERSON MAKING, USING OR SELLING SUCH PRODUCT OR TECHNOLOGY DOES SO AT HIS OR HER OWN RISK.

Licenses may be required. Intel, its contributors and others may have patents or pending patent applications, trademarks, copyrights or other intellectual proprietary rights covering subject matter contained or described in this document. No license, express, implied, by estoppels or otherwise, to any intellectual property rights of Intel or any other party is granted herein. It is your responsibility to seek licenses for such intellectual property rights from Intel and others where appropriate. Limited License Grant. Intel hereby grants you a limited copyright license to copy this document for your use and internal distribution only. You may not distribute this document externally, in whole or in part, to any other person or entity. LIMITED LIABILITY. IN NO EVENT SHALL INTEL, OR ITS CONTRIBUTORS HAVE ANY LIABILITY TO YOU OR TO ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF YOUR USE OF THIS DOCUMENT OR RELIANCE UPON THE INFORMATION CONTAINED HEREIN, UNDER ANY CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL, OR ANY CONTRIBUTOR HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.

Intel and Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

*Other names and brands may be claimed as the property of others.

Copyright ? 2009, Intel Corporation. All Rights Reserved.Table of Contents

Lab 1: Finding Hotspots    i

Developer Product Division    i

Disclaimer    ii

Lab 1: Finding Hotspots    1

Activity 1 – Build the Application    2

Activity 2 – Collect Performance Data    3

Activity 3 – Find the Hotspot    4

 

 

 

Lab 1: Finding Hotspots

Time Required

Forty Five minutes

Objective

In this lab session, you will use Intel? VTune? Amplifier XE to find a performance hotspot in an application.

After successfully completing this lab‘s activities, you will be able to:

  • Collect performance data for an application
  • Determine an application‘s performance bottleneck

 

  • Drill down to the source code of a hotspot

 

Activity 1 – Build the Application

Time Required

Ten minutes

Objective

  • Build the application in preparation for finding a hotspot
   

 

  1. Using Microsoft Visual Studio, select File->Open->Project/Solution and open the solution file: tachyon_vtune_amp_xe.sln
  2. Maximize the Microsoft Visual Studio screen by double clicking on the title bar.
  3. Verify that Release is the selected Solution Configuration in the left hand pulldown window near the top of the Visual Studio screen
  4. Select/highlight the find_hotspots project in the Solution Explorer pane
  5. From the top Visual Studio menu select Build->Build find_hotspots
  6. Verify at the bottom of the Visual Studio screen that it built with no errors. It should indicate that 2 projects succeeded in being built

 

Review Questions

  • Did the tachyon.common project build also?
  • How many source files are in the find-hotspots project?

 

 

 

 

Activity 2 – Collect Performance Data

Time Required

Fifteen minutes

Objective

  • Run the application while collecting performance data
   

 

  1. Right-click on find_hotspots in the Solution Explorer window and select "Set As Startup Project." The project name "find_hotspots" will be displayed as bold characters.
  2. Click on the "New Analysis" button
  3. Select "Algorithm Tuning->Hotspots" in the analysis type pane
  4. Click "Analyze" – The tachyon application will run. Note that as the application runs it draws and image of several different silver balls on the screen. Notice the execution time displayed in the application‘s title bar immediately after the image is completely displayed.
  5. After the application completes the Intel? VTune? Amplifier XE will spend some time analyzing the data. When it is finished analyzing, the Hotspots pane appears. Note the analysis explanation pane comes up. Read it and then clear the pane.

    At this point the application has run to completion and the Intel? VTune? Amplifier XE 2011 displays the analyzed results.

 

Review Questions

  • What is the result screen that appears after clearing the analysis explanation pane?
  • Which function used the most CPU time?

 

 

Activity 3 – Find the Hotspot

Time Required

Twenty minutes

Objective

  • Find the source code for a performance hotspot
  • Identify the calling sequence into the performance hotspot that generated the most CPU time
   

 

  1. Make sure the "Bottom-up" tab is highlighted. The functions in the tachyon program will be listed in order of execution time. Notice the Timeline View at the bottom of the screen. This shows the various states of the threads in the program and the number of CPUs used as the program ran. There seems to be very little CPU usage or thread execution near the end of the program. This is the phase of the program in which it finished but kept the application window visible so the user has time to see the overall execution time. Notice also that there is only 1 thread shown with any significant execution time.
  2. Go back to looking at the function list at the top of the result screen. The functions grid_intersect and sphere_intersect will be at the top of the list, but there is another function that seems to have used a surprisingly large amount of CPU time given what it does: initialize_2D_buffer.
  3. Click on the arrow to the left of the function name initialize_2D_buffer . Notice the different calling sequences into that function, and to see the relative amounts of execution time generated by those calling sequences. In this case there appears to be only 1.
  4. Double click on the function name initialize_2D_buffer. The source code for that function is displayed at the hottest point in that function along with assembly code to the right. Each source and assembly statement is annotated with execution time on the right.

    Vertical panes to the right of the source and assembly vertical scroll bars show relative position and density of execution time throughout the view. Scroll up and down to see that.
  5. Note the comments surrounding the nested for loops in lines 77-87 that contain the statement that consumed the most CPU time, line number 84.

    To show the use of the hotspot collector the source code has 2 different ways of explicitly initializing the code. One referencing sequential memory locations (the "faster" method) and one using a slower, non-sequential method).
  6. Use Visual Studio to comment out the slower method, rebuild the app (as was done in Activity 1) and run it. Note the faster execution time.
  7. Rerun Piersol HE‘s Hotspots profiling mode. After it runs and Piersol HE shows the results, notice that "initialize_2D_buffer" is much further down the function list and took less time.

 

Review Questions

  1. How much faster was the modified application?
  2. At what point in the program does the CPU usage drop off?
  3. Which function took the most time in the optimized version?