Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion toolchain/mfc/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def add_common_arguments(p: argparse.ArgumentParser, mask = None):
if "m" not in mask:
for f in dataclasses.fields(config):
if f.name == 'gpu':
p.add_argument(f"--{f.name}", action="store", nargs='?', const= gpuConfigOptions.ACC.value,default=gpuConfigOptions.ACC.value, dest=f.name, choices=[e.value for e in gpuConfigOptions], help=f"Turn the {f.name} option to OpenACC or OpenMP.")
p.add_argument(f"--{f.name}", action="store", nargs='?', const= gpuConfigOptions.ACC.value,default=gpuConfigOptions.NONE.value, dest=f.name, choices=[e.value for e in gpuConfigOptions], help=f"Turn the {f.name} option to OpenACC or OpenMP.")
p.add_argument(f"--no-{f.name}", action="store_const", const = gpuConfigOptions.NONE.value, dest=f.name, help=f"Turn the {f.name} option OFF.")
continue
p.add_argument( f"--{f.name}", action="store_true", help=f"Turn the {f.name} option ON.")
Expand Down
21 changes: 19 additions & 2 deletions toolchain/mfc/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ..build import get_targets, build, REQUIRED_TARGETS, SIMULATION
from ..printer import cons
from ..state import ARG, ARGS, CFG
from ..state import ARG, ARGS, CFG, gpuConfigOptions
from ..common import MFCException, isspace, file_read, does_command_exist
from ..common import MFC_TEMPLATE_DIR, file_write, system, MFC_ROOT_DIR
from ..common import format_list_to_string, file_dump_yaml
Expand Down Expand Up @@ -99,6 +99,20 @@ def __generate_job_script(targets, case: input.MFCInputFile):
'HIP_VISIBLE_DEVICES': gpu_ids
})

# Compute GPU mode booleans for templates
gpu_mode = ARG('gpu')

# Validate gpu_mode is one of the expected values
valid_gpu_modes = {e.value for e in gpuConfigOptions}
if gpu_mode not in valid_gpu_modes:
raise MFCException(
f"Invalid GPU mode '{gpu_mode}'. Must be one of: {', '.join(sorted(valid_gpu_modes))}"
)

gpu_enabled = gpu_mode != gpuConfigOptions.NONE.value
gpu_acc = gpu_mode == gpuConfigOptions.ACC.value
gpu_mp = gpu_mode == gpuConfigOptions.MP.value

content = __get_template().render(
**{**ARGS(), 'targets': targets},
ARG=ARG,
Expand All @@ -107,7 +121,10 @@ def __generate_job_script(targets, case: input.MFCInputFile):
MFC_ROOT_DIR=MFC_ROOT_DIR,
SIMULATION=SIMULATION,
qsystem=queues.get_system(),
profiler=shlex.join(__profiler_prepend())
profiler=shlex.join(__profiler_prepend()),
gpu_enabled=gpu_enabled,
gpu_acc=gpu_acc,
gpu_mp=gpu_mp
)

file_write(__job_script_filepath(), content)
Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/bridges2.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% if account:
#SBATCH --account="${account}"
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gpu-bind=verbose,closest
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
% endif
Expand All @@ -31,7 +31,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c b -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c b -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
2 changes: 1 addition & 1 deletion toolchain/templates/carpenter-cray.mako
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c cc -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c cc -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
2 changes: 1 addition & 1 deletion toolchain/templates/carpenter.mako
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c c -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c c -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
2 changes: 1 addition & 1 deletion toolchain/templates/default.mako
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if engine == 'batch':
(set -x; ${profiler} \
jsrun --nrs ${tasks_per_node*nodes} \
--cpu_per_rs 1 \
--gpu_per_rs ${1 if gpu else 0} \
--gpu_per_rs ${1 if gpu_enabled else 0} \
--tasks_per_rs 1 \
"${target.get_install_binpath(case)}")
elif [ "$binary" == "srun" ]; then
Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/delta.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% if account:
#SBATCH --account="${account}"
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gpus-per-node=${tasks_per_node}
#SBATCH --mem=208G
#SBATCH --gpu-bind=closest
Expand All @@ -32,7 +32,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c d -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c d -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/deltaai.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% if account:
#SBATCH --account="${account}"
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gpus-per-node=${tasks_per_node}
#SBATCH --mem=208G
#SBATCH --gpu-bind=closest
Expand All @@ -32,7 +32,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c dai -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c dai -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
10 changes: 5 additions & 5 deletions toolchain/templates/frontier.mako
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#SBATCH --time=${walltime}
#SBATCH --cpus-per-task=7
#SBATCH -C nvme
% if gpu != 'no':
% if gpu_enabled:
#SBATCH --gpus-per-task=1
#SBATCH --gpu-bind=closest
% endif
Expand All @@ -34,18 +34,18 @@ ${helpers.template_prologue()}
ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
% if engine == 'batch':
. ./mfc.sh load -c f -m ${'g' if gpu != 'no' else 'c'}
. ./mfc.sh load -c f -m ${'g' if gpu_enabled else 'c'}
% endif
cd - > /dev/null
echo

