Differences

This shows you the differences between two versions of the page.

Link to this comparison view

dss:laboratoare:05 [2019/06/26 15:31]
eduard.staniloiu [Exercises]
dss:laboratoare:05 [2019/06/26 16:12] (current)
eduard.staniloiu [Exercises]
Line 458: Line 458:
  
 ==== Exercises ==== ==== Exercises ====
 +
 +The lab can be found at this [[https://​github.com/​RazvanN7/​D-Summer-School/​tree/​master/​lab-05|link]]. ​
  
 === 1. Parallel programming === === 1. Parallel programming ===
Line 492: Line 494:
 </​note>​ </​note>​
  
 +=== 4. I did it My way ===
 +
 +Let's implement our own concurrent **map** function.
 +Navigate to the 4-concurrent-map directory. Starting from the serial implementation found in **mymap.d** modify the code such that
 +the call to **mymap** function will execute on multiple threads. You are required to use the **std.concurrency** module for this task.
 +
 +Creating a thread implies some overhead, thus we don't want to create a thread for each element, but rather have a thread process chunks of elements; basically we need a **workUnitSize**.
 +
 +=== 5. Don't stop me now ===
 +
 +Since we just got started, let's implement our our concurrent **reduce** function. **reduce** must take the initial accumulator value as it's first parameter, and then the list of elements to reduce.
 +
 +<​note>​
 +Be careful about those race conditions.
 +</​note>​
 +
 +=== 6. Under pressure ===
 +
 +The implementations we did at ex. 4 and ex. 5 are great and all, but they have the following shortcoming:​ they will each spawn a number of threads (most likely equal to the number of physical cores), so calling them both in parallel will spawn twice the amount of threads that can run in parallel.
 +
 +Change your implementations to use a thread pool. The worker threads will consume jobs from a queue. The map and reduce implementations will push job abstractions into the queue.
 +
 +Now we're talking!
dss/laboratoare/05.1561552291.txt.gz ยท Last modified: 2019/06/26 15:31 by eduard.staniloiu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0