1
1

add the configure logic to check for sem_open and sem_init.

Change the code to rely on HAVE_SEM_OPEN etc. instead of my internal macro.
Этот коммит содержится в:
Edgar Gabriel 2015-07-24 10:23:43 -05:00
родитель d1d23054c6
Коммит 4f85e0d833
4 изменённых файлов: 61 добавлений и 23 удалений

38
ompi/mca/sharedfp/sm/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,38 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2012 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2008-2015 University of Houston. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# MCA_sharedfp_sm_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_ompi_sharedfp_sm_CONFIG],[
AC_CONFIG_FILES([ompi/mca/sharedfp/sm/Makefile])
sharedfp_sm_happy=no
AC_CHECK_HEADER([semaphore.h],
[AC_CHECK_FUNCS([sem_open],[sharedfp_sm_happy=yes],[])])
AC_CHECK_HEADER([semaphore.h],
[AC_CHECK_FUNCS([sem_init],[sharedfp_sm_happy=yes],[])])
AS_IF([test "$sharedfp_sm_happy" = "yes"],
[$1],
[$2])
])dnl

Просмотреть файл

@ -164,13 +164,13 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
/* Initialize semaphore so that is shared between processes. */ /* Initialize semaphore so that is shared between processes. */
/* the semaphore is shared by keeping it in the shared memory segment */ /* the semaphore is shared by keeping it in the shared memory segment */
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
if(sem_init(&sm_offset_ptr->mutex, 1, 1) != -1){
#else
sm_data->sem_name = (char*) malloc( sizeof(char) * (strlen(filename_basename)+32) ); sm_data->sem_name = (char*) malloc( sizeof(char) * (strlen(filename_basename)+32) );
sprintf(sm_data->sem_name,"OMPIO_sharedfp_sem_%s",filename_basename); sprintf(sm_data->sem_name,"OMPIO_sharedfp_sem_%s",filename_basename);
if( (sm_data->mutex = sem_open(sm_data->sem_name, O_CREAT, 0644, 1)) != SEM_FAILED ) { if( (sm_data->mutex = sem_open(sm_data->sem_name, O_CREAT, 0644, 1)) != SEM_FAILED ) {
#elif defined(HAVE_SEM_INIT)
if(sem_init(&sm_offset_ptr->mutex, 1, 1) != -1){
#endif #endif
/*If opening was successful*/ /*If opening was successful*/
/*Store the new file handle*/ /*Store the new file handle*/
@ -184,14 +184,14 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
if(rank==0){ if(rank==0){
MPI_Offset position=0; MPI_Offset position=0;
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_wait(&sm_offset_ptr->mutex);
sm_offset_ptr->offset=position;
sem_post(&sm_offset_ptr->mutex);
#else
sem_wait(sm_data->mutex); sem_wait(sm_data->mutex);
sm_offset_ptr->offset=position; sm_offset_ptr->offset=position;
sem_post(sm_data->mutex); 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 #endif
} }
}else{ }else{
@ -235,11 +235,11 @@ int mca_sharedfp_sm_file_close (mca_io_ompio_file_t *fh)
/*Close sm handle*/ /*Close sm handle*/
if (file_data->sm_offset_ptr) { if (file_data->sm_offset_ptr) {
/* destroy semaphore */ /* destroy semaphore */
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_destroy(&file_data->sm_offset_ptr->mutex);
#else
sem_unlink (file_data->sem_name); sem_unlink (file_data->sem_name);
free (file_data->sem_name); free (file_data->sem_name);
#elif defined(HAVE_SEM_INIT)
sem_destroy(&file_data->sm_offset_ptr->mutex);
#endif #endif
/*Release the shared memory segment.*/ /*Release the shared memory segment.*/
munmap(file_data->sm_offset_ptr,sizeof(struct mca_sharedfp_sm_offset)); munmap(file_data->sm_offset_ptr,sizeof(struct mca_sharedfp_sm_offset));

Просмотреть файл

@ -48,10 +48,10 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
/* Aquire an exclusive lock */ /* Aquire an exclusive lock */
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_wait(&sm_offset_ptr->mutex);
#else
sem_wait(sm_data->mutex); sem_wait(sm_data->mutex);
#elif defined(HAVE_SEM_INIT)
sem_wait(&sm_offset_ptr->mutex);
#endif #endif
if ( mca_sharedfp_sm_verbose ) { if ( mca_sharedfp_sm_verbose ) {
@ -74,10 +74,10 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
printf("Releasing sm lock...rank=%d",rank); printf("Releasing sm lock...rank=%d",rank);
} }
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_post(&sm_offset_ptr->mutex);
#else
sem_post(sm_data->mutex); sem_post(sm_data->mutex);
#elif defined(HAVE_SEM_INIT)
sem_post(&sm_offset_ptr->mutex);
#endif #endif
if ( mca_sharedfp_sm_verbose ) { if ( mca_sharedfp_sm_verbose ) {
printf("Released lock! released lock.for rank=%d\n",rank); printf("Released lock! released lock.for rank=%d\n",rank);

Просмотреть файл

@ -121,10 +121,10 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
/* Aquire an exclusive lock */ /* Aquire an exclusive lock */
sm_offset_ptr = sm_data->sm_offset_ptr; sm_offset_ptr = sm_data->sm_offset_ptr;
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_wait(&sm_offset_ptr->mutex);
#else
sem_wait(sm_data->mutex); sem_wait(sm_data->mutex);
#elif defined(HAVE_SEM_INIT)
sem_wait(&sm_offset_ptr->mutex);
#endif #endif
if ( mca_sharedfp_sm_verbose ) { if ( mca_sharedfp_sm_verbose ) {
@ -134,10 +134,10 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
if ( mca_sharedfp_sm_verbose ) { if ( mca_sharedfp_sm_verbose ) {
printf("sharedfp_sm_seek: Releasing sm lock...rank=%d",rank); fflush(stdout); printf("sharedfp_sm_seek: Releasing sm lock...rank=%d",rank); fflush(stdout);
} }
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES #if defined(HAVE_SEM_OPEN)
sem_post(&sm_offset_ptr->mutex);
#else
sem_post(sm_data->mutex); sem_post(sm_data->mutex);
#elif defined(HAVE_SEM_INIT)
sem_post(&sm_offset_ptr->mutex);
#endif #endif
} }