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.
Этот коммит содержится в:
родитель
d1d23054c6
Коммит
4f85e0d833
38
ompi/mca/sharedfp/sm/configure.m4
Обычный файл
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. */
|
||||
/* the semaphore is shared by keeping it in the shared memory segment */
|
||||
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
if(sem_init(&sm_offset_ptr->mutex, 1, 1) != -1){
|
||||
#else
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sm_data->sem_name = (char*) malloc( sizeof(char) * (strlen(filename_basename)+32) );
|
||||
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 ) {
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
if(sem_init(&sm_offset_ptr->mutex, 1, 1) != -1){
|
||||
#endif
|
||||
/*If opening was successful*/
|
||||
/*Store the new file handle*/
|
||||
@ -184,14 +184,14 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
||||
if(rank==0){
|
||||
MPI_Offset position=0;
|
||||
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
sm_offset_ptr->offset=position;
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#else
|
||||
#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{
|
||||
@ -235,11 +235,11 @@ int mca_sharedfp_sm_file_close (mca_io_ompio_file_t *fh)
|
||||
/*Close sm handle*/
|
||||
if (file_data->sm_offset_ptr) {
|
||||
/* destroy semaphore */
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_destroy(&file_data->sm_offset_ptr->mutex);
|
||||
#else
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_unlink (file_data->sem_name);
|
||||
free (file_data->sem_name);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_destroy(&file_data->sm_offset_ptr->mutex);
|
||||
#endif
|
||||
/*Release the shared memory segment.*/
|
||||
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 */
|
||||
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
#else
|
||||
#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 ) {
|
||||
@ -74,10 +74,10 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
|
||||
printf("Releasing sm lock...rank=%d",rank);
|
||||
}
|
||||
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#else
|
||||
#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);
|
||||
|
@ -121,10 +121,10 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
|
||||
/* Aquire an exclusive lock */
|
||||
sm_offset_ptr = sm_data->sm_offset_ptr;
|
||||
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_wait(&sm_offset_ptr->mutex);
|
||||
#else
|
||||
#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 ) {
|
||||
@ -134,10 +134,10 @@ 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);
|
||||
}
|
||||
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#else
|
||||
#if defined(HAVE_SEM_OPEN)
|
||||
sem_post(sm_data->mutex);
|
||||
#elif defined(HAVE_SEM_INIT)
|
||||
sem_post(&sm_offset_ptr->mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user