From c714798d5c146946f9ccce06da87bc1707b2de2d Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 28 Feb 2012 11:22:30 +0100 Subject: [PATCH] Deprecate MSG_get_host_{table,number}; Implement MSG_hosts_as_dynar() instead. --- ChangeLog | 3 +++ examples/msg/io/file.c | 11 ++++----- examples/msg/masterslave/masterslave_arg.c | 8 ++++--- .../msg/masterslave/masterslave_cluster.c | 5 +++- examples/msg/parallel_task/parallel_task.c | 17 ++++++++----- examples/msg/token_ring/ring_call.c | 16 ++++++------- include/msg/msg.h | 6 +++-- src/msg/msg_host.c | 24 ++++++++++++++----- teshsuite/simdag/platforms/basic_tracing.c | 7 +++++- 9 files changed, 64 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 444c12f293..4662d246c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,9 @@ SimGrid (3.7) NOT RELEASED; urgency=low SIMGRID_DEPRECATED before loading the msg.h if you really need to use these (crappy) functions in your code. These functions will be removed at some point. Stop using them now. + * Deprecate MSG_get_host_{table,number} + Implement MSG_hosts_as_dynar() instead. + * Implement MSG_processes_as_dynar() (Closes gforge #13642) Simix: * Stabilize the parallel execution mode of user contexts diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index ed5ed3afc4..3cd1c8310a 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -39,18 +39,17 @@ int main(int argc, char **argv) int i,res; MSG_global_init(&argc, argv); MSG_create_environment(argv[1]); - m_host_t *host_table = MSG_get_host_table(); - int number_of_hosts = MSG_get_host_number(); + xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_function_register("host", host); - XBT_INFO("Number of host '%d'",number_of_hosts); - for(i = 0 ; i */ SURFXML_BUFFER_SET(platform_version, "3"); diff --git a/examples/msg/parallel_task/parallel_task.c b/examples/msg/parallel_task/parallel_task.c index f546f6cea9..c45849b9a2 100644 --- a/examples/msg/parallel_task/parallel_task.c +++ b/examples/msg/parallel_task/parallel_task.c @@ -20,6 +20,7 @@ MSG_error_t test_all(const char *platform_file); /** Emitter function */ int test(int argc, char *argv[]) { + xbt_dynar_t slaves_dynar; int slaves_count = 0; m_host_t *slaves = NULL; double task_comp_size = 100000; @@ -29,8 +30,10 @@ int test(int argc, char *argv[]) m_task_t ptask = NULL; int i, j; - slaves_count = MSG_get_host_number(); - slaves = MSG_get_host_table(); + slaves_dynar = MSG_hosts_as_dynar(); + slaves_count = xbt_dynar_length(slaves_dynar); + slaves = xbt_dynar_to_array(slaves_dynar); + xbt_dynar_free(&slaves_dynar); computation_amount = xbt_new0(double, slaves_count); communication_amount = xbt_new0(double, slaves_count * slaves_count); @@ -62,15 +65,17 @@ int test(int argc, char *argv[]) MSG_error_t test_all(const char *platform_file) { MSG_error_t res = MSG_OK; - m_host_t *hosts; + xbt_dynar_t all_hosts; + m_host_t first_host; MSG_config("workstation/model", "ptask_L07"); MSG_create_environment(platform_file); - hosts = MSG_get_host_table(); - MSG_process_create("test", test, NULL, hosts[0]); + all_hosts = MSG_hosts_as_dynar(); + first_host = xbt_dynar_pop_as(all_hosts,m_host_t); + MSG_process_create("test", test, NULL, first_host); res = MSG_main(); - xbt_free(hosts); + xbt_dynar_free(&all_hosts); XBT_INFO("Simulation time %g", MSG_get_clock()); return res; diff --git a/examples/msg/token_ring/ring_call.c b/examples/msg/token_ring/ring_call.c index be67d1ccae..2793022761 100644 --- a/examples/msg/token_ring/ring_call.c +++ b/examples/msg/token_ring/ring_call.c @@ -12,7 +12,8 @@ int host(int argc, char *argv[]); unsigned int task_comp_size = 50000000; unsigned int task_comm_size = 1000000; -int number_of_hosts; + +xbt_dynar_t hosts; /* All declared hosts */ XBT_LOG_NEW_DEFAULT_CATEGORY(ring, "Messages specific for this msg example"); @@ -40,7 +41,7 @@ int host(int argc, char *argv[]) xbt_assert(res == MSG_OK, "MSG_task_get failed"); XBT_INFO("Host \"%d\" received \"%s\"",host_number, MSG_task_get_name(task)); - if(host_number+1 == number_of_hosts ) + if(host_number+1 == xbt_dynar_length(hosts) ) sprintf(mailbox, "0"); else sprintf(mailbox, "%d", host_number+1); @@ -55,18 +56,17 @@ int main(int argc, char **argv) int i,res; MSG_global_init(&argc, argv); MSG_create_environment(argv[1]); - m_host_t *host_table = MSG_get_host_table(); - number_of_hosts = MSG_get_host_number(); + hosts = MSG_hosts_as_dynar(); MSG_function_register("host", host); - XBT_INFO("Number of host '%d'",number_of_hosts); - for(i = 0 ; i