From a84e557815ff02a6a369536683c40fe410d4fcc3 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Tue, 1 Aug 2006 22:23:57 +0000 Subject: [PATCH] Add new loop mode OPAL_EVLOOP_ONELOOP that behaved like OPAL_EVLOOP_ONCE did pre-libevent update. The problem is that the behavior of OPAL_EVLOOP_ONCE was changed by the OMPI team, which them broke things during the update, so it had to be reverted to the old meaning of loop until one event occurs. OPAL_EVLOOP_ONELOOP will go through the event loop once (like EVLOOP_NONBLOCK) but will pause in the event library for a bit (like EVLOOP_ONCE). fixes trac:234 This commit was SVN r11081. The following Trac tickets were found above: Ticket 234 --> https://svn.open-mpi.org/trac/ompi/ticket/234 --- ompi/runtime/ompi_mpi_finalize.c | 10 ++++++---- ompi/runtime/ompi_mpi_init.c | 11 ++++++----- opal/event/event.c | 3 ++- opal/event/event.h | 4 ++++ opal/runtime/opal_progress.c | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ompi/runtime/ompi_mpi_finalize.c b/ompi/runtime/ompi_mpi_finalize.c index ab0f3ca8e5..efcff6a293 100644 --- a/ompi/runtime/ompi_mpi_finalize.c +++ b/ompi/runtime/ompi_mpi_finalize.c @@ -114,17 +114,19 @@ int ompi_mpi_finalize(void) /* Proceed with MPI_FINALIZE */ ompi_mpi_finalized = true; + #if OMPI_ENABLE_PROGRESS_THREADS == 0 - opal_progress_events(OPAL_EVLOOP_NONBLOCK); + opal_progress_events(OPAL_EVLOOP_ONELOOP); #endif + + /* Change progress function priority back to RTE level stuff */ + opal_progress_mpi_disable(); + /* If maffinity was setup, tear it down */ if (ompi_mpi_maffinity_setup) { opal_maffinity_base_close(); } - /* Change progress function priority back to RTE level stuff */ - opal_progress_mpi_disable(); - /* begin recording compound command */ /* if (OMPI_SUCCESS != (ret = orte_gpr.begin_compound_cmd())) { return ret; diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index b750fb1449..190790259f 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -591,11 +591,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) goto error; } - /* BWB - is this still needed? */ -#if OMPI_ENABLE_PROGRESS_THREADS == 0 - opal_progress_events(OPAL_EVLOOP_NONBLOCK); -#endif - /* Second barrier -- wait for message from RMGR_PROC_STAGE_GATE_MGR to arrive */ @@ -624,6 +619,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) return ret; } +#if OMPI_ENABLE_PROGRESS_THREADS == 0 + /* switch from letting us sit in the event library for a bit each + time through opal_progress() to completely non-blocking */ + opal_progress_events(OPAL_EVLOOP_NONBLOCK); +#endif + /* put the event library in "high performance MPI mode" */ if (OMPI_SUCCESS != opal_progress_mpi_enable()) { error = "opal_progress_mpi_enable() failed"; diff --git a/opal/event/event.c b/opal/event/event.c index c9502760f8..2d48cd88e3 100644 --- a/opal/event/event.c +++ b/opal/event/event.c @@ -609,7 +609,8 @@ opal_event_base_loop(struct event_base *base, int flags) opal_event_process_active(base); if (!base->event_count_active && (flags & OPAL_EVLOOP_ONCE)) done = 1; - } else if (flags & OPAL_EVLOOP_NONBLOCK) + } else if ((flags & OPAL_EVLOOP_NONBLOCK) || + (flags & OPAL_EVLOOP_ONELOOP)) done = 1; if (evsel->recalc(base, evbase, 0) == -1) { diff --git a/opal/event/event.h b/opal/event/event.h index a8152386ab..18b21ec4a9 100644 --- a/opal/event/event.h +++ b/opal/event/event.h @@ -174,6 +174,10 @@ int opal_event_base_set(struct event_base *, struct opal_event *); #define OPAL_EVLOOP_ONCE 0x01 #define OPAL_EVLOOP_NONBLOCK 0x02 + /* run once through the loop, but do have the default timeout. + Need to be both something special *AND* EVLOOP_ONCE */ +#define OPAL_EVLOOP_ONELOOP 0x03 + OMPI_DECLSPEC int opal_event_loop(int); int opal_event_base_loop(struct event_base *, int); int opal_event_loopexit(struct timeval *); /* Causes the loop to exit */ diff --git a/opal/runtime/opal_progress.c b/opal/runtime/opal_progress.c index 51dde68ade..a2a69b584d 100644 --- a/opal/runtime/opal_progress.c +++ b/opal/runtime/opal_progress.c @@ -33,7 +33,7 @@ /* * default parameters */ -static int opal_progress_event_flag = OPAL_EVLOOP_ONCE; +static int opal_progress_event_flag = OPAL_EVLOOP_ONELOOP; #if OPAL_PROGRESS_USE_TIMERS static const opal_timer_t opal_progress_default_tick_rate = 10000; /* 10ms */ #else