Skip to content

Commit

Permalink
fix some merges
Browse files Browse the repository at this point in the history
  • Loading branch information
okBrian committed Nov 19, 2024
1 parent 7da5cea commit dc93dee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
15 changes: 6 additions & 9 deletions toolchain/mfc/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os, typing, hashlib, dataclasses

from .case import Case
from .printer import cons
from .common import MFCException, system, delete_directory, create_directory, \
format_list_to_string
Expand All @@ -22,7 +21,7 @@ def compute(self) -> typing.Set:
return r

name: str # Name of the target
flags: typing.List[str] # Extra flags to pass to CMake
flags: typing.List[str] # Extra flags to pass to CMakeMFCTarget
isDependency: bool # Is it a dependency of an MFC target?
isDefault: bool # Should it be built by default? (unspecified -t | --targets)
isRequired: bool # Should it always be built? (no matter what -t | --targets is)
Expand All @@ -32,7 +31,7 @@ def compute(self) -> typing.Set:
def __hash__(self) -> int:
return hash(self.name)

def get_slug(self, case: Case) -> str:
def get_slug(self, case: input.MFCInputFile) -> str:
if self.isDependency:
return self.name

Expand All @@ -47,7 +46,7 @@ def get_slug(self, case: Case) -> str:
return m.hexdigest()[:10]

# Get path to directory that will store the build files
def get_staging_dirpath(self, case: Case) -> str:
def get_staging_dirpath(self, case: input.MFCInputFile) -> str:
return os.sep.join([os.getcwd(), "build", "staging", self.get_slug(case) ])

# Get the directory that contains the target's CMakeLists.txt
Expand All @@ -64,18 +63,18 @@ def get_install_dirpath(self, case: input.MFCInputFile) -> str:
# The install directory is located <root>/build/install/<slug>
return os.sep.join([os.getcwd(), "build", "install", self.get_slug(case)])

def get_install_binpath(self, case: Case) -> str:
def get_install_binpath(self, case: input.MFCInputFile) -> str:
# <root>/install/<slug>/bin/<target>
return os.sep.join([self.get_install_dirpath(case), "bin", self.name])

def is_configured(self, case: Case) -> bool:
def is_configured(self, case: input.MFCInputFile) -> bool:
# We assume that if the CMakeCache.txt file exists, then the target is
# configured. (this isn't perfect, but it's good enough for now)
return os.path.isfile(
os.sep.join([self.get_staging_dirpath(case), "CMakeCache.txt"])
)

def get_configuration_txt(self, case: Case) -> typing.Optional[dict]:
def get_configuration_txt(self, case: input.MFCInputFile) -> typing.Optional[dict]:
if not self.is_configured(case):
return None

Expand Down Expand Up @@ -261,8 +260,6 @@ def build(targets = None, case: input.MFCInputFile = None, history: typing.Set[s
targets = [ targets ]
if targets is None:
targets = ARG("targets")
elif isinstance(targets, (MFCTarget, str)):
targets = [targets]

targets = get_targets(list(REQUIRED_TARGETS) + targets)
case = case or input.load(ARG("input"), ARG("--"), {})
Expand Down
6 changes: 3 additions & 3 deletions toolchain/mfc/test/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ..run import input
from ..build import MFCTarget, get_target

count = 0
Tend = 0.25
Nt = 50
mydt = 0.0005
Expand Down Expand Up @@ -219,7 +218,7 @@ def __str__(self) -> str:

def to_input_file(self) -> input.MFCInputFile:
return input.MFCInputFile(
self.get_filepath(),
os.path.basename(self.get_filepath()),
self.get_dirpath(),
self.get_parameters())

Expand Down Expand Up @@ -262,7 +261,7 @@ def get_uuid(self) -> str:
return trace_to_uuid(self.trace)

def to_case(self) -> TestCase:
dictionary = {}
dictionary = self.mods.copy()
if self.path:
dictionary.update(input.load(self.path, self.args, do_print=False).params)

Expand All @@ -274,6 +273,7 @@ def to_case(self) -> TestCase:
path = os.path.abspath(path)
if os.path.exists(path):
dictionary[key] = path
break

if self.mods:
dictionary.update(self.mods)
Expand Down
7 changes: 3 additions & 4 deletions toolchain/mfc/test/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,13 @@ def modify_example_case(case: dict):
case['t_step_save'] = 50

caseSize = case['m'] * max(case['n'], 1) * max(case['p'], 1)
if caseSize > 625:
if caseSize > 25 * 25:
if case['n'] == 0 and case['p'] == 0:
case['m'] = 625
case['m'] = 25 * 25
elif case['p'] == 0:
case['m'] = 25
case['n'] = 25
# m, n, p < 25 causes errors
elif caseSize > 15625:
elif caseSize > 25 * 25 * 25:
case['m'] = 25
case['n'] = 25
case['p'] = 25
Expand Down
3 changes: 3 additions & 0 deletions toolchain/mfc/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
start_time = time.time()

tol = case.compute_tolerance()
case.delete_output()
case.create_directory()

cmd = case.run([PRE_PROCESS, SIMULATION], gpus=devices)
out_filepath = os.path.join(case.get_dirpath(), "out_pre_sim.txt")

Expand Down

0 comments on commit dc93dee

Please sign in to comment.