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

Resolve overhead Threads.@threads (> 8 threads) #261

Merged
merged 20 commits into from
Jun 12, 2023

Conversation

verseve
Copy link
Member

@verseve verseve commented May 11, 2023

The use of Threads.@threads has changed to:

  • spawning tasks for kinematic wave routing and the vertical SBM concept (<= 8 threads), for more than 8 threads the low overhead threading Polyester.@batch is used.
  • for local inertial routing threaded loop vectorization (river and 1D floodplain local inertial momentum equation) has been implemented and Polyester.@batch for 2D overland flow local inertial routing and the local inertial continuity equation.

verseve added 17 commits May 10, 2023 10:10
Make use of Threads.@Spawn and basesize to have more control on the amount of work per thread. Added this for vertical and kinematic wave routing components.
and removed eachindex when not required
Use only catchment scale stream order to partition river and land domain for parallel running of kinematic wave solution. Different minimum stream order values can be supplied for the river and land domain.
SurfaceFlow is used for both kinematic wave river and overland flow. This is now split into structs SurfaceFlowRiver and SurfaceFlowLand. It simplifies the orginal update function (split into two, logic easier to follow), and dispatching on these types is easier (e.g. for BMI to extract relevant properties as grid type).
use threaded_foreach instead of @threads
For threads <= 8 spawn tasks is used (outperforms Polyester threads in this range), and for threads > 8 Polyester threads is used (spawn tasks slows down in this range).
Reduce run time by applying loopvectorization only for edges above flow threshold and by pre-allocating more variables (river and floodplain).
and stable_timestep calculation is now faster with @tturbo.
and rename variable index of struct FloodPlain
- update model parameters docs because of split of struct SurfaceFlow in river and overland flow structs.
- remove field to_river from struct SurfaceFlowRiver (not used as part of river flow).
@verseve verseve requested a review from JoostBuitink May 11, 2023 11:04
For Julia version < 1.8 Base.ifelse is not working with Loopvectorization (`LoopVectorization.check_args` on your inputs failed).
Copy link
Contributor

@JoostBuitink JoostBuitink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Looks good to me (and some additional testing I did). Only have one minor comment to update the docstring, but other than that, it looks good to go!

src/subdomains.jl Show resolved Hide resolved
@verseve verseve merged commit b7fca5c into master Jun 12, 2023
@verseve verseve deleted the threads_spawn-polyester branch May 14, 2024 16:57
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

Successfully merging this pull request may close these issues.

2 participants