X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e5ffbd7cb554dd3678545d575126a1a97d6c57c9..5937b88aaa18de687b2de15a97ee3ae0dc480f64:/docs/source/tuto_smpi.rst diff --git a/docs/source/tuto_smpi.rst b/docs/source/tuto_smpi.rst index fe11f833c5..434a16152d 100644 --- a/docs/source/tuto_smpi.rst +++ b/docs/source/tuto_smpi.rst @@ -333,11 +333,11 @@ nodes from the ``cluster_crossbar.xml`` platform as follows: .. code-block:: shell - $ smpirun -np 16 -platform cluster_crossbar.xml -hostfile cluster_hostfile.txt ./roundtrip + $ smpirun -np 16 -platform cluster_crossbar.xml -hostfile cluster_hostfile ./roundtrip - The ``-np 16`` option, just like in regular MPI, specifies the number of MPI processes to use. -- The ``-hostfile cluster_hostfile.txt`` option, just like in regular +- The ``-hostfile cluster_hostfile`` option, just like in regular MPI, specifies the host file. If you omit this option, ``smpirun`` will deploy the application on the first machines of your platform. - The ``-platform cluster_crossbar.xml`` option, **which doesn't exist @@ -346,9 +346,149 @@ nodes from the ``cluster_crossbar.xml`` platform as follows: - At the end of the line, one finds the executable name and command-line arguments (if any -- roundtrip does not expect any arguments). +Feel free to tweak the content of the XML platform file and the +program to see the effect on the simulated execution time. It may be +easier to compare the executions with the extra option +``--cfg=smpi/display_timing:yes``. Note that the simulation accounts +for realistic network protocol effects and MPI implementation +effects. As a result, you may see "unexpected behavior" like in the +real world (e.g., sending a message 1 byte larger may lead to +significant higher execution time). + +Lab 1: Visualizing LU +--------------------- + +We will now simulate a larger application: the LU benchmark of the NAS +suite. The version provided in the code template was modified to +compile with SMPI instead of the regular MPI. Compare the difference +between the original ``config/make.def.template`` and the +``config/make.def`` that was adapted to SMPI. We use ``smpiff`` and +``smpicc`` as compilers, and don't pass any additional library. + +Now compile and execute the LU benchmark, class S (i.e., for `small +data size +`_) with +4 nodes. +.. code-block:: shell + + $ make lu NPROCS=4 CLASS=S + (compilation logs) + $ smpirun -np 4 -platform ../cluster_backbone.xml bin/lu.S.4 + (execution logs) + +To get a better understanding of what is going on, activate the +vizualization tracing, and convert the produced trace for later +use: + +.. code-block:: shell + + smpirun -np 4 -platform ../cluster_backbone.xml -trace --cfg=tracing/filename:lu.S.4.trace bin/lu.S.4 + pj_dump --ignore-incomplete-links lu.S.4.trace | grep State > lu.S.4.state.csv + +You can then produce a Gantt Chart with the following R chunk. You can +either copy/paste it in a R session, or `turn it into a Rscript executable +`_ to +run it again and again. + +.. code-block:: R + + library(ggplot2) + + # Read the data + df_state = read.csv("lu.S.4.state.csv", header=F, strip.white=T) + names(df_state) = c("Type", "Rank", "Container", "Start", "End", "Duration", "Level", "State"); + df_state = df_state[!(names(df_state) %in% c("Type","Container","Level"))] + df_state$Rank = as.numeric(gsub("rank-","",df_state$Rank)) + + # Draw the Gantt Chart + gc = ggplot(data=df_state) + geom_rect(aes(xmin=Start, xmax=End, ymin=Rank, ymax=Rank+1,fill=State)) + + # Produce the output + plot(gc) + dev.off() + +This produces a file called ``Rplots.pdf`` with the following +content. You can find more visualization examples `online +`_. + +.. image:: /tuto_smpi/img/lu.S.4.png + :align: center + +Lab 2: Tracing and Replay of LU +------------------------------- + +Now compile and execute the LU benchmark, class A, with 32 nodes. + +.. code-block:: shell + + $ make lu NPROCS=32 CLASS=A + +This takes several minutes to to simulate, because all code from all +processes has to be really executed, and everything is serialized. + +SMPI provides several methods to speed things up. One of them is to +capture a time independent trace of the running application, and +replay it on a different platform with the same amount of nodes. The +replay is much faster than live simulation, as the computations are +skipped (the application must be network-dependent for this to work). + +You can even generate the trace during as live simulation, as follows: + +.. code-block:: shell + + $ smpirun -trace-ti --cfg=tracing/filename:LU.A.32 -np 32 -platform ../cluster_backbone.xml bin/lu.A.32 + +The produced trace is composed of a file ``LU.A.32`` and a folder +``LU.A.32_files``. To replay this with SMPI, you need to first compile +the provided ``smpi_replay.cpp`` file, that comes from +`simgrid/examples/smpi/replay +`_. + +.. code-block:: shell + + $ smpicxx ../replay.cpp -O3 -o ../smpi_replay + +Afterward, you can replay your trace in SMPI as follows: + + $ smpirun -np 32 -platform ../cluster_torus.xml -ext smpi_replay ../smpi_replay LU.A.32 + +All the outputs are gone, as the application is not really simulated +here. Its trace is simply replayed. But if you visualize the live +simulation and the replay, you will see that the behavior is +unchanged. The simulation does not run much faster on this very +example, but this becomes very interesting when your application +is computationally hungry. + +.. todo:: smpi_replay should be installed by SimGrid, and smpirun interface could be simplified here. + +Lab 3: Execution Sampling on EP +------------------------------- + +The second method to speed up simulations is to sample the computation +parts in the code. This means that the person doing the simulation +needs to know the application and identify parts that are compute +intensive and take time, while being regular enough not to ruin +simulation accuracy. Furthermore there should not be any MPI calls +inside such parts of the code. + +Use the EP benchmark, class B, 16 processes. + +.. todo:: write this section, and the following ones. + +Further Readings +---------------- + +You may also be interested in the `SMPI reference article +`_ or these `introductory slides +`_. The `SMPI +reference documentation `_ covers much more content than +this short tutorial. -We will use following simple MPI program, roundtrip.c, in which the processes pass around a message and print the elpased time: +Finally, we regularly use SimGrid in our teachings on MPI. This way, +our student can experiment with platforms that they do not have access +to, and the associated visualisation tools helps them to understand +their work. The whole material is available online, in a separate +project: the `SMPI CourseWare `_. - .. LocalWords: SimGrid