怎么提高Fortran并行计算的效率 10
我这有一段Fortran的加法计算程序,用OpenMP实现并行计算,在visualstudio2010下计算,有两台主机一台是两个IntelXeonE5CPU的,另外一台...
我这有一段Fortran的加法计算程序,用OpenMP实现并行计算,在visual studio2010下计算,有两台主机一台是两个Intel Xeon E5 CPU的,另外一台是4个Intel Xeon E7CPU,系统用的是Windows2008,问题:4个CPU的计算机并行计算的时间跟2个CPU的并行计算时间相差不大,但是Intel Xeon E7比E5性能强很多,而且还有4个E7,为什么计算效率却相差不大呢?要怎么设置才可以提高4个CPU计算机的计算效率? 跪求答案,谢谢!
以下是程序
program test1
implicit none
integer,parameter::nscanpts =8
integer:: n=10000,m=5000
integer i,j,k
real time1,time2,timescan(nscanpts),time3,time4
integer rel(nscanpts)
rel = 0
call cputime(time3)
!$OMP PARALLEL SHARED(n,m,timescan,rel), PRIVATE(i,j,k,time1,time2)
!$OMP DO
do i = 1, nscanpts
write(*,*) "iscan=",i
call cputime(time1)
do j = 1, 4*n
do k = 1, 4*m
rel(i) = k*(j-1)/j
end do
end do
call cputime(time2)
timescan(i) = time2-time1 展开
以下是程序
program test1
implicit none
integer,parameter::nscanpts =8
integer:: n=10000,m=5000
integer i,j,k
real time1,time2,timescan(nscanpts),time3,time4
integer rel(nscanpts)
rel = 0
call cputime(time3)
!$OMP PARALLEL SHARED(n,m,timescan,rel), PRIVATE(i,j,k,time1,time2)
!$OMP DO
do i = 1, nscanpts
write(*,*) "iscan=",i
call cputime(time1)
do j = 1, 4*n
do k = 1, 4*m
rel(i) = k*(j-1)/j
end do
end do
call cputime(time2)
timescan(i) = time2-time1 展开
展开全部
你这个时间根本不对
time1-time2是每个进程的运行时间,而你想要的是总时间,本身这个程序就有问题,还是你没把整个程序传上来,而且你的程序写法太不标准
rel = 0
call cputime(time3)
!$OMP PARALLEL SHARED(n,m,timescan,rel), PRIVATE(i,j,k,time1,time2)
!$OMP DO
do i = 1, nscanpts
write(*,*) "iscan=",i
call cputime(time1)
do j = 1, 4*n
do k = 1, 4*m
rel(i) = k*(j-1)/j
end do
end do
call cputime(time2)
timescan(i) = time2-time1
!$OMP end DO
!$OMP END PARALLEL
call cputime(time4)
elapsed time=time4-time3
在end parallel前面最好加上!$OMP barrier,防止某些特殊状况导致出现问题time4不对
time1-time2是每个进程的运行时间,而你想要的是总时间,本身这个程序就有问题,还是你没把整个程序传上来,而且你的程序写法太不标准
rel = 0
call cputime(time3)
!$OMP PARALLEL SHARED(n,m,timescan,rel), PRIVATE(i,j,k,time1,time2)
!$OMP DO
do i = 1, nscanpts
write(*,*) "iscan=",i
call cputime(time1)
do j = 1, 4*n
do k = 1, 4*m
rel(i) = k*(j-1)/j
end do
end do
call cputime(time2)
timescan(i) = time2-time1
!$OMP end DO
!$OMP END PARALLEL
call cputime(time4)
elapsed time=time4-time3
在end parallel前面最好加上!$OMP barrier,防止某些特殊状况导致出现问题time4不对
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询