Ejemplo n.º 1
0
void BoostParallelContext::suspend()
{
  smx_process_t next_work = (smx_process_t) xbt_parmap_next(parmap_);
  BoostParallelContext* next_context = nullptr;

  if (next_work != nullptr) {
    XBT_DEBUG("Run next process");
    next_context = static_cast<BoostParallelContext*>(next_work->context);
  }
  else {
    XBT_DEBUG("No more processes to run");
    unsigned long worker_id =
      (unsigned long) xbt_os_thread_get_specific(worker_id_key_);
    next_context = static_cast<BoostParallelContext*>(
      workers_context_[worker_id]);
  }

  SIMIX_context_set_current((smx_context_t) next_context);
#if HAVE_BOOST_CONTEXTS == 1
  boost::context::jump_fcontext(
    this->fc_, next_context->fc_, (intptr_t)next_context);
#else
  boost::context::jump_fcontext(
    &this->fc_, next_context->fc_, (intptr_t)next_context);
#endif
}
Ejemplo n.º 2
0
void RawContext::suspend_parallel()
{
#if HAVE_THREAD_CONTEXTS
  /* determine the next context */
  smx_process_t next_work = (smx_process_t) xbt_parmap_next(raw_parmap);
  RawContext* next_context = nullptr;

  if (next_work != NULL) {
    /* there is a next process to resume */
    XBT_DEBUG("Run next process");
    next_context = (RawContext*) next_work->context;
  }
  else {
    /* all processes were run, go to the barrier */
    XBT_DEBUG("No more processes to run");
    uintptr_t worker_id = (uintptr_t)
      xbt_os_thread_get_specific(raw_worker_id_key);
    next_context = (RawContext*) raw_workers_context[worker_id];
    XBT_DEBUG("Restoring worker stack %zu (working threads = %zu)",
        worker_id, raw_threads_working);
  }

  SIMIX_context_set_current(next_context);
  raw_swapcontext(&this->stack_top_, next_context->stack_top_);
#endif
}
Ejemplo n.º 3
0
static void smx_ctx_boost_suspend_parallel(smx_context_t context)
{
  smx_process_t next_work = (smx_process_t) xbt_parmap_next(boost_parmap);
  smx_ctx_boost_t next_context;

  if (next_work != NULL) {
    XBT_DEBUG("Run next process");
    next_context = (smx_ctx_boost_t) next_work->context;
  }
  else {
    XBT_DEBUG("No more processes to run");
    unsigned long worker_id =
        (unsigned long) xbt_os_thread_get_specific(boost_worker_id_key);
    next_context = boost_workers_context[worker_id];
  }

  SIMIX_context_set_current((smx_context_t) next_context);
#if HAVE_BOOST_CONTEXT == 1
  boost::context::jump_fcontext(
    ((smx_ctx_boost_t)context)->fc, next_context->fc, (intptr_t)next_context);
#else
  boost::context::jump_fcontext(
    &((smx_ctx_boost_t)context)->fc, next_context->fc, (intptr_t)next_context);
#endif
}