Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added adaptive algorithm to find optimal threshold over simulations
[simgrid.git] / src / simix / smx_context_raw.c
1 /* context_raw - fast context switching inspired from System V ucontexts   */
2
3 /* Copyright (c) 2009-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "smx_private.h"
9 #include "xbt/parmap.h"
10 #include "xbt/dynar.h"
11 #include "mc/mc.h"
12
13 typedef char * raw_stack_t;
14 typedef void (*rawctx_entry_point_t)(void *);
15
16 typedef struct s_smx_ctx_raw {
17   s_smx_ctx_base_t super;         /* Fields of super implementation */
18   char *malloced_stack;           /* malloced area containing the stack */
19   raw_stack_t stack_top;          /* pointer to stack top (within previous area) */
20 #ifdef TIME_BENCH_PER_SR
21   unsigned int thread;            /* Just for measuring purposes */
22 #endif
23 } s_smx_ctx_raw_t, *smx_ctx_raw_t;
24
25 #ifdef CONTEXT_THREADS
26 static xbt_parmap_t raw_parmap;
27 static smx_ctx_raw_t* raw_workers_context;    /* space to save the worker context in each thread */
28 static unsigned long raw_threads_working;     /* number of threads that have started their work */
29 static xbt_os_thread_key_t raw_worker_id_key; /* thread-specific storage for the thread id */
30 #endif
31
32 #ifdef ADAPTIVE_THRESHOLD
33 #define SCHED_ROUND_LIMIT 5
34 xbt_os_timer_t round_time;
35 double par_time,seq_time;
36 static unsigned int par_proc_that_ran = 0,seq_proc_that_ran = 0;  /* Counters of processes that have run in SCHED_ROUND_LIMIT scheduling rounds */
37 static unsigned int seq_sched_round, par_sched_round; /* Amount of SR that ran serial/parallel*/
38 #endif
39
40 static unsigned long raw_process_index = 0;   /* index of the next process to run in the
41                                                * list of runnable processes */
42 static smx_ctx_raw_t raw_maestro_context;
43
44 extern raw_stack_t raw_makecontext(char* malloced_stack, int stack_size,
45                                    rawctx_entry_point_t entry_point, void* arg);
46 extern void raw_swapcontext(raw_stack_t* old, raw_stack_t new);
47
48 #if PROCESSOR_x86_64
49 __asm__ (
50 #if defined(APPLE)
51    ".text\n"
52    ".globl _raw_makecontext\n"
53    "_raw_makecontext:\n"
54 #elif defined(_WIN32)
55    ".text\n"
56    ".globl raw_makecontext\n"
57    "raw_makecontext:\n"
58 #else
59    ".text\n"
60    ".globl raw_makecontext\n"
61    ".type raw_makecontext,@function\n"
62    "raw_makecontext:\n"/* Calling convention sets the arguments in rdi, rsi, rdx and rcx, respectively */
63 #endif
64    "   mov %rdi,%rax\n"      /* stack */
65    "   add %rsi,%rax\n"      /* size  */
66    "   andq $-16, %rax\n"    /* align stack */
67    "   movq $0,   -8(%rax)\n" /* @return for func */
68    "   mov %rdx,-16(%rax)\n" /* func */
69    "   mov %rcx,-24(%rax)\n" /* arg/rdi */
70    "   movq $0,  -32(%rax)\n" /* rsi */
71    "   movq $0,  -40(%rax)\n" /* rdx */
72    "   movq $0,  -48(%rax)\n" /* rcx */
73    "   movq $0,  -56(%rax)\n" /* r8  */
74    "   movq $0,  -64(%rax)\n" /* r9  */
75    "   movq $0,  -72(%rax)\n" /* rbp */
76    "   movq $0,  -80(%rax)\n" /* rbx */
77    "   movq $0,  -88(%rax)\n" /* r12 */
78    "   movq $0,  -96(%rax)\n" /* r13 */
79    "   movq $0, -104(%rax)\n" /* r14 */
80    "   movq $0, -112(%rax)\n" /* r15 */
81    "   sub $112,%rax\n"
82    "   ret\n"
83 );
84
85 __asm__ (
86 #if defined(APPLE)
87    ".text\n"
88    ".globl _raw_swapcontext\n"
89    "_raw_swapcontext:\n"
90 #elif defined(_WIN32)
91    ".text\n"
92    ".globl raw_swapcontext\n"
93    "raw_swapcontext:\n"
94 #else
95    ".text\n"
96    ".globl raw_swapcontext\n"
97    ".type raw_swapcontext,@function\n"
98    "raw_swapcontext:\n" /* Calling convention sets the arguments in rdi and rsi, respectively */
99 #endif
100    "   push %rdi\n"
101    "   push %rsi\n"
102    "   push %rdx\n"
103    "   push %rcx\n"
104    "   push %r8\n"
105    "   push %r9\n"
106    "   push %rbp\n"
107    "   push %rbx\n"
108    "   push %r12\n"
109    "   push %r13\n"
110    "   push %r14\n"
111    "   push %r15\n"
112    "   mov %rsp,(%rdi)\n" /* old */
113    "   mov %rsi,%rsp\n" /* new */
114    "   pop %r15\n"
115    "   pop %r14\n"
116    "   pop %r13\n"
117    "   pop %r12\n"
118    "   pop %rbx\n"
119    "   pop %rbp\n"
120    "   pop %r9\n"
121    "   pop %r8\n"
122    "   pop %rcx\n"
123    "   pop %rdx\n"
124    "   pop %rsi\n"
125    "   pop %rdi\n"
126    "   ret\n"
127 );
128 #elif PROCESSOR_i686
129 __asm__ (
130 #if defined(APPLE) || defined(_WIN32)
131    ".text\n"
132    ".globl _raw_makecontext\n"
133    "_raw_makecontext:\n"
134 #else
135    ".text\n"
136    ".globl raw_makecontext\n"
137    ".type raw_makecontext,@function\n"
138    "raw_makecontext:\n"
139 #endif
140    "   movl 4(%esp),%eax\n"   /* stack */
141    "   addl 8(%esp),%eax\n"   /* size  */
142    "   andl $-16, %eax\n"     /* align stack */
143    "   movl 12(%esp),%ecx\n"  /* func  */
144    "   movl 16(%esp),%edx\n"  /* arg   */
145    "   movl %edx, -4(%eax)\n"
146    "   movl $0,   -8(%eax)\n" /* @return for func */
147    "   movl %ecx,-12(%eax)\n"
148    "   movl $0,  -16(%eax)\n" /* ebp */
149    "   movl $0,  -20(%eax)\n" /* ebx */
150    "   movl $0,  -24(%eax)\n" /* esi */
151    "   movl $0,  -28(%eax)\n" /* edi */
152    "   subl $28,%eax\n"
153    "   retl\n"
154 );
155
156 __asm__ (
157 #if defined(APPLE) || defined(_WIN32)
158    ".text\n"
159    ".globl _raw_swapcontext\n"
160    "_raw_swapcontext:\n"
161 #else
162    ".text\n"
163    ".globl raw_swapcontext\n"
164    ".type raw_swapcontext,@function\n"
165    "raw_swapcontext:\n"
166 #endif
167    "   movl 4(%esp),%eax\n" /* old */
168    "   movl 8(%esp),%edx\n" /* new */
169    "   pushl %ebp\n"
170    "   pushl %ebx\n"
171    "   pushl %esi\n"
172    "   pushl %edi\n"
173    "   movl %esp,(%eax)\n"
174    "   movl %edx,%esp\n"
175    "   popl %edi\n"
176    "   popl %esi\n"
177    "   popl %ebx\n"
178    "   popl %ebp\n"
179    "   retl\n"
180 );
181 #else
182
183
184 /* If you implement raw contexts for other processors, don't forget to
185    update the definition of HAVE_RAWCTX in buildtools/Cmake/CompleteInFiles.cmake */
186
187 raw_stack_t raw_makecontext(char* malloced_stack, int stack_size,
188                             rawctx_entry_point_t entry_point, void* arg) {
189    THROW_UNIMPLEMENTED;
190 }
191
192 void raw_swapcontext(raw_stack_t* old, raw_stack_t new) {
193    THROW_UNIMPLEMENTED;
194 }
195
196 #endif
197
198 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
199
200 #ifdef TIME_BENCH_PER_SR
201 #include "xbt/xbt_os_time.h"
202 #define NUM_THREADS 4
203 static xbt_os_timer_t timer;
204 static double time_thread_sr[NUM_THREADS];
205 static double time_thread_ssr[NUM_THREADS];
206 static double time_wasted_sr = 0;
207 static double time_wasted_ssr = 0;
208 static unsigned int sr_count = 0;
209 static unsigned int ssr_count = 0;
210 static char new_sr = 0;
211 #endif
212
213 static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
214 static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory);
215 static smx_context_t smx_ctx_raw_create_context(xbt_main_func_t code, int argc,
216     char **argv, void_pfn_smxprocess_t cleanup_func, smx_process_t process);
217 static void smx_ctx_raw_free(smx_context_t context);
218 static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
219 static void smx_ctx_raw_stop(smx_context_t context);
220 static void smx_ctx_raw_suspend_serial(smx_context_t context);
221 static void smx_ctx_raw_resume_serial(smx_process_t first_process);
222 #ifdef TIME_BENCH_PER_SR
223 static void smx_ctx_raw_runall_serial(xbt_dynar_t processes);
224 void smx_ctx_raw_new_sr(void);
225 #else
226 static void smx_ctx_raw_runall_serial(void);
227 #endif
228 static void smx_ctx_raw_suspend_parallel(smx_context_t context);
229 static void smx_ctx_raw_resume_parallel(smx_process_t first_process);
230 static void smx_ctx_raw_runall_parallel(void);
231 static void smx_ctx_raw_runall(void);
232
233 /**
234  * \brief Initializes the raw context factory.
235  * \param factory where to initialize the factory
236  */
237 void SIMIX_ctx_raw_factory_init(smx_context_factory_t *factory)
238 {
239
240   XBT_VERB("Using raw contexts. Because the glibc is just not good enough for us.");
241   smx_ctx_base_factory_init(factory);
242
243   (*factory)->finalize  = smx_ctx_raw_factory_finalize;
244   (*factory)->create_context = smx_ctx_raw_create_context;
245   /* Do not overload that method (*factory)->finalize */
246   (*factory)->free = smx_ctx_raw_free;
247   (*factory)->stop = smx_ctx_raw_stop;
248   (*factory)->name = "smx_raw_context_factory";
249
250   if (SIMIX_context_is_parallel()) {
251 #ifdef CONTEXT_THREADS
252     int nthreads = SIMIX_context_get_nthreads();
253     xbt_os_thread_key_create(&raw_worker_id_key);
254     raw_parmap = xbt_parmap_new(nthreads, SIMIX_context_get_parallel_mode());
255     raw_workers_context = xbt_new(smx_ctx_raw_t, nthreads);
256     raw_maestro_context=NULL;
257
258 #endif
259     if (SIMIX_context_get_parallel_threshold() > 1) {
260       /* choose dynamically */
261       (*factory)->runall = smx_ctx_raw_runall;
262       (*factory)->suspend = NULL;
263     }
264     else {
265       /* always parallel */
266       (*factory)->runall = smx_ctx_raw_runall_parallel;
267       (*factory)->suspend = smx_ctx_raw_suspend_parallel;
268     }
269   }
270   else {
271     /* always serial */
272     (*factory)->runall = smx_ctx_raw_runall_serial;
273     (*factory)->suspend = smx_ctx_raw_suspend_serial;
274   }
275 #ifdef TIME_BENCH_PER_SR
276   timer = xbt_os_timer_new();
277 #endif
278 }
279
280 /**
281  * \brief Finalizes the raw context factory.
282  * \param factory the raw context factory
283  */
284 static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory)
285 {
286 #ifdef TIME_BENCH_PER_SR
287   XBT_VERB("Total wasted time in %u SR: %f", sr_count, time_wasted_sr);
288   XBT_VERB("Total wasted time in %u SSR: %f", ssr_count, time_wasted_ssr);
289 #endif
290
291 #ifdef CONTEXT_THREADS
292   if (raw_parmap)
293     xbt_parmap_destroy(raw_parmap);
294   xbt_free(raw_workers_context);
295 #endif
296   return smx_ctx_base_factory_finalize(factory);
297 }
298
299 /**
300  * \brief Creates a new raw context.
301  * \param code main function of this context or NULL to create the maestro
302  * context
303  * \param argc argument number
304  * \param argv arguments to pass to the main function
305  * \param cleanup_func a function to call to free the user data when the
306  * context finished
307  * \param process SIMIX process
308  */
309 static smx_context_t
310 smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
311                            void_pfn_smxprocess_t cleanup_func,
312                            smx_process_t process)
313 {
314
315   smx_ctx_raw_t context =
316       (smx_ctx_raw_t) smx_ctx_base_factory_create_context_sized(
317           sizeof(s_smx_ctx_raw_t),
318           code,
319           argc,
320           argv,
321           cleanup_func,
322           process);
323
324   /* if the user provided a function for the process then use it,
325      otherwise it is the context for maestro */
326      if (code) {
327        context->malloced_stack = SIMIX_context_stack_new();
328        context->stack_top =
329            raw_makecontext(context->malloced_stack,
330                            smx_context_usable_stack_size,
331                            (void_f_pvoid_t)smx_ctx_raw_wrapper, context);
332
333      } else {
334        if(process != NULL && raw_maestro_context==NULL)
335          raw_maestro_context = context;
336
337        if(MC_is_active())
338          MC_ignore_heap(&(raw_maestro_context->stack_top), sizeof(raw_maestro_context->stack_top));
339
340      }
341
342      return (smx_context_t) context;
343 }
344
345 /**
346  * \brief Destroys a raw context.
347  * \param context a raw context
348  */
349 static void smx_ctx_raw_free(smx_context_t context)
350 {
351   if (context) {
352     SIMIX_context_stack_delete(((smx_ctx_raw_t) context)->malloced_stack);
353   }
354   smx_ctx_base_free(context);
355 }
356
357 /**
358  * \brief Wrapper for the main function of a context.
359  * \param context a raw context
360  */
361 static void smx_ctx_raw_wrapper(smx_ctx_raw_t context)
362 {
363   (context->super.code) (context->super.argc, context->super.argv);
364
365   smx_ctx_raw_stop((smx_context_t) context);
366 }
367
368 /**
369  * \brief Stops a raw context.
370  *
371  * This function is called when the main function of the context if finished.
372  *
373  * \param context the current context
374  */
375 static void smx_ctx_raw_stop(smx_context_t context)
376 {
377   smx_ctx_base_stop(context);
378   simix_global->context_factory->suspend(context);
379 }
380
381 /**
382  * \brief Suspends a running context and resumes another one or returns to
383  * maestro.
384  * \param context the current context
385  */
386 static void smx_ctx_raw_suspend_serial(smx_context_t context)
387 {
388   /* determine the next context */
389   smx_context_t next_context;
390   unsigned long int i; 
391 #ifdef TIME_BENCH_PER_SR
392   i = ++raw_process_index;
393 #else
394   i = raw_process_index++;
395 #endif
396   if (i < xbt_dynar_length(simix_global->process_to_run)) {
397     /* execute the next process */
398     XBT_DEBUG("Run next process");
399     next_context = xbt_dynar_get_as(
400         simix_global->process_to_run, i, smx_process_t)->context;
401   }
402   else {
403     /* all processes were run, return to maestro */
404     XBT_DEBUG("No more process to run");
405     next_context = (smx_context_t) raw_maestro_context;
406   }
407   SIMIX_context_set_current(next_context);
408   raw_swapcontext(&((smx_ctx_raw_t) context)->stack_top,
409       ((smx_ctx_raw_t) next_context)->stack_top);
410 }
411
412 /**
413  * \brief Resumes sequentially all processes ready to run.
414  * \param first_process the first process to resume
415  */
416 static void smx_ctx_raw_resume_serial(smx_process_t first_process)
417 {
418   smx_ctx_raw_t context = (smx_ctx_raw_t) first_process->context;
419   SIMIX_context_set_current((smx_context_t) context);
420   raw_swapcontext(&raw_maestro_context->stack_top,
421       ((smx_ctx_raw_t) context)->stack_top);
422 }
423
424 #ifdef TIME_BENCH_PER_SR
425 static void smx_ctx_raw_runall_serial(xbt_dynar_t processes)
426 {
427   smx_process_t process;
428   unsigned int cursor;
429   double elapsed = 0;
430   double tmax = 0;
431   unsigned long num_proc = xbt_dynar_length(simix_global->process_to_run);
432   unsigned int t=0;
433   unsigned int data_size = (num_proc / NUM_THREADS) + ((num_proc % NUM_THREADS) ? 1 : 0);
434
435   ssr_count++;
436   time_thread_ssr[0] = 0;
437   xbt_dynar_foreach(processes, cursor, process){ 
438         XBT_VERB("Schedule item %u of %lu",cursor,num_proc);
439         if(cursor >= t * data_size + data_size){
440           if(time_thread_ssr[t] > tmax)
441             tmax = time_thread_ssr[t];
442           t++;
443           time_thread_ssr[t] = 0;
444         }
445
446         if(new_sr){
447           ((smx_ctx_raw_t)process->context)->thread = t;
448           time_thread_sr[t] = 0;
449         }
450
451         xbt_os_cputimer_start(timer);
452         smx_ctx_raw_resume_serial(process);
453         xbt_os_cputimer_stop(timer);
454         elapsed = xbt_os_timer_elapsed(timer);
455         time_thread_ssr[t] += elapsed;
456         time_thread_sr[((smx_ctx_raw_t)process->context)->thread] += elapsed;
457   }
458
459   if(new_sr)
460     new_sr = FALSE;
461
462   if(time_thread_ssr[t] > tmax)
463     tmax = time_thread_ssr[t];
464
465   for(cursor=0; cursor <= t; cursor++){
466     XBT_VERB("Time SSR thread %u = %f (max %f)", cursor, time_thread_ssr[cursor], tmax);
467     time_wasted_ssr += tmax - time_thread_ssr[cursor];
468   }
469 }
470
471 void smx_ctx_raw_new_sr(void)
472 {
473   int i;
474   double tmax = 0;
475   new_sr = TRUE;
476   sr_count++;
477   for(i=0; i < NUM_THREADS; i++){
478     if(time_thread_sr[i] > tmax)
479       tmax = time_thread_sr[i];
480   }
481
482   for(i=0; i < NUM_THREADS; i++){
483     XBT_CRITICAL("Time SR thread %u = %f (max %f)", i, time_thread_sr[i], tmax);
484     time_wasted_sr += tmax - time_thread_sr[i];
485   }
486
487   XBT_CRITICAL("Total time SR %u = %f, %d", sr_count, tmax, xbt_dynar_length(simix_global->process_that_ran));
488   XBT_CRITICAL("New scheduling round");
489 }
490 #else
491 /**
492  * \brief Resumes sequentially all processes ready to run.
493  */
494 static void smx_ctx_raw_runall_serial(void)
495 {
496   smx_process_t first_process =
497       xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t);
498   raw_process_index = 1;
499
500   /* execute the first process */
501   smx_ctx_raw_resume_serial(first_process);
502 }
503 #endif
504
505 /**
506  * \brief Suspends a running context and resumes another one or returns to
507  * the main function of the current worker thread.
508  * \param context the context of the current worker thread
509  */
510 static void smx_ctx_raw_suspend_parallel(smx_context_t context)
511 {
512 #ifdef CONTEXT_THREADS
513   /* determine the next context */
514   smx_process_t next_work = xbt_parmap_next(raw_parmap);
515   smx_context_t next_context;
516   raw_stack_t next_stack;
517
518   if (next_work != NULL) {
519     /* there is a next process to resume */
520     XBT_DEBUG("Run next process");
521     next_context = next_work->context;
522     next_stack = ((smx_ctx_raw_t) next_context)->stack_top;
523   }
524   else {
525     /* all processes were run, go to the barrier */
526     XBT_DEBUG("No more processes to run");
527
528     unsigned long worker_id =
529         (unsigned long) xbt_os_thread_get_specific(raw_worker_id_key);
530
531     next_context = (smx_context_t)raw_workers_context[worker_id];
532     XBT_DEBUG("Restoring worker stack %lu (working threads = %lu)",
533         worker_id, raw_threads_working);
534     next_stack = ((smx_ctx_raw_t)next_context)->stack_top;
535   }
536
537   SIMIX_context_set_current(next_context);
538   raw_swapcontext(&((smx_ctx_raw_t) context)->stack_top, next_stack);
539 #endif
540 }
541
542 /**
543  * \brief Resumes sequentially in the current worker thread the processes ready
544  * to run.
545  * \param first_process the first process to resume
546  */
547 static void smx_ctx_raw_resume_parallel(smx_process_t first_process)
548 {
549 #ifdef CONTEXT_THREADS
550   unsigned long worker_id = __sync_fetch_and_add(&raw_threads_working, 1);
551   xbt_os_thread_set_specific(raw_worker_id_key, (void*) worker_id);
552   smx_ctx_raw_t worker_context = (smx_ctx_raw_t)SIMIX_context_self();
553   raw_workers_context[worker_id] = worker_context;
554   XBT_DEBUG("Saving worker stack %lu", worker_id);
555   raw_stack_t* worker_stack = &(worker_context)->stack_top;
556
557
558   smx_context_t context = first_process->context;
559   SIMIX_context_set_current(context);
560   raw_swapcontext(worker_stack, ((smx_ctx_raw_t) context)->stack_top);
561 #endif
562 }
563
564 /**
565  * \brief Resumes in parallel all processes ready to run.
566  */
567 static void smx_ctx_raw_runall_parallel(void)
568 {
569 #ifdef CONTEXT_THREADS
570   raw_threads_working = 0;
571   xbt_parmap_apply(raw_parmap, (void_f_pvoid_t) smx_ctx_raw_resume_parallel,
572       simix_global->process_to_run);
573 #else
574   xbt_die("You asked for a parallel execution, but you don't have any threads.");
575 #endif
576 }
577
578 /**
579  * \brief Resumes all processes ready to run.
580  */
581 #ifdef ADAPTIVE_THRESHOLD
582 static void smx_ctx_raw_runall(void)
583 {
584   unsigned long nb_processes = xbt_dynar_length(simix_global->process_to_run);
585
586   if(seq_sched_round % SCHED_ROUND_LIMIT == 0 && par_sched_round % SCHED_ROUND_LIMIT == 0){
587     seq_sched_round = 1;
588     par_sched_round = 1;
589     if((seq_time / (double)seq_proc_that_ran) > (par_time / (double)par_proc_that_ran)){
590         SIMIX_context_set_parallel_threshold(SIMIX_context_get_parallel_threshold() - 1);
591     } else {
592         SIMIX_context_set_parallel_threshold(SIMIX_context_get_parallel_threshold() + 1);
593     }
594     par_time = 0; par_proc_that_ran = 0;
595     seq_time = 0; seq_proc_that_ran = 0;
596   }
597   round_time = xbt_os_timer_new(); 
598   if (nb_processes >= SIMIX_context_get_parallel_threshold()) {
599     XBT_DEBUG("Runall // %lu", nb_processes);
600     simix_global->context_factory->suspend = smx_ctx_raw_suspend_parallel;
601     xbt_os_cputimer_start(round_time);
602     smx_ctx_raw_runall_parallel();
603     xbt_os_cputimer_stop(round_time);
604     par_time += xbt_os_timer_elapsed(round_time);
605     par_proc_that_ran += xbt_dynar_length(simix_global->process_that_ran);
606     par_sched_round += 1;
607   } else {
608     XBT_DEBUG("Runall serial %lu", nb_processes);
609     simix_global->context_factory->suspend = smx_ctx_raw_suspend_serial;
610     xbt_os_cputimer_start(round_time);
611 #ifdef TIME_BENCH_PER_SR
612     smx_ctx_raw_runall_serial(simix_global->process_to_run);
613 #else
614     smx_ctx_raw_runall_serial();
615 #endif
616     xbt_os_cputimer_stop(round_time);
617     seq_time += xbt_os_timer_elapsed(round_time);
618     seq_proc_that_ran += xbt_dynar_length(simix_global->process_that_ran);
619     seq_sched_round += 1;
620   }
621 }
622
623 #else
624
625 static void smx_ctx_raw_runall(void)
626 {
627   unsigned long nb_processes = xbt_dynar_length(simix_global->process_to_run);
628   if (nb_processes >= SIMIX_context_get_parallel_threshold()) {
629     XBT_DEBUG("Runall // %lu", nb_processes);
630     simix_global->context_factory->suspend = smx_ctx_raw_suspend_parallel;
631     smx_ctx_raw_runall_parallel();
632   } else {
633     XBT_DEBUG("Runall serial %lu", nb_processes);
634     simix_global->context_factory->suspend = smx_ctx_raw_suspend_serial;
635   #ifdef TIME_BENCH_PER_SR
636     smx_ctx_raw_runall_serial(simix_global->process_to_run);
637   #else
638     smx_ctx_raw_runall_serial();
639   #endif
640   }
641 }
642 #endif