Upload
hillary-oconnor
View
220
Download
0
Embed Size (px)
DESCRIPTION
3 Risks of Threads But if they are not used properly, they can lead to degrade performance, and sometimes unpredictable behavior, and error conditions Data race (race conditions) Deadlock And other extra burdens. Code complexity Portability issues Testing and debugging difficulty
Citation preview
1
How to do MultithreadingFirst step: Sampling and Hotspot hunting
2010. 3. 19Myongji University
Sugwon Hong
1
2
Benefits of Threads Threads are intended to improve
performance and responsiveness of a program.
Quick turnaroud time Completing a single job in the smallest
amount of time possible High throughput
Finishing the most tasks in a fixed amount of time
3
Risks of Threads But if they are not used properly, they can
lead to degrade performance, and sometimes unpredictable behavior,
and error conditions Data race (race conditions) Deadlock
And other extra burdens. Code complexity Portability issues Testing and debugging difficulty
4
Common questions for multithreading Where to thread? Is it worth threading a selected region? What should the expected speedup be? Will we meet the expected performance? Can we correct any error while threading? How long would it take to thread? How much re-design/effort is required? Will it scale as more threads/data are
added? Which threading model to use?
5
Starting point: Measurement Before answering all questions, we just
try to start the first step. Measurement may give us plenty of
information about where we start. Collect data which provide you with
CPU hotspots, I/O hotspots, and the degree of parallelism in your code while the program is running.
Measure before/during/after threading.
6
Performance tools To do measurement, we need proper
performance tools. The Intel VTune Performance Analyzer, along
with the Thread Profiler, identifies “hot spots” of code that may benefit from threading, locates thread performance bottlenecks, estimates achievable/available performance, and shows call graph to help to identify threading candidates.
The Intel Thread Checker allows you to quickly validate designs and create prototypes by locating deadlocks and race conditions.
7
Development cycle Analysis
–Verify timings, verify dependencies–Intel® VTune™ Performance Analyzer
Design (Introduce Threads)–Use a threaded library
–e.g. Intel® Performance libraries: IPP and MKL–OpenMP* (Intel® Compiler)–Explicit threading (Win32*, Pthreads*)
Analyze for correctness–Intel® Thread Checker–Intel Debugger
Tune performance–Thread Profiler–Intel® VTune™ Performance Analyzer
(source : Intel Academy program)
8
Today’s lab Using the Vtune performance
analyzer, we do measurements for three cases. Measure and hunt the hot spot for the
serial version of Mandelbrot program. Do multithreading and observe any
change by measurement. Do some tweak and observe the result
for load balancing by measurement.