【发布时间】:2020-02-23 02:55:19
【问题描述】:
这段代码在使用 mpi 之前运行良好
#include <mpi.h>
#include <iostream>
using namespace std;
int id, p;
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Comm_size(MPI_COMM_WORLD, &p);
cout << "Processor " << id << " of " << p << endl;
cout.flush();
MPI_Barrier(MPI_COMM_WORLD);
if (id == 0) cout << "Every process has got to this point now!" << endl;
MPI_Finalize();
}
给出输出:
Processor 0 of 4
Processor 1 of 4
Processor 2 of 4
Processor 3 of 4
Every process has got to this point now!
使用命令mpiexec -n 4 ${executable filename}$ 在 4 核上运行时
我重新启动了我的笔记本电脑(我不确定这是否是原因)并运行了相同的代码并在一个内核上输出:
Processor 0 of 1
Every process has got to this point now!
Processor 0 of 1
Every process has got to this point now!
Processor 0 of 1
Every process has got to this point now!
Processor 0 of 1
Every process has got to this point now!
我正在使用 microsoft mpi 并且项目配置没有改变。 我真的不知道该怎么做。 我还安装了英特尔并行工作室,并在重新启动之前将其与 Visual Studio 集成。 但我仍在使用 Visual c++ 进行编译(与正常工作时相同的配置)
【问题讨论】:
-
当您的应用使用 MPI 库(例如 MS MPI)但您使用来自其他 MPI 库(例如英特尔 MPI)的
mpiexec时,通常会发生这种情况
标签: c++ visual-c++ parallel-processing mpi