4 - Reduction Pattern Flashcards

1
Q

What is the Reduction pattern?

A

Reducing N elements into a single value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the issue with the Reduction pattern?

A

There is data dependency between elements, sum at i depends on the sum at i-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you implement the Reduction pattern?

A

Parallelise calculating the partial pairwise sums at each step then combine the steps sequentially

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Reduce function?

A

A combiner function used to combine all the elements of a collection pairwise and create a summary value.

Pairs of elements can be combined in any order, combiner function should be associative to be parallelisable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name some example combiner functions

A

Addition, multiplication, max, min

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an associative function?

A

Where the order in which operations are performed does not matter if the sequence of operands is unchanged

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the complexity of the serial Reduction pattern?

A
Work = O(n)
Span = O(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the complexity of the parallel Reduction pattern?

A
Work = O(n)
Span = O(log n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the synchronisation problem in the reduction pattern?

A

Individual work items take different time to execute

i.e in step 1 all threads check the if condition, the even threads need to read/write to memory, the odd threads just carry on

Potential for race conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you solve the synchronisation problem in the Reduction pattern?

A

Use a Barrier to wait for all threads to finish each step

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you do Reduction with large inputs?

A

Multi-pass reduction, break down a large problem into smaller chunks then operate on each chunk and then combine the results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Tiling in the Reduction pattern?

A

Breaking down into chunks/tiles/blocks, operating on each tile separately and then combining the results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In the reduction pattern what are global and local indices?

A

Tiling requires different work item indexing as the number of elements to be reduced within a group is M (group size)

Local ID is a unique index within each work group

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the Fusion of Map and Reduction pattern?

A

Combining the Map and Reduce results in a straightforward and efficient implementation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the Fusion of Map and Reduction patterns useful for?

A

Dot product and matrix multiplication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you optimise the Reduction pattern?

A

Modern hardware optimises common accesses to memory (global/local), sequential addressing groups memory access together, leading to better performance

Use of local (fast) memory