Skip to content

Commit

Permalink
Remove float casting in ntasks calculation b/c using float division.
Browse files Browse the repository at this point in the history
Was casting integer value as floats in calculation of
`ntasks` and `min_task`, but as Trevor pointed out because we are
using the floating point operator for division (`/`), this isn't
really necessary. Removed the float casting to make the code a bit
more legible.
  • Loading branch information
andrewdnolan committed Feb 22, 2024
1 parent a54b36f commit b60e3cd
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions compass/landice/tests/mismipplus/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ def get_ntasks_from_cell_count(config, cell_count):

# from Xylar: machines (e.g. Perlmutter) seem to be happier with ntasks
# that are multiples of 4
min_tasks = max(
1, 4 * round(float(cell_count) / (4 * float(max_cells_per_core))))
ntasks = max(
1, 4 * round(float(cell_count) / (4 * float(goal_cells_per_core))))
min_tasks = max(1, 4 * round(cell_count / (4 * max_cells_per_core)))
ntasks = max(1, 4 * round(cell_count / (4 * goal_cells_per_core)))

# if ntasks exceeds the number of cores per node, round to the nearest
# multiple of `cores_per_node`.
if ntasks > cores_per_node:
ntasks = int(
cores_per_node) * round(float(ntasks) / float(cores_per_node))
ntasks = cores_per_node * round(ntasks / cores_per_node)

return ntasks, min_tasks

Expand Down

0 comments on commit b60e3cd

Please sign in to comment.