[SimGrid-user] Accessing Hosts from Platform file
martin.quinson at ens-rennes.fr
Sun Jul 2 18:20:56 CEST 2017
On Sun, Jul 02, 2017 at 10:49:20AM -0400, Monika Sharma wrote:
> Hi Martin,
> I am using MSG_hosts_as_dynar() to get all the hosts from the platform file
> for my application. However as mentioned in the documentation, the host
> order in the returned array is different from the host creation order in
> the XML platform. I am wondering if there are any functions to get the
> hosts in the same order of the platform file or to sort in some order.
There is unfortunately no easy way to retrieve the hosts in the
creation order. The best is probably to sort the array yourself. This
is done for example in teshsuite/simdag/flatifier/flatifier.cpp, using
std::sort() because this code is in C++. But you should be able to use
qsort(3) in the C standard library.
If you really really want to have the hosts in the order of XML file,
then you create a s4u plugin. This allows to have a given function
called each time that a host is created. Check this example:
You need to create a function with this prototype:
void on_host_created(simgrid::s4u::Host& host)
And then, you need to connect it to the relevant signal as follows:
You should obviously connect your function to the signal before you
load the platform file.
Then, in this function, save the hosts in a vector or array in the
Configurability: emacs' hell.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Simgrid-user