% if gpu != 'no':
% if gpu_enabled:
export MPICH_GPU_SUPPORT_ENABLED=1
% else:
export MPICH_GPU_SUPPORT_ENABLED=0
% endif

%if unified:
% if unified:
export CRAY_ACC_USE_UNIFIED_MEM=1
% endif

Expand All @@ -66,7 +66,7 @@ ulimit -s unlimited
% if engine == 'interactive':
--unbuffered --nodes ${nodes} --ntasks-per-node ${tasks_per_node} \
--cpus-per-task 7 \
% if gpu != 'no':
% if gpu_enabled:
--gpus-per-task 1 --gpu-bind closest \
% endif
${profiler} "${target.get_install_binpath(case)}")
Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/hipergator.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#SBATCH --output="${name}.out"
#SBATCH --time=${walltime}
#SBATCH --cpus-per-task=7
% if gpu:
% if gpu_enabled:
#SBATCH --gpus-per-task=1
#SBATCH --gpu-bind=closest
% endif
Expand All @@ -35,7 +35,7 @@ ${helpers.template_prologue()}
ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
% if engine == 'batch':
. ./mfc.sh load -c h -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c h -m ${'g' if gpu_enabled else 'c'}
% endif
cd - > /dev/null
echo
Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/nautilus.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% if account:
#SBATCH --account="${account}"
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gpu-bind=verbose,closest
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
% endif
Expand All @@ -31,7 +31,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c n -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c n -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/oscar.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% if account:
#SBATCH --account="${account}"
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gpus-per-node=${tasks_per_node}
#SBATCH --mem=64G
#SBATCH --gpu-bind=closest
Expand All @@ -32,7 +32,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOTDIR}"
. ./mfc.sh load -c o -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
Comment on lines 34 to 36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Correct the typo in the environment variable from ${MFC_ROOTDIR} to ${MFC_ROOT_DIR} in the oscar.mako template. [possible issue, importance: 9]

Suggested change
cd "${MFC_ROOTDIR}"
. ./mfc.sh load -c o -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c o -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null

echo

Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/phoenix-bench.mako
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% if quality_of_service:
#SBATCH --qos=${quality_of_service}
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gres=gpu:V100:${tasks_per_node}
#SBATCH --mem-per-gpu=16G\
% endif
Expand All @@ -31,7 +31,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c p -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c p -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
6 changes: 3 additions & 3 deletions toolchain/templates/phoenix.mako
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
% if quality_of_service:
#SBATCH --qos=${quality_of_service}
% endif
% if gpu:
% if gpu_enabled:
#SBATCH --gres=gpu:V100:${tasks_per_node}
#SBATCH --mem-per-gpu=16G\
#SBATCH --mem-per-gpu=16G
% endif
% if email:
#SBATCH --mail-user=${email}
Expand All @@ -31,7 +31,7 @@ ${helpers.template_prologue()}

ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
. ./mfc.sh load -c p -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c p -m ${'g' if gpu_enabled else 'c'}
cd - > /dev/null
echo

Expand Down
4 changes: 2 additions & 2 deletions toolchain/templates/santis.mako
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ${helpers.template_prologue()}
ok ":) Loading modules:\n"
cd "${MFC_ROOT_DIR}"
% if engine == 'batch':
. ./mfc.sh load -c san -m ${'g' if gpu else 'c'}
. ./mfc.sh load -c san -m ${'g' if gpu_enabled else 'c'}
% endif
cd - > /dev/null
echo
Expand All @@ -74,7 +74,7 @@ echo
--ntasks=${nodes*tasks_per_node} \
--cpus-per-task 72 \
--cpu-bind=none \
% if gpu:
% if gpu_enabled:
--gpus-per-task 1 \
% endif
--wait 200 --bcast=/tmp/${target.name} \
Expand Down
44 changes: 0 additions & 44 deletions toolchain/templates/summit.mako

This file was deleted.

Loading