-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shell scheduler: seems to be working
- Loading branch information
1 parent
83df48b
commit 7d58ed6
Showing
3 changed files
with
63 additions
and
85 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def group_items_by_parallel_steps(items, n_workers): | ||
items.sort(key=lambda item: item.n_proc, reverse=True) | ||
|
||
remaining_n_procs_by_step = [] | ||
items_by_step = [] | ||
items_to_skip = [] | ||
for item in items: | ||
if item.n_proc > n_workers: | ||
items_to_skip += [item] | ||
else: | ||
found_step = False | ||
for idx, remaining_procs in enumerate(remaining_n_procs_by_step): | ||
if item.n_proc <= remaining_procs: | ||
items_by_step[idx] += [item] | ||
remaining_n_procs_by_step[idx] -= item.n_proc | ||
found_step = True | ||
break | ||
if not found_step: | ||
items_by_step += [[item]] | ||
remaining_n_procs_by_step += [n_workers - item.n_proc] | ||
|
||
return items_by_step, items_to_skip | ||
|
||
|