我使用ms mpi在VS 2015中创建了简单的控制台程序.
#include <stdio.h>
#include <mpi.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int rank=0, size=0;
MPI_Init(&argc, &argv); /* starts MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (rank == 0)
{
char helloStr[] = "Hello World";
// MPI_Send(helloStr, _countof(helloStr), MPI_CHAR, 1, 0, MPI_COMM_WORLD);
}
else if (rank == 1)
{
char helloStr[12];
MPI_Recv(helloStr, _countof(helloStr), MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Rank 1 received string %s from Rank 0\n", helloStr);
}
printf("hello from proccess rank %d from size %d\n",rank,size);
MPI_Finalize();
return 0;
}
这个程序编译和执行.但如果使用> mpiexec -n 2 myprog.exe,我收到错误:无法分配启动块.
最佳答案 由于您使用的是VS2015,我猜原因是您的用户名包含非ASCII字符.
尝试在仅包含ASCII字符的路径中运行mpiexec.