Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run parallel program

Status
Not open for further replies.

jean2019

Programmer
Apr 11, 2019
1
DZ
Dear all
How can i run a fortran program in parallel with openmpi or mpi
to reduce time


i try to run fortran program on 8 cores with linux so
i compile and run my program with gfortan and mpi

gfortran -o pp test.f90
mpirun -n 8 ./pp
my question is why serial is faster than parallel
and parallel program show 8 copies of my results
thank you
my program is
PROGRAM test
REAL :: a, b,c

a = 1
b=500


DO WHILE (a < 10)
PRINT* ,a
c=a*b/a

a = a + 1
END DO

END program test
 
It depends entirely on what you are doing and what your machine can handle. Some programs run better in parallel, some better in serial. A machine with one core would do everything very well in serial.

Note that it is not just the computation time. Parallel programming has the added complication of scheduling, which is hidden from you. So even though the actual computation time will be less, if you add the scheduling time, both methods may seem equal or the parallel method may seem to take longer.
 
It seems that what you are doing is running the same process on the 8 cores. That's why you get 8 times the same output.

You should learn some parallel programming in order to parallelize your code, or try with the automatic parallelization that the intel fortran compiler has. You can't get automatic parallelization with the gfortran compiler.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top