diff --git a/lib/gpt/core/foundation/lattice/__init__.py b/lib/gpt/core/foundation/lattice/__init__.py index 6c415035..d856362f 100644 --- a/lib/gpt/core/foundation/lattice/__init__.py +++ b/lib/gpt/core/foundation/lattice/__init__.py @@ -29,7 +29,22 @@ def rank_inner_product(a, b, use_accelerator): def inner_product(a, b, use_accelerator): - return a[0].grid.globalsum(rank_inner_product(a, b, use_accelerator)) + t = gpt.timer("inner_product") + gpt.barrier() + t("rank inner product") + rip = rank_inner_product(a, b, use_accelerator) + t("barrier") + gpt.barrier() + t("global sum") + rip2 = numpy.array(rip) + gs = a[0].grid.globalsum(rip) + t("barrier") + gpt.barrier() + t("reduce") + gs2 = a[0].grid.reduce(rip2, lambda a, b: a.__iadd__(b)) + t() + gpt.message(t, gs, gs2) + return gs def norm2(l): diff --git a/lib/gpt/core/grid.py b/lib/gpt/core/grid.py index d6806483..a6d0050b 100644 --- a/lib/gpt/core/grid.py +++ b/lib/gpt/core/grid.py @@ -42,9 +42,10 @@ def global_sum_default(grid, x): if isinstance(x, np.ndarray): return grid.reduce(x, lambda a, b: a.__iadd__(b)) elif gpt.util.is_num(x): + t = type(x) x = np.array([x], dtype=np.complex128) global_sum_default(grid, x) - return gpt.util.to_num(x[0]) + return t(x[0]) else: raise Exception(f"Unknown data type in global sum: {type(x)}") diff --git a/lib/gpt/qcd/fermion/register.py b/lib/gpt/qcd/fermion/register.py index 8f065af2..93d42a0a 100644 --- a/lib/gpt/qcd/fermion/register.py +++ b/lib/gpt/qcd/fermion/register.py @@ -11,25 +11,15 @@ def register(reg, op): reg.Mdiag = lambda dst, src: op.apply_unary_operator(2009, dst, src) reg.Dminus = lambda dst, src: op.apply_unary_operator(2010, dst, src) reg.DminusDag = lambda dst, src: op.apply_unary_operator(2011, dst, src) - reg.ImportPhysicalFermionSource = lambda dst, src: op.apply_unary_operator( - 2012, dst, src - ) - reg.ImportUnphysicalFermion = lambda dst, src: op.apply_unary_operator( - 2013, dst, src - ) - reg.ExportPhysicalFermionSolution = lambda dst, src: op.apply_unary_operator( - 2014, dst, src - ) - reg.ExportPhysicalFermionSource = lambda dst, src: op.apply_unary_operator( - 2015, dst, src - ) + reg.ImportPhysicalFermionSource = lambda dst, src: op.apply_unary_operator(2012, dst, src) + reg.ImportUnphysicalFermion = lambda dst, src: op.apply_unary_operator(2013, dst, src) + reg.ExportPhysicalFermionSolution = lambda dst, src: op.apply_unary_operator(2014, dst, src) + reg.ExportPhysicalFermionSource = lambda dst, src: op.apply_unary_operator(2015, dst, src) reg.Dhop = lambda dst, src: op.apply_unary_operator(3001, dst, src) reg.DhopDag = lambda dst, src: op.apply_unary_operator(4001, dst, src) reg.DhopEO = lambda dst, src: op.apply_unary_operator(3002, dst, src) reg.DhopEODag = lambda dst, src: op.apply_unary_operator(4002, dst, src) - reg.Mdir = lambda dst, src, dir, disp: op.apply_dirdisp_operator( - 5001, dst, src, dir, disp - ) + reg.Mdir = lambda dst, src, dir, disp: op.apply_dirdisp_operator(5001, dst, src, dir, disp) reg.MDeriv = lambda mat, dst, src: op.apply_deriv_operator(6001, mat, dst, src) reg.MDerivDag = lambda mat, dst, src: op.apply_deriv_operator(7001, mat, dst, src) reg.MoeDeriv = lambda mat, dst, src: op.apply_deriv_operator(6002, mat, dst, src) @@ -37,14 +27,8 @@ def register(reg, op): reg.MeoDeriv = lambda mat, dst, src: op.apply_deriv_operator(6003, mat, dst, src) reg.MeoDerivDag = lambda mat, dst, src: op.apply_deriv_operator(7003, mat, dst, src) reg.DhopDeriv = lambda mat, dst, src: op.apply_deriv_operator(6004, mat, dst, src) - reg.DhopDerivDag = lambda mat, dst, src: op.apply_deriv_operator( - 7004, mat, dst, src - ) + reg.DhopDerivDag = lambda mat, dst, src: op.apply_deriv_operator(7004, mat, dst, src) reg.DhopDerivEO = lambda mat, dst, src: op.apply_deriv_operator(6005, mat, dst, src) - reg.DhopDerivEODag = lambda mat, dst, src: op.apply_deriv_operator( - 7005, mat, dst, src - ) + reg.DhopDerivEODag = lambda mat, dst, src: op.apply_deriv_operator(7005, mat, dst, src) reg.DhopDerivOE = lambda mat, dst, src: op.apply_deriv_operator(6006, mat, dst, src) - reg.DhopDerivOEDag = lambda mat, dst, src: op.apply_deriv_operator( - 7006, mat, dst, src - ) + reg.DhopDerivOEDag = lambda mat, dst, src: op.apply_deriv_operator(7006, mat, dst, src)