fortran - MPI_ALLGATHER error parallelizing code -


i'm trying parallelize following code.

subroutine log_likelihood(y, theta, lli, ll)     doubleprecision, allocatable, intent(in)    :: y(:)      doubleprecision, intent(in)                 :: theta(2)     doubleprecision, allocatable, intent(out)   :: lli(:)     doubleprecision, intent(out)                :: ll     integer                                     :: allocate (lli(size(y))) lli = 0.0d0 ll = 0.0d0 = 1, size(y)     lli(i) = -log(sqrt(theta(2))) - 0.5*log(2.0d0*pi) &            - (1.0d0/(2.0d0*theta(2)))*((y(i)-theta(1))**2) end ll = sum(lli) end subroutine log_likelihood 

to this, i'm trying use mpi_allgather. code wrote

subroutine log_likelihood(y, theta, lli, ll)     doubleprecision, allocatable, intent(in)    :: y(:)      doubleprecision, intent(in)                 :: theta(2)     doubleprecision, allocatable, intent(out)   :: lli(:)     doubleprecision, intent(out)                :: ll     integer                                     :: i, size_y, diff size_y=size(y) allocate (lli(size_y)) !broadcasting call mpi_bcast(theta, 1, mpi_double_precision, 0, mpi_comm_world, ierr) call mpi_bcast(y, 1, mpi_double_precision, 0, mpi_comm_world, ierr)  ! determine how many points handle each proc points_per_proc = (size_y + numprocs - 1)/numprocs ! determine start , end index proc's points istart = proc_num * points_per_proc + 1 iend = min((proc_num + 1)*points_per_proc, size_y) diff = iend-istart+1 allocate(proc_contrib(istart:iend)) = istart, iend     proc_contrib(i) = -log(sqrt(theta(2))) - 0.5*log(2.0d0*pi) &                     - (1.0d0/(2.0d0*theta(2)))*((y(i)-theta(1))**2) end call mpi_allgather(proc_contrib, diff, mpi_double_precision, &                    lli, diff, mpi_double_precision, &                    mpi_comm_world, ierr) ll = sum(lli) end subroutine log_likelihood 

when try run program, following error.

$ mpiexec -n 2 ./mle.x  fatal error in pmpi_allgather: internal mpi error!, error stack: pmpi_allgather(961)......: mpi_allgather(sbuf=0x7ff2f251b860, scount=1500000, mpi_double_precision, rbuf=0x7ff2f2ad5650, rcount=3000000, mpi_double_precision, mpi_comm_world) failed mpir_allgather_impl(807).:  mpir_allgather(766)......:  mpir_allgather_intra(560):  mpir_localcopy(357)......: memcpy arguments alias each other, dst=0x7ff2f2ad5650 src=0x7ff2f251b860 len=12000000  =================================================================================== =   bad termination of 1 of application processes =   exit code: 1 =   cleaning remaining processes =   can ignore below cleanup messages =================================================================================== 

can please explain me i'm doing wrong?

thanks!

i able solve problem. serial , parallel versions of code available @ https://bitbucket.org/ignacio82/bhhh

subroutine log_likelihood(y, n, theta, lli, ll)     integer, intent(in)                         :: n     doubleprecision, intent(in)                 :: y(n)      doubleprecision, intent(in)                 :: theta(2)     doubleprecision, intent(out)                :: lli(n)     doubleprecision, intent(out)                :: ll     integer                                     ::  = istart, iend     proc_contrib(i-istart+1) = -log(sqrt(theta(2))) - 0.5*log(2.0d0*pi) &                     - (1.0d0/(2.0d0*theta(2)))*((y(i)-theta(1))**2) end  if ( mod(n,numprocs)==0 )     call mpi_allgather(proc_contrib, points_per_proc, mpi_double_precision, &                        lli, points_per_proc, mpi_double_precision, &                        mpi_comm_world, ierr)     else if (numprocs-1 == proc_num )      recvcounts(numprocs) = iend-istart+1     call mpi_allgatherv(proc_contrib, points_per_proc, mpi_double_precision, &                         lli, recvcounts, displs, mpi_double_precision, &                         mpi_comm_world, ierr)  end if  ll = sum(lli) end subroutine log_likelihood 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -