目录
3.3 deployment:li-s4u-actor-create_d.xml
1. s4u概念与使用简介
s4u全称为 SimGrid for you,具体介绍如官网[1]中所写:The S4U interface (SimGrid for you) mixes the full power of SimGrid with the full power of C++. This is the preferred interface to describe abstract algorithms in the domains of Cloud, P2P, HPC, IoT, and similar settings.
简单而言就是,SimGrid推荐使用s4u来进行编写C++程序,可以表示云计算,P2P,HPC,IoT等抽象算法。
要使用s4u进行模拟,必须要自己写一下几部分的代码。
(1)Actors:显示的s4u描述Actors的Activities,包括, computation, communication, disk usage, and other Activities
(2)Platform:Platform files define the simulated platform on which the provided application will take place. In contains one or several Network Zone that contain both Host and Link Resources, as well as routing information.
(3)deployment:Deployment files specify the execution scenario: it lists the actors that should be started, along with their parameter.
2. mailbox的概念与使用简介
mailbox这一概念出现在通信的时候,在SimGrid中communication不是直接一个Actor至另一个Actor,是通过mailbox进行中转的(这里没能理解),可以是同步阻塞的也可以是异步的。官方文档中的比喻是相当于电话号码,caller可以通过其查找到receiver。Mailboxes are rendez-vous points for network communications, similar to URLs on which you could post and retrieve data. Actually, the mailboxes are not involved in the communication once it starts, but only to find the contact with which you want to communicate.
They are similar to many common things: The phone number, which allows the caller to find the receiver. The twitter hashtag, which help senders and receivers to find each others. In TCP, the pair {host name, host port}
to which you can connect to find your peer. In HTTP, URLs through which the clients can connect to the servers. In ZeroMQ, the queues are used to match senders and receivers.
put()与get()是同步阻塞式的消息传递方式,The matching algorithm simple: first come, first serve. When a new send arrives, it matches the oldest enqueued receive. If no receive is currently enqueued, then the incoming send is enqueued. As you can see, the mailbox cannot contain both send and receive requests: all enqueued requests must be of the same sort.(没懂,以后遇到代码在进行理解......)
3. actor-create 例子
安装SimGrid后,其example夹下自带很多的例子,我学习与修改的是example/s4u/actor-create的例子。主要说明的是SimGrid代码中3大元素的actor如何定义与启动。
3.1 actor-create.cpp
/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This example shows how to declare and start your actors.
*
* The first step is to declare the code of your actors (what they do exactly does not matter to this example) and then
* you ask SimGrid to start your actors. There is three ways of doing so:
* - Directly, by instantiating your actor as parameter to Actor::create()
* - By first registering your actors before instantiating it
* - Through the deployment file.
*
* This example shows all these solutions, even if you obviously should use only one of these solutions to start your
* actors. The most advised solution is to use a deployment file, as it creates a clear separation between your
* application and the settings to test it. This is a better scien