My parallel program is implemented by using c++ and OpenMPI. When I test it, I found if I used more cpus it costs more time. How could this happens?
The structure of my code is as follows:
BEGIN
MPI::Init
if (rank == 0)
{ Read files }
MPI::Bcast
MPI::Scatter
for (i=0; i<N;i++)
{
do something here
MPI::Gather
if(rank ==0)
{ save result}
}
MPI::Finallize()
END
I am confused about this.
For your program the amont of code that runs parallel declares the performance http://en.wikipedia.org/wiki/Amdahl‘s_law .and many other parameters affect the performance such as your computer architecture for example if you use shared memory system your memory is important,in your code if files are big it can decrease the performance and in this case you must use derived datatypes for communication,network speed is important for distributed systems,….