2,408
社区成员
发帖
与我相关
我的任务
分享
在vscode上试着调用MPI并行输出,按着Windows系统下在VSCode中配置MPI开发环境 来实现。一个最基本的代码可是一直输出不出来,所以求助论坛大佬!
hello.cpp的代码如下:
#include<iostream>
#include "stdint.h"
#include "mpi.h"
using namespace std;
int main(int argc,char * argv[]){
cout<<"1"<<endl;
int myid,numprocs;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
cout<<"2"<<endl;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
MPI_Get_processor_name(processor_name,&namelen);
cout<<"3"<<endl;
cout<<myid<<endl;
cout<<"Hello World! Process "<<myid<<" of "<<numprocs<<" on "<<processor_name<<endl;
MPI_Finalize();
return 0;
}
code runner配置如下:
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -fopenmp -l msmpi -L \"D:\\Program Files (x86)\\MPI\\Lib\\x64\" -I \"D:\\Program Files (x86)\\MPI\\Include\" && mpiexec -n 2 $fileNameWithoutExt",
;输出结果如下:
发现没有成功调用MPI方法,但也不知道哪里有问题,请问这是哪里出问题了呢?
麻烦各位解惑,谢谢大家