Changeset 5694

Show
Ignore:
Timestamp:
11/04/09 17:45:41 (3 weeks ago)
Author:
balaji
Message:

Simple version of the asynchronous progress code, where we have a
thread waiting around for a request that only completes at
MPI_Finalize time. Fixes ticket #917.

Reviewed by goodell.

Location:
mpich2/trunk/src/mpi/init
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/src/mpi/init/Makefile.sm

    r100 r5694  
    11mpi_sources = abort.c init.c initialized.c initthread.c \ 
    2  ismain.c finalize.c finalized.c querythread.c  
     2 ismain.c finalize.c finalized.c querythread.c async.c 
    33HEADERS = mpi_init.h 
    44# Note that initinfo is only in the MPI library, not the profile library 
  • mpich2/trunk/src/mpi/init/finalize.c

    r5502 r5694  
    77 
    88#include "mpiimpl.h" 
     9#include "mpi_init.h" 
    910 
    1011/* -- Begin Profiling Symbol Block for routine MPI_Finalize */ 
     
    115116    static const char FCNAME[] = "MPI_Finalize"; 
    116117    int mpi_errno = MPI_SUCCESS; 
     118    int rc; 
    117119#if defined(HAVE_USLEEP) && defined(USE_COVERAGE) 
    118120    int rank=0; 
     
    129131     
    130132    /* ... body of routine ... */ 
     133 
     134    /* If the user requested for asynchronous progress, we need to 
     135     * shutdown the progress thread */ 
     136    if (MPIR_async_thread_initialized) { 
     137        mpi_errno = MPIR_Finalize_async_thread(); 
     138        if (mpi_errno) goto fn_fail; 
     139    } 
    131140     
    132141#if defined(HAVE_USLEEP) && defined(USE_COVERAGE) 
  • mpich2/trunk/src/mpi/init/init.c

    r5355 r5694  
    3030/* Any internal routines can go here.  Make them static if possible */ 
    3131#endif 
     32 
     33int MPIR_async_thread_initialized = 0; 
    3234 
    3335#undef FUNCNAME 
     
    7072    int mpi_errno = MPI_SUCCESS; 
    7173    int rc; 
    72     int threadLevel; 
     74    int threadLevel, provided; 
    7375    MPIU_THREADPRIV_DECL; 
    7476    MPID_MPI_INIT_STATE_DECL(MPID_STATE_MPI_INIT); 
     
    141143    threadLevel = MPI_THREAD_SINGLE; 
    142144#endif 
    143      
    144     mpi_errno = MPIR_Init_thread( argc, argv, threadLevel, (int *)0 ); 
     145 
     146    /* If the user requested for asynchronous progress, request for 
     147     * THREAD_MULTIPLE. */ 
     148    rc = 0; 
     149    MPIU_GetEnvBool("MPICH_ASYNC_PROGRESS", &rc); 
     150    if (rc) 
     151        threadLevel = MPI_THREAD_MULTIPLE; 
     152 
     153    mpi_errno = MPIR_Init_thread( argc, argv, threadLevel, &provided ); 
    145154    if (mpi_errno != MPI_SUCCESS) goto fn_fail; 
     155 
     156    if (provided == MPI_THREAD_MULTIPLE) { 
     157        mpi_errno = MPIR_Init_async_thread(); 
     158        if (mpi_errno) goto fn_fail; 
     159 
     160        MPIR_async_thread_initialized = 1; 
     161    } 
    146162 
    147163    /* ... end of body of routine ... */ 
  • mpich2/trunk/src/mpi/init/initthread.c

    r5355 r5694  
    503503    static const char FCNAME[] = "MPI_Init_thread"; 
    504504    int mpi_errno = MPI_SUCCESS; 
    505     int rc; 
     505    int rc, reqd = required; 
    506506    MPIU_THREADPRIV_DECL; 
    507507    MPID_MPI_INIT_STATE_DECL(MPID_STATE_MPI_INIT_THREAD); 
     
    554554 
    555555    /* ... body of routine ... */ 
    556      
    557     mpi_errno = MPIR_Init_thread( argc, argv, required, provided ); 
    558     if (mpi_errno != MPI_SUCCESS) goto fn_fail;  
     556 
     557    /* If the user requested for asynchronous progress, request for 
     558     * THREAD_MULTIPLE. */ 
     559    rc = 0; 
     560    MPIU_GetEnvBool("MPICH_ASYNC_PROGRESS", &rc); 
     561    if (rc) 
     562        reqd = MPI_THREAD_MULTIPLE; 
     563 
     564    mpi_errno = MPIR_Init_thread( argc, argv, reqd, provided ); 
     565    if (mpi_errno != MPI_SUCCESS) goto fn_fail; 
     566 
     567    if (rc && *provided == MPI_THREAD_MULTIPLE) { 
     568        mpi_errno = MPIR_Init_async_thread(); 
     569        if (mpi_errno) goto fn_fail; 
     570 
     571        MPIR_async_thread_initialized = 1; 
     572    } 
    559573 
    560574    /* ... end of body of routine ... */ 
  • mpich2/trunk/src/mpi/init/mpi_init.h

    r100 r5694  
    44 *      See COPYRIGHT in top-level directory. 
    55 */ 
     6 
    67/* Definitions local to src/mpi/init only */ 
    78int MPIR_Init_thread(int *, char ***, int, int *); 
     9int MPIR_Init_async_thread(void); 
     10int MPIR_Finalize_async_thread(void); 
     11 
     12extern int MPIR_async_thread_initialized;