Skip to content

Commit c312cd7

Browse files
authored
Merge pull request #218 from henryleberre/upstream-old-fixes
2 parents 973e9ab + 5354660 commit c312cd7

File tree

12 files changed

+341
-320
lines changed

12 files changed

+341
-320
lines changed

misc/run-phoenix-release-gpu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -x
1717
. ./mfc.sh load -c p -m GPU
1818

1919
gpu_count=$(nvidia-smi -L | wc -l) # number of GPUs on node
20-
gpu_ids=$(seq -s ',' 0 $(($gpu_count-1))) # 0,1,2,...,gpu_count-1
20+
gpu_ids=$(seq -s ' ' 0 $(($gpu_count-1))) # 0,1,2,...,gpu_count-1
2121

2222
./mfc.sh test -a -b mpirun -j $(nproc) \
2323
--gpu -g $gpu_ids

toolchain/mfc/args.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re, os.path, argparse, dataclasses
22

3-
from .build import get_mfc_target_names, get_target_names, get_dependencies_names
3+
from .build import TARGETS, DEFAULT_TARGETS, DEPENDENCY_TARGETS
44
from .common import format_list_to_string
55
from .test.test import CASES as TEST_CASES
66
from .packer import packer
@@ -44,8 +44,9 @@ def add_common_arguments(p, mask = None):
4444
mask = ""
4545

4646
if "t" not in mask:
47-
p.add_argument("-t", "--targets", metavar="TARGET", nargs="+", type=str.lower, choices=get_target_names(),
48-
default=get_mfc_target_names(), help=f"Space separated list of targets to act upon. Allowed values are: {format_list_to_string(get_target_names())}.")
47+
p.add_argument("-t", "--targets", metavar="TARGET", nargs="+", type=str.lower, choices=[ _.name for _ in TARGETS ],
48+
default=[ _.name for _ in DEFAULT_TARGETS ],
49+
help=f"Space separated list of targets to act upon. Allowed values are: {format_list_to_string([ _.name for _ in TARGETS ])}.")
4950

5051
if "m" not in mask:
5152
for f in dataclasses.fields(config):
@@ -61,14 +62,17 @@ def add_common_arguments(p, mask = None):
6162
p.add_argument("-v", "--verbose", action="store_true", help="Enables verbose compiler & linker output.")
6263

6364
if "n" not in mask:
64-
for name in get_dependencies_names():
65-
p.add_argument(f"--no-{name}", action="store_true", help=f"Do not build the {name} dependency. Use the system's instead.")
65+
for target in DEPENDENCY_TARGETS:
66+
p.add_argument(f"--no-{target.name}", action="store_true", help=f"Do not build the {target.name} dependency. Use the system's instead.")
67+
68+
if "g" not in mask:
69+
p.add_argument("-g", "--gpus", nargs="+", type=int, default=[0], help="(GPU) List of GPU #s to use.")
6670

6771
# === BUILD ===
68-
add_common_arguments(build)
72+
add_common_arguments(build, "g")
6973

7074
# === CLEAN ===
71-
add_common_arguments(clean, "j")
75+
add_common_arguments(clean, "jg")
7276

7377
binaries = [ b.bin for b in BINARIES ]
7478

@@ -81,7 +85,6 @@ def add_common_arguments(p, mask = None):
8185
test.add_argument("-b", "--binary", choices=binaries, type=str, default=None, help="(Serial) Override MPI execution binary")
8286
test.add_argument("-r", "--relentless", action="store_true", default=False, help="Run all tests, even if multiple fail.")
8387
test.add_argument("-a", "--test-all", action="store_true", default=False, help="Run the Post Process Tests too.")
84-
test.add_argument("-g", "--gpus", type=str, default="0", help="(GPU) Comma separated list of GPU #s to use.")
8588
test.add_argument("-%", "--percent", type=int, default=100, help="Percentage of tests to run.")
8689
test.add_argument("-m", "--max-attempts", type=int, default=3, help="Maximum number of attempts to run a test.")
8790

@@ -119,7 +122,7 @@ def add_common_arguments(p, mask = None):
119122
add_common_arguments(bench, "t")
120123

121124
# === COUNT ===
122-
add_common_arguments(count)
125+
add_common_arguments(count, "g")
123126

124127
args: dict = vars(parser.parse_args())
125128

@@ -149,8 +152,4 @@ def append_defaults_to_data(name: str, parser):
149152
if args[e] is not None:
150153
args[e] = os.path.abspath(args[e])
151154

152-
# Turn GPU ID list into a comma separated string
153-
if "gpus" in args:
154-
args["gpus"] = [int(g) for g in args["gpus"].split(",")]
155-
156155
return args

toolchain/mfc/bench.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from .printer import cons
66
from .state import ARG
7-
from .build import build_targets
7+
from .build import PRE_PROCESS, SIMULATION, build_targets
88
from .common import system, MFC_SUBDIR
99
from . import sched
1010

1111
def bench():
12-
build_targets(["pre_process", "simulation"])
12+
build_targets([PRE_PROCESS, SIMULATION])
1313

1414
cons.print("[bold]Benchmarking [magenta]simulation[/magenta]:[/bold]")
1515
cons.indent()
@@ -21,7 +21,7 @@ def bench():
2121
table.add_column("Case")
2222
table.add_column("(Simulation) Runtime (s)")
2323

24-
def __worker(case: str):
24+
def __worker(case: str, devices: typing.Set[int]):
2525
nonlocal RESULTS
2626

2727
system(["./mfc.sh", "run", f"examples/{case}/case.py", "--no-build", "-t", "pre_process"], stdout=subprocess.DEVNULL)
@@ -39,11 +39,15 @@ def __worker(case: str):
3939
table.add_row(case, str(runtime))
4040

4141
tasks: typing.List[sched.Task] = [
42-
sched.Task(1, __worker, [ case ]) for case in CASES
42+
sched.Task(1, __worker, [ case ], 1) for case in CASES
4343
]
4444

4545
cons.print()
46-
sched.sched(tasks, 1 if ARG('case_optimization') else ARG('jobs'))
46+
nThreads = min(ARG('jobs'), len(ARG('gpus'))) if ARG("gpu") else ARG('jobs')
47+
if ARG('case_optimization'):
48+
nThreads = 1
49+
50+
sched.sched(tasks, nThreads, ARG("gpus"))
4751
cons.print()
4852
cons.unindent()
4953
cons.print("[bold]Benchmark Results:[/bold]")

0 commit comments

Comments
 (0)