Carnegie Mellon Parralel Computing Notes on Lecture 6

Carnegie Mellon Parralel Computing Notes on Lecture 6

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: loat **A = allocate(n+2, n+2, BLOCK_Y, NUM_PROCESSORS); void solve(float** A) { while (!done) { for_all (red cells (i,j)) { float prev = A[i,j]; A[i,j] = 0.2f * (A[i- 1,j] + A[i,j- 1] + A[i,j] + A[i+1,j], A[i,j+1]); reduceAdd(diff, abs(A[i,j] - prev)); } if (diff/(n*n) < TOLERANCE) done = true; } } Example from: Culler, Singh, and Gupta CMU 15-418, Spring 2014 Solver implementation in two programming models ▪ Data-parallel programming model - Synchronization: - forall loop iterations are independent (can be parallelized) - Implicit barrier at end of outer forall loop body - Communication - Implicit in loads and stores (like shared address space) - Special built-in primitives: e.g., reduce ▪ Shared address space - Synchronization: - Locks (for mutual exclusion) and barriers (to separate phases of computation) are used to express dependencies - Communication - Implicit in loads/stores to shared variables CMU 15-418, Spring 2014 Today: message passing model ▪ No shared address space abstraction (i.e., no shared variables) ▪ Each thread has its own address space ▪ Threads communicate & synchronize by sending/receiving messages One possible message passing machine implementation: a cluster of workstation...
View Full Document

This document was uploaded on 03/19/2014 for the course CMP 15-418 at Carnegie Mellon.

Ask a homework question - tutors are online