A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sed -i -e 's/\t/ /g' [sources] Please people, stop using tabs
[simgrid.git]
/
examples
/
msg
/
masterslave
/
masterslave_arg.c
diff --git
a/examples/msg/masterslave/masterslave_arg.c
b/examples/msg/masterslave/masterslave_arg.c
index
4fd570a
..
ecaafac
100644
(file)
--- a/
examples/msg/masterslave/masterslave_arg.c
+++ b/
examples/msg/masterslave/masterslave_arg.c
@@
-1,11
+1,11
@@
-/* Copyright (c) 2010. The SimGrid Team.
+/* Copyright (c) 2010
-2015
. 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. */
#include <stdio.h>
* 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. */
#include <stdio.h>
-#include "
msg/msg.h" /* Yeah! If you want to use msg, you need to include msg
/msg.h */
+#include "
simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid
/msg.h */
#include "xbt/sysdep.h" /* calloc, printf */
/* Create a log channel to have nice outputs. */
#include "xbt/sysdep.h" /* calloc, printf */
/* Create a log channel to have nice outputs. */
@@
-14,9
+14,6
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
"Messages specific for this msg example");
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
"Messages specific for this msg example");
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-
#define task_comp_size 50000000
#define task_comm_size 1000000
#define task_comp_size 50000000
#define task_comm_size 1000000
@@
-29,33
+26,30
@@
static long my_random(long n)
}
/** Emitter function */
}
/** Emitter function */
-int master(int argc, char *argv[])
+
static
int master(int argc, char *argv[])
{
int i;
for (i = 1; i <= number_of_jobs; i++) {
char mailbox[256];
char sprintf_buffer[256];
{
int i;
for (i = 1; i <= number_of_jobs; i++) {
char mailbox[256];
char sprintf_buffer[256];
- m_task_t task = NULL;
+ m
sg
_task_t task = NULL;
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
sprintf(sprintf_buffer, "Task_%d", i);
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
sprintf(sprintf_buffer, "Task_%d", i);
- task =
- MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
- NULL);
+ task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
number_of_jobs, mailbox);
MSG_task_send(task, mailbox);
}
XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
number_of_jobs, mailbox);
MSG_task_send(task, mailbox);
}
- XBT_DEBUG
- ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+ XBT_DEBUG("All tasks have been dispatched. Let's tell everybody the computation is over.");
for (i = 0; i < number_of_slaves; i++) {
char mailbox[80];
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
for (i = 0; i < number_of_slaves; i++) {
char mailbox[80];
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
- m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+ m
sg
_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_send(finalize, mailbox);
}
MSG_task_send(finalize, mailbox);
}
@@
-64,10
+58,10
@@
int master(int argc, char *argv[])
} /* end_of_master */
/** Receiver function */
} /* end_of_master */
/** Receiver function */
-int slave(int argc, char *argv[])
+
static
int slave(int argc, char *argv[])
{
{
- m_task_t task = NULL;
-
_XBT_GNUC
_UNUSED int res;
+ m
sg
_task_t task = NULL;
+
XBT_ATTRIB
_UNUSED int res;
XBT_DEBUG("mailbox: %s",MSG_process_get_name(MSG_process_self()));
while (1) {
XBT_DEBUG("mailbox: %s",MSG_process_get_name(MSG_process_self()));
while (1) {
@@
-85,22
+79,19
@@
int slave(int argc, char *argv[])
MSG_task_destroy(task);
task = NULL;
}
MSG_task_destroy(task);
task = NULL;
}
- XBT_DEBUG("I'm done. See you!");
return 0;
} /* end_of_slave */ /* end_of_test_all */
/** Main function */
int main(int argc, char *argv[])
{
return 0;
} /* end_of_slave */ /* end_of_test_all */
/** Main function */
int main(int argc, char *argv[])
{
-
MSG
_error_t res = MSG_OK;
+
msg
_error_t res = MSG_OK;
long i;
MSG_init(&argc, argv);
long i;
MSG_init(&argc, argv);
- if (argc < 4) {
- printf("Usage: %s platform_file number_of_jobs number_of_slaves\n", argv[0]);
- printf("example: %s msg_platform.xml 10 5\n", argv[0]);
- exit(1);
- }
+ xbt_assert(argc > 3, "Usage: %s platform_file number_of_jobs number_of_slaves\n"
+ "\tExample: %s msg_platform.xml 10 5\n",
+ argv[0], argv[0]);
MSG_function_register("master", master);
MSG_function_register("slave", slave);
MSG_function_register("master", master);
MSG_function_register("slave", slave);
@@
-113,20
+104,16
@@
int main(int argc, char *argv[])
long number_max = xbt_dynar_length(host_dynar);
XBT_INFO("Got %ld slaves, %ld tasks to process, and %ld hosts", number_of_slaves, number_of_jobs,number_max);
long number_max = xbt_dynar_length(host_dynar);
XBT_INFO("Got %ld slaves, %ld tasks to process, and %ld hosts", number_of_slaves, number_of_jobs,number_max);
- m_host_t *host_table = xbt_dynar_to_array(host_dynar);
- //xbt_dynar_free(&host_dynar);
+ msg_host_t *host_table = xbt_dynar_to_array(host_dynar);
- MSG_process_create( "master",
- master,
+ MSG_process_create( "master", master,
NULL,
host_table[my_random(number_max)]
);
NULL,
host_table[my_random(number_max)]
);
- for(i = 0 ; i<number_of_slaves; i++)
- {
+ for(i = 0 ; i<number_of_slaves; i++) {
char* name_host = bprintf("slave-%ld",i);
char* name_host = bprintf("slave-%ld",i);
- MSG_process_create( name_host,
- slave,
+ MSG_process_create( name_host, slave,
NULL,
host_table[my_random(number_max)]
);
NULL,
host_table[my_random(number_max)]
);
@@
-138,10
+125,5
@@
int main(int argc, char *argv[])
XBT_INFO("Simulation time %g", MSG_get_clock());
XBT_INFO("Simulation time %g", MSG_get_clock());
- MSG_clean();
-
- if (res == MSG_OK)
- return 0;
- else
- return 1;
-} /* end_of_main */
+ return res != MSG_OK;
+}