MPI Broadcast variable of auto type

Viewed 613

I'm working on a compiler that generates C++ code. In instances such as:

MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0){
    auto i = function();
    // do something
    MPI_Bcast(&i, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
else{
    auto i;
    MPI_Bcast(&i, 1, MPI_INT, 0, MPI_COMM_WORLD);
    cout << i;
}

The type of variable 'i' is determined at compile-time, does MPI have a generic type that allows broadcasting such variables? If not, how do I broadcast such variables? And, how should I recieve such variables since simply declaring auto i; isn't allowed.

4 Answers
Related