mpi and array rank
rank=1
program main
implicit none
include 'mpif.h'
integer :: nprocs,ierr,myid
real(8) :: time1
real(8) :: time2
integer,parameter :: n=1000
complex(kind=8) :: a(n*n)
integer :: i,j
call mpi_init(ierr)
call mpi_comm_size(mpi_comm_world,nprocs,ierr)
call mpi_comm_rank(mpi_comm_world,myid,ierr)
a=0
call mpi_barrier(mpi_comm_world,ierr)
time1=mpi_wtime()
do i=1,1000
a=a+cmplx(2.d0,-1.d0,8)
end do
time2=mpi_wtime()
call mpi_barrier(mpi_comm_world,ierr)
write(*,*)(time2-time1),a(1)
call mpi_finalize(ierr)
end program main
program main
implicit none
include 'mpif.h'
integer :: nprocs,ierr,myid
real(8) :: time1
real(8) :: time2
integer,parameter :: n=1000
complex(kind=8) :: a(n,n)
integer :: i,j
call mpi_init(ierr)
call mpi_comm_size(mpi_comm_world,nprocs,ierr)
call mpi_comm_rank(mpi_comm_world,myid,ierr)
a=0
call mpi_barrier(mpi_comm_world,ierr)
time1=mpi_wtime()
do i=1,1000
a=a+cmplx(2.d0,-1.d0,8)
end do
time2=mpi_wtime()
call mpi_barrier(mpi_comm_world,ierr)
write(*,*)(time2-time1),a(1,1)
call mpi_finalize(ierr)
end program main
compiler | cores | rank | time (s) |
---|---|---|---|
gfortran(mpif90) | 1 | 1 | 1.574819803237915 |
gfortran(mpif90) | 8 | 1 | 1.591102361679077 |
gfortran(mpif90) | 1 | 2 | 0.679260969161987 |
gfortran(mpif90) | 8 | 2 | 8.840477943420410 |
ifort(mpiifort) | 1 | 1 | 0.391342599992640 |
ifort(mpiifort) | 8 | 1 | 0.393174800032284 |
ifort(mpiifort) | 1 | 2 | 0.557108099979814 |
ifort(mpiifort) | 8 | 2 | 9.059296299994460 |
I am so confuse about the result . I think the time should be the same orders,like rank=1. But rank=2 array has more than 15times difference. Is there some errors ,or maybe some skills? Thanks in advance .
Compile option : -O3
Computer : intel i9-10900k, 20 cores, 16GB