Thanks, Lu.
My simple code is as following.
//server
#include "mpi.h"
int main(int argc, char *argv[])
{
MPI_Comm client;
MPI_Status status;
char port_name[MPI_MAX_PORT_NAME];
int size, again;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Open_port(MPI_INFO_NULL, port_name);
printf("server port_name is %s\n\n", port_name);
MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&client);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("At server, comm_size=%d @ MPI_COMM_WORLD=%x, Client_World=%x\n",size,MPI_COMM_WORLD, client);
MPI_Comm_size(client, &size);
printf("At server, client_size=%d @ MPI_COMM_WORLD=%x, Client_World=%x\n",size,MPI_COMM_WORLD, client);
MPI_Comm_disconnect(&client);
MPI_Finalize();
return 0;
}
//client
#include "mpi.h"
int main( int argc, char **argv )
{
MPI_Comm server;
char port_name[MPI_MAX_PORT_NAME];
int size;
MPI_Init( &argc, &argv );
strcpy( port_name, argv[1] );
printf("server port name:%s\n",port_name);
MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&server );
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("At client, comm_size=%d @ MPI_COMM_WORLD=%x, Server_World=%x\n",size,MPI_COMM_WORLD,server);
MPI_Comm_size(server, &size);
printf("At client, server_size=%d @ MPI_COMM_WORLD=%x, Server_World=%x\n",size,MPI_COMM_WORLD,server);
MPI_Comm_disconnect( &server );
MPI_Finalize();
return 0;
}
The run command is as following.
mpiexec -n 1 ./server
mpiexec -n 1 ./client
BUT, the SIZE is 1, NOT 2.
My question is as before: How does the size of MPI_COMM_WORLD change to 2 ?
At 2015-01-23 00:30:43, "Huiwei Lu" <huiweilu@mcs.anl.gov> wrote: