This is activated by defining the TIME_BENCH_AMDAHL macro at compile
time (for example by decomenting its definition in smx_private.h).
This is useful to evaluate the maximal possible speedup of a given
simulation by applying the Amdahl Law.
This could be changed into a command line flag at some point, but we
first have to assess the performance impact of playing that much with
the timers (should be limited, but who knows?).
The initial patch was from Jean-Noel Quintin, thanks for that!
#ifdef HAVE_VALGRIND_VALGRIND_H
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
#ifdef HAVE_VALGRIND_VALGRIND_H
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
+#ifdef TIME_BENCH_PER_SR
unsigned int thread; /* Just for measuring purposes */
#endif
} s_smx_ctx_raw_t, *smx_ctx_raw_t;
unsigned int thread; /* Just for measuring purposes */
#endif
} s_smx_ctx_raw_t, *smx_ctx_raw_t;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+#ifdef TIME_BENCH_PER_SR
#include "xbt/xbt_os_time.h"
#define NUM_THREADS 4
static xbt_os_timer_t timer;
#include "xbt/xbt_os_time.h"
#define NUM_THREADS 4
static xbt_os_timer_t timer;
(*factory)->runall = smx_ctx_raw_runall_serial;
(*factory)->suspend = smx_ctx_raw_suspend_serial;
}
(*factory)->runall = smx_ctx_raw_runall_serial;
(*factory)->suspend = smx_ctx_raw_suspend_serial;
}
+#ifdef TIME_BENCH_PER_SR
timer = xbt_os_timer_new();
#endif
}
timer = xbt_os_timer_new();
#endif
}
*/
static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory)
{
*/
static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory)
{
+#ifdef TIME_BENCH_PER_SR
XBT_CRITICAL("Total wasted time in %u SR: %lf", sr_count, time_wasted_sr);
XBT_CRITICAL("Total wasted time in %u SSR: %lf", ssr_count, time_wasted_ssr);
#endif
XBT_CRITICAL("Total wasted time in %u SR: %lf", sr_count, time_wasted_sr);
XBT_CRITICAL("Total wasted time in %u SSR: %lf", ssr_count, time_wasted_ssr);
#endif
((smx_ctx_raw_t) context)->stack_top);
}
((smx_ctx_raw_t) context)->stack_top);
}
+#ifdef TIME_BENCH_PER_SR
static void smx_ctx_raw_runall_serial(xbt_dynar_t processes)
{
smx_process_t process;
static void smx_ctx_raw_runall_serial(xbt_dynar_t processes)
{
smx_process_t process;
if (!simix_global) {
simix_global = xbt_new0(s_smx_global_t, 1);
if (!simix_global) {
simix_global = xbt_new0(s_smx_global_t, 1);
+#ifdef TIME_BENCH_AMDAHL
+ simix_global->timer_seq = xbt_os_timer_new();
+ simix_global->timer_par = xbt_os_timer_new();
+ xbt_os_timer_start(simix_global->timer_seq);
+#endif
simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_list =
simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_list =
*/
void SIMIX_clean(void)
{
*/
void SIMIX_clean(void)
{
+#ifdef TIME_BENCH_PER_SR
smx_ctx_raw_new_sr();
#endif
smx_ctx_raw_new_sr();
#endif
+#ifdef TIME_BENCH_AMDAHL
+ xbt_os_timer_stop(simix_global->timer_seq);
+ XBT_INFO("Amdhal timing informations. Sequential time: %lf; Parallel time: %lf",
+ xbt_os_timer_elapsed(simix_global->timer_seq),
+ xbt_os_timer_elapsed(simix_global->timer_par));
+ xbt_os_timer_free(simix_global->timer_seq);
+ xbt_os_timer_free(simix_global->timer_par);
+#endif
+
xbt_mallocator_free(simix_global->action_mallocator);
xbt_free(simix_global);
simix_global = NULL;
xbt_mallocator_free(simix_global->action_mallocator);
xbt_free(simix_global);
simix_global = NULL;
do {
XBT_DEBUG("New Schedule Round; size(queue)=%lu",
xbt_dynar_length(simix_global->process_to_run));
do {
XBT_DEBUG("New Schedule Round; size(queue)=%lu",
xbt_dynar_length(simix_global->process_to_run));
+#ifdef TIME_BENCH_PER_SR
smx_ctx_raw_new_sr();
#endif
while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
smx_ctx_raw_new_sr();
#endif
while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
xbt_dynar_length(simix_global->process_to_run));
/* Run all processes that are ready to run, possibly in parallel */
xbt_dynar_length(simix_global->process_to_run));
/* Run all processes that are ready to run, possibly in parallel */
+#ifdef TIME_BENCH_AMDAHL
+ xbt_os_timer_stop(simix_global->timer_seq);
+ xbt_os_timer_resume(simix_global->timer_par);
+#endif
+#ifdef TIME_BENCH_AMDAHL
+ xbt_os_timer_stop(simix_global->timer_par);
+ xbt_os_timer_resume(simix_global->timer_seq);
+#endif
/* Move all killing processes to the end of the list, because killing a process that have an ongoing simcall is a bad idea */
xbt_dynar_three_way_partition(simix_global->process_that_ran, process_syscall_color);
/* Move all killing processes to the end of the list, because killing a process that have an ongoing simcall is a bad idea */
xbt_dynar_three_way_partition(simix_global->process_that_ran, process_syscall_color);
#include "xbt/dict.h"
#include "xbt/mallocator.h"
#include "xbt/config.h"
#include "xbt/dict.h"
#include "xbt/mallocator.h"
#include "xbt/config.h"
+#include "xbt/xbt_os_time.h"
#include "xbt/function_types.h"
#include "xbt/ex_interface.h"
#include "instr/instr_private.h"
#include "xbt/function_types.h"
#include "xbt/ex_interface.h"
#include "instr/instr_private.h"
#include "smx_synchro_private.h"
/* Define only for SimGrid benchmarking purposes */
#include "smx_synchro_private.h"
/* Define only for SimGrid benchmarking purposes */
+//#define TIME_BENCH_PER_SR /* this aims at measuring the time spent in each scheduling round per each thread. The code is thus run in sequential to bench separately each SSR */
+//#define TIME_BENCH_AMDAHL /* this aims at measuring the porting of time that could be parallelized at maximum (to get the optimal speedup by applying the amdahl law). */
/********************************** Simix Global ******************************/
typedef struct s_smx_global {
/********************************** Simix Global ******************************/
typedef struct s_smx_global {
void_pfn_smxprocess_t cleanup_process_function;
xbt_mallocator_t action_mallocator;
void_pfn_smxhost_t autorestart;
void_pfn_smxprocess_t cleanup_process_function;
xbt_mallocator_t action_mallocator;
void_pfn_smxhost_t autorestart;
+
+#ifdef TIME_BENCH_AMDAHL
+ xbt_os_timer_t timer_seq; /* used to bench the sequential and parallel parts of the simulation, if requested to */
+ xbt_os_timer_t timer_par;
+#endif
} s_smx_global_t, *smx_global_t;
extern smx_global_t simix_global;
} s_smx_global_t, *smx_global_t;
extern smx_global_t simix_global;