[MPICH] C++ 64 bit problem

Andrew Hakman andrew.hakman at gmail.com
Wed May 16 13:47:44 CDT 2007


Hi

I'm trying to compile a simple test C++ MPI program using mpic++
(which is calling g++). The machine is a 64 bit machine, but I'm not
compiling my program with any flags to indicate 64 bit. The test
program does not require C++, but the real code I'm working on does.
All the test program does is call MPI_Init, MPI_Comm_rank, and
MPI_Comm_size, then MPI_Finalize. If I compile the program with mpicc
(gcc), it runs just fine. If I compile it with mpic++ (g++), it
segfaults on MPI_Comm_rank. From what I have found, it seems to be a
64 bit pointer issue, but I'm not sure how to fix it.

Here's some output

$ mpiexec -n 1 ./HIS3DT_master
MPI process rank 0 (n0, p6573) caught a SIGSEGV in MPI_Comm_rank.
got to 1
got to 1a
Rank (0, MPI_COMM_WORLD): Call stack within LAM:
Rank (0, MPI_COMM_WORLD):  - MPI_Comm_rank()
Rank (0, MPI_COMM_WORLD):  - main()

And this is the code
#include <stdio.h>

//MPI C++ workaround
#undef SEEK_SET
#undef SEEK_CUR
#undef SEEK_END

//mpi
#include <mpi.h>

int main(int argc, char **argv)
{
    int my_rank;
    int com_size;

    printf("got to 1\n");
    //start MPI
    MPI_Init(&argc, &argv);
    printf("got to 1a\n");
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
    printf("got to 1b\n");
    MPI_Comm_size(MPI_COMM_WORLD, &com_size);
    printf("got to 2\n");
    MPI_Finalize();
    return 0;
}

Any help on how to fix this issue would be greatly appreciated. Just
to re-iterate, the very same code works fine when compiled using gcc
not g++.

Thanks
Andrew Hakman




More information about the mpich-discuss mailing list