|
| 1 | +--- |
| 2 | +title: Load Balancing Particle Exercise (Extension) |
| 3 | +homec: home |
| 4 | +tutorialc: tutorial |
| 5 | +applicationsc: applications |
| 6 | +miniAppsc: miniApps |
| 7 | +downloadc: download |
| 8 | +toolsc: tools |
| 9 | +helpc: help |
| 10 | +--- |
| 11 | + |
| 12 | +<link rel="stylesheet" type="text/css" href="../../tutorial/TutorialStyle.css"> |
| 13 | + |
| 14 | +<h1>Load Balancing: Particle Exercise <em>(Extension)</em></h1> |
| 15 | + |
| 16 | +<table class="StandardFigure" align="right" border="0"> |
| 17 | + <tr><td align="center" valign="middle"> |
| 18 | + <a href="../images/particlescode_lb.png"> |
| 19 | + <img class="StandardFigure" src="../images/particlescode_lb.png" border="0" width="375"> |
| 20 | + </a> |
| 21 | + </td></tr> |
| 22 | + <tr><td align="center" valign="middle"><b>Figure 1</b></td></tr> |
| 23 | +</table> |
| 24 | +<h2>Part 1 – Introducing Imbalance</h2> |
| 25 | + |
| 26 | +<p>The very first task is to create measurable imbalance so that load balancers have something meaningful to fix.</p> |
| 27 | + |
| 28 | +<ol> |
| 29 | + <li> |
| 30 | + Let <code>m × m</code> be the chare-array dimensions and <code>k</code> the baseline number of particles per chare. Update the number of particles per chare to be |
| 31 | +<span lang="latex">N_{x,y} = k + \frac{2k(x + y)}{2m}</span>. |
| 32 | + </li> |
| 33 | + |
| 34 | + <li> |
| 35 | + Build with tracing enabled using the <code>-tracemode projections</code> flag. |
| 36 | + </li> |
| 37 | + <li> |
| 38 | + Install <a href="https://github.com/charmplusplus/projections">projections</a>, and focus on the time profile view to see how the imbalance affects performance and efficiency. |
| 39 | + </li> |
| 40 | +</ol> |
| 41 | + |
| 42 | +<!-- =================================================================== --> |
| 43 | +<h2>Part 2 – Adding Migration Support & Load-Balancing</h2> |
| 44 | + |
| 45 | +<p>Now enable dynamic migration so Charm++ balancers can actually move work around.</p> |
| 46 | + |
| 47 | +<ol> |
| 48 | + <li> |
| 49 | + Implement <code>PUP</code> serialization for your chare array as <a href="https://charm.readthedocs.io/en/latest/charm++/manual.html#arraymigratable">documented</a>. |
| 50 | + </li> |
| 51 | + <li> |
| 52 | + At appropriate intervals, call <code><a href="https://charm.readthedocs.io/en/latest/charm++/manual.html#load-balancing-chare-arrays">AtSync()</a></code> so the runtime knows the chare is ready for potential migration. |
| 53 | + </li> |
| 54 | + <li> |
| 55 | + Select a load-balancing strategy. For this exercise we will use |
| 56 | + <code>GreedyRefineLB</code> (use option <code>-balancer GreedyRefineLB</code>). |
| 57 | + </li> |
| 58 | + |
| 59 | + <li> |
| 60 | + Re-run the application as in Part 1 and compare how the program behaves differently. |
| 61 | + </li> |
| 62 | +</ol> |
| 63 | + |
| 64 | +<h2>Part 3 – Visualising with LiveViz</h2> |
| 65 | + |
| 66 | +<p>Add colour to emphasise the skew and watch the balancer work.</p> |
| 67 | + |
| 68 | +<ol> |
| 69 | + <li> |
| 70 | + Extend each chare to contain particles of three different colors. Each color should move at different speeds - green should move at the default speed, red should move twice as fast and green should move half as fast. |
| 71 | + </li> |
| 72 | + |
| 73 | + <li> |
| 74 | + Distribute colours to reproduce the imbalance as shown in the figure: reds bunched in the centre, greens in the upper-left, blues in the lower-right. |
| 75 | + </li> |
| 76 | + |
| 77 | + <li> |
| 78 | + Compile with <a href="https://github.com/UIUC-PPL/ccs_tools">LiveViz</a> using the <code>-module liveViz</code> flag. |
| 79 | + </li> |
| 80 | + |
| 81 | + <li> |
| 82 | + Run your C++ code using <code>++server</code> and <code>++server-port 1234</code>, and then run the liveViz client using <code>liveVize localhost 1234</code>, and observe how the particles behave. |
| 83 | + </li> |
| 84 | +</ol> |
0 commit comments