0

I have two blocks of code which consume 2 seconds each, In a classic structure they run sequentially, in 4 seconds

In mpi format, it supposed to consume 2 seconds but it takes 5 seconds

WHY?

int main ( int argc, char *argv[] )  
{  
    MPI_Init( &argc, &argv );  
    MPI_Comm_size(MPI_COMM_WORLD,&p );  
    MPI_Comm_rank(MPI_COMM_WORLD,&id);  

    if(id==0)
    {
        // 2 seconds Block
    }
    if(id==1)
    {
        // 2 seconds Block
    }
    MPI_Finalize();  
}
2
  • Did you measure the different blocks? ANd did you measure the MPI initialization and finalization as well? MPI is not priceless, especially the initialization needs "some" time, which varies for every machine and for every MPI implementation. Commented Nov 6, 2014 at 10:16
  • 2
    Welcome to Stack Overflow; please provide a good example. There is not enough information provided in this question for us to help you. If you run your program above with sleep(2) as the blocks, for instance, you'll find the program runs in just a few tens of milliseconds longer than 2s. Commented Nov 6, 2014 at 19:25

1 Answer 1

0

What does take 5 seconds? If you have measured the time for the whole program, the problem is that MPI_Init() and MPI_Finalize() are very time consuming. In order to see speedup you could increase your "Blocks".

Sign up to request clarification or add additional context in comments.

2 Comments

yes, you're right , but when i split a 4's block to two 2's block . I expect to run in 2 second but it runs in 5
In this case you need to post the code for the "block". How does your "block" (2 seconds) behave on one core? Do you have enough processors? Are they occupied with something else?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.