Buffersize sync real cobegin producer consumer proc

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: until full, leaves empty } } 72 —  Syntax single-type: single type —  SemanDcs —  Similar to sync variables, but stays full once wriMen —  Example: MulDple Consumers of a future var future$: single real; begin future$ = compute(); computeSomethingElse(future$); computeSomethingElse(future$); 73 —  readFE():t —  readFF():t —  readXX():t —  writeEF(v:t) —  writeFF(v:t) —  writeXF(v:t) —  isFull: bool —  reset() block unDl full, leave empty, return value block unDl full, leave full, return value return value (non-­‐blocking) block unDl empty, set value to v, leave full wait unDl full, set value to v, leave full set value to v, leave full (non-­‐blocking) reset value, leave empty (non-­‐blocking) return true if full else false (non-­‐blocking) —  Defaults: read: readFE, write: writeEF 74 —  readFE():t —  readFF():t —  readXX():t —  writeEF(v:t) —  writeFF(v:t) —  writeXF(v:t) —  isFull: bool —  reset() block unDl full, leave empty, return value block unDl full, leave full, return value return value (non-­‐blocking) block unDl empty, set value to v, leave full wait unDl full, set value to v, leave full set value to v, leave full (non-­‐blocking) reset value, leave empty (non-­‐blocking) return true if full else false (non-­‐blocking) —  Defaults: read: readFF, write: writeEF 75 Using Sync vars to fix RRWW bugs var totTime$: sync real = 0.0; // starts full coforall tid in 0..#numTasks { … totTime$ += myTime; // readFE followed by writeEF … } CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 76 Summary: Pthreads vs. Chapel Synchroniza3on Pthreads mutex & condi3on variables: + arguably a reasonable backbone for synchronizaDon •  based on the endurance of Pthreads •  use of these concepts in other languages/contexts –  arguably result in complex code for common paMerns Chapel sync/single variables: + data-­‐centric synchroniza@on: expressing synchronizaDon in terms of the data being accessed –  arguably a liMle arDficial/confusing when used as a mutex •  e.g., see unused boolean value in previous criDcal secDon example Both approaches also have some common liabili@es (stay tuned) CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 77 Diagnosing Deadlock/Livelock in Chapel •  If you suspect you have a deadlock problem… –  re-­‐execute your program using –b/-­‐-­‐blockreport •  adds a certain amount of overhead, but beats deadlocking! –  if deadlock is detected, the program will… •  terminate •  do its best to tell you where the tasks were •  If you suspect you have a livelock problem… –  re-­‐execute your program using –t/-­‐-­‐taskreport •  again, adds a certain amount of overhead –  upon hixng Ctrl-­‐C/sending SIGINT, the program will… •  terminate and do its best to tell you where the tasks are CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 78 This week’s assignment •  extend the single-­‐producer/single-­‐consumer bounded buffer paMern shown in lecture to support mulDple producers and consumers –  in Chapel (to get pracDce with sync/single variables) –  in Pthreads (to get pracDce with mutex/condiDon variables) •  write a dynamic load balancing distribuDon in Chapel OR Pthreads –  apply to ramp + factorial case •  some wriMen quesDons CSEP 524: Parallel ComputaDon Winter 2013: Chamberlain 79...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online