From 1f3b94b59127cc48e7e840ab84e85087f538309a Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 3 Aug 2020 21:52:07 +0300 Subject: [PATCH] Build KERNEL with native openmpi on CentOS-8 --- src/Communication/Receivers.cxx | 20 ++++++++++++++++++-- src/Communication/SALOME_Comm_i.cxx | 14 +++++++++++--- src/MPIContainer/MPIObject_i.cxx | 9 ++++++++- src/MPIContainer/testMPI2.cxx | 10 +++++++++- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/Communication/Receivers.cxx b/src/Communication/Receivers.cxx index 53fae588c..14fd55d6a 100644 --- a/src/Communication/Receivers.cxx +++ b/src/Communication/Receivers.cxx @@ -182,11 +182,19 @@ T *MPIReceiver::getDistValue(long &size){ SALOME::MPISender::param_var p =_mySender->getParam(); _mySender->send(); sproc = p->myproc; +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#endif while ( i != TIMEOUT && MPI_Lookup_name((char*)p->service,MPI_INFO_NULL,port_name_clt) != MPI_SUCCESS) { i++; - } + } +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#endif if ( i == TIMEOUT ) { MPI_Finalize(); exit(-1); @@ -199,12 +207,20 @@ T *MPIReceiver::getDistValue(long &size){ // TIMEOUT is inefficient since MPI_Comm_Connect doesn't return if we asked for // a service that has been unpublished ! +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#endif i = 0; while ( i != TIMEOUT && MPI_Comm_connect(port_name_clt, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &com)!=MPI_SUCCESS ) { i++; - } + } +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#endif if ( i == TIMEOUT ) { MPI_Finalize(); exit(-1); diff --git a/src/Communication/SALOME_Comm_i.cxx b/src/Communication/SALOME_Comm_i.cxx index 87d6beebd..75af1c528 100644 --- a/src/Communication/SALOME_Comm_i.cxx +++ b/src/Communication/SALOME_Comm_i.cxx @@ -260,11 +260,19 @@ SALOME::MPISender::param* SALOME_MPISender_i::getParam() service += stag; p->service = CORBA::string_dup(service.c_str()); MPI_Open_port(MPI_INFO_NULL, _portName); - MPI_Errhandler_set(MPI_COMM_WORLD,MPI_ERRORS_RETURN); +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#else + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#endif while ( i != TIMEOUT && MPI_Publish_name((char*)service.c_str(),MPI_INFO_NULL,_portName) != MPI_SUCCESS) { i++; - } - MPI_Errhandler_set(MPI_COMM_WORLD,MPI_ERRORS_ARE_FATAL); + } +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#else + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#endif if ( i == TIMEOUT ) { MPI_Close_port(_portName); MPI_Finalize(); diff --git a/src/MPIContainer/MPIObject_i.cxx b/src/MPIContainer/MPIObject_i.cxx index 2395f8756..ede2f4dd6 100644 --- a/src/MPIContainer/MPIObject_i.cxx +++ b/src/MPIContainer/MPIObject_i.cxx @@ -153,8 +153,11 @@ void MPIObject_i::remoteMPI2Connect(std::string service) _srv[service] = false; MPI_Barrier(MPI_COMM_WORLD); - +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#endif MPI_Info_create(&info); MPI_Info_set(info, "ompi_unique", "true"); if( _numproc == 0 ) @@ -203,7 +206,11 @@ void MPIObject_i::remoteMPI2Connect(std::string service) throw SALOME_Exception(msg.str().c_str()); } } +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#endif /* If rank 0 is server, all processes call MPI_Comm_accept */ /* If rank 0 is not server, all processes call MPI_Comm_connect */ diff --git a/src/MPIContainer/testMPI2.cxx b/src/MPIContainer/testMPI2.cxx index d55645256..163e1fa13 100644 --- a/src/MPIContainer/testMPI2.cxx +++ b/src/MPIContainer/testMPI2.cxx @@ -58,8 +58,12 @@ int main(int argc, char**argv) MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Barrier(MPI_COMM_WORLD); - +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); +#endif + #ifdef HAVE_MPI2 MPI_Info_create(&info); MPI_Info_set(info, "ompi_unique", "true"); @@ -105,7 +109,11 @@ int main(int argc, char**argv) exit(1); } } +#if OMPI_MAJOR_VERSION >= 4 + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#else MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); +#endif MPI_Bcast(&srv,1,MPI_INT,0,MPI_COMM_WORLD); if ( srv ) MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &icom ); -- 2.39.2