#ifdef HAVE_VALGRIND_VALGRIND_H
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
unsigned int thread; /* Just for measuring purposes */
#endif
} s_smx_ctx_raw_t, *smx_ctx_raw_t;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
#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;
}
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
timer = xbt_os_timer_new();
#endif
}
*/
static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory)
{
-#ifdef TIME_BENCH
+#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
((smx_ctx_raw_t) context)->stack_top);
}
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
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);
+#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 =
*/
void SIMIX_clean(void)
{
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
smx_ctx_raw_new_sr();
#endif
surf_exit();
+#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;
do {
XBT_DEBUG("New Schedule Round; size(queue)=%lu",
xbt_dynar_length(simix_global->process_to_run));
-#ifdef TIME_BENCH
+#ifdef TIME_BENCH_PER_SR
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 */
+#ifdef TIME_BENCH_AMDAHL
+ xbt_os_timer_stop(simix_global->timer_seq);
+ xbt_os_timer_resume(simix_global->timer_par);
+#endif
SIMIX_process_runall();
+#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);
#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 "smx_synchro_private.h"
/* Define only for SimGrid benchmarking purposes */
-#undef TIME_BENCH
+//#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 {
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;