Skip to content

Commit 831a8ca

Browse files
committed
fix gpu templates for real though
1 parent 6c380cd commit 831a8ca

File tree

15 files changed

+43
-34
lines changed

15 files changed

+43
-34
lines changed

toolchain/mfc/run/run.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from ..build import get_targets, build, REQUIRED_TARGETS, SIMULATION
99
from ..printer import cons
10-
from ..state import ARG, ARGS, CFG
10+
from ..state import ARG, ARGS, CFG, gpuConfigOptions
1111
from ..common import MFCException, isspace, file_read, does_command_exist
1212
from ..common import MFC_TEMPLATE_DIR, file_write, system, MFC_ROOT_DIR
1313
from ..common import format_list_to_string, file_dump_yaml
@@ -99,6 +99,12 @@ def __generate_job_script(targets, case: input.MFCInputFile):
9999
'HIP_VISIBLE_DEVICES': gpu_ids
100100
})
101101

102+
# Compute GPU mode booleans for templates
103+
gpu_mode = ARG('gpu')
104+
gpu_enabled = (gpu_mode != gpuConfigOptions.NONE.value)
105+
gpu_acc = (gpu_mode == gpuConfigOptions.ACC.value)
106+
gpu_mp = (gpu_mode == gpuConfigOptions.MP.value)
107+
102108
content = __get_template().render(
103109
**{**ARGS(), 'targets': targets},
104110
ARG=ARG,
@@ -107,7 +113,10 @@ def __generate_job_script(targets, case: input.MFCInputFile):
107113
MFC_ROOT_DIR=MFC_ROOT_DIR,
108114
SIMULATION=SIMULATION,
109115
qsystem=queues.get_system(),
110-
profiler=shlex.join(__profiler_prepend())
116+
profiler=shlex.join(__profiler_prepend()),
117+
gpu_enabled=gpu_enabled,
118+
gpu_acc=gpu_acc,
119+
gpu_mp=gpu_mp
111120
)
112121

113122
file_write(__job_script_filepath(), content)

toolchain/templates/bridges2.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
% if account:
1515
#SBATCH --account="${account}"
1616
% endif
17-
% if gpu:
17+
% if gpu_enabled:
1818
#SBATCH --gpu-bind=verbose,closest
1919
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
2020
% endif
@@ -31,7 +31,7 @@ ${helpers.template_prologue()}
3131

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

toolchain/templates/carpenter-cray.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ${helpers.template_prologue()}
2525

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

toolchain/templates/carpenter.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ${helpers.template_prologue()}
2525

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

toolchain/templates/default.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if engine == 'batch':
4848
(set -x; ${profiler} \
4949
jsrun --nrs ${tasks_per_node*nodes} \
5050
--cpu_per_rs 1 \
51-
--gpu_per_rs ${1 if gpu else 0} \
51+
--gpu_per_rs ${1 if gpu_enabled else 0} \
5252
--tasks_per_rs 1 \
5353
"${target.get_install_binpath(case)}")
5454
elif [ "$binary" == "srun" ]; then

toolchain/templates/delta.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
% if account:
1515
#SBATCH --account="${account}"
1616
% endif
17-
% if gpu:
17+
% if gpu_enabled:
1818
#SBATCH --gpus-per-node=${tasks_per_node}
1919
#SBATCH --mem=208G
2020
#SBATCH --gpu-bind=closest
@@ -32,7 +32,7 @@ ${helpers.template_prologue()}
3232

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

toolchain/templates/deltaai.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
% if account:
1515
#SBATCH --account="${account}"
1616
% endif
17-
% if gpu:
17+
% if gpu_enabled:
1818
#SBATCH --gpus-per-node=${tasks_per_node}
1919
#SBATCH --mem=208G
2020
#SBATCH --gpu-bind=closest
@@ -32,7 +32,7 @@ ${helpers.template_prologue()}
3232

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

toolchain/templates/frontier.mako

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#SBATCH --time=${walltime}
1111
#SBATCH --cpus-per-task=7
1212
#SBATCH -C nvme
13-
% if gpu != 'no':
13+
% if gpu_enabled:
1414
#SBATCH --gpus-per-task=1
1515
#SBATCH --gpu-bind=closest
1616
% endif
@@ -34,12 +34,12 @@ ${helpers.template_prologue()}
3434
ok ":) Loading modules:\n"
3535
cd "${MFC_ROOT_DIR}"
3636
% if engine == 'batch':
37-
. ./mfc.sh load -c f -m ${'g' if gpu != 'no' else 'c'}
37+
. ./mfc.sh load -c f -m ${'g' if gpu_enabled else 'c'}
3838
% endif
3939
cd - > /dev/null
4040
echo
4141

42-
% if gpu != 'no':
42+
% if gpu_enabled:
4343
export MPICH_GPU_SUPPORT_ENABLED=1
4444
% else:
4545
export MPICH_GPU_SUPPORT_ENABLED=0
@@ -66,7 +66,7 @@ ulimit -s unlimited
6666
% if engine == 'interactive':
6767
--unbuffered --nodes ${nodes} --ntasks-per-node ${tasks_per_node} \
6868
--cpus-per-task 7 \
69-
% if gpu != 'no':
69+
% if gpu_enabled:
7070
--gpus-per-task 1 --gpu-bind closest \
7171
% endif
7272
${profiler} "${target.get_install_binpath(case)}")

toolchain/templates/hipergator.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#SBATCH --output="${name}.out"
1010
#SBATCH --time=${walltime}
1111
#SBATCH --cpus-per-task=7
12-
% if gpu:
12+
% if gpu_enabled:
1313
#SBATCH --gpus-per-task=1
1414
#SBATCH --gpu-bind=closest
1515
% endif
@@ -35,7 +35,7 @@ ${helpers.template_prologue()}
3535
ok ":) Loading modules:\n"
3636
cd "${MFC_ROOT_DIR}"
3737
% if engine == 'batch':
38-
. ./mfc.sh load -c h -m ${'g' if gpu else 'c'}
38+
. ./mfc.sh load -c h -m ${'g' if gpu_enabled else 'c'}
3939
% endif
4040
cd - > /dev/null
4141
echo

toolchain/templates/nautilus.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
% if account:
1515
#SBATCH --account="${account}"
1616
% endif
17-
% if gpu:
17+
% if gpu_enabled:
1818
#SBATCH --gpu-bind=verbose,closest
1919
#SBATCH --gres=gpu:v100-16:${tasks_per_node}
2020
% endif
@@ -31,7 +31,7 @@ ${helpers.template_prologue()}
3131

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

0 commit comments

Comments
 (0)