From: Arnaud Giersch Date: Fri, 23 Nov 2012 09:15:46 +0000 (+0100) Subject: Kill xbt_dynar_dopar(). X-Git-Tag: v3_9_rc1~91^2~47^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3676269c65359df0174fd13b6c11687992437df8 Kill xbt_dynar_dopar(). Keep it as a separated commit, to make a potential revert easier. --- diff --git a/ChangeLog b/ChangeLog index 3eebff956e..368047a4cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,8 +8,9 @@ SimGrid (3.9) NOT RELEASED; urgency=low * New function: MSG_process_get_number() XBT: - * kill synchronized dynars. We cannot think of a usecase where it's - really mandatory, and maintaining it was a pain in our codebase. + * Kill synchronized dynars, and xbt_dynar_dopar(). We cannot think of a + usecase where it's really mandatory, and maintaining it was a pain in + our codebase. -- $date Da SimGrid team diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 726379c9b0..a2e0d47ed8 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -154,7 +154,6 @@ set(XBT_SRC src/xbt/xbt_sha.c src/xbt/xbt_str.c src/xbt/xbt_strbuff.c - src/xbt/xbt_synchro.c src/xbt/xbt_virtu.c src/xbt_modinter.h ) @@ -402,7 +401,6 @@ set(headers_to_install include/xbt/str.h include/xbt/strbuff.h include/xbt/swag.h - include/xbt/synchro.h include/xbt/synchro_core.h include/xbt/sysdep.h include/xbt/virtu.h diff --git a/buildtools/Cmake/UnitTesting.cmake b/buildtools/Cmake/UnitTesting.cmake index 62fb68a210..4351f1b60e 100644 --- a/buildtools/Cmake/UnitTesting.cmake +++ b/buildtools/Cmake/UnitTesting.cmake @@ -12,7 +12,6 @@ set(TEST_CFILES src/xbt/xbt_strbuff.c src/xbt/xbt_sha.c src/xbt/config.c - src/xbt/xbt_synchro.c src/xbt/parmap.c ) set(TEST_UNITS @@ -26,7 +25,6 @@ set(TEST_UNITS ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_sha_unit.c ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c - ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_synchro_unit.c ${CMAKE_CURRENT_BINARY_DIR}/src/parmap_unit.c ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c diff --git a/examples/platforms/content/storage_content.txt b/examples/platforms/content/storage_content.txt index 4a13ec42d7..c63534f564 100644 --- a/examples/platforms/content/storage_content.txt +++ b/examples/platforms/content/storage_content.txt @@ -546,7 +546,6 @@ -rw-r--r-- 1 user user 648 2011-10-05 16:04 ./include/xbt/module.h -rw-r--r-- 1 user user 5523 2011-10-05 16:04 ./include/xbt/cunit.h -rw-r--r-- 1 user user 1166 2011-10-05 16:04 ./include/xbt/parmap.h --rw-r--r-- 1 user user 845 2011-10-05 16:04 ./include/xbt/synchro.h -rw-r--r-- 1 user user 2296 2011-10-05 16:04 ./include/xbt/mallocator.h -rw-r--r-- 1 user user 9553 2011-10-05 16:04 ./include/xbt/dynar.h -rw-r--r-- 1 user user 1444 2011-10-05 16:04 ./include/xbt/heap.h diff --git a/include/xbt/synchro.h b/include/xbt/synchro.h deleted file mode 100644 index e735325a1d..0000000000 --- a/include/xbt/synchro.h +++ /dev/null @@ -1,22 +0,0 @@ -/* xbt/synchro.h -- Synchronization tools */ -/* Usable in simulator, (or in real life when mixing with GRAS) */ - -/* Copyright (c) 2007, 2009, 2010. 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. */ - -/* synchro_core.h is splited away since it is used by dynar.h, and we use dynar here */ - -#ifndef SYNCHRO_H_ -#define SYNCHRO_H_ -#include "xbt/misc.h" /* SG_BEGIN_DECL */ -#include "xbt/dynar.h" -SG_BEGIN_DECL() - -XBT_PUBLIC(void) xbt_dynar_dopar(xbt_dynar_t datas, - void_f_int_pvoid_t function); - -SG_END_DECL() -#endif /* SYNCHRO_H_ */ diff --git a/include/xbt/synchro_core.h b/include/xbt/synchro_core.h index 51fee8ee07..afa9207f23 100644 --- a/include/xbt/synchro_core.h +++ b/include/xbt/synchro_core.h @@ -1,4 +1,4 @@ -/* xbt/synchro.h -- Synchronization tools */ +/* xbt/synchro_core.h -- Synchronization tools */ /* Usable in simulator, (or in real life when mixing with GRAS) */ /* Copyright (c) 2009, 2010. The SimGrid Team. diff --git a/src/xbt/ex.c b/src/xbt/ex.c index f4ab2b7304..d853cf56dd 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -48,7 +48,6 @@ #include "xbt/str.h" #include "xbt/module.h" /* xbt_binary_name */ #include "xbt_modinter.h" /* backtrace initialization headers */ -#include "xbt/synchro.h" /* xbt_thread_self */ #include "xbt/ex_interface.h" diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 5d03f6ff34..651a2ffef6 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -11,7 +11,6 @@ #include "xbt/sysdep.h" #include "xbt/strbuff.h" #include "xbt/log_private.h" -#include "xbt/synchro.h" /* xbt_thread_self_name */ #include "simgrid/simix.h" /* SIMIX_host_self_get_name */ #include "surf/surf.h" #include diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index 84571d6a86..be6b390676 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -9,7 +9,6 @@ #include "xbt/sysdep.h" #include "xbt/strbuff.h" /* For dynamic version when the static one fails */ #include "xbt/log_private.h" -#include "xbt/synchro.h" /* xbt_thread_name */ #include "simgrid/simix.h" /* SIMIX_host_self_get_name */ #include "surf/surf.h" diff --git a/src/xbt/xbt_queue.c b/src/xbt/xbt_queue.c index 4585ae1673..6dc3c95f80 100644 --- a/src/xbt/xbt_queue.c +++ b/src/xbt/xbt_queue.c @@ -12,7 +12,6 @@ #include "xbt/log.h" #include "xbt/dynar.h" -#include "xbt/synchro.h" #include "xbt/queue.h" /* this module */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_queue, xbt, "Message exchanging queue"); diff --git a/src/xbt/xbt_rl_synchro.c b/src/xbt/xbt_rl_synchro.c index a0a855b5f6..c33b03e554 100644 --- a/src/xbt/xbt_rl_synchro.c +++ b/src/xbt/xbt_rl_synchro.c @@ -14,7 +14,6 @@ #include "xbt/ex.h" #include "portable.h" -#include "xbt/synchro.h" /* This module */ #include "xbt/xbt_os_thread.h" /* The implementation we use */ /* the implementation would be cleaner (and faster) with ELF symbol aliasing */ diff --git a/src/xbt/xbt_sg_synchro.c b/src/xbt/xbt_sg_synchro.c index 7e3bcba31d..f0f87efa7e 100644 --- a/src/xbt/xbt_sg_synchro.c +++ b/src/xbt/xbt_sg_synchro.c @@ -11,8 +11,6 @@ #include "xbt/ex.h" -#include "xbt/synchro.h" /* This module */ - #include "simgrid/simix.h" /* used implementation */ #include "../simix/smx_private.h" /* FIXME */ diff --git a/src/xbt/xbt_synchro.c b/src/xbt/xbt_synchro.c deleted file mode 100644 index a2349d8449..0000000000 --- a/src/xbt/xbt_synchro.c +++ /dev/null @@ -1,103 +0,0 @@ -/* xbt_synchro -- advanced multithreaded features */ -/* Working on top of real threads in RL and of simulated processes in SG */ - -/* Copyright (c) 2009, 2010. 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 "xbt/sysdep.h" -#include "xbt/dynar.h" -#include "xbt/synchro.h" -#include "xbt/xbt_os_thread.h" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_sync); - -typedef struct { - xbt_dynar_t data; - int rank; - void_f_int_pvoid_t function; - xbt_os_thread_t worker; -} s_worker_data_t, *worker_data_t; - -static void worker_wait_n_free(void *w) -{ - worker_data_t worker = *(worker_data_t *) w; - xbt_os_thread_join(worker->worker, NULL); - xbt_free(worker); -} - -static void *worker_wrapper(void *w) -{ - worker_data_t me = (worker_data_t) w; - me->function(me->rank, xbt_dynar_get_ptr(me->data, me->rank)); - return NULL; -} - -void xbt_dynar_dopar(xbt_dynar_t datas, void_f_int_pvoid_t function) -{ - xbt_dynar_t workers = - xbt_dynar_new(sizeof(worker_data_t), worker_wait_n_free); - unsigned int cursor; - void *data; - if (xbt_dynar_is_empty(datas)) - return; /* nothing to do */ - if (xbt_dynar_length(datas) == 1) { - /* don't start any new thread, do it directly */ - function(0, xbt_dynar_get_ptr(datas, 0)); - return; - } - /* Start all workers */ - XBT_DEBUG("Dopar for %lu elements", xbt_dynar_length(datas)); - xbt_dynar_foreach(datas, cursor, data) { - worker_data_t w = xbt_new0(s_worker_data_t, 1); - w->data = datas; - w->function = function; - w->rank = cursor; - xbt_dynar_push(workers, &w); - w->worker = - xbt_os_thread_create("dopar worker", worker_wrapper, w, NULL); - } - /* wait them all */ - xbt_dynar_free(&workers); -} - -#ifdef SIMGRID_TEST -#define NB_ELEM 50 -#include "xbt/synchro.h" - -XBT_TEST_SUITE("synchro", "Advanced synchronization mecanisms"); -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_dyn); - -static void add100(int rank, void *data) -{ - //XBT_INFO("Thread%d: Add 100 to %d",rank,*(int*)data); - *(int *) data += 100; -} - -XBT_TEST_UNIT("dopar", test_dynar_dopar, "do parallel on dynars of integers") -{ - xbt_dynar_t d; - int i, cpt; - unsigned int cursor; - - xbt_test_add - ("==== Push %d int, add 100 to each of them in parallel and check the results", - NB_ELEM); - d = xbt_dynar_new(sizeof(int), NULL); - for (cpt = 0; cpt < NB_ELEM; cpt++) { - xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */ - xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d)); - } - xbt_dynar_dopar(d, add100); - cpt = 100; - xbt_dynar_foreach(d, cursor, i) { - xbt_test_assert(i == cpt, - "The retrieved value is not the expected one (%d!=%d)", - i, cpt); - cpt++; - } - xbt_dynar_free(&d); -} - -#endif /* SIMGRID_TEST */ diff --git a/teshsuite/xbt/log_large_test.c b/teshsuite/xbt/log_large_test.c index b27529cf66..20c4bbc4b9 100644 --- a/teshsuite/xbt/log_large_test.c +++ b/teshsuite/xbt/log_large_test.c @@ -7,7 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt.h" -#include "xbt/synchro.h" XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logs of this example"); diff --git a/teshsuite/xbt/parallel_log_crashtest.c b/teshsuite/xbt/parallel_log_crashtest.c index 7fd9780e31..f181bdf47e 100644 --- a/teshsuite/xbt/parallel_log_crashtest.c +++ b/teshsuite/xbt/parallel_log_crashtest.c @@ -7,7 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt.h" -#include "xbt/synchro.h" XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example");