Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
某些内核使用MPI从不返回值_Mpi_Dynamic Programming_Hpc - Fatal编程技术网

某些内核使用MPI从不返回值

某些内核使用MPI从不返回值,mpi,dynamic-programming,hpc,Mpi,Dynamic Programming,Hpc,我正在用MPI做一个学校项目。我使用MPICH2并用Fortran编写代码。我在学校的服务器上用多个计算插槽运行代码。每个插槽由几个计算核心组成。我尝试使用并行计算来加速我的代码。我将子作业分配给每个核心,并使用MPI_gather收集值。有些内核永远不会返回值,似乎它们被困在了某个无限循环中。有些内核从来不称第一个MPI_屏障。 但子作业中没有无限循环。我也做系列代码,它工作得很好。我把代码放在附件里 call MPI_COMM_RANK(MP_LIBRARY_WORLD, r

我正在用MPI做一个学校项目。我使用MPICH2并用Fortran编写代码。我在学校的服务器上用多个计算插槽运行代码。每个插槽由几个计算核心组成。我尝试使用并行计算来加速我的代码。我将子作业分配给每个核心,并使用MPI_gather收集值。有些内核永远不会返回值,似乎它们被困在了某个无限循环中。有些内核从来不称第一个MPI_屏障。 但子作业中没有无限循环。我也做系列代码,它工作得很好。我把代码放在附件里

        call MPI_COMM_RANK(MP_LIBRARY_WORLD, rank, ierr) 
        call MPI_COMM_SIZE(MP_LIBRARY_WORLD, numtasks, ierr)             
        loop_min=int(rank*ceiling(float(point_num)/float(numtasks)))+1             
        loop_max=int((rank+1)*ceiling(float(point_num)/float(numtasks)))  

        do ind=loop_min,loop_max,1
            if (ind>point_num) then
                exit
            end if 
            current_wealth_dist=total_grid(:,ind)
            if (current_wealth_dist(1)==0.) then
                call X_init_aiyagarizero(sendbuf(2:))
            else
                call X_init_aiyagari(sendbuf(2:))
            end if
            sendbuf(1)=ind 
            call MPI_GATHER(sendbuf,number_plc_function+1,MPI_REAL,recvbuf,number_plc_function+1,MPI_REAL,0,MP_LIBRARY_WORLD,ierr)
            !print *, "Point", ind, "Finished"  
        end do
        print *,rank, "work finished"

        call MPI_BARRIER(MP_LIBRARY_WORLD,ierr)
        print *, "After the First Barrier"

        call MPI_Bcast(recvbuf,(number_plc_function+1)*point_num,MPI_REAL,0,MP_LIBRARY_WORLD,ierr)
        print *, rank, "Finish Broadcast"
        call MPI_BARRIER(MP_LIBRARY_WORLD,ierr)

        do iter=1,point_num
            do jter=1,4
                init_policy_functions(int(recvbuf(1,iter)),:,jter)=recvbuf(2:,iter)
            end do               
        end do

如果
numtasks
的值未除以
point_num
的值,则第一个
do
-循环的迭代次数将随MPI等级的不同而不同(多迭代一次)。这将导致
MPI\u聚集
挂起那些执行一次迭代多于其他迭代的列组。我同意。每个核心的作业数量将不同。自从两周前我来到MPI,我觉得MPI_Gather是一个将值收集到根核心的子程序。我不明白为什么每个核心的工作数量不同会导致“挂断”。在不知道numtask是否除以point_num的值的情况下,是否有办法避免这种“挂起”?
MPI_Gather
是一个集体调用。只有当通信器中的所有级别都调用它时,它才会成功。在您的情况下,这将是
MP\u LIBRARY\u WORLD
中的所有级别。如果某些列组少进行一次迭代,则聚集将不会在最后一次迭代中完成,因为并非所有列组都将参与。你应该重写你的算法。非常感谢!我重写了我的代码,现在就可以了!