-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
Description
Finite differencing should have better performance
- Bug appears in
MMSP.grid.cppin functionslaplacian(GRID,...), etc. - The expected behavior is fast computation of gradients, Laplacians, and divergence using built-in functions.
- The observed behavior in profiling is unusually high residence time in
laplacian()andoperator()(GRID, vector<int>).
Proposed fix
- Our stock implementation of discrete Laplacian and gradient operators computes the addresses of neighboring cells every time the function is called, despite neighboring coords being static entities.
- Operators then call
operator()(GRID, vector<int>), which passes coords throughcheck_boundarybefore computing the index location. - Entire process would be much faster by creating a function
neighbor_coordswhich would store a grid of n-dimensional coordinates for high- and low-side neighboring cells, and applyingcheck_boundariesto each stored position vector. - Discrete vector operators could then call
GRID[x][y]instead ofGRID(x)to efficiently access stored values, reducing overhead and improving performance.
Reactions are currently unavailable