What is loop parallelism?
Parallelizing loops by distributing iterations across multiple threads
What are the three types of loop dependencies?
Flow dependencies (RAW - read after write), Anti-dependencies (WAR - write after read), Output dependencies (WAW - write after write)
How do you identify loop dependencies?
Check if variables are read/written in different iterations in conflicting orders
What is the solution for flow dependencies?
Use temporary arrays to break the read-after-write dependency
What happens in the incorrect parallel shift example?
for(i=0; i<n-1; i++) a[i] = a[i+1]; - threads overwrite values before others read them
What is the correct solution for parallel array shifting?
Use a temporary array: copy to temp first, then shift from temp
What is the Gauss-Seidel method?
Iterative numerical method where each element is updated using neighbors: a[i] = 0.5*(a[i-1] + a[i+1])
Why is standard Gauss-Seidel not parallelizable?
Each update depends on the previous update in the loop
What is red-black Gauss-Seidel?
Modified version where even indices are updated first, then odd indices, removing dependencies within each phase
How does red-black ordering remove dependencies?
Even elements depend on odd neighbors, odd elements depend on even neighbors - separating by parity breaks this cycle
What are the two phases in red-black Gauss-Seidel?
Phase 1: update all even indices, Phase 2: update all odd indices
What is the key insight for parallelizing dependent algorithms?
Sometimes a small algorithm change can remove dependencies while preserving correctness
What are the limitations of the dependency removal approach?
May require more iterations to converge, but each iteration is now parallelizable
What is the general strategy for handling loop dependencies?
1) Identify dependencies, 2) Try to remove them with algorithm changes, 3) Use synchronization if removal impossible, 4) Consider if parallelization is worth the overhead