1 / 21

Performance of mathematical software

Performance of mathematical software. Agner Fog Technical University of Denmark www.agner.org. Agenda. Intel and AMD microarchitecture Performance bottlenecks Parallelization C++ vector classes, example Instruction set dispatching Performance measuring Hands-on examples.

egil
Download Presentation

Performance of mathematical software

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Performance of mathematical software Agner Fog Technical University of Denmark www.agner.org

  2. Agenda • Intel and AMD microarchitecture • Performance bottlenecks • Parallelization • C++ vector classes, example • Instruction set dispatching • Performance measuring • Hands-on examples

  3. AMD Microarchitecture • 2 threads per CPU unit • 4 instructions per clock • Out-of-order execution

  4. Intel Micro-architecture

  5. Typical bottlenecks • Installation of program • Program start, load framework and libraries • System database • Network • File input / output • Graphics • RAM access, cache utilization • Algorithm • Dependency chains • CPU pipeline • CPU execution units Speed

  6. Efficient cache use • Store data in contiguous blocks • Avoid advanced data containers such as resizable data structures, linked lists, etc. • Store local data inside the function they are used in

  7. Branch prediction

  8. Out-Of-Order Execution x = a / b; y = c * d; z = x + y;

  9. Dependency chains x = a + b + c + d; x = (a + b) + (c + d);

  10. Loop-carrieddependency chain for (i = 0; i < n; i++) { sum += x[i]; } for (i = 0; i < n; i += 2) { sum1 += x[i]; sum2 += x[i+1]; } sum = sum1 + sum2;

  11. Levels of parallelization • Multiple threads running in different CPU units • Out-of-order execution • SIMD instructions

  12. SIMD programming methods • Assembly language • Intrinsic functions • Vector classes • Automatic vectorization by compiler

  13. Obstacles to automatic vectorization • Pointer aliasing • Array alignment • Array size • Algebraic reduction • Branches • Table lookup

  14. Vector math libraries Short vectors Long vectors Intel VML Intel IPP Yeppp • Intel SVML • AMD libm • Agner’s VCL

  15. Example Exponential function in vector classes

  16. Instruction set dispatching Future extensions

  17. Performance measurement • Profiler • Insert measuring instruments into code • Performance monitor counters

  18. When timing results are unstable • Stop other running programs • Warm up CPU with heavy work • Disable power saving features in BIOS setup • Disable hyperthreading • Use “core clock cycles” counter (Intel only)

  19. Example Measuring latency and throughput of machine instruction

  20. Hands-on example Compare performance of different mathematical function libraries http://cern.agner.org

More Related