Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large overheads for product range style loops on Green's functions #658

Open
HugoStrand opened this issue Dec 12, 2018 · 2 comments
Open
Assignees
Milestone

Comments

@HugoStrand
Copy link
Member

Dear all,

I am doing timings for the two-particle accumulation in cthyb where the computational bottleneck is the product of two M-matrices in frequency space into a contribution to the two-particle Green's function.

In clef syntax I want to do

G2(w,n1,n2)(i,j,k,l) << G2(w,n1,n2)(i j,k,l) - s * M_il(n1,n2)(i,l) * M_kj(n2+w,n1+w)(k,j);

However this is 10x slower than the direct naive 7-level for loop

    for (const auto &w : b_mesh)
      for (const auto &n1 : f_mesh)
        for (const auto &n2 : f_mesh)
	  for (const auto i : range(G2.target_shape()[0]))
	  for (const auto j : range(G2.target_shape()[1]))
	  for (const auto k : range(G2.target_shape()[2]))
	  for (const auto l : range(G2.target_shape()[3]))
	  G2[w, n1, n2](i, j, k, l) -= s * M_il[n1, n2](i, l) * M_kj[n2 + w, n1 + w](k, j);

Using the c++17 style product range for loops looks nicer

for (const auto &[w, n1, n2] : G2.mesh())
      for (const auto [i, j, k, l] : G2.target_indices())
	G2[w, n1, n2](i, j, k, l) -= s * M_il[n1, n2](i, l) * M_kj[n2 + w, n1 + w](k, j);

however, it comes with a factor of 2 runtime overhead, where 75% of the time is spent in the first loop over the mesh. This is rather far from zero cost abstraction...

Can something be done to get us closer to "zero cost" ?

Best, Hugo

@HugoStrand HugoStrand added this to the 2.1 milestone Dec 12, 2018
@Wentzell
Copy link
Member

Hey @HugoStrand
Thanks for the information!
This is indeed too much overhead for use in performance critical parts.

Could you possibly wrap that up into a small google benchmark?

@parcollet parcollet modified the milestones: 2.1, 2.2 Jan 23, 2019
@Wentzell
Copy link
Member

To be rechecked with TRIQS 3.1 (using nda).

@Wentzell Wentzell modified the milestones: 2.2, 3.2 Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants