Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coyote
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nils
coyote
Commits
d267d9b9
Commit
d267d9b9
authored
4 months ago
by
Nils-Arne Dreier
Browse files
Options
Downloads
Patches
Plain Diff
fix: distribute work
parent
68a8045e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!16
Fix and test distribute work
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/hiopy/_distribute_work.py
+4
-2
4 additions, 2 deletions
apps/hiopy/_distribute_work.py
with
4 additions
and
2 deletions
apps/hiopy/_distribute_work.py
+
4
−
2
View file @
d267d9b9
...
...
@@ -25,7 +25,7 @@ def _map_weighted(a, b, wa=None, wb=None):
partial_sum_b
=
np
.
cumsum
(
wb
)
factor
=
partial_sum_a
[
-
1
]
/
partial_sum_b
[
-
1
]
# Normalization factor
indices
=
np
.
searchsorted
(
factor
*
partial_sum_b
,
partial_sum_a
,
side
=
"
lef
t
"
)
indices
=
[
0
,
*
np
.
searchsorted
(
factor
*
partial_sum_b
,
partial_sum_a
,
side
=
"
righ
t
"
)
]
return
{
a
[
ai
]:
b
[
i
:
j
]
for
ai
,
(
i
,
j
)
in
enumerate
(
zip
(
indices
[:
-
1
],
indices
[
1
:]))}
...
...
@@ -88,6 +88,7 @@ def distribute_work(grouped_data_vars, size):
A list of tuples, each representing the distribution of work to a specific rank.
"""
if
size
==
0
:
assert
len
(
grouped_data_vars
)
==
0
,
"
Cannot distribute non-empty dataset on 0 processes
"
return
[]
# Estimate sizes for each group of variables
...
...
@@ -99,7 +100,7 @@ def distribute_work(grouped_data_vars, size):
if
gsize
>
bytes_per_rank
:
# Compute the number of ranks required for this group
nranks
=
min
(
size
-
1
,
gsize
//
bytes_per_rank
)
nranks
=
gsize
//
bytes_per_rank
cell_chunk_size
=
dict
(
zip
(
variables
[
0
].
attrs
[
"
_ARRAY_DIMENSIONS
"
],
variables
[
0
].
chunks
))[
"
cell
"
]
ncells
=
dict
(
zip
(
variables
[
0
].
attrs
[
"
_ARRAY_DIMENSIONS
"
],
variables
[
0
].
shape
))[
"
cell
"
]
...
...
@@ -127,6 +128,7 @@ def distribute_work(grouped_data_vars, size):
if
gsize
+
next_gsize
>
bytes_per_rank
:
break
result
.
append
((
group
,
0
,
slice
(
None
),
grouped_data_vars
.
pop
(
group
)))
del
group_sizes
[
group
]
gsize
+=
next_gsize
return
[
result
,
*
distribute_work
(
grouped_data_vars
,
size
-
1
)]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment