From b60e3cde1cbd5b6f756568bdb68fb7818aa6ac67 Mon Sep 17 00:00:00 2001 From: Andrew Nolan Date: Thu, 22 Feb 2024 09:45:30 -0700 Subject: [PATCH] Remove float casting in `ntasks` calculation b/c using float division. 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. --- compass/landice/tests/mismipplus/tasks.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compass/landice/tests/mismipplus/tasks.py b/compass/landice/tests/mismipplus/tasks.py index f441bf28fb..6039cc7e95 100644 --- a/compass/landice/tests/mismipplus/tasks.py +++ b/compass/landice/tests/mismipplus/tasks.py @@ -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