Carnegie Mellon Parralel Computing Notes on Lecture 6

its serial execution recall amdahls law what is s

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: w int[N]; bool* is_prime = new bool[N]; // initialize elements of x while (1) { int i; lock(counter_lock); i = counter++; atomic_incr(counter); unlock(counter_lock); if (i >= N) break; is_prime[i] = test_primality(x[i]); } CMU 15-418, Spring 2014 Dynamic assignment using work queues Sub-problems (a.k.a. “tasks”, “work”) Shared work queue: a list of work to do (for now, let’s assume each piece of work is independent) Worker threads: Pull data from shared work queue Push new work to queue as it’s created T1 T2 T3 T4 CMU 15-418, Spring 2014 What constitutes a piece of work? ▪ What is a potential problem with this implementation? LOCK counter_lock; int counter = 0; // shared variable (assume // initialization to 0) const int N = 1024; float* x = new float[N]; bool* prime = new bool[N]; // initialize elements of x...
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