/usr/share/doc/simgrid/html/use.html is in simgrid-doc 3.10-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SimGrid: Using SimGrid</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">SimGrid
 <span id="projectnumber">3.10</span>
</div>
<div id="projectbrief">Versatile Simulation of Distributed Systems</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="http://simgrid.gforge.inria.fr/"><span>Home page</span></a></li>
<li><a href="http://simgrid.gforge.inria.fr/documentation.html"><span>Online documentation</span></a></li>
<li><a href="https://gforge.inria.fr/projects/simgrid"><span>Dev's Corner</span></a></li>
<li> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('use.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">Using SimGrid </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#using_msg">Using MSG</a><ul><li class="level2"><a href="#MSG_ex_basics">Basic examples and features</a><ul><li class="level3"><a href="#MSG_ex_asynchronous_communications">Asynchronous communications</a><ul><li class="level4"><a href="#MSG_ext_icomms_code">Code of the application</a></li>
<li class="level4"><a href="#MSG_ext_icomms_preliminary">Preliminary declarations</a></li>
<li class="level4"><a href="#MSG_ext_icomms_Sender">Sender function</a></li>
<li class="level4"><a href="#MSG_ext_icomms_Receiver">Receiver function</a></li>
<li class="level4"><a href="#MSG_ext_icomms_core">Simulation core</a></li>
<li class="level4"><a href="#MSG_ext_icomms_Main">Main function</a></li>
<li class="level4"><a href="#MSG_ext_icomms_fct_Waitall">Waitall function for sender</a></li>
<li class="level4"><a href="#MSG_ext_icomms_fct_Waitany">Waitany function</a></li>
<li class="level4"><a href="#MSG_ext_icomms_fct_Waitany_sender">From a sender</a></li>
<li class="level4"><a href="#MSG_ext_icomms_fct_Waitany_receiver">From a receiver</a></li>
</ul>
</li>
<li class="level3"><a href="#MSG_ex_master_slave">Basic Master/Slaves</a><ul><li class="level4"><a href="#MSG_ex_ms_TOC">Table of contents:</a></li>
<li class="level4"><a href="#MSG_ext_ms_preliminary">Preliminary declarations</a></li>
<li class="level4"><a href="#MSG_ext_ms_master">Master code</a></li>
<li class="level4"><a href="#MSG_ext_ms_slave">Slave code</a></li>
<li class="level4"><a href="#MSG_ext_ms_forwarder">Forwarder code</a></li>
<li class="level4"><a href="#MSG_ext_ms_core">Simulation core</a></li>
<li class="level4"><a href="#MSG_ext_ms_main">Main() function</a></li>
</ul>
</li>
<li class="level3"><a href="#MSG_ext_ms_helping">Helping files</a><ul><li class="level4"><a href="#MSG_ext_ms_application">Example of application file</a></li>
<li class="level4"><a href="#MSG_ext_ms_platform">Example of platform file</a></li>
</ul>
</li>
<li class="level1"><a href="#using_smpi">Using SMPI</a></li>
<li class="level1"><a href="#using_MC">Using Model Checking</a></li>
<li class="level1"><a href="#using_trace">Using Trace</a></li>
<li class="level1"><a href="#using_simdag">Using SimDag</a></li>
<li class="level1"><a href="#using_simix">Using SIMIX</a></li>
</ul>
</div>
<div class="textblock"><p>This page is under work – sorry for the inconvinience (FIXME).</p>
<ul>
<li><a class="el" href="platform.html">Platform Description</a></li>
<li><a class="el" href="deployment.html">Deployment Description</a></li>
<li><a class="el" href="tracing.html">Tracing Simulations</a></li>
<li><a class="el" href="options.html">Simgrid options and configurations</a></li>
<li><a class="el" href="help.html">Getting help</a></li>
</ul>
<p>SimGrid comes with many examples provided in the examples/ directory. Those examples are described in section <a class="el" href="group__MSG__examples.html">MSG examples</a> . Those examples are commented and should be easy to understand. for a first step into SimGrid we also provide some more detailed examples in the sections below.</p>
You should also check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html"> tutorial section</a> that contains a generic tutorial about using SimGrid.
<h1><a class="anchor" id="using_msg"></a>
Using MSG</h1>
You should also check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html"> tutorial section</a> that contains a dedicated tutorial.
<p>Here are some examples on how to use MSG, the most used API.</p>
<p>tr MSG comes with an extensive set of examples. It is sometimes difficult to find the one you need. This list aims at helping you finding the example from which you can learn what you want to.</p>
<h2><a class="anchor" id="MSG_ex_basics"></a>
Basic examples and features</h2>
<h3><a class="anchor" id="MSG_ex_asynchronous_communications"></a>
Asynchronous communications</h3>
<p>Simulation of asynchronous communications between a sender and a receiver using a realistic platform and an external description of the deployment.</p>
<ul>
<li><a class="el" href="use.html#MSG_ext_icomms_code">Code of the application</a><ul>
<li><a class="el" href="use.html#MSG_ext_icomms_preliminary">Preliminary declarations</a></li>
<li><a class="el" href="use.html#MSG_ext_icomms_Sender">Sender function</a></li>
<li><a class="el" href="use.html#MSG_ext_icomms_Receiver">Receiver function</a></li>
<li><a class="el" href="use.html#MSG_ext_icomms_core">Simulation core</a></li>
<li><a class="el" href="use.html#MSG_ext_icomms_Main">Main function</a></li>
</ul>
</li>
<li><a class="el" href="use.html#MSG_ext_icomms_fct_Waitall">Waitall function for sender</a></li>
<li><a class="el" href="use.html#MSG_ext_icomms_fct_Waitany">Waitany function</a></li>
</ul>
<hr/>
<h4><a class="anchor" id="MSG_ext_icomms_code"></a>
Code of the application</h4>
<h4><a class="anchor" id="MSG_ext_icomms_preliminary"></a>
Preliminary declarations</h4>
<p><div class="fragment"><div class="line"><span class="preprocessor">#include <stdio.h></span></div>
<div class="line"><span class="preprocessor">#include "msg/msg.h"</span> <span class="comment">/* Yeah! If you want to use msg, you need to include msg/msg.h */</span></div>
<div class="line"><span class="preprocessor">#include "xbt/sysdep.h"</span> <span class="comment">/* calloc, printf */</span></div>
<div class="line"></div>
<div class="line"><span class="comment">/* Create a log channel to have nice outputs. */</span></div>
<div class="line"><span class="preprocessor">#include "xbt/log.h"</span></div>
<div class="line"><span class="preprocessor">#include "xbt/asserts.h"</span></div>
<div class="line"><a class="code" href="group__XBT__log.html#ga5094a0e812d0012e6ee4d2257b1a13f1">XBT_LOG_NEW_DEFAULT_CATEGORY</a>(msg_test,</div>
<div class="line"> <span class="stringliteral">"Messages specific for this msg example"</span>);</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> sender(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><span class="keywordtype">int</span> receiver(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div>
<div class="line"></div>
<div class="line"><a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> test_all(<span class="keyword">const</span> <span class="keywordtype">char</span> *platform_file,</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *application_file);</div>
<div class="line"></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_Sender"></a>
Sender function</h4>
<p>The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()". It also available to "make MSG_comm_wait()" which make both of them.</p>
<p>C style arguments (argc/argv) are interpreted as:</p>
<ul>
<li>the number of tasks to distribute</li>
<li>the computation size of each task</li>
<li>the size of the files associated to each task</li>
<li>a list of host that will accept those tasks.</li>
<li>the time to sleep at the beginning of the function</li>
<li>This time defined the process sleep time if time = 0 use of <a class="el" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait()</a> if time > 0 use of <a class="el" href="group__msg__task__usage.html#gafd22dad001b95804f5e93aa146c84fd3" title="Checks whether a communication is done, and if yes, finalizes it.">MSG_comm_test()</a></li>
</ul>
<p><div class="fragment"><div class="line"><span class="keywordtype">int</span> sender(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">long</span> number_of_tasks = atol(argv[1]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comp_size = atof(argv[2]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comm_size = atof(argv[3]);</div>
<div class="line"> <span class="keywordtype">long</span> receivers_count = atol(argv[4]);</div>
<div class="line"> <span class="keywordtype">double</span> sleep_start_time = atof(argv[5]);</div>
<div class="line"> <span class="keywordtype">double</span> sleep_test_time = atof(argv[6]);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"sleep_start_time : %f , sleep_test_time : %f"</span>, sleep_start_time,</div>
<div class="line"> sleep_test_time);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> comm = NULL;</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task = NULL;</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(sleep_start_time);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks; i++) {</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[256];</div>
<div class="line"> <span class="keywordtype">char</span> sprintf_buffer[256];</div>
<div class="line"></div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%ld"</span>, i % receivers_count);</div>
<div class="line"> sprintf(sprintf_buffer, <span class="stringliteral">"Task_%d"</span>, i);</div>
<div class="line"></div>
<div class="line"> task =</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(sprintf_buffer, task_comp_size, task_comm_size,</div>
<div class="line"> NULL);</div>
<div class="line"> comm = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(task, mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Send to receiver-%ld Task_%d"</span>, i % receivers_count, i);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (sleep_test_time == 0) {</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait</a>(comm, -1);</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="keywordflow">while</span> (<a class="code" href="group__msg__task__usage.html#gafd22dad001b95804f5e93aa146c84fd3" title="Checks whether a communication is done, and if yes, finalizes it.">MSG_comm_test</a>(comm) == 0) {</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(sleep_test_time);</div>
<div class="line"> };</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(comm);</div>
<div class="line"></div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < receivers_count; i++) {</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[80];</div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%ld"</span>, i % receivers_count);</div>
<div class="line"> task = <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(<span class="stringliteral">"finalize"</span>, 0, 0, 0);</div>
<div class="line"> comm = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(task, mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Send to receiver-%ld finalize"</span>, i % receivers_count);</div>
<div class="line"> <span class="keywordflow">if</span> (sleep_test_time == 0) {</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait</a>(comm, -1);</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="keywordflow">while</span> (<a class="code" href="group__msg__task__usage.html#gafd22dad001b95804f5e93aa146c84fd3" title="Checks whether a communication is done, and if yes, finalizes it.">MSG_comm_test</a>(comm) == 0) {</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(sleep_test_time);</div>
<div class="line"> };</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(comm);</div>
<div class="line"></div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Goodbye now!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_sender */</span></div>
<div class="line"></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_Receiver"></a>
Receiver function</h4>
<p>This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".</p>
<p>C style arguments (argc/argv) are interpreted as:</p>
<ul>
<li>the id to use for received the communication.</li>
<li>the time to sleep at the beginning of the function</li>
<li>This time defined the process sleep time if time = 0 use of <a class="el" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait()</a> if time > 0 use of <a class="el" href="group__msg__task__usage.html#gafd22dad001b95804f5e93aa146c84fd3" title="Checks whether a communication is done, and if yes, finalizes it.">MSG_comm_test()</a></li>
</ul>
<p><div class="fragment"><div class="line"><span class="keywordtype">int</span> receiver(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task = NULL;</div>
<div class="line"> _XBT_GNUC_UNUSED <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res;</div>
<div class="line"> <span class="keywordtype">int</span> <span class="keywordtype">id</span> = -1;</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[80];</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> res_irecv;</div>
<div class="line"> <span class="keywordtype">double</span> sleep_start_time = atof(argv[2]);</div>
<div class="line"> <span class="keywordtype">double</span> sleep_test_time = atof(argv[3]);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"sleep_start_time : %f , sleep_test_time : %f"</span>, sleep_start_time,</div>
<div class="line"> sleep_test_time);</div>
<div class="line"></div>
<div class="line"> _XBT_GNUC_UNUSED <span class="keywordtype">int</span> read;</div>
<div class="line"> read = sscanf(argv[1], <span class="stringliteral">"%d"</span>, &<span class="keywordtype">id</span>);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(read,</div>
<div class="line"> <span class="stringliteral">"Invalid argument %s\n"</span>, argv[1]);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(sleep_start_time);</div>
<div class="line"></div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%d"</span>, <span class="keywordtype">id</span>);</div>
<div class="line"> <span class="keywordflow">while</span> (1) {</div>
<div class="line"> res_irecv = <a class="code" href="group__msg__task__usage.html#gadb4623d587d75ad3b078928f0f1b27a5" title="Starts listening for receiving a task from an asynchronous communication.">MSG_task_irecv</a>(&(task), mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Wait to receive a task"</span>);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (sleep_test_time == 0) {</div>
<div class="line"> res = <a class="code" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait</a>(res_irecv, -1);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>, <span class="stringliteral">"MSG_task_get failed"</span>);</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="keywordflow">while</span> (<a class="code" href="group__msg__task__usage.html#gafd22dad001b95804f5e93aa146c84fd3" title="Checks whether a communication is done, and if yes, finalizes it.">MSG_comm_test</a>(res_irecv) == 0) {</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(sleep_test_time);</div>
<div class="line"> };</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(res_irecv);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Received \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <span class="keywordflow">if</span> (!strcmp(<a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task), <span class="stringliteral">"finalize"</span>)) {</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> <span class="keywordflow">break</span>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Processing \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga6ebbb75fe9ff779eac6ca57c5ad5bfe3" title="Executes a task and waits for its termination.">MSG_task_execute</a>(task);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"\"%s\" done"</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> task = NULL;</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"I'm done. See you!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_receiver */</span></div>
<div class="line"></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_core"></a>
Simulation core</h4>
<p>This function is the core of the simulation and is divided only into 3 parts thanks to <a class="el" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment()</a> and <a class="el" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application()</a>.</p>
<ol type="1">
<li>Simulation settings : <a class="el" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment()</a> creates a realistic environment</li>
<li>Application deployment : create the processes on the right locations with <a class="el" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application()</a></li>
<li>The simulation is run with <a class="el" href="group__msg__simulation.html#ga638072e92edcf9c5aed498daefed010c" title="Launch the MSG simulation.">MSG_main()</a></li>
</ol>
<p>Its arguments are:</p>
<ul>
<li><em>platform_file</em>: the name of a file containing an valid surfxml platform description.</li>
<li><em>application_file</em>: the name of a file containing a valid surfxml application description</li>
</ul>
<p><div class="fragment"><div class="line"><a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> test_all(<span class="keyword">const</span> <span class="keywordtype">char</span> *platform_file,</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *application_file)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res = <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* MSG_config("workstation/model","KCCFLN05"); */</span></div>
<div class="line"> { <span class="comment">/* Simulation setting */</span></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment</a>(platform_file);</div>
<div class="line"> }</div>
<div class="line"> { <span class="comment">/* Application deployment */</span></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register</a>(<span class="stringliteral">"sender"</span>, sender);</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register</a>(<span class="stringliteral">"receiver"</span>, receiver);</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application</a>(application_file);</div>
<div class="line"> }</div>
<div class="line"> res = <a class="code" href="group__msg__simulation.html#ga638072e92edcf9c5aed498daefed010c" title="Launch the MSG simulation.">MSG_main</a>();</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Simulation time %g"</span>, <a class="code" href="group__msg__simulation.html#gacfeb7fa281abd0ff74b0591937cbb574" title="A clock (in second).">MSG_get_clock</a>());</div>
<div class="line"> <span class="keywordflow">return</span> res;</div>
<div class="line">} <span class="comment">/* end_of_test_all */</span></div>
<div class="line"></div>
<div class="line"></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_Main"></a>
Main function</h4>
<p>This initializes MSG, runs a simulation, and free all data-structures created by MSG.</p>
<p><div class="fragment"><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res = <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gab394a1043a25ec62f498c097d805f0a1" title="Initialize the MSG internal data.">MSG_init</a>(&argc, argv);</div>
<div class="line"> <span class="keywordflow">if</span> (argc < 3) {</div>
<div class="line"> printf(<span class="stringliteral">"Usage: %s platform_file deployment_file\n"</span>, argv[0]);</div>
<div class="line"> printf(<span class="stringliteral">"example: %s msg_platform.xml msg_deployment.xml\n"</span>, argv[0]);</div>
<div class="line"> exit(1);</div>
<div class="line"> }</div>
<div class="line"> res = test_all(argv[1], argv[2]);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (res == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>)</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> <span class="keywordflow">else</span></div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line">} <span class="comment">/* end_of_main */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_fct_Waitall"></a>
Waitall function for sender</h4>
<p>The use of this function permit to send all messages and wait for the completion of all in one time.</p>
<p><div class="fragment"><div class="line"></div>
<div class="line"><span class="keywordtype">int</span> sender(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">long</span> number_of_tasks = atol(argv[1]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comp_size = atof(argv[2]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comm_size = atof(argv[3]);</div>
<div class="line"> <span class="keywordtype">long</span> receivers_count = atol(argv[4]);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> *comm = <a class="code" href="group__XBT__syscall.html#ga1d356d21c8a37c3e19de37d5f7896810" title="like calloc, but xbt_die() on error and don't memset to 0">xbt_new</a>(<a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a>, number_of_tasks + receivers_count);</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task = NULL;</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks; i++) {</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[256];</div>
<div class="line"> <span class="keywordtype">char</span> sprintf_buffer[256];</div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%ld"</span>, i % receivers_count);</div>
<div class="line"> sprintf(sprintf_buffer, <span class="stringliteral">"Task_%d"</span>, i);</div>
<div class="line"> task =</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(sprintf_buffer, task_comp_size, task_comm_size,</div>
<div class="line"> NULL);</div>
<div class="line"> comm[i] = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(task, mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Send to receiver-%ld Task_%d"</span>, i % receivers_count, i);</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < receivers_count; i++) {</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[80];</div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%ld"</span>, i % receivers_count);</div>
<div class="line"> task = <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(<span class="stringliteral">"finalize"</span>, 0, 0, 0);</div>
<div class="line"> comm[i + number_of_tasks] = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(task, mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Send to receiver-%ld finalize"</span>, i % receivers_count);</div>
<div class="line"></div>
<div class="line"> }</div>
<div class="line"> <span class="comment">/* Here we are waiting for the completion of all communications */</span></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga01ce9097c976b96664e6785f6ab5d4b6" title="This function is called by a sender and permit to wait for each communication.">MSG_comm_waitall</a>(comm, (number_of_tasks + receivers_count), -1);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks + receivers_count; i++)</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(comm[i]);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Goodbye now!"</span>);</div>
<div class="line"> xbt_free(comm);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_sender */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_fct_Waitany"></a>
Waitany function</h4>
<p>The <a class="el" href="group__msg__task__usage.html#ga62772e7b378bc485c114231af4b8f596" title="This function waits for the first communication finished in a list.">MSG_comm_waitany()</a> function return the place of the first message send or receive from a xbt_dynar_t table.</p>
<h4><a class="anchor" id="MSG_ext_icomms_fct_Waitany_sender"></a>
From a sender</h4>
<p>We can use this function to wait all sent messages. <div class="fragment"><div class="line"></div>
<div class="line"><span class="keywordtype">int</span> sender(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">long</span> number_of_tasks = atol(argv[1]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comp_size = atof(argv[2]);</div>
<div class="line"> <span class="keywordtype">double</span> task_comm_size = atof(argv[3]);</div>
<div class="line"> <span class="keywordtype">long</span> receivers_count = atol(argv[4]);</div>
<div class="line"> <span class="keywordtype">int</span> diff_com = atol(argv[5]);</div>
<div class="line"> <span class="keywordtype">double</span> coef = 0;</div>
<div class="line"> <a class="code" href="group__XBT__dynar__cons.html#gac826571988d2b63ae225e5c62ecdbc79" title="Dynar data type (opaque type)">xbt_dynar_t</a> d = <a class="code" href="group__XBT__dynar__cons.html#ga69ab371f667dfe5aa51fb612b9afaca5" title="Constructor.">xbt_dynar_new</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a>), NULL);</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task;</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[256];</div>
<div class="line"> <span class="keywordtype">char</span> sprintf_buffer[256];</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> comm;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks; i++) {</div>
<div class="line"> <span class="keywordflow">if</span> (diff_com == 0)</div>
<div class="line"> coef = 1;</div>
<div class="line"> <span class="keywordflow">else</span></div>
<div class="line"> coef = (i + 1);</div>
<div class="line"></div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%ld"</span>, (i % receivers_count));</div>
<div class="line"> sprintf(sprintf_buffer, <span class="stringliteral">"Task_%d"</span>, i);</div>
<div class="line"> task =</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(sprintf_buffer, task_comp_size,</div>
<div class="line"> task_comm_size / coef, NULL);</div>
<div class="line"> comm = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(task, mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__dynar__speed.html#ga50d763465a98678a3e83afa6b5ecd243" title="Quick insertion of scalar content.">xbt_dynar_push_as</a>(d, <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a>, comm);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Send to receiver-%ld %s comm_size %f"</span>, i % receivers_count,</div>
<div class="line"> sprintf_buffer, task_comm_size / coef);</div>
<div class="line"> }</div>
<div class="line"> <span class="comment">/* Here we are waiting for the completion of all communications */</span></div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">while</span> (!<a class="code" href="group__XBT__dynar__misc.html#ga57aab83ad4ff1a1df5a1c293627c41d8" title="check if a dynar is empty">xbt_dynar_is_empty</a>(d)) {</div>
<div class="line"> <a class="code" href="group__XBT__dynar__array.html#ga32a7eaf157e28533482cda7d84460705" title="Remove the Nth dynar's element, sliding the previous values to the left.">xbt_dynar_remove_at</a>(d, <a class="code" href="group__msg__task__usage.html#ga62772e7b378bc485c114231af4b8f596" title="This function waits for the first communication finished in a list.">MSG_comm_waitany</a>(d), &comm);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(comm);</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__XBT__dynar__cons.html#ga9b7808eb7a87dcf331a467f323ae16a6" title="Destructor.">xbt_dynar_free</a>(&d);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Here we are waiting for the completion of all tasks */</span></div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"finalize"</span>);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> res_irecv;</div>
<div class="line"> _XBT_GNUC_UNUSED <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res_wait;</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < receivers_count; i++) {</div>
<div class="line"> task = NULL;</div>
<div class="line"> res_irecv = <a class="code" href="group__msg__task__usage.html#gadb4623d587d75ad3b078928f0f1b27a5" title="Starts listening for receiving a task from an asynchronous communication.">MSG_task_irecv</a>(&(task), mailbox);</div>
<div class="line"> res_wait = <a class="code" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait</a>(res_irecv, -1);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res_wait == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>, <span class="stringliteral">"MSG_comm_wait failed"</span>);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(res_irecv);</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Goodbye now!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_sender */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_icomms_fct_Waitany_receiver"></a>
From a receiver</h4>
<p>We can also wait for the arrival of all messages. <div class="fragment"><div class="line"></div>
<div class="line"><span class="keywordtype">int</span> receiver(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">int</span> <span class="keywordtype">id</span> = -1;</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> <span class="keywordtype">char</span> mailbox[80];</div>
<div class="line"> <a class="code" href="group__XBT__dynar__cons.html#gac826571988d2b63ae225e5c62ecdbc79" title="Dynar data type (opaque type)">xbt_dynar_t</a> comms = <a class="code" href="group__XBT__dynar__cons.html#ga69ab371f667dfe5aa51fb612b9afaca5" title="Constructor.">xbt_dynar_new</a>(<span class="keyword">sizeof</span>(<a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a>), NULL);</div>
<div class="line"> <span class="keywordtype">int</span> tasks = atof(argv[2]);</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> *task = <a class="code" href="group__XBT__syscall.html#ga1d356d21c8a37c3e19de37d5f7896810" title="like calloc, but xbt_die() on error and don't memset to 0">xbt_new</a>(<a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a>, tasks);</div>
<div class="line"></div>
<div class="line"> _XBT_GNUC_UNUSED <span class="keywordtype">int</span> read;</div>
<div class="line"> read = sscanf(argv[1], <span class="stringliteral">"%d"</span>, &<span class="keywordtype">id</span>);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(read, <span class="stringliteral">"Invalid argument %s\n"</span>, argv[1]);</div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"receiver-%d"</span>, <span class="keywordtype">id</span>);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gab7c18061b167e38f28886512ea73be6b" title="Sleep for the specified number of seconds.">MSG_process_sleep</a>(10);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a> res_irecv;</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < tasks; i++) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Wait to receive task %d"</span>, i);</div>
<div class="line"> task[i] = NULL;</div>
<div class="line"> res_irecv = <a class="code" href="group__msg__task__usage.html#gadb4623d587d75ad3b078928f0f1b27a5" title="Starts listening for receiving a task from an asynchronous communication.">MSG_task_irecv</a>(&task[i], mailbox);</div>
<div class="line"> <a class="code" href="group__XBT__dynar__speed.html#ga50d763465a98678a3e83afa6b5ecd243" title="Quick insertion of scalar content.">xbt_dynar_push_as</a>(comms, <a class="code" href="group__msg__task__usage.html#gafe19e97b54682048a5b2f1c79add21cf" title="Communication action.Object representing an ongoing communication between processes. Such beast is usually obtained by using MSG_task_isend, MSG_task_irecv or friends.">msg_comm_t</a>, res_irecv);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Here we are waiting for the receiving of all communications */</span></div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task_com;</div>
<div class="line"> <span class="keywordflow">while</span> (!<a class="code" href="group__XBT__dynar__misc.html#ga57aab83ad4ff1a1df5a1c293627c41d8" title="check if a dynar is empty">xbt_dynar_is_empty</a>(comms)) {</div>
<div class="line"> _XBT_GNUC_UNUSED <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> err;</div>
<div class="line"> <a class="code" href="group__XBT__dynar__array.html#ga32a7eaf157e28533482cda7d84460705" title="Remove the Nth dynar's element, sliding the previous values to the left.">xbt_dynar_remove_at</a>(comms, <a class="code" href="group__msg__task__usage.html#ga62772e7b378bc485c114231af4b8f596" title="This function waits for the first communication finished in a list.">MSG_comm_waitany</a>(comms), &res_irecv);</div>
<div class="line"> task_com = <a class="code" href="group__msg__task__usage.html#gaf4fbe7c481859674d29475a0085d7333" title="Get a task (msg_task_t) from a communication.">MSG_comm_get_task</a>(res_irecv);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(res_irecv);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Processing \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task_com));</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga6ebbb75fe9ff779eac6ca57c5ad5bfe3" title="Executes a task and waits for its termination.">MSG_task_execute</a>(task_com);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"\"%s\" done"</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task_com));</div>
<div class="line"> err = <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task_com);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(err == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>, <span class="stringliteral">"MSG_task_destroy failed"</span>);</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__XBT__dynar__cons.html#ga9b7808eb7a87dcf331a467f323ae16a6" title="Destructor.">xbt_dynar_free</a>(&comms);</div>
<div class="line"> xbt_free(task);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Here we tell to sender that all tasks are done */</span></div>
<div class="line"> sprintf(mailbox, <span class="stringliteral">"finalize"</span>);</div>
<div class="line"> res_irecv = <a class="code" href="group__msg__task__usage.html#gaa280111a523d70bb36061e6e52ca1b42" title="Sends a task on a mailbox.">MSG_task_isend</a>(<a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(NULL, 0, 0, NULL), mailbox);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga2ae956f1e7a1014652d85b5f8db42aa3" title="Wait for the completion of a communication.">MSG_comm_wait</a>(res_irecv, -1);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#gaa1b107438e7a295058e098a8c2c1bc4a" title="Destroys a communication.">MSG_comm_destroy</a>(res_irecv);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"I'm done. See you!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_receiver */</span></div>
</div><!-- fragment --></p>
<h3><a class="anchor" id="MSG_ex_master_slave"></a>
Basic Master/Slaves</h3>
<p>Simulation of a master-slave application using a realistic platform and an external description of the deployment.</p>
<h4><a class="anchor" id="MSG_ex_ms_TOC"></a>
Table of contents:</h4>
<ul>
<li><a class="el" href="use.html#MSG_ext_ms_preliminary">Preliminary declarations</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_master">Master code</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_slave">Slave code</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_forwarder">Forwarder code</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_core">Simulation core</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_main">Main() function</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_helping">Helping files</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_application">Example of application file</a></li>
<li><a class="el" href="use.html#MSG_ext_ms_platform">Example of platform file</a></li>
</ul>
<hr/>
<h4><a class="anchor" id="MSG_ext_ms_preliminary"></a>
Preliminary declarations</h4>
<p><div class="fragment"><div class="line"><span class="preprocessor">#include <stdio.h></span></div>
<div class="line"><span class="preprocessor">#include "msg/msg.h"</span> <span class="comment">/* Yeah! If you want to use msg, you need to include msg/msg.h */</span></div>
<div class="line"><span class="preprocessor">#include "xbt/sysdep.h"</span> <span class="comment">/* calloc, printf */</span></div>
<div class="line"></div>
<div class="line"><span class="comment">/* Create a log channel to have nice outputs. */</span></div>
<div class="line"><span class="preprocessor">#include "xbt/log.h"</span></div>
<div class="line"><span class="preprocessor">#include "xbt/asserts.h"</span></div>
<div class="line"><a class="code" href="group__XBT__log.html#ga5094a0e812d0012e6ee4d2257b1a13f1">XBT_LOG_NEW_DEFAULT_CATEGORY</a>(msg_test,</div>
<div class="line"> <span class="stringliteral">"Messages specific for this msg example"</span>);</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> master(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><span class="keywordtype">int</span> slave(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><span class="keywordtype">int</span> forwarder(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> test_all(<span class="keyword">const</span> <span class="keywordtype">char</span> *platform_file,</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *application_file);</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#define FINALIZE ((void*)221297) </span><span class="comment">/* a magic number to tell people to stop working */</span><span class="preprocessor"></span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="keywordtype">int</span> master(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">int</span> slaves_count = 0;</div>
<div class="line"> <a class="code" href="group__m__host__management.html#ga0cc2134715cceaeea82df1c1305fbecf" title="Host datatype.A location (or host) is any possible place where a process may run. Thus it is represen...">msg_host_t</a> *slaves = NULL;</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> *todo = NULL;</div>
<div class="line"> <span class="keywordtype">int</span> number_of_tasks = 0;</div>
<div class="line"> <span class="keywordtype">double</span> task_comp_size = 0;</div>
<div class="line"> <span class="keywordtype">double</span> task_comm_size = 0;</div>
<div class="line"></div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"></div>
<div class="line"> _XBT_GNUC_UNUSED <span class="keywordtype">int</span> res = sscanf(argv[1], <span class="stringliteral">"%d"</span>, &number_of_tasks);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res,<span class="stringliteral">"Invalid argument %s\n"</span>, argv[1]);</div>
<div class="line"> res = sscanf(argv[2], <span class="stringliteral">"%lg"</span>, &task_comp_size);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res, <span class="stringliteral">"Invalid argument %s\n"</span>, argv[2]);</div>
<div class="line"> res = sscanf(argv[3], <span class="stringliteral">"%lg"</span>, &task_comm_size);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res, <span class="stringliteral">"Invalid argument %s\n"</span>, argv[3]);</div>
<div class="line"></div>
<div class="line"> { <span class="comment">/* Task creation */</span></div>
<div class="line"> <span class="keywordtype">char</span> sprintf_buffer[64];</div>
<div class="line"></div>
<div class="line"> todo = <a class="code" href="group__XBT__syscall.html#gaaea21518b543392c869f6564c36cdc2b" title="like calloc, but xbt_die() on error">xbt_new0</a>(<a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a>, number_of_tasks);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks; i++) {</div>
<div class="line"> sprintf(sprintf_buffer, <span class="stringliteral">"Task_%d"</span>, i);</div>
<div class="line"> todo[i] =</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(sprintf_buffer, task_comp_size, task_comm_size,</div>
<div class="line"> NULL);</div>
<div class="line"> }</div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_ms_master"></a>
Master code</h4>
<p>This function has to be assigned to a msg_process_t that will behave as the master. It should not be called directly but either given as a parameter to <a class="el" href="group__m__process__management.html#ga943d27b38754b2af9f78e80cc29db306" title="Creates and runs a new msg_process_t.">MSG_process_create()</a> or registered as a public function through <a class="el" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register()</a> and then automatically assigned to a process through <a class="el" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application()</a>.</p>
<p>C style arguments (argc/argv) are interpreted as:</p>
<ul>
<li>the number of tasks to distribute</li>
<li>the computation size of each task</li>
<li>the size of the files associated to each task</li>
<li>a list of host that will accept those tasks.</li>
</ul>
<p>Tasks are dumbly sent in a round-robin style.</p>
<p><div class="fragment"><div class="line"> }</div>
<div class="line"></div>
<div class="line"> { <span class="comment">/* Process organisation */</span></div>
<div class="line"> slaves_count = argc - 4;</div>
<div class="line"> slaves = <a class="code" href="group__XBT__syscall.html#gaaea21518b543392c869f6564c36cdc2b" title="like calloc, but xbt_die() on error">xbt_new0</a>(<a class="code" href="group__m__host__management.html#ga0cc2134715cceaeea82df1c1305fbecf" title="Host datatype.A location (or host) is any possible place where a process may run. Thus it is represen...">msg_host_t</a>, slaves_count);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 4; i < argc; i++) {</div>
<div class="line"> slaves[i - 4] = MSG_get_host_by_name(argv[i]);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(slaves[i - 4] != NULL, <span class="stringliteral">"Unknown host %s. Stopping Now! "</span>,</div>
<div class="line"> argv[i]);</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Got %d slaves and %d tasks to process"</span>, slaves_count,</div>
<div class="line"> number_of_tasks);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < slaves_count; i++)</div>
<div class="line"> <a class="code" href="group__XBT__log.html#gaec7da836fa1482fcda89227dfb1284d9" title="Log an event at the DEBUG priority on the default category with these args.">XBT_DEBUG</a>(<span class="stringliteral">"%s"</span>, <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i]));</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < number_of_tasks; i++) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Sending \"%s\" to \"%s\""</span>,</div>
<div class="line"> todo[i]->name, <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i % slaves_count]));</div>
<div class="line"> <span class="keywordflow">if</span> (<a class="code" href="group__m__host__management.html#ga8552d95b844f896978eca735cbd73e9f" title="Return the location on which the current process is executed.">MSG_host_self</a>() == slaves[i % slaves_count]) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Hey ! It's me ! :)"</span>);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga33c924177135850888f25378b8e0b3cf" title="Sends a task to a mailbox.">MSG_task_send</a>(todo[i], <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i % slaves_count]));</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Sent"</span>);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a></div>
<div class="line"> (<span class="stringliteral">"All tasks have been dispatched. Let's tell everybody the computation is over."</span>);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < slaves_count; i++) {</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> finalize = <a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(<span class="stringliteral">"finalize"</span>, 0, 0, FINALIZE);</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga33c924177135850888f25378b8e0b3cf" title="Sends a task to a mailbox.">MSG_task_send</a>(finalize, <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i]));</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Goodbye now!"</span>);</div>
<div class="line"> free(slaves);</div>
<div class="line"> free(todo);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_master */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_ms_slave"></a>
Slave code</h4>
<p>This function has to be assigned to a <a class="el" href="group__m__process__management.html#ga49407197cb1ba4a2b1943285786eacec" title="Process datatype.A process may be defined as a code, with some private data, executing in a location...">msg_process_t</a> that has to behave as a slave. Just like the master fuction (described in <a class="el" href="use.html#MSG_ext_ms_master">Master code</a>), it should not be called directly.</p>
<p>This function keeps waiting for tasks and executes them as it receives them.</p>
<p><div class="fragment"><div class="line"></div>
<div class="line"><span class="keywordtype">int</span> slave(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task = NULL;</div>
<div class="line"> _XBT_GNUC_UNUSED <span class="keywordtype">int</span> res;</div>
<div class="line"> <span class="keywordflow">while</span> (1) {</div>
<div class="line"> res = <a class="code" href="group__msg__task__usage.html#ga710ee9d4ea587ab6ae66014913ac91e1" title="Receives a task from a mailbox.">MSG_task_receive</a>(&(task),<a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(<a class="code" href="group__m__host__management.html#ga8552d95b844f896978eca735cbd73e9f" title="Return the location on which the current process is executed.">MSG_host_self</a>()));</div>
<div class="line"> <a class="code" href="group__XBT__error.html#gadd837b8bf67480aea409a8580072f0be" title="The condition which failed will be displayed.">xbt_assert</a>(res == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>, <span class="stringliteral">"MSG_task_get failed"</span>);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Received \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <span class="keywordflow">if</span> (!strcmp(<a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task), <span class="stringliteral">"finalize"</span>)) {</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> <span class="keywordflow">break</span>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Processing \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga6ebbb75fe9ff779eac6ca57c5ad5bfe3" title="Executes a task and waits for its termination.">MSG_task_execute</a>(task);</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"\"%s\" done"</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> task = NULL;</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"I'm done. See you!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_slave */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_ms_forwarder"></a>
Forwarder code</h4>
<p>This function has to be assigned to a <a class="el" href="group__m__process__management.html#ga49407197cb1ba4a2b1943285786eacec" title="Process datatype.A process may be defined as a code, with some private data, executing in a location...">msg_process_t</a> that has to behave as a forwarder. Just like the master function (described in <a class="el" href="use.html#MSG_ext_ms_master">Master code</a>), it should not be called directly.</p>
<p>C style arguments (argc/argv) are interpreted as a list of host that will accept those tasks.</p>
<p>This function keeps waiting for tasks and dispathes them to its slaves.</p>
<p><div class="fragment"><div class="line"></div>
<div class="line"><span class="keywordtype">int</span> forwarder(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">int</span> i;</div>
<div class="line"> <span class="keywordtype">int</span> slaves_count;</div>
<div class="line"> <a class="code" href="group__m__host__management.html#ga0cc2134715cceaeea82df1c1305fbecf" title="Host datatype.A location (or host) is any possible place where a process may run. Thus it is represen...">msg_host_t</a> *slaves;</div>
<div class="line"></div>
<div class="line"> { <span class="comment">/* Process organisation */</span></div>
<div class="line"> slaves_count = argc - 1;</div>
<div class="line"> slaves = <a class="code" href="group__XBT__syscall.html#gaaea21518b543392c869f6564c36cdc2b" title="like calloc, but xbt_die() on error">xbt_new0</a>(<a class="code" href="group__m__host__management.html#ga0cc2134715cceaeea82df1c1305fbecf" title="Host datatype.A location (or host) is any possible place where a process may run. Thus it is represen...">msg_host_t</a>, slaves_count);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">for</span> (i = 1; i < argc; i++) {</div>
<div class="line"> slaves[i - 1] = MSG_get_host_by_name(argv[i]);</div>
<div class="line"> <span class="keywordflow">if</span> (slaves[i - 1] == NULL) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Unknown host %s. Stopping Now! "</span>, argv[i]);</div>
<div class="line"> abort();</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> i = 0;</div>
<div class="line"> <span class="keywordflow">while</span> (1) {</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaa7cd89c7f542d19fd817a614d1c1cc95" title="Task datatype.A task may then be defined by a computing amount, a message size and some private data...">msg_task_t</a> task = NULL;</div>
<div class="line"> <span class="keywordtype">int</span> a;</div>
<div class="line"> a = <a class="code" href="group__msg__task__usage.html#ga710ee9d4ea587ab6ae66014913ac91e1" title="Receives a task from a mailbox.">MSG_task_receive</a>(&(task),<a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(<a class="code" href="group__m__host__management.html#ga8552d95b844f896978eca735cbd73e9f" title="Return the location on which the current process is executed.">MSG_host_self</a>()));</div>
<div class="line"> <span class="keywordflow">if</span> (a == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Received \"%s\""</span>, <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task));</div>
<div class="line"> <span class="keywordflow">if</span> (<a class="code" href="group__m__task__management.html#gab0ef7c694fcc69282cf4da632ae64d5b" title="Return the user data of a msg_task_t.">MSG_task_get_data</a>(task) == FINALIZE) {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a></div>
<div class="line"> (<span class="stringliteral">"All tasks have been dispatched. Let's tell everybody the computation is over."</span>);</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < slaves_count; i++)</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga33c924177135850888f25378b8e0b3cf" title="Sends a task to a mailbox.">MSG_task_send</a>(<a class="code" href="group__m__task__management.html#gaafe2ccabd38b13d1734323f86e40706a" title="Creates a new msg_task_t.">MSG_task_create</a>(<span class="stringliteral">"finalize"</span>, 0, 0, FINALIZE),</div>
<div class="line"> <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i]));</div>
<div class="line"> <a class="code" href="group__m__task__management.html#gaf6369e840095c428218e494bf8b6dee6" title="Destroy a msg_task_t.">MSG_task_destroy</a>(task);</div>
<div class="line"> <span class="keywordflow">break</span>;</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Sending \"%s\" to \"%s\""</span>,</div>
<div class="line"> <a class="code" href="group__m__task__management.html#ga2adce7c9dbe8ecab1d6db1fdc420ea80" title="Return the name of a msg_task_t.">MSG_task_get_name</a>(task), <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i % slaves_count]));</div>
<div class="line"> <a class="code" href="group__msg__task__usage.html#ga33c924177135850888f25378b8e0b3cf" title="Sends a task to a mailbox.">MSG_task_send</a>(task, <a class="code" href="group__m__host__management.html#gad4daf43406f4dce8caae5310cdf40bde" title="Return the name of the msg_host_t.">MSG_host_get_name</a>(slaves[i % slaves_count]));</div>
<div class="line"> i++;</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Hey ?! What's up ? "</span>);</div>
<div class="line"> <a class="code" href="group__XBT__error.html#ga9bf4916de59dbf2c5bc790e85df7c189" title="Kill the program with an error message.">xbt_die</a>(<span class="stringliteral">"Unexpected behavior"</span>);</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line"> xbt_free(slaves);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"I'm done. See you!"</span>);</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">/* end_of_forwarder */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_ms_core"></a>
Simulation core</h4>
<p>This function is the core of the simulation and is divided only into 3 parts thanks to <a class="el" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment()</a> and <a class="el" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application()</a>.</p>
<ol type="1">
<li>Simulation settings : <a class="el" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment()</a> creates a realistic environment</li>
<li>Application deployment : create the processes on the right locations with <a class="el" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application()</a></li>
<li>The simulation is run with <a class="el" href="group__msg__simulation.html#ga638072e92edcf9c5aed498daefed010c" title="Launch the MSG simulation.">MSG_main()</a></li>
</ol>
<p>Its arguments are:</p>
<ul>
<li><em>platform_file</em>: the name of a file containing an valid surfxml platform description.</li>
<li><em>application_file</em>: the name of a file containing a valid surfxml application description</li>
</ul>
<p><div class="fragment"><div class="line"></div>
<div class="line"><a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> test_all(<span class="keyword">const</span> <span class="keywordtype">char</span> *platform_file,</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *application_file)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res = <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* MSG_config("workstation/model","KCCFLN05"); */</span></div>
<div class="line"> { <span class="comment">/* Simulation setting */</span></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gae08e089d52a2928680e0957e7152d79d" title="A platform constructor.">MSG_create_environment</a>(platform_file);</div>
<div class="line"> }</div>
<div class="line"> { <span class="comment">/* Application deployment */</span></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register</a>(<span class="stringliteral">"master"</span>, master);</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register</a>(<span class="stringliteral">"slave"</span>, slave);</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga21e94a4e7b26dea140b0c71a2a4f4352" title="Registers the main function of a process in a global table.">MSG_function_register</a>(<span class="stringliteral">"forwarder"</span>, forwarder);</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#ga012d470de7974da7262d0020e00117e9" title="An application deployer.">MSG_launch_application</a>(application_file);</div>
<div class="line"> }</div>
<div class="line"> res = <a class="code" href="group__msg__simulation.html#ga638072e92edcf9c5aed498daefed010c" title="Launch the MSG simulation.">MSG_main</a>();</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__XBT__log.html#ga57f4469c36aeb5f44b5786882b364af8" title="Log an event at the INFO priority on the default category with these args.">XBT_INFO</a>(<span class="stringliteral">"Simulation time %g"</span>, <a class="code" href="group__msg__simulation.html#gacfeb7fa281abd0ff74b0591937cbb574" title="A clock (in second).">MSG_get_clock</a>());</div>
<div class="line"> <span class="keywordflow">return</span> res;</div>
<div class="line">} <span class="comment">/* end_of_test_all */</span></div>
</div><!-- fragment --></p>
<h4><a class="anchor" id="MSG_ext_ms_main"></a>
Main() function</h4>
<p>This initializes MSG, runs a simulation, and free all data-structures created by MSG.</p>
<p><div class="fragment"><div class="line"></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gaf79b56c0bd3b78b539b0cb4c12e56425" title="Return code of most MSG functions.">msg_error_t</a> res = <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__msg__simulation.html#gab394a1043a25ec62f498c097d805f0a1" title="Initialize the MSG internal data.">MSG_init</a>(&argc, argv);</div>
<div class="line"> <span class="keywordflow">if</span> (argc < 3) {</div>
<div class="line"> printf(<span class="stringliteral">"Usage: %s platform_file deployment_file\n"</span>, argv[0]);</div>
<div class="line"> printf(<span class="stringliteral">"example: %s msg_platform.xml msg_deployment.xml\n"</span>, argv[0]);</div>
<div class="line"> exit(1);</div>
<div class="line"> }</div>
<div class="line"> res = test_all(argv[1], argv[2]);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (res == <a class="code" href="group__msg__simulation.html#ggaf79b56c0bd3b78b539b0cb4c12e56425a7db209a18c6374183567534787dccc1b" title="Everything is right. Keep on going this way !">MSG_OK</a>)</div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line"> <span class="keywordflow">else</span></div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line">} <span class="comment">/* end_of_main */</span></div>
</div><!-- fragment --></p>
<h3><a class="anchor" id="MSG_ext_ms_helping"></a>
Helping files</h3>
<h4><a class="anchor" id="MSG_ext_ms_application"></a>
Example of application file</h4>
<div class="fragment"><div class="line"><?xml version=<span class="stringliteral">'1.0'</span>?></div>
<div class="line"><!DOCTYPE platform SYSTEM <span class="stringliteral">"http://simgrid.gforge.inria.fr/simgrid.dtd"</span>></div>
<div class="line"><platform version=<span class="stringliteral">"3"</span>></div>
<div class="line"> <!-- The master process (with some arguments) --></div>
<div class="line"> <process host=<span class="stringliteral">"Tremblay"</span> <span class="keyword">function</span>=<span class="stringliteral">"master"</span>></div>
<div class="line"> <argument value=<span class="stringliteral">"20"</span>/> <!-- Number of tasks --></div>
<div class="line"> <argument value=<span class="stringliteral">"50000000"</span>/> <!-- Computation size of tasks --></div>
<div class="line"> <argument value=<span class="stringliteral">"1000000"</span>/> <!-- Communication size of tasks --></div>
<div class="line"> <argument value=<span class="stringliteral">"Jupiter"</span>/> <!-- First slave --></div>
<div class="line"> <argument value=<span class="stringliteral">"Fafard"</span>/> <!-- Second slave --></div>
<div class="line"> <argument value=<span class="stringliteral">"Ginette"</span>/> <!-- Third slave --></div>
<div class="line"> <argument value=<span class="stringliteral">"Bourassa"</span>/> <!-- Last slave --></div>
<div class="line"> <argument value=<span class="stringliteral">"Tremblay"</span>/> <!-- Me! I can work too! --></div>
<div class="line"> </process></div>
<div class="line"> <!-- The slave process (with no argument) --></div>
<div class="line"> <process host=<span class="stringliteral">"Tremblay"</span> <span class="keyword">function</span>=<span class="stringliteral">"slave"</span> on_failure=<span class="stringliteral">"RESTART"</span>/></div>
<div class="line"> <process host=<span class="stringliteral">"Jupiter"</span> <span class="keyword">function</span>=<span class="stringliteral">"slave"</span> on_failure=<span class="stringliteral">"RESTART"</span>/></div>
<div class="line"> <process host=<span class="stringliteral">"Fafard"</span> <span class="keyword">function</span>=<span class="stringliteral">"slave"</span> on_failure=<span class="stringliteral">"RESTART"</span>/></div>
<div class="line"> <process host=<span class="stringliteral">"Ginette"</span> <span class="keyword">function</span>=<span class="stringliteral">"slave"</span> on_failure=<span class="stringliteral">"RESTART"</span>/></div>
<div class="line"> <process host=<span class="stringliteral">"Bourassa"</span> <span class="keyword">function</span>=<span class="stringliteral">"slave"</span> on_failure=<span class="stringliteral">"RESTART"</span>/></div>
<div class="line"></platform></div>
</div><!-- fragment --><h4><a class="anchor" id="MSG_ext_ms_platform"></a>
Example of platform file</h4>
<div class="fragment"><div class="line"><?xml version=<span class="stringliteral">'1.0'</span>?></div>
<div class="line"> <!DOCTYPE platform SYSTEM <span class="stringliteral">"http://simgrid.gforge.inria.fr/simgrid.dtd"</span>></div>
<div class="line"> <platform version=<span class="stringliteral">"3"</span>></div>
<div class="line"> <AS <span class="keywordtype">id</span>=<span class="stringliteral">"AS0"</span> routing=<span class="stringliteral">"Full"</span>></div>
<div class="line"> <!-- ljlkj --></div>
<div class="line"> <host <span class="keywordtype">id</span>=<span class="stringliteral">"Tremblay"</span> power=<span class="stringliteral">"98.095Mf"</span>/></div>
<div class="line"> <host <span class="keywordtype">id</span>=<span class="stringliteral">"Jupiter"</span> power=<span class="stringliteral">"76.296Mf"</span>/></div>
<div class="line"> <host <span class="keywordtype">id</span>=<span class="stringliteral">"Fafard"</span> power=<span class="stringliteral">"76.296Mf"</span>/></div>
<div class="line"> <host <span class="keywordtype">id</span>=<span class="stringliteral">"Ginette"</span> power=<span class="stringliteral">"48.492Mf"</span>/></div>
<div class="line"> <host <span class="keywordtype">id</span>=<span class="stringliteral">"Bourassa"</span> power=<span class="stringliteral">"48.492Mf"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"6"</span> bandwidth=<span class="stringliteral">"41.279125MBps"</span> latency=<span class="stringliteral">"59.904us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"11"</span> bandwidth=<span class="stringliteral">"252.75kBps"</span> latency=<span class="stringliteral">"5.70455ms"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span> bandwidth=<span class="stringliteral">"34.285625MBps"</span> latency=<span class="stringliteral">"514.433us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"7"</span> bandwidth=<span class="stringliteral">"11.618875MBps"</span> latency=<span class="stringliteral">"189.98us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"9"</span> bandwidth=<span class="stringliteral">"7.20975MBps"</span> latency=<span class="stringliteral">"1.461517ms"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"12"</span> bandwidth=<span class="stringliteral">"1.792625MBps"</span> latency=<span class="stringliteral">"7.877863ms"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span> bandwidth=<span class="stringliteral">"118.6825MBps"</span> latency=<span class="stringliteral">"136.931us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"8"</span> bandwidth=<span class="stringliteral">"8.158MBps"</span> latency=<span class="stringliteral">"270.544us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span> bandwidth=<span class="stringliteral">"34.285625MBps"</span> latency=<span class="stringliteral">"514.433us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span> bandwidth=<span class="stringliteral">"10.099625MBps"</span> latency=<span class="stringliteral">"479.78us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span> bandwidth=<span class="stringliteral">"41.279125MBps"</span> latency=<span class="stringliteral">"59.904us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"10"</span> bandwidth=<span class="stringliteral">"4.67975MBps"</span> latency=<span class="stringliteral">"848.712us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"5"</span> bandwidth=<span class="stringliteral">"27.94625MBps"</span> latency=<span class="stringliteral">"278.066us"</span>/></div>
<div class="line"> <link <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span> bandwidth=<span class="stringliteral">"498MBps"</span> latency=<span class="stringliteral">"15us"</span> sharing_policy=<span class="stringliteral">"FATPIPE"</span>/></div>
<div class="line"> <route src=<span class="stringliteral">"Tremblay"</span> dst=<span class="stringliteral">"Tremblay"</span>><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span>/></route></div>
<div class="line"> <route src=<span class="stringliteral">"Jupiter"</span> dst=<span class="stringliteral">"Jupiter"</span>><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span>/></route></div>
<div class="line"> <route src=<span class="stringliteral">"Fafard"</span> dst=<span class="stringliteral">"Fafard"</span>><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span>/></route></div>
<div class="line"> <route src=<span class="stringliteral">"Ginette"</span> dst=<span class="stringliteral">"Ginette"</span>><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span>/></route></div>
<div class="line"> <route src=<span class="stringliteral">"Bourassa"</span> dst=<span class="stringliteral">"Bourassa"</span>><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"loopback"</span>/></route></div>
<div class="line"> <route src=<span class="stringliteral">"Tremblay"</span> dst=<span class="stringliteral">"Jupiter"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"9"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Tremblay"</span> dst=<span class="stringliteral">"Fafard"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"8"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Tremblay"</span> dst=<span class="stringliteral">"Ginette"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"5"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Tremblay"</span> dst=<span class="stringliteral">"Bourassa"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"6"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"7"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Jupiter"</span> dst=<span class="stringliteral">"Fafard"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"9"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"8"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Jupiter"</span> dst=<span class="stringliteral">"Ginette"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"9"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"5"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Jupiter"</span> dst=<span class="stringliteral">"Bourassa"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"9"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"4"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"3"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"6"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"7"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Fafard"</span> dst=<span class="stringliteral">"Ginette"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"8"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"5"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Fafard"</span> dst=<span class="stringliteral">"Bourassa"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"8"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"6"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"7"</span>/></div>
<div class="line"> </route></div>
<div class="line"> <route src=<span class="stringliteral">"Ginette"</span> dst=<span class="stringliteral">"Bourassa"</span>></div>
<div class="line"> <link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"5"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"2"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"0"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"1"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"6"</span>/><link_ctn <span class="keywordtype">id</span>=<span class="stringliteral">"7"</span>/></div>
<div class="line"> </route></div>
<div class="line"> </AS></div>
<div class="line"> </platform></div>
</div><!-- fragment --><h1><a class="anchor" id="using_smpi"></a>
Using SMPI</h1>
<p>You should check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html">tutorial section</a> that contains a dedicated tutorial.</p>
<h1><a class="anchor" id="using_MC"></a>
Using Model Checking</h1>
<p>You should check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html">tutorial section</a> that contains a dedicated tutorial.</p>
<h1><a class="anchor" id="using_trace"></a>
Using Trace</h1>
<p>Check out the <a class="el" href="tracing.html">Tracing Simulations</a> section.</p>
<p>You should check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html">tutorial section</a> that contains a dedicated tutorial.</p>
<h1><a class="anchor" id="using_simdag"></a>
Using SimDag</h1>
<p>You should check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html">tutorial section</a> that contains a dedicated tutorial.</p>
<h1><a class="anchor" id="using_simix"></a>
Using SIMIX</h1>
<p>You should check our online <a href="http://simgrid.gforge.inria.fr/tutorials.html">tutorial section</a> that contains a dedicated tutorial. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Sun Nov 17 2013 21:34:46 for SimGrid by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.2 </li>
</ul>
</div>
</body>
</html>
|