def norm(self,x):
""" norm = sum(x*x) """
nbduplicates = (self.np0*self.mp0)/(self.np*self.mp)
# computenorm is done in Fortran
self.typenorm='l2'
t0 = time()
# MPI.COMM_WORLD.Barrier()
if self.typenorm=='l2':
local_sum = computenorm(self.msk,x,self.nh)
t1 = time()
self.time['norm']+=t1-t0
self.ncalls['norm']+=1
z=MPI.COMM_WORLD.allreduce(local_sum,op=MPI.SUM)/ nbduplicates
z=sqrt(z)
t0 = time()
self.time['reduce']+=t0-t1
self.ncalls['reduce']+=1
if self.typenorm=='inf':
local_z= computemax(self.msk,x,self.nh)
t1 = time()
self.time['norm']+=t1-t0
self.ncalls['norm']+=1
z=MPI.COMM_WORLD.allreduce(local_z,op=MPI.MAX)
t0 = time()
self.time['reduce']+=t0-t1
self.ncalls['reduce']+=1
return z
评论列表
文章目录