Skip to content

Commit bac089d

Browse files
committed
Update toolchain to support swapping between OpenACC and OpenMP
1 parent 0d550aa commit bac089d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

toolchain/mfc/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def add_common_arguments(p: argparse.ArgumentParser, mask = None):
5959
if "m" not in mask:
6060
for f in dataclasses.fields(config):
6161
if f.name == 'gpu':
62-
p.add_argument(f"--{f.name}", action="store", nargs='?', default=gpuConfigOptions.ACC.value, choices=[e.value for e in gpuConfigOptions])
62+
p.add_argument(f"--{f.name}", action="store", nargs='?', 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.")
6363
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.")
6464
continue
6565
p.add_argument( f"--{f.name}", action="store_true", help=f"Turn the {f.name} option ON.")

toolchain/mfc/state.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,24 @@ def items(self) -> typing.Iterable[typing.Tuple[str, typing.Any]]:
3535
def make_options(self) -> typing.List[str]:
3636
""" Returns a list of options that could be passed to mfc.sh again.
3737
Example: --no-debug --mpi --no-gpu --no-gcov --no-unified"""
38-
return [ f"--{'no-' if not v else ''}{k}" for k, v in self.items() ]
38+
options = []
39+
for k, v in self.items():
40+
if (k == 'gpu'):
41+
options.append(f"--{v}-{k}")
42+
else:
43+
options.append(f"--{'no-' if not v else ''}{k}")
44+
return options
3945

4046
def make_slug(self) -> str:
4147
""" Sort the items by key, then join them with underscores. This uniquely
4248
identifies the configuration. Example: no-debug_no-gpu_no_mpi_no-gcov """
43-
return '_'.join([ f"{'no-' if not v else ''}{k}" for k, v in sorted(self.items(), key=lambda x: x[0]) ])
49+
options = []
50+
for k, v in sorted(self.items(), key=lambda x: x[0]):
51+
if (k == 'gpu'):
52+
options.append(f"--{v}-{k}")
53+
else:
54+
options.append(f"--{'no-' if not v else ''}{k}")
55+
return '_'.join(options)
4456

4557
def __eq__(self, other) -> bool:
4658
""" Check if two MFCConfig objects are equal, field by field. """

0 commit comments

Comments
 (0)