18-GPU-Atomic-Operations Flashcards

(21 cards)

1
Q

What is an atomic operation?

A

Operation that completes without interruption - appears instantaneous

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

What is the load-compute-store problem?

A

Multiple threads reading, modifying, writing same variable cause races

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

What is the histogram example?

A

Counting frequency of values - multiple threads incrementing same counters

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

What is the problem with naive histogram?

A

Race conditions cause lost increments

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

What is the solution?

A

Use atomic_inc() for thread-safe increments

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

What are OpenCL atomic operations?

A

atomic_inc, atomic_dec, atomic_add, atomic_min, atomic_max, etc.

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

What is atomic_inc(p)?

A

Atomically increments *p, returns old value

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

What is atomic_cmpxchg(p

A

cmp

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

What is the spinlock pattern?

A

while(atomic_cmpxchg(&lock, 0, 1) == 1) - busy wait for lock

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

What is the problem with spinlocks on GPU?

A

Global memory lock causes contention, divergence issues

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

What is lock-free programming?

A

Thread-safe data structures without locks, using atomics

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

What is the linked list prepend problem?

A

Multiple threads adding to list head simultaneously

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

What is the lock-free solution?

A

Use atomic_cmpxchg in loop to update head pointer atomically

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

What is optimistic concurrency?

A

Assume operation succeeds, retry if conflict detected

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

What is the trade-off with atomics?

A

Lower overhead than locks but limited to simple operations

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

When to use atomics vs locks?

A

Atomics for simple operations, locks for complex multi-statement sections

17
Q

What is the histogram optimization?

A

Use local memory per work group, then atomic add to global

18
Q

Why use local memory for histogram?

A

Reduces contention on global memory locations

19
Q

What is the local histogram pattern?

A

Each work group builds local histogram, then atomically adds to global

20
Q

What is the performance benefit?

A

Less contention, local memory is faster

21
Q

What is the key insight about GPU atomics?

A

Essential for coordinating access to shared resources like histograms