-
Notifications
You must be signed in to change notification settings - Fork 38
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
Update algorithm for core counts for MPAS partition files #563
Merged
xylar
merged 5 commits into
MPAS-Dev:main
from
xylar:update_algorithm_for_mesh_partitioning
Mar 22, 2023
+88
−26
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b51a032
Update algo. for MPAS possible MPAS partition cores
xylar 74effaf
Put partition files in own directory
xylar ecae3d9
Remove files_for_e3sm from the pr suite
xylar 1931c31
Turn off sea-ice partition plot file by default
xylar dca42b8
Update developer's guide
xylar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import numpy as np | ||
|
||
|
||
def get_core_list(ncells, max_cells_per_core=6000, min_cells_per_core=100): | ||
def get_core_list(ncells, max_cells_per_core=30000, min_cells_per_core=2): | ||
""" | ||
Get a fairly exhaustive list of core counts to partition a given number of | ||
cells into | ||
|
@@ -24,17 +24,36 @@ def get_core_list(ncells, max_cells_per_core=6000, min_cells_per_core=100): | |
cores : numpy.ndarray | ||
Likely numbers of cores to run with | ||
""" | ||
min_graph_size = int(ncells / max_cells_per_core) | ||
min_graph_size = max(2, int(ncells / max_cells_per_core)) | ||
max_graph_size = int(ncells / min_cells_per_core) | ||
n_power2 = 2**np.arange(1, 21) | ||
n_multiples12 = 12 * np.arange(1, 9) | ||
|
||
cores = n_power2 | ||
for power10 in range(3): | ||
cores = np.concatenate([cores, 10**power10 * n_multiples12]) | ||
|
||
mask = np.logical_and(cores >= min_graph_size, | ||
cores <= max_graph_size) | ||
cores = cores[mask] | ||
|
||
return cores | ||
cores = [] | ||
for candidate in range(min_graph_size, max_graph_size): | ||
factors = _prime_factors(candidate) | ||
twos = np.count_nonzero(factors == 2) | ||
fives = np.count_nonzero(factors == 5) | ||
gt_five = np.count_nonzero(factors > 5) | ||
big_factor = factors.max() | ||
if twos > 0 and fives <= twos and gt_five <= 1 and big_factor <= 7: | ||
cores.append(candidate) | ||
Comment on lines
+32
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The core counts are allowed in based on their prime factors. Most require:
In addition(see below) there is a small list of other allowed sizes:
|
||
# small odd multiples of 3 and a few that correspond to divisors of the | ||
# ne30 (30x30x6=5400) size | ||
elif candidate in [3, 9, 15, 21, 225, 675, 1350]: | ||
cores.append(candidate) | ||
|
||
return np.array(cores) | ||
|
||
|
||
# https://stackoverflow.com/a/22808285 | ||
def _prime_factors(n): | ||
i = 2 | ||
factors = [] | ||
while i * i <= n: | ||
if n % i: | ||
i += 1 | ||
else: | ||
n //= i | ||
factors.append(i) | ||
if n > 1: | ||
factors.append(n) | ||
return np.array(factors) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like there are situations where folks really want to push the limits of how many or how few cells you can get away with. I'm including some partitions that accommodate these needs. We can back off, but it's at the risk that E3SM developers generate their own partitions (which is a little riskier with the new sea ice approach).