Skip to content

Commit d65e328

Browse files
committed
Add EXCL_STRIDE to XML PE configs
1 parent c64260e commit d65e328

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

CIME/Tools/pelayout

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def parse_command_line(args, description):
7070

7171
parser.add_argument(
7272
"--format",
73-
default="%4C: %6T/%6H; %6R %6P",
73+
default="%4C: %6T/%6H; %6R %6P %6X",
7474
help="Format the PE layout items for each component (see below)",
7575
)
7676

7777
parser.add_argument(
7878
"--header",
79-
default="Comp NTASKS NTHRDS ROOTPE PSTRIDE",
79+
default="Comp NTASKS NTHRDS ROOTPE PSTRIDE XSTRIDE",
8080
help="Custom header for PE layout display",
8181
)
8282

@@ -116,26 +116,27 @@ def get_value_as_string(case, var, attribute=None, resolved=False, subgroup=None
116116

117117

118118
###############################################################################
119-
def format_pelayout(comp, ntasks, nthreads, rootpe, pstride, arg_format):
119+
def format_pelayout(comp, ntasks, nthreads, rootpe, pstride, xstride, arg_format):
120120
###############################################################################
121121
"""
122122
Format the PE layout information for each component, using a default format,
123123
or using the arg_format input, if it exists.
124124
"""
125-
subs = {"C": comp, "T": ntasks, "H": nthreads, "R": rootpe, "P": pstride}
125+
subs = {"C": comp, "T": ntasks, "H": nthreads, "R": rootpe, "P": pstride, "X": xstride}
126126
layout_str = re.sub(r"%([0-9]*)C", r"{C:\1}", arg_format)
127127
layout_str = re.sub(r"%([-+0-9]*)T", r"{T:\1}", layout_str)
128128
layout_str = re.sub(r"%([-+0-9]*)H", r"{H:\1}", layout_str)
129129
layout_str = re.sub(r"%([-+0-9]*)R", r"{R:\1}", layout_str)
130130
layout_str = re.sub(r"%([-+0-9]*)P", r"{P:\1}", layout_str)
131+
layout_str = re.sub(r"%([-+0-9]*)X", r"{X:\1}", layout_str)
131132
layout_str = layout_str.format(**subs)
132133
return layout_str
133134

134135

135136
# End def format_pelayout
136137

137138
###############################################################################
138-
def print_pelayout(case, ntasks, nthreads, rootpes, pstrid, arg_format, header):
139+
def print_pelayout(case, ntasks, nthreads, rootpes, pstrid, xstrid, arg_format, header):
139140
###############################################################################
140141
"""
141142
Print the PE layout information for each component, using the format,
@@ -155,6 +156,7 @@ def print_pelayout(case, ntasks, nthreads, rootpes, pstrid, arg_format, header):
155156
nthreads[comp],
156157
rootpes[comp],
157158
pstrid[comp],
159+
xstrid[comp],
158160
arg_format,
159161
)
160162
)
@@ -185,15 +187,17 @@ def gather_pelayout(case):
185187
nthreads = {}
186188
rootpes = {}
187189
pstride = {}
190+
xstride = {}
188191
comp_classes = case.get_values("COMP_CLASSES")
189192

190193
for comp in comp_classes:
191194
ntasks[comp] = int(case.get_value("NTASKS_" + comp))
192195
nthreads[comp] = int(case.get_value("NTHRDS_" + comp))
193196
rootpes[comp] = int(case.get_value("ROOTPE_" + comp))
194197
pstride[comp] = int(case.get_value("PSTRID_" + comp))
198+
xstride[comp] = int(case.get_value("EXCL_STRIDE_" + comp))
195199
# End for
196-
return ntasks, nthreads, rootpes, pstride
200+
return ntasks, nthreads, rootpes, pstride, xstride
197201

198202

199203
# End def gather_pelayout
@@ -274,8 +278,8 @@ def _main_func(description):
274278
if set_ntasks is not None:
275279
modify_ntasks(case, int(set_ntasks))
276280
# End if
277-
ntasks, nthreads, rootpes, pstrid = gather_pelayout(case)
278-
print_pelayout(case, ntasks, nthreads, rootpes, pstrid, arg_format, header)
281+
ntasks, nthreads, rootpes, pstrid, xstrid = gather_pelayout(case)
282+
print_pelayout(case, ntasks, nthreads, rootpes, pstrid, xstrid, arg_format, header)
279283
# End with
280284

281285

CIME/XML/pes.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
2525
opes_nthrds = {}
2626
opes_rootpe = {}
2727
opes_pstrid = {}
28+
opes_excl_stride= {}
2829
oother_settings = {}
2930
other_settings = {}
3031
append = {}
@@ -41,6 +42,7 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
4142
opes_nthrds,
4243
opes_rootpe,
4344
opes_pstrid,
45+
opes_excl_stride,
4446
oother_settings,
4547
append,
4648
ocomments,
@@ -60,6 +62,7 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
6062
pes_nthrds,
6163
pes_rootpe,
6264
pes_pstrid,
65+
pes_excl_stride,
6366
other_settings,
6467
os_append,
6568
comments,
@@ -68,6 +71,7 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
6871
pes_nthrds.update(opes_nthrds)
6972
pes_rootpe.update(opes_rootpe)
7073
pes_pstrid.update(opes_pstrid)
74+
pes_excl_stride.update(opes_excl_stride)
7175
other_settings.update(oother_settings)
7276
os_append.update(append)
7377
if ocomments is not None:
@@ -80,13 +84,16 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
8084
pes_rootpe[i] = 0
8185
for i in iter(pes_pstrid):
8286
pes_pstrid[i] = 0
87+
for i in iter(pes_excl_stride):
88+
pes_pstrid[i] = 0
8389

8490
logger.info("Pes setting: grid is {} ".format(grid))
8591
logger.info("Pes setting: compset is {} ".format(compset))
8692
logger.info("Pes setting: tasks is {} ".format(pes_ntasks))
8793
logger.info("Pes setting: threads is {} ".format(pes_nthrds))
8894
logger.info("Pes setting: rootpe is {} ".format(pes_rootpe))
8995
logger.info("Pes setting: pstrid is {} ".format(pes_pstrid))
96+
logger.info("Pes setting: excl_stride is {} ".format(pes_excl_stride))
9097
logger.info("Pes other settings: {}".format(other_settings))
9198
logger.info("Pes other settings append: {}".format(os_append))
9299
if comments is not None:
@@ -97,6 +104,7 @@ def find_pes_layout(self, grid, compset, machine, pesize_opts="M", mpilib=None):
97104
pes_nthrds,
98105
pes_rootpe,
99106
pes_pstrid,
107+
pes_excl_stride,
100108
other_settings,
101109
os_append,
102110
comments,
@@ -110,7 +118,8 @@ def _find_matches(
110118
compset_choice = None
111119
pesize_choice = None
112120
max_points = -1
113-
pes_ntasks, pes_nthrds, pes_rootpe, pes_pstrid, other_settings, append = (
121+
pes_ntasks, pes_nthrds, pes_rootpe, pes_pstrid, pes_excl_stride, other_settings, append = (
122+
{},
114123
{},
115124
{},
116125
{},
@@ -173,6 +182,11 @@ def _find_matches(
173182
pes_pstrid[
174183
self.name(child).upper()
175184
] = int(self.text(child))
185+
elif "excl_stride" in vid:
186+
for child in self.get_children(root=node):
187+
pes_excl_stride[
188+
self.name(child).upper()
189+
] = int(self.text(child))
176190
# if the value is already upper case its something else we are trying to set
177191
else:
178192
other_settings[vid] = self.text(node)
@@ -231,6 +245,9 @@ def _find_matches(
231245
elif "pstrid" in vid:
232246
for child in self.get_children(root=node):
233247
pes_pstrid[self.name(child).upper()] = int(self.text(child))
248+
elif "excl_stride" in vid:
249+
for child in self.get_children(root=node):
250+
pes_excl_stride[self.name(child).upper()] = int(self.text(child))
234251
# if the value is already upper case its something else we are trying to set
235252
elif vid == self.name(node):
236253
text = self.text(node).strip()
@@ -250,6 +267,7 @@ def _find_matches(
250267
pes_nthrds,
251268
pes_rootpe,
252269
pes_pstrid,
270+
pes_excl_stride,
253271
other_settings,
254272
append,
255273
comment,

CIME/case/case.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ def _setup_mach_pes(self, pecount, multi_driver, ninst, machine_name, mpilib):
12041204
pes_nthrds = {}
12051205
pes_rootpe = {}
12061206
pes_pstrid = {}
1207+
pes_excl_stride = {}
12071208
other = {}
12081209
append = {}
12091210
comment = None
@@ -1233,6 +1234,7 @@ def _setup_mach_pes(self, pecount, multi_driver, ninst, machine_name, mpilib):
12331234
pes_nthrds,
12341235
pes_rootpe,
12351236
pes_pstrid,
1237+
pes_excl_stride,
12361238
other,
12371239
append,
12381240
comment,
@@ -1287,17 +1289,20 @@ def _setup_mach_pes(self, pecount, multi_driver, ninst, machine_name, mpilib):
12871289
nthrds_str = "NTHRDS_{}".format(comp_class)
12881290
rootpe_str = "ROOTPE_{}".format(comp_class)
12891291
pstrid_str = "PSTRID_{}".format(comp_class)
1292+
excl_stride_str = "EXCL_STRIDE_{}".format(comp_class)
12901293

12911294
ntasks = pes_ntasks[ntasks_str] if ntasks_str in pes_ntasks else 1
12921295
nthrds = pes_nthrds[nthrds_str] if nthrds_str in pes_nthrds else 1
12931296
rootpe = pes_rootpe[rootpe_str] if rootpe_str in pes_rootpe else 0
12941297
pstrid = pes_pstrid[pstrid_str] if pstrid_str in pes_pstrid else 1
1298+
excl_stride = pes_excl_stride[excl_stride_str] if excl_stride_str in pes_excl_stride else 0
12951299

12961300
totaltasks.append((ntasks + rootpe) * nthrds)
12971301
mach_pes_obj.set_value(ntasks_str, ntasks)
12981302
mach_pes_obj.set_value(nthrds_str, nthrds)
12991303
mach_pes_obj.set_value(rootpe_str, rootpe)
13001304
mach_pes_obj.set_value(pstrid_str, pstrid)
1305+
mach_pes_obj.set_value(excl_stride_str, excl_stride)
13011306

13021307
# Make sure that every component has been accounted for
13031308
# set, nthrds and ntasks to 1 otherwise. Also set the ninst values here.

CIME/data/config/config_headers.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
ROOTPE: the global mpi task of the component root task, if negative, indicates nodes rather than tasks.
7070
PSTRID: the stride of MPI tasks across the global set of pes (for now set to 1)
7171
NINST : the number of component instances (will be spread evenly across NTASKS)
72+
EXCL_STRIDE: the stride of MPI tasks owned exclusively by a component. If 0, exclusivity is disabled.
7273

7374
for example, for NTASKS = 8, NTHRDS = 2, ROOTPE = 32, NINST = 2
7475
the MPI tasks would be placed starting on global pe 32 and each pe would be threaded 2-ways

doc/source/ccs/model-configuration/variables/pes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ following meanings:
326326
- The global MPI task of the component root task; if negative, indicates nodes rather than tasks. The root processor for each component is set relative to the MPI global communicator.
327327
* - PSTRID
328328
- The stride of MPI tasks across the global set of pes (for now set to 1). This variable is currently not used and is a placeholder for future development.
329+
* - EXCL_STRIDE
330+
- Stride of MPI tasks owned exclusively by a component. If 0, exclusivity is disabled.
329331
* - NINST
330332
- The number of component instances, which are spread evenly across NTASKS.
331333
* - COST_PER_NODE

0 commit comments

Comments
 (0)