Thanks to Hristo Iliev for his comments. As it turns out I was using two different data types in my call to MPI_Gather()
.
Revised code is as follows:
int main(int argc, char **argv) {
init_MPI(argc, argv);
if (argc == 2) {
string arg1 = argv[1];
if (arg1 == "--help" || arg1 == "-?") print_help_message();
}
glutInit(&argc,argv);
bool OK = get_params(argc, argv);
Ray cam;
if (buildScene(scene, cam) == -1) {
MPI_Abort(MPI_COMM_WORLD,rc);
exit(1);
}
if (pid == MASTER) scn = new RGBApixmap[w*h];
int rows = h / numprocs;
RGBApixmap *subscn = new RGBApixmap[w*rows];
samples = samples > 0 ? whitted ? 1 : samples : 1;
MPI_Barrier(MPI_COMM_WORLD); /* Synchronize all processes */
rtrace_time = 0.0 - MPI_Wtime(); /* Begin timer */
raytrace(cam, rows, subscn);
MPI_Gather(subscn,w*rows,MPI_BYTE,scn,w*rows,MPI_BYTE,0,MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD); /* Synchronize all processes */
rtrace_time += MPI_Wtime(); /* End timer */
if (pid == MASTER) {
initGlut(argc, argv);
glutMainLoop();
}
MPI_Finalize();
return 0;
}
So the lesson here is to always check your datatypes and ensure that you're not using different classes in MPI Scatter and Gather.