Skip to content

Commit

Permalink
try to fix the pre-commit error
Browse files Browse the repository at this point in the history
  • Loading branch information
sjsprecious committed Oct 7, 2024
1 parent 40d8c5d commit 246eea7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions CIME/case/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def _case_setup_impl(
# ----------------------------------------------------------------------------------------------------------
# Sanity check for a GPU run:
# 1. GPU_TYPE and GPU_OFFLOAD must both be defined to use GPUs
# 2. If the NGPUS_PER_NODE XML variable in the env_mach_pes.xml file is larger than
# 2. If the NGPUS_PER_NODE XML variable in the env_mach_pes.xml file is larger than
# the value of MAX_GPUS_PER_NODE, set it to MAX_GPUS_PER_NODE automatically.
# 3. If the NGPUS_PER_NODE XML variable is equal to 0, it will be updated to 1 automatically.
# ----------------------------------------------------------------------------------------------------------
Expand All @@ -401,13 +401,19 @@ def _case_setup_impl(
openacc_gpu_offload = case.get_value("OPENACC_GPU_OFFLOAD")
openmp_gpu_offload = case.get_value("OPENMP_GPU_OFFLOAD")
kokkos_gpu_offload = case.get_value("KOKKOS_GPU_OFFLOAD")
gpu_offload = (openacc_gpu_offload or openmp_gpu_offload or kokkos_gpu_offload)
gpu_offload = (
openacc_gpu_offload or openmp_gpu_offload or kokkos_gpu_offload
)
ngpus_per_node = case.get_value("NGPUS_PER_NODE")
if gpu_type and str(gpu_type).lower() != "none":
if max_gpus_per_node <= 0:
raise RuntimeError(f"MAX_GPUS_PER_NODE must be larger than 0 for machine={mach} and compiler={compiler} in order to configure a GPU run")
raise RuntimeError(
f"MAX_GPUS_PER_NODE must be larger than 0 for machine={mach} and compiler={compiler} in order to configure a GPU run"
)
if not gpu_offload:
raise RuntimeError("GPU_TYPE is defined but none of the GPU OFFLOAD options are enabled")
raise RuntimeError(
"GPU_TYPE is defined but none of the GPU OFFLOAD options are enabled"
)
case.gpu_enabled = True
if ngpus_per_node >= 0:
case.set_value(
Expand All @@ -417,9 +423,13 @@ def _case_setup_impl(
else max_gpus_per_node,
)
elif gpu_offload:
raise RuntimeError("GPU_TYPE is not defined but at least one GPU OFFLOAD option is enabled")
raise RuntimeError(
"GPU_TYPE is not defined but at least one GPU OFFLOAD option is enabled"
)
elif ngpus_per_node and ngpus_per_node != 0:
raise RuntimeError(f"ngpus_per_node is expected to be 0 for a pure CPU run ; {ngpus_per_node} is provided instead ;")
raise RuntimeError(
f"ngpus_per_node is expected to be 0 for a pure CPU run ; {ngpus_per_node} is provided instead ;"
)

# May need to select new batch settings if pelayout changed (e.g. problem is now too big for prev-selected queue)
env_batch = case.get_env("batch")
Expand Down Expand Up @@ -559,7 +569,6 @@ def case_setup(self, clean=False, test_mode=False, reset=False, keep=None):


def _create_case_repo(self, caseroot):

self._gitinterface = GitInterface(caseroot, logger, branch=self.get_value("CASE"))
if self._gitinterface and not os.path.exists(os.path.join(caseroot, ".gitignore")):
safe_copy(
Expand Down

0 comments on commit 246eea7

Please sign in to comment.