TL;DR I believe I am incorrectly transmitting a string with MPI_Send. What is the best way to send a string?
I'm trying to send a string from the master to the slave processes but I believe it's not sending the entire string or not reconstructi9ng it properly at the slave end.
Master MPI_Send code:
MPI_Send(&parent, sizeof(char) * selection::target_length(), MPI_BYTE, i, MSEND, MPI_COMM_WORLD);
Slave MPI_Recv Code:
char parentChars [selection::target_length()];
MPI_Recv(&parentChars, sizeof(char) * selection::target_length(), MPI_BYTE, 0, MSEND, MPI_COMM_WORLD, &status);
parent = parentChars;
The assertion assert(target.length() == candidate.length()); fails and gives the following results:
weasel: weaselparallel.cpp:34: static int selection::fitness(std::string): Assertion `target.length() == candidate.length()' failed.
↑ This is output for each slave process
And then there's the segmentation fault that I assume occurs because of the incorrectly transmitted string:
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)is1. - Carl Norumparent? - Carl NorumparentCharslooks like a C VLA, but you have::operators in there. Which is it, C or C++? - Carl NorumparentCharsarray) is not part of C++, though some compilers allow it as an extension. You should not use it if you want your code to be portable. - Some programmer dudestring parent;and parentChars is declared like this:char parentChars [selection::target_length()];. Portability isn't an issue. Thanks for your feedback so far. - Jarrod Cabalzar