首页 > 解决方案 > 简单的 MPI 程序不会执行并进入睡眠模式 (C++)

问题描述

我正在尝试使用mpic++编译器运行这个简单的 MPI 程序。

#include <mpi.h>
#include <iostream>

int main(int argc, char** argv) {
  // Initialize the MPI environment
  MPI_Init(&argc, &argv);
  
  // 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
  std::cout << "Hello world from processor" << processor_name << " rank" << world_rank << " out of " << world_size << "processors" << std::endl;

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

我编译mpic++ main.cpp 并在执行时mpirun -n 2 ./a.out 收到警告no protocol specified,这可能与我通过 ssh 连接到桌面并且我试图在那里运行程序的事实有关,但最重要的是,它什么也没做。

如果我输入top没有a.out列出,如果我输入 ps aux | grep ./a.out我得到:

angelos+ 1925884  0.0  0.0  44664  7652 pts/9    S+   18:54   0:00 mpirun -n 2 ./a.out

这是一个动态链接问题还是什么?有什么建议么?

标签: c++mpimpic++

解决方案


推荐阅读