编译 MPI 时出错
Errors while compiling MPI
我正在尝试使用来自 https://stackoverflow.com/questions/5953979/sending-and-receiving-array-using-mpi-part-2 的代码编译C++代码。
我使用以下命令进行编译:mpiicpc -o <filename> xxxx.cc -lmpi
编译后,我的所有错误似乎都是指我在源代码中定义的两个函数,用于打印输出值并执行 MPI Isend 和 MPI Irecv。具体来说,我得到两种类型的错误
- 错误:标识符"变量"未定义
- 错误:函数调用中的参数太少:
MPI_Isend/MPI_Irecv
和MPI Waitall();
最后,它与以下消息一起存在:编译中止 xxxx.cc(代码 2)。
您能否指出我在定义变量时一定做错了什么?
以下是我的源代码摘录(完整的代码可在 https://stackoverflow.com/questions/5953979/sending-and-receiving-array-using-mpi-part-2 获得):
int main (int argc, char *argv[])
{
int my_rank;
int p;
int source;
int dest;
int tag = 0;
//Allocating Memory
double *A = new double[Rows*sizeof(double)];
double *B = new double[Rows*sizeof(double)];
....
....
....
//MPI Commands
MPI_Status status;
MPI_Init (&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &p);
//For number of beats
for (ibeat=0;ibeat<beats;ibeat++)
{
for (i=0; i<Cols/2; i++)
{
for (y=0; y<Rows/2; y++)
{
if (my_rank == 0)
if (i < 48)
if (y<48)
V[i][y] = 0;
if (my_rank ==
.....
....
....
}
}
//Load the Array with the edge values
for (r=0; r<Rows/2; y++)
{
if ((my_rank == 0) || (my_rank == 1))
{
A[r] = V[r][48];
BB[r] = V[r][48];
}
if ((my_rank
...
...
}
prttofile ();
outputpass ();
ibeat = ibeat+1;
}
MPI_Finalize ();
}
void prttofile ()
{
for (i = 0; i<Cols/2; i++)
{
for (y = 0; y<Rows/2; y++)
{
if (my_rank == 0)
fout << V[i][y] << " " ;
....
....
}
}
if (my_rank == 0)
fout << endl;
....
}
void outputpass ()
{
int test = 2;
if ((my_rank%test) == 0)
{
MPI_Isend(C, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD); //Non blocking Send
MPI_Irecv(CC, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD, &status); //Non Blocking Recv
}
else if ((my_rank%test) == 1)
....
....
MPI_Waitall ();
}
-
您没有声明很多变量 - 特别是循环计数器。 将它们全部声明在函数的顶部,你会没事的。
-
根据文档,
MPI_Isend()
的签名是:int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request )
它有七个参数 - 你只传递五个参数。 您需要更正这一点。
MPI_Irecv()
也是如此.
MPI_Isend()
需要的参数比您提供的要多得多。这是你的台词:
MPI_Isend(C, Rows, MPI_DOUBLE, my_rank+1, MPI_COMM_WORLD);
标签在哪里?请求在哪里?
同样,您的MPI_Waitall()
根本没有任何论据!您需要请求数组、请求数和状态数组。
我建议您阅读 MPI 中的非阻塞通信示例。
相关文章:
- 访问者访问变体并返回不同类型时出错
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- 在Google Kick start中提交时出错
- 在c++中访问int到类对象的映射时出错
- 分段错误当我试图运行程序时出错
- 使用dynamic_cast和构造函数时出错
- CHECK(调用)函数在Google Colab中出错
- 用pybind11包装C++抽象类时出错
- MPI突然停止了对多个核心的操作
- 为x86而非x64编译时出错
- 从R调用C++函数并对其进行集成时出错
- 混合开放MP/MPI代码中的多线程发送/接收时出错
- 写入PBS MPI文件时出错
- 编译 MPI 时出错