parallel programming multicore systems · hyper-threading • hyper-threading is a technology that...
TRANSCRIPT
![Page 1: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/1.jpg)
FYS3240
PC-based instrumentation and microcontrollers
Parallel Programming – Multicore
systems
Spring 2014 – Lecture #9
Bekkeng, 12.5.2014
![Page 2: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/2.jpg)
Introduction
• Until recently, innovations in processor technology have
resulted in computers with CPUs that operate at higher clock
rates.
• However, as clock rates approach their theoretical physical
limits, companies are developing new processors with multiple
processing cores.
– P = ACV2f (P is consumed power, A is active chip area, C is the switched
capacitance, f is frequency and V is voltage).
• With these multicore processors the best performance and
highest throughput is achieved by using parallel programming
techniques
This requires knowledge and suitable programming
tools to take advantage of the multicore processors
![Page 3: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/3.jpg)
Multiprocessors & Multicore
Processors
The multiprocessor system has a divided
cache with long-interconnects
The multicore processors share the
cache with short interconnects
Multiprocessor systems contain multiple
CPUs that are not on the same chip
Multicore Processors contain any
number of multiple CPUs on a
single chip
![Page 4: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/4.jpg)
Hyper-threading
• Hyper-threading is a technology that was introduced by Intel,
with the primary purpose of improving support for multi-
threaded code.
• Under certain workloads hyper-threading technology
provides a more efficient use of CPU resources by
executing threads in parallel on a single processor.
• Hyper-threading works by duplicating certain sections of the
processor.
• A hyper-threading equipped processor (core) pretends to be
two "logical" processors to the host operating system, allowing
the operating system to schedule two threads or processes
simultaneously.
• E.g. Pentium 4, Xeon, Core i5 and Core i7 processors
implement hyper-threading.
![Page 5: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/5.jpg)
FPGAs
• FPGA = Field Programmable Gate Array
– VHDL for programming of FPGAs is part of FYS4220!
• Contains huge amount of programmable gates that can be
programmed into many parallel hardware paths
• FPGAs are truly parallel in nature so different processing
operations do not have to compete for the same resources (no
thread prioritization as typical to most common operating
system)
![Page 6: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/6.jpg)
How LabVIEW Implements Multithreading
• Parallel code paths on a block diagram can execute in
unique threads
• LabVIEW automatically divides each application into multiple
execution threads (originally introduced in 1998 with LabVIEW
5.0)
![Page 7: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/7.jpg)
LabVIEW Example: DAQ
Two separate tasks that are not dependent on one another
for data will run in parallel without the need for any extra
programming.
![Page 8: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/8.jpg)
How LabVIEW Implements Multithreading II
• Automatic Multithreading using LabVIEW Execution
System (Implicit Parallelism / Threading)
![Page 9: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/9.jpg)
Multicore Programming Goals
• Increase code execution speed
– execution time: time from start to completion of task (response time)
• Maintain rate of execution but increase data throughput
– throughput is the amount of work that can be done in a given time
• Evenly balance tasks across available CPUs (fair distribution of
processing load)
• Dedicate time-critical tasks to a single CPU
In computing, FLOPS (floating-point operations per
second) is a measure of a computer's performance
http://www.top500.org/
![Page 10: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/10.jpg)
Data Parallelism
![Page 11: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/11.jpg)
Example: Data Parallelism in LabVIEW
Data parallelism; by dividing the matrix
in half the operation can be computed
simultaneously on two CPU cores.
A standard implementation of matrix
multiplication in LabVIEW does not use
data parallelism
Split
Combine
Mult.
With 1000 x 1000 matrices used for the input matrices:
![Page 12: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/12.jpg)
Data Flow
• Many applications involve sequential, multistep
algorithms
![Page 13: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/13.jpg)
LabVIEW: Sequential data flow
Signal processing Write
The five tasks run in the same thread because
they are connected sequentially
Sim
![Page 14: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/14.jpg)
Data Flow Parallelism - Pipelining
• Applying pipelining can increase performance
– Increase throughput (amount of data processed in a given
time period)
• Pipelining Strategy:
![Page 15: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/15.jpg)
Pipelining in LabVIEW using shift registers
![Page 16: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/16.jpg)
Producer-consumer loops and pipelining
using queues
In general, the CPU and data bus
operate most efficiently when
processing large blocks of data
Note: Pipelined
processing does
introduce latency
between input and
output!
![Page 17: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/17.jpg)
Pipelining increases latency
• Pipelining increase throughput but
it also introduces additional
latency
![Page 18: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/18.jpg)
Producer-Consumer for DAQ
![Page 19: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/19.jpg)
Producer-Consumer LabVIEW
example
![Page 20: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/20.jpg)
Multicore Programming Challenges
• Thread (loop) Synchronization
• Race Conditions
• Deadlocks
• Shared resources
• Data transfer between processor cores
![Page 21: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/21.jpg)
Synchronization in LabVIEW
• Synchronization mechanisms in LabVIEW:
– Notifiers
– Queues
– Semaphores
– Rendezvous
– Occurrences
![Page 22: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/22.jpg)
Data Transfer between cores
• Physical distance between processors and
the quality of the processor connections can
have large effect on execution speed
![Page 23: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/23.jpg)
Pipelining and balancing
• In order to gain the most performance increase possible from
pipelining, individual stages must be carefully balanced so that
no single stage takes a much longer time to complete than
other stages.
• In addition, any data transfer between pipeline stages should
be minimized to avoid decreased performance due to memory
access from multiple cores.
Not optimal for pipelining! Move tasks from
Stage 1 to Stage 2 until both stages take
approximately equal times to execute
![Page 24: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/24.jpg)
Unbalanced vs. balanced Parallel Tasks
Unbalanced Balanced
![Page 25: Parallel Programming Multicore systems · Hyper-threading • Hyper-threading is a technology that was introduced by Intel, with the primary purpose of improving support for multi-threaded](https://reader030.vdocument.in/reader030/viewer/2022040517/5e766e084359f13f8a56b4c4/html5/thumbnails/25.jpg)
Conclusions
• PC-based instrumentation benefit greatly from
advances in multicore processor technology and
improved data bus speeds.
• As new CPUs improve performance by adding
multiple processing cores, parallel or pipelined
processing structures are necessary to maximize
CPU efficiency.
• You can achieve significant performance
improvements by structuring algorithms to take
advantage of parallel processing.