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

Causes of slower execution compared to fatscapelib-fortran low-level API #3

Open
benbovy opened this issue Oct 7, 2019 · 0 comments

Comments

@benbovy
Copy link
Member

benbovy commented Oct 7, 2019

After #1, running a model using the xarray-simlab based, high-level API here might be slightly slower than running the same model using the low-level fatscapelib-fortran API.

This is mainly due to a key difference in design between the xarray-simlab components and the fastscapelib-fortran library:

  • In fastscapelib-fortran, every process like erosion, uplift or advection is meant to be applied sequentially in a user-defined order. Each related function updates the global state (e.g., topographic surface elevation, bedrock elevation) in place.

  • The xarray-simlab model components implemented in this package take another approach, where each process yields its own outputs without modifying the global state. After all processes are executed, all outputs are aggregated (e.g., sum all erosion) before updating the state at the end of the time step execution.

Because we reuse the functions implemented in fastscapelib-fortran for the high-level API, there is a lot of duplicate computation and copies that cannot be avoided.

Eventually switching from fastscapelib-fortran to fastscapelib C++ will solve this issue, as the latter is designed more like a library and is more compliant with the second approach explained above. This might even be faster (at the cost of more memory expensive) than using the low-level fatscapelib-fortran API as it would avoid things like:

  • repetitive b=min(h,b), etot=etot+ht-h, etc. found in subroutines of fastscapelib-fortran
  • solving advection for h, b and etot in fastscapelib-fortran Advect.f90
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

1 participant