Search code examples
mpimulticore

Being sure that mpi split work among cores


As you know mpi can run a bunch of processes even though there is only one processor with one core. Let's say I have a dual core single processor. If I run a program with mpiexec.mpich -np 2 ./out how can I be sure that the work was split among two cores?


Solution

  • Probably the simplest way for you to confirm that you're running on both cores is to do something like a tight while loop that will spike the processor usage:

    #include <mpi.h>
    
    int main(int argc, char** argv)
    {
        MPI_Init(&argc, &argv);
    
        while(1) {}
    }
    

    Then you can to look at your usage with something like top to make sure it's what you expect.

    If you want to have fine-grained control over where your processes are run, MPICH has options to let you do that. You can find out all of the options on the wiki page. There's flags to let you bind to cores, hardware threads, sockets, etc.