MOVING PARTICLES IN A 2x2 GRID
In this exercise we will simulate a set of particles moving randomly in a 2-dimensional space
within a bounding box. The coordinates of the overall simulation box are
between 0.0 and 1.0 along each dimension. The particles are divided among chares
based on their coordinates. The chares are organized in a 2-dimensional array
of chares (using a chare array) of size k x k. So, each chare owns a bounding
box of its own with size 1/k x 1/k.
This exercise will include
- doing reductions
- doing load balancing
- using projections to analyze the performance
- using liveViz to visualize the particle distribution
The relevant code for this exercise can be downloaded here. There are three folders consisting of the base code and the solution for that exercise. Modify the Makefile to point to your compiled charm and run make test to run the test.
Exercise 1: Reductions
You can refer to the reductions section in the charm manual.
- cd exercise1/base_code/
- Modify the code to calculate and print to screen the maximum and average number of particles per cell every iteration.
- Use reduction via the contribute call.
- Make sure the Cells don't wait for the reduction to complete. It asynchronously completes and prints even as the cells move on to the subsequent iterations.
- Do make test to run the test
- Solution can be found in the exercise1/solution/.
Exercise 2: Load Balancing
You can refer to the load balancing section in the charm manual. You can also look at various examples located in charm/examples/charm++/load_balancing/.
- cd exercise2/base_code/
- Add load balancing to the code: call AtSync every 10 steps, and wait for balancing to finish before continuing.
- Modify the Makefile to add the link time flag -module CommonLBs
- Do make test to run the test. Note that you can specify the type of load balancer to use during run time using the run time option +balancer RefineLB.
- It prints the maximum and average number of particles per processor. Notice the maximum and average number of particles per processor before and after load balancing.
- Solution can be found in the exercise2/solution/.
Exercise 3: Projections for performance evaluation
You can refer to the projections section in the charm manual.
- cd exercise2/base_code/
- Modify the Makefile to add the link time flag -tracemode projections
- Do make test to run the test. This will create the log files.
- Projections tool can be downloaded from http://charm.cs.illinois.edu/software.
- Build projections tool. Follow the instructions given here.
- Start projections PROJECTIONS_LOCATION/bin/projections [NAME.sts]
- Observe the effect of load balancing on the total execution time.
Exercise 4: Using liveViz for live visualization
(NOTE: Do this part on a local machine, LiveViz may not work on some remote clusters because of the secured ssh connections.)
In this part you will visualize the 2-D grid with moving particles with LiveViz. Each particle has a variable called color. In the beginning Green particles will be distributed on the left half of the array, blue particles will be on the right half of the array and red at the 4 quarter corners. This part of the code is given.
You can refer to the liveViz section in the manual. You can also look at wave2d application located in charm/examples/charm++/wave2d.
- cd exercise4/base_code/
- Modify the Makefile to add the link time flag -module liveViz
- Add an entry method that takes a liveVizRequestMsg message. Create the image to be deposited and call liveVizDeposit function.
- Initialize liveViz in the main chare with the config.
- Do make test to run the test. Note that the program needs to be launched with ++server ++server-port xxxx. This will launch the ccs server.
- To install the ccs client, follow the instructions given here.
- Start liveViz client liveViz
- Solution can be found in the exercise4/solution/.