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

Index mapping is expensive #471

Open
icui opened this issue Feb 13, 2025 · 1 comment
Open

Index mapping is expensive #471

icui opened this issue Feb 13, 2025 · 1 comment

Comments

@icui
Copy link
Collaborator

icui commented Feb 13, 2025

The cost of accessing the indices through saved index mapping, e.g.

const int iglob = field.assembly_index_mapping(field.index_mapping(ispec, iz, ix), static_cast<int>(MediumTag));

seems very expensive. In specfem2d all the indices are computed on the fly. A toy benchmark shows that if we could make that happen there could be ~20% speedup, which accounts for the current performance difference between specfem2d and specfem++.

Acoustic:
0.594864s (remove iglob and index mapping)
0.628938s (remove iglob mapping)
0.778316s (current)

Elastic isotropic:
0.886881s (remove iglob and index mapping)
0.934282s (remove iglob mapping)
1.10545s (current)

Elastic anisotropic:
1.08351s (remove iglob and index mapping)
1.13898s (remove iglob mapping)
1.30267s (current)

@icui icui changed the title Reshape simulation_field to (nspec, nz, nx)? Index mapping is expensive Feb 13, 2025
@Rohit-Kakodkar
Copy link
Collaborator

How would we track assembly of the domain in that case? I.e. when we do atomic add at the end of stiffness routine, multiple (ispec, iz, ix) can relate to the same iglob. The mapping is not a simple one i.e. some linear combination of (ispec, iz, ix) when the domain is not regular.

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

2 participants