Merge pull request #4 from jsquyres/edgargabriel-pr/sharedfp-sm-logic3
Commits on top of open-mpi/ompi#745
Этот коммит содержится в:
Коммит
8932387cf2
@ -10,6 +10,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -101,7 +102,7 @@ int mca_sharedfp_sm_iwrite (mca_io_ompio_file_t *fh,
|
||||
*Structures and definitions only for this component
|
||||
*--------------------------------------------------------------*/
|
||||
struct mca_sharedfp_sm_offset{
|
||||
sem_t mutex; /* the mutex: a Posix memory-based unnamed semaphore */
|
||||
sem_t mutex; /* the mutex: a POSIX memory-based unnamed semaphore */
|
||||
long long offset; /* and the shared file pointer offset */
|
||||
};
|
||||
|
||||
@ -113,7 +114,10 @@ struct mca_sharedfp_sm_data
|
||||
struct mca_sharedfp_sm_offset * sm_offset_ptr;
|
||||
/*save filename so that we can remove the file on close*/
|
||||
char * sm_filename;
|
||||
sem_t *mutex; /* the mutex: a Posix memory-based named semaphore */
|
||||
/* The mutex: it will either point to a POSIX memory-based named
|
||||
semaphore, or it will point to the a POSIX memory-based unnamed
|
||||
semaphore located in sm_offset_ptr->mutex. */
|
||||
sem_t *mutex;
|
||||
char *sem_name; /* Name of the semaphore */
|
||||
};
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* Copyright (c) 2013 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -170,6 +171,7 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
||||
|
||||
if( (sm_data->mutex = sem_open(sm_data->sem_name, O_CREAT, 0644, 1)) != SEM_FAILED ) {
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sm_data->mutex = &sm_offset_ptr->mutex;
|
||||
if(sem_init(&sm_offset_ptr->mutex, 1, 1) != -1){
|
||||
#endif
|
||||
/*If opening was successful*/
|
||||
@ -184,15 +186,9 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
||||
if(rank==0){
|
||||
MPI_Offset position=0;
|
||||
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_wait(sm_data->mutex);
|
||||
sm_offset_ptr->offset=position;
|
||||
sem_post(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
sm_offset_ptr->offset=position;
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
free(sm_filename);
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -48,11 +49,7 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
|
||||
|
||||
/* Aquire an exclusive lock */
|
||||
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_wait(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
|
||||
if ( mca_sharedfp_sm_verbose ) {
|
||||
printf("Succeeded! Acquired sm lock.for rank=%d\n",rank);
|
||||
@ -74,11 +71,7 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
|
||||
printf("Releasing sm lock...rank=%d",rank);
|
||||
}
|
||||
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_post(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
if ( mca_sharedfp_sm_verbose ) {
|
||||
printf("Released lock! released lock.for rank=%d\n",rank);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -121,11 +122,7 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
|
||||
/* Aquire an exclusive lock */
|
||||
sm_offset_ptr = sm_data->sm_offset_ptr;
|
||||
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_wait(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
|
||||
if ( mca_sharedfp_sm_verbose ) {
|
||||
printf("sharedfp_sm_seek: Success! Acquired sm lock.for rank=%d\n",rank);
|
||||
@ -134,11 +131,7 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
|
||||
if ( mca_sharedfp_sm_verbose ) {
|
||||
printf("sharedfp_sm_seek: Releasing sm lock...rank=%d",rank); fflush(stdout);
|
||||
}
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_post(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* since we are only letting process 0, update the current pointer
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user