Skip to content

streamline vector calc #52

@tkphd

Description

@tkphd

Finite differencing should have better performance

  • Bug appears in MMSP.grid.cpp in functions laplacian(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() and operator()(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 through check_boundary before computing the index location.
  • Entire process would be much faster by creating a function neighbor_coords which would store a grid of n-dimensional coordinates for high- and low-side neighboring cells, and applying check_boundaries to each stored position vector.
  • Discrete vector operators could then call GRID[x][y] instead of GRID(x) to efficiently access stored values, reducing overhead and improving performance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions