1
TL; DR我相信我错误地发送了一个MPI_Send字符串。什么是发送字符串的最佳方式?在C++ MPI中发送字符串
我试图从主到从进程发送一个字符串,但我相信它不会发送整个字符串或不从动端正确reconstructi9ng它。
万事达MPI_SEND代码:
MPI_Send(&parent, sizeof(char) * selection::target_length(), MPI_BYTE, i, MSEND, MPI_COMM_WORLD);
从属MPI_RECV代码:
char parentChars [selection::target_length()];
MPI_Recv(&parentChars, sizeof(char) * selection::target_length(), MPI_BYTE, 0, MSEND, MPI_COMM_WORLD, &status);
parent = parentChars;
断言assert(target.length() == candidate.length());
失败并给出以下结果:
weasel: weaselparallel.cpp:34: static int selection::fitness(std::string): Assertion `target.length() == candidate.length()' failed.
↑这是为每个从输出过程
然后还有分段错误,我认为是因为错误地发送字符串:
mpiexec noticed that process rank 2 with PID 23531 on node node02.emperor exited on signal 11 (Segmentation fault).
6 total processes killed (some possibly by mpiexec during cleanup)
'的sizeof更多信息(char)'是'1'。 – 2013-04-30 05:19:15
你能显示“父”的定义吗? – 2013-04-30 05:20:13
它看起来像在混合C和C++一样。 'parentChars'看起来像一个C VLA,但是你有'::'运算符。这是什么,C或C++? – 2013-04-30 05:24:30