来自更多进程的输出超过参数中指定的数量

时间:2019-01-15 19:10:26

标签: c mpi

我是不熟悉mpi并重新运行此处给出的代码:http://mpitutorial.com/tutorials/mpi-hello-world/

#include <mpi.h>
#include <stdio.h>


int main(int argc, char** argv) {

// Initialize the MPI environment
MPI_Init(NULL, NULL);

// Get the number of processes
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);

// Get the rank of the process
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);

// Print off a hello world message
printf("Hello world from processor %s, rank %d out of %d processors\n",
       processor_name, world_rank, world_size);

// Finalize the MPI environment.
MPI_Finalize();
}

使用mpicc -o mpi_hello_world mpi_hello_world.c编译并运行mpiexec -np 4 ./mpi_hello_world

我希望在网页上获得类似的结果

Hello world from processor cetus2, rank 1 out of 4 processors
Hello world from processor cetus1, rank 0 out of 4 processors
Hello world from processor cetus4, rank 3 out of 4 processors
Hello world from processor cetus3, rank 2 out of 4 processors

但是我不是从4个进程中获取输出,而是从24个中获取。是这样的。

Hello world from processor cetus3, rank <n> out of 24 processors

n是从0到23。我正在远程使用linux集群。使用mpirun得到相似的结果。如果指定np - 36,则24个进程的结果相同。有人可以告诉我出了什么问题吗?

0 个答案:

没有答案