Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream old fixes / features #218

Merged
merged 3 commits into from
Oct 8, 2023
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 misc/run-phoenix-release-gpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -x
. ./mfc.sh load -c p -m GPU

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

./mfc.sh test -a -b mpirun -j $(nproc) \
--gpu -g $gpu_ids
Expand Down
25 changes: 12 additions & 13 deletions toolchain/mfc/args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re, os.path, argparse, dataclasses

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

if "t" not in mask:
p.add_argument("-t", "--targets", metavar="TARGET", nargs="+", type=str.lower, choices=get_target_names(),
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())}.")
p.add_argument("-t", "--targets", metavar="TARGET", nargs="+", type=str.lower, choices=[ _.name for _ in TARGETS ],
default=[ _.name for _ in DEFAULT_TARGETS ],
help=f"Space separated list of targets to act upon. Allowed values are: {format_list_to_string([ _.name for _ in TARGETS ])}.")

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

if "n" not in mask:
for name in get_dependencies_names():
p.add_argument(f"--no-{name}", action="store_true", help=f"Do not build the {name} dependency. Use the system's instead.")
for target in DEPENDENCY_TARGETS:
p.add_argument(f"--no-{target.name}", action="store_true", help=f"Do not build the {target.name} dependency. Use the system's instead.")

if "g" not in mask:
p.add_argument("-g", "--gpus", nargs="+", type=int, default=[0], help="(GPU) List of GPU #s to use.")

# === BUILD ===
add_common_arguments(build)
add_common_arguments(build, "g")

# === CLEAN ===
add_common_arguments(clean, "j")
add_common_arguments(clean, "jg")

binaries = [ b.bin for b in BINARIES ]

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

Expand Down Expand Up @@ -119,7 +122,7 @@ def add_common_arguments(p, mask = None):
add_common_arguments(bench, "t")

# === COUNT ===
add_common_arguments(count)
add_common_arguments(count, "g")

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

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

# Turn GPU ID list into a comma separated string
if "gpus" in args:
args["gpus"] = [int(g) for g in args["gpus"].split(",")]

return args
14 changes: 9 additions & 5 deletions toolchain/mfc/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from .printer import cons
from .state import ARG
from .build import build_targets
from .build import PRE_PROCESS, SIMULATION, build_targets
from .common import system, MFC_SUBDIR
from . import sched

def bench():
build_targets(["pre_process", "simulation"])
build_targets([PRE_PROCESS, SIMULATION])

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

def __worker(case: str):
def __worker(case: str, devices: typing.Set[int]):
nonlocal RESULTS

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

tasks: typing.List[sched.Task] = [
sched.Task(1, __worker, [ case ]) for case in CASES
sched.Task(1, __worker, [ case ], 1) for case in CASES
]

cons.print()
sched.sched(tasks, 1 if ARG('case_optimization') else ARG('jobs'))
nThreads = min(ARG('jobs'), len(ARG('gpus'))) if ARG("gpu") else ARG('jobs')
if ARG('case_optimization'):
nThreads = 1

sched.sched(tasks, nThreads, ARG("gpus"))
cons.print()
cons.unindent()
cons.print("[bold]Benchmark Results:[/bold]")
Expand Down
Loading
Loading