CS代写 XJCO3221 Parallel Computation – cscodehelp代写
Overview Multi-threaded vector addition Nested loops in parallel Summary and next lecture
XJCO3221 Parallel Computation
University of Leeds
Copyright By cscodehelp代写 加微信 cscodehelp
Lecture 3: Data parallel problems
XJCO3221 Parallel Computation
Multi-threaded vector addition Previous lectures
Nested loops in parallel Today’s lecture Summary and next lecture
Previous lectures
In the last lecture we started looking at shared memory parallelism (SMP):
Relevant to multi-core CPUs.
Separate processing units (cores) share some levels of
memory cache.
Various frameworks for programming SMP systems. Widely-implemented standard: OpenMP.
XJCO3221 Parallel Computation
Multi-threaded vector addition Previous lectures Nested loops in parallel Today’s lecture
Summary and next lecture
Today’s lecture
Today we are going to look at a some actual problems.
Examples of a data parallel problems, where the same operation is applied to multiple data elements.
Also known as a map1.
Multi-threading solution employs a fork-join pattern.
How to parallelise nested loops.
Parallel code can be non-deterministic, even when the serial code is deterministic.
1McCool et al., Structured parallel programming (Morgan-Kaufman, 2012). XJCO3221 Parallel Computation
Multi-threaded vector addition
Nested loops in parallel Summary and next lecture
Vector addition in serial
Vector addition in parallel
Thread-level description
Data parallel and embarrassingly parallel
Vector addition
An n-vector a can be thought of as an array of n numbers: a = (a1,a2,…,an).
If two vectors a and b are the same size, they can be added to generate a new n-vector c:
a=( a1, a2, a3, …, an ) +++++ b=( b1, b2, b3, … bn ) ↓↓↓↓↓ c=( c1, c2, c3 …, cn )
ci=ai+bi , i=1…n.
XJCO3221 Parallel Computation
Multi-threaded vector addition
Nested loops in parallel Summary and next lecture
Vector addition in serial
Vector addition in parallel
Thread-level description
Data parallel and embarrassingly parallel
Serial vector addition
Code on Minerva: vectorAddition serial.c
#define n 100
int main () {
float a[n], b[n], c[n];
… // Initialise a[n] and b[n]
for( i=0; i