[Core][DO NOT MERGE] Improve OpenMP loop scheduling and chunk partitioning configurability in ParallelUtilities#14273
Draft
loumalouomega wants to merge 25 commits intomasterfrom
Draft
[Core][DO NOT MERGE] Improve OpenMP loop scheduling and chunk partitioning configurability in ParallelUtilities#14273loumalouomega wants to merge 25 commits intomasterfrom
ParallelUtilities#14273loumalouomega wants to merge 25 commits intomasterfrom
Conversation
Member
Author
|
Maybe this conflicts with C++ implementation |
…tilities; add accessors and mutators
… performance measurement
ParallelUtilitiesParallelUtilities
…osMultiphysics/Kratos into core/dynamic-scheduling-omp
…replace fixed-size arrays with vectors for improved flexibility
…ZE for BlockPartition and related functions
…osMultiphysics/Kratos into core/dynamic-scheduling-omp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
This PR updates shared-memory loop execution in
ParallelUtilitiesto improve load balancing and runtime tunability, while keeping dynamic scheduling as the default fastest option from local benchmarking.This is kind of a retake of #12923
NOTE: After discussing with @pooyan-dadvand we need further changes, and I may retake this later.
🚀Benchmarking
Intel® Core™ Ultra 9 Processor 285HX in Windows 11
Performance improvement for large sets, for small sets equal or slightly worse
Intel® Core™ Ultra 9 Processor 285HX in Ubuntu 24.04 via WSL
Consistent x8+ performance
🔀 What changed
ChunkPartitioningSchemewith two modes:DIVIDE_BY_NUMBER_OF_CHUNKSDIVIDE_BY_CHUNK_SIZEBlockPartitionandIndexPartitiontemplates to accept the partitioning scheme as a template parameter.N(interpreted as chunk count or chunk size depending on scheme).ParallelUtilitiesMaxChunkSize(default1024)ParallelUtilitiesMaxNumberOfChunks(defaultGlobals::MaxAllowedThreads, then adapted at init)InitializeNumberOfThreads():KRATOS_PARALLEL_MAX_CHUNK_SIZEKRATOS_PARALLEL_MAX_CHUNKSKRATOS_PARALLEL_MAX_CHUNKSis not set, default is adjusted tomin(4 * num_threads, ParallelUtilitiesMaxNumberOfChunks).schedule(dynamic)in all relevant loops inparallel_utilities.h.📒Notes
schedule(dynamic)is intentionally kept hardcoded for now based on benchmark results; switching toschedule(runtime)can be done later if runtime policy control is preferred.😅 TODO
🆕 Changelog
ParallelUtilitiesand considerdynamicschedullingParallelUtilitiesto useGlobals::MaxAllowedThreads)InitializeNumberOfThreadsbased on thread count