Carnegie Mellon Parralel Computing Notes on Lecture 6

Int i lockcounterlock i counter atomicincrcounter

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: : Redistribute particles as they move over course of simulation (if motion is slow, redistribution need not occur often) Mesh is changed as object moves or ow over object changes, but changes occur slowly (color indicates assignment of parts of mesh to processors) CMU 15-418, Spring 2014 Dynamic assignment ▪ Assignment is determined at runtime to ensure a well distributed load. (The execution time of tasks, or the total number of tasks, is unpredictable.) Sequential program (independent loop iterations) int N = 1024; int* x = new int[N]; bool* prime = new bool[N]; // initialize elements of x for (int i=0; i<N; i++) { // unknown execution time is_prime[i] = test_primality(x[i]); } Parallel program (SPMD execution of multiple threads, shared address space model) LOCK counter_lock; int counter = 0; // shared variable (assume // initialization to 0) int N = 1024; int* x = ne...
View Full Document

Ask a homework question - tutors are online