X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMPIContainer%2FtestMPI2.cxx;h=163e1fa13486180ddcd36cd618a44f7531242180;hb=1f3b94b59127cc48e7e840ab84e85087f538309a;hp=5714412efe95e4ac60b7cda7dabcd0796bd44a14;hpb=641929d327319a80b4fc6f6157605a21f46413c4;p=modules%2Fkernel.git diff --git a/src/MPIContainer/testMPI2.cxx b/src/MPIContainer/testMPI2.cxx old mode 100755 new mode 100644 index 5714412ef..163e1fa13 --- a/src/MPIContainer/testMPI2.cxx +++ b/src/MPIContainer/testMPI2.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -31,23 +31,19 @@ int main(int argc, char**argv) { int *indg; - double *vector, sum=0., norm, etalon; + double *vector, sum=0., norm=1., etalon=0.; int rank, size, grank, gsize, rsize; int vsize=20, lvsize, rlvsize; int i, k1, k2, imin, imax, nb; int srv=0; MPI_Comm com, icom; - MPI_Status status; + MPI_Status status; + MPI_Info info; char port_name [MPI_MAX_PORT_NAME]; char port_name_clt [MPI_MAX_PORT_NAME]; std::string service = "SERVICE"; bool debug=false; -#ifndef WITHOPENMPI - std::cout << "This test only works with openmpi implementation" << std::endl; - exit(1); -#endif - for(i=1;i= 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"); if(rank==0){ MPI_Open_port(MPI_INFO_NULL, port_name); if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ) { @@ -71,7 +74,7 @@ int main(int argc, char**argv) std::cout << "[" << rank << "] I am client: I get the service " << service << " !" << std::endl; MPI_Close_port( port_name ); } - else if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS ) { + else if ( MPI_Publish_name((char*)service.c_str(), info, port_name) == MPI_SUCCESS ) { if(debug) std::cout << "[" << rank << "] I am server: I've managed to publish the service " << service << " !" << std::endl; srv = 1; @@ -106,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 ); @@ -206,6 +213,7 @@ int main(int argc, char**argv) free(indg); free(vector); +#endif MPI_Finalize(); if(rank==0){