From 69bda77da19ca8ea4baa5bfd57238ad43b14d62d Mon Sep 17 00:00:00 2001 From: Christoph Lehner Date: Sun, 22 Sep 2024 16:37:41 +0200 Subject: [PATCH] further performance tweaks --- .../qcd/pseudofermion/action/exact_one_flavor.py | 13 +++++++++---- lib/gpt/qcd/pseudofermion/action/two_flavor.py | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py b/lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py index 4389c4df..ba8a06a4 100644 --- a/lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py +++ b/lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py @@ -28,14 +28,19 @@ class exact_one_flavor_ratio(action_base): def __init__(self, fermion, m1, m2, inverter): self.m1 = m1 self.m2 = m2 - super().__init__([fermion(m1, m2), fermion(m1, m1)], inverter, fermion) + M12 = fermion(m1, m2) + M11 = fermion(m1, m1) + super().__init__([M12, M11], inverter, fermion) + self.P12 = M12.propagator(inverter) + self.P11 = M11.propagator(inverter) + def matrix(self, fields): M12, M11, U, phi = self._updated(fields) - P12 = M12.propagator(self.inverter) - P11 = M11.propagator(self.inverter) - + P12 = self.P12 + P11 = self.P11 + m1 = self.m1 m2 = self.m2 diff --git a/lib/gpt/qcd/pseudofermion/action/two_flavor.py b/lib/gpt/qcd/pseudofermion/action/two_flavor.py index 5905f393..2ceef84c 100644 --- a/lib/gpt/qcd/pseudofermion/action/two_flavor.py +++ b/lib/gpt/qcd/pseudofermion/action/two_flavor.py @@ -136,6 +136,9 @@ class two_flavor_ratio_base(action_base): def __init__(self, M, inverter, operator): assert len(M) == 2 super().__init__(M, inverter, operator) + M1, M2 = M + self.inv_MMdag_M1 = inverter(operator.MMdag(M1)) + self.inv_MMdag_M2 = inverter(operator.MMdag(M2)) def __call__(self, fields): M1, M2, U, phi = self._updated(fields) @@ -143,7 +146,7 @@ def __call__(self, fields): psi = g.lattice(phi) psi @= self.operator.M(M2) * phi chi = g.lattice(phi) - chi @= self.inverter(self.operator.MMdag(M1)) * psi + chi @= self.inv_MMdag_M1 * psi return g.inner_product(psi, chi).real def draw(self, fields, rng): @@ -155,7 +158,7 @@ def draw(self, fields, rng): # phi^dag M2dag (M1 M1dag)^-1 M2 phi # eta = M1^-1 M2 phi chi = g.lattice(phi) - chi @= self.inverter(self.operator.MMdag(M2)) * self.operator.M(M1) * eta + chi @= self.inv_MMdag_M2 * self.operator.M(M1) * eta phi @= self.operator.Mdag(M2) * chi return g.norm2(eta) @@ -167,7 +170,7 @@ def gradient(self, fields, dfields): psi = g.lattice(phi) psi @= self.operator.M(M2) * phi chi = g.lattice(phi) - chi @= self.inverter(self.operator.MMdag(M1)) * psi + chi @= self.inv_MMdag_M1 * psi psi @= self.operator.Mdag(M1) * chi self._accumulate(frc, self.operator.Mderiv(M2)(chi, phi), +1)