Csep 524 parallel computadon winter 2013 chamberlain

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: ComputaDon Winter 2013: Chamberlain 46 Mul3dimensional Distribu3ons •  So far, we’ve primarily looked at 1D distribuDons •  DistribuDons can also be mulDdimensional –  one opDon is to apply a 1D distribuDon per dimension –  another is to distribute the items holisDcally CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 47 Holis3c Distribu3on: Recursive Bisec3on Note: Can’t be expressed as the conflaDon of two 1D distribuDons CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 48 Mul3dimensional Distribu3ons •  So far, we’ve primarily looked at 1D distribuDons •  DistribuDons can also be mulDdimensional –  one opDon is to apply a 1D distribuDon per dimension –  another is to distribute the items holisDcally •  Or, even unstructured (e.g., distribute a graph) –  a topic for another day CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 49 Measuring Load Imbalance •  In assignment #1, we used the following paMern to measure the overall execuDon Dme of the code: var totTime, maxTime = 0.0; var minTime = max(real); This essenDally measured start timer max(Dmepurple, Dmegreen) create tasks do work join tasks check timer CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 50 Measuring Load Imbalance •  Imagine instead, pushing the Dming into the loop: s var totTime, maxTime = 0.0; var minTime = max(real); This permits us to measure create tasks Dmepurple and Dmegreen disDnctly start timer do work check timer join tasks CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 51 Measuring Load Imbalance •  Now, we can compute staDsDcs on a task-­‐by-­‐task basis: var totTime, maxTime = 0.0; var minTime = max(real); coforall tid in 0..#numTasks { What’s the bug in this code? start timer do work const myTime = check timer totTime += myTime; if myTime < minTime then minTime = myTime; if myTime > maxTime then maxTime = myTime; } const avgTime = totTime / numTasks; CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 52 Bug of the week •  The previous slide contains a classic bug –  Code that looks innocuous is actually problemaDc –  Cause: reading parallel code as though it were sequenDal coforall tid in 0..#numTasks { … totTime += myTime; … } Task 1 Task 2 reg = read totTime reg = reg + myTime totTime = write reg CSEP 524: Parallel ComputaDon reg = read totTime reg = reg + myTime totTime = write reg Winter 2013: Chamberlain 53 Bug of the week •  Whether or not this bug exhibits itself depends on the scheduling of the tasks –  the following schedule would be fine: @me CSEP 524: Parallel ComputaDon Task 1 reg = read totTime reg = reg + myTime totTime = write reg Task 2 reg = read totTime reg = reg + myTime totTime = write reg Winter 2013: Chamberlain 54 Bug of the week •  Whether or not this bug exhibits itself depends on the scheduling of the tasks –  the following schedule is problemaDc: @me Task 1 reg = read totTime reg = reg + myTime totTime = write reg Task 2 reg = read totTime reg = reg + myTime totTime = write reg 3.7 myTime 2.3 myTime reg reg 0.0 totTime CSEP 52...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online