Skip to content

Commit

Permalink
Made mpi and openmp default to False in the BuildConfig constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiker committed Oct 21, 2024
1 parent a79b41d commit 2617322
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 64 deletions.
2 changes: 1 addition & 1 deletion run_configs/gcom/build_gcom_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if __name__ == '__main__':

with BuildConfig(project_label='gcom object archive $compiler',
mpi=False, openmp=False, tool_box=ToolBox()) as state:
mpi=True, openmp=False, tool_box=ToolBox()) as state:
common_build_steps(state)
archive_objects(state, output_fpath='$output/libgcom.a')
cleanup_prebuilds(state, all_unused=True)
2 changes: 1 addition & 1 deletion run_configs/gcom/build_gcom_so.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
parsed_args = arg_parser.parse_args()

with BuildConfig(project_label='gcom shared library $compiler',
mpi=False, openmp=False, tool_box=ToolBox()) as state:
mpi=True, openmp=False, tool_box=ToolBox()) as state:
common_build_steps(state, fpic=True)
link_shared_object(state, output_fpath='$output/libgcom.so')
cleanup_prebuilds(state, all_unused=True)
2 changes: 1 addition & 1 deletion run_configs/gcom/grab_gcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# we put this here so the two build configs can read its source_root
grab_config = BuildConfig(project_label=f'gcom_source {revision}',
mpi=False, openmp=False, tool_box=ToolBox())
tool_box=ToolBox())


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions run_configs/lfric/grab_lfric.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
tool_box = ToolBox()
lfric_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
mpi=False, openmp=False, tool_box=tool_box)
tool_box=tool_box)
gpl_utils_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
mpi=False, openmp=False, tool_box=tool_box)
tool_box=tool_box)


if __name__ == '__main__':
Expand Down
6 changes: 2 additions & 4 deletions run_configs/lfric/gungho.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
gpl_utils_source = gpl_utils_source_config.source_root / 'gpl_utils'

with BuildConfig(project_label='gungho $compiler $two_stage',
mpi=False, openmp=False, tool_box=ToolBox()) as state:
mpi=True, openmp=True, tool_box=ToolBox()) as state:
grab_folder(state, src=lfric_source / 'infrastructure/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components/driver/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components' / 'inventory' / 'source', dst_label='')
Expand Down Expand Up @@ -87,7 +87,7 @@
state,
common_flags=[
'-c',
'-ffree-line-length-none', '-fopenmp',
'-ffree-line-length-none',
'-g',
'-std=f2008',

Expand All @@ -104,8 +104,6 @@
link_exe(
state,
flags=[
'-fopenmp',

'-lyaxt', '-lyaxt_c', '-lnetcdff', '-lnetcdf', '-lhdf5', # EXTERNAL_DYNAMIC_LIBRARIES
'-lxios', # EXTERNAL_STATIC_LIBRARIES
'-lstdc++',
Expand Down
2 changes: 1 addition & 1 deletion run_configs/lfric/mesh_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
psyclone_overrides = Path(__file__).parent / 'mesh_tools_overrides'

with BuildConfig(project_label='mesh tools $compiler $two_stage',
mpi=False, openmp=False, tool_box=ToolBox()) as state:
mpi=True, openmp=False, tool_box=ToolBox()) as state:
grab_folder(state, src=lfric_source / 'infrastructure/source/', dst_label='')
grab_folder(state, src=lfric_source / 'mesh_tools/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components/science/source/', dst_label='')
Expand Down
2 changes: 1 addition & 1 deletion run_configs/tiny_fortran/build_tiny_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
tool_box.add_tool(Linker(compiler=fc))

with BuildConfig(project_label='tiny_fortran $compiler',
mpi=False, openmp=False, tool_box=tool_box) as state:
tool_box=tool_box) as state:
git_checkout(state, src='https://github.com/metomi/fab-test-data.git',
revision='main', dst_label='src')

Expand Down
4 changes: 3 additions & 1 deletion run_configs/um/build_um.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ def replace_in_file(inpath, outpath, find, replace):
revision = 'vn12.1'
um_revision = revision.replace('vn', 'um')

# The original build script disabled openmp, so for now
# we keep this disabled.
state = BuildConfig(
project_label=f'um atmos safe {revision} $compiler $two_stage',
mpi=False, openmp=False, tool_box=ToolBox())
mpi=True, openmp=False, tool_box=ToolBox())

# compiler-specific flags
compiler = state.tool_box[Category.FORTRAN_COMPILER]
Expand Down
4 changes: 2 additions & 2 deletions source/fab/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class BuildConfig():
"""
def __init__(self, project_label: str,
tool_box: ToolBox,
mpi: bool,
openmp: bool,
mpi: bool = False,
openmp: bool = False,
multiprocessing: bool = True,
n_procs: Optional[int] = None,
reuse_artefacts: bool = False,
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/CFortranInterop/test_CFortranInterop.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def test_CFortranInterop(tmp_path):

# build
with BuildConfig(fab_workspace=tmp_path, project_label='foo',
mpi=False, openmp=False, tool_box=ToolBox(),
multiprocessing=False) as config:
tool_box=ToolBox(), multiprocessing=False) as config:
grab_folder(config, src=PROJECT_SOURCE)
find_source_files(config)
c_pragma_injector(config)
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/CUserHeader/test_CUserHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def test_CUseHeader(tmp_path):

# build
with BuildConfig(fab_workspace=tmp_path, tool_box=ToolBox(),
mpi=False, openmp=False, project_label='foo',
multiprocessing=False) as config:
project_label='foo', multiprocessing=False) as config:

grab_folder(config, PROJECT_SOURCE)
find_source_files(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def test_fortran_dependencies(tmp_path):

# build
with BuildConfig(fab_workspace=tmp_path, tool_box=ToolBox(),
mpi=False, openmp=False,
project_label='foo', multiprocessing=False) as config:
grab_folder(config, src=Path(__file__).parent / 'project-source')
find_source_files(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

def build(fab_workspace, fpp_flags=None):
with BuildConfig(fab_workspace=fab_workspace, tool_box=ToolBox(),
mpi=False, openmp=False, project_label='foo',
multiprocessing=False) as config:
project_label='foo', multiprocessing=False) as config:
grab_folder(config, Path(__file__).parent / 'project-source')
find_source_files(config)
preprocess_fortran(config, common_flags=fpp_flags)
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/MinimalC/test_MinimalC.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def test_minimal_c(tmp_path):

# build
with BuildConfig(fab_workspace=tmp_path, tool_box=ToolBox(),
mpi=False, openmp=False, project_label='foo',
multiprocessing=False) as config:
project_label='foo', multiprocessing=False) as config:

grab_folder(config, PROJECT_SOURCE)
find_source_files(config)
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/MinimalFortran/test_MinimalFortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def test_minimal_fortran(tmp_path):

# build
with BuildConfig(fab_workspace=tmp_path, tool_box=ToolBox(),
mpi=False, openmp=False, project_label='foo',
multiprocessing=False) as config:
project_label='foo', multiprocessing=False) as config:
grab_folder(config, PROJECT_SOURCE)
find_source_files(config)
preprocess_fortran(config)
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/git/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@

@pytest.fixture
def config(tmp_path):
return BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path)
return BuildConfig('proj', ToolBox(), fab_workspace=tmp_path)


class TestGitCheckout:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class TestIncremental():
def config(self, tmp_path): # tmp_path is a pytest fixture which differs per test, per run
logging.getLogger('fab').setLevel(logging.WARNING)

with BuildConfig(project_label=PROJECT_LABEL, mpi=False, openmp=False,
tool_box=ToolBox(), fab_workspace=tmp_path,
with BuildConfig(project_label=PROJECT_LABEL, tool_box=ToolBox(),
fab_workspace=tmp_path,
multiprocessing=False) as grab_config:
grab_folder(grab_config, Path(__file__).parent / 'project-source',
dst_label='src')

build_config = BuildConfig(project_label=PROJECT_LABEL, mpi=False,
openmp=False, tool_box=ToolBox(),
build_config = BuildConfig(project_label=PROJECT_LABEL,
tool_box=ToolBox(),
fab_workspace=tmp_path,
multiprocessing=False)

Expand Down Expand Up @@ -246,8 +246,7 @@ class TestCleanupPrebuilds():
@pytest.mark.parametrize("kwargs,expect", in_out)
def test_clean(self, tmp_path, kwargs, expect):

with BuildConfig(project_label=PROJECT_LABEL, mpi=False, openmp=False,
tool_box=ToolBox(),
with BuildConfig(project_label=PROJECT_LABEL, tool_box=ToolBox(),
fab_workspace=tmp_path, multiprocessing=False) as config:
remaining = self._prune(config, kwargs=kwargs)

Expand All @@ -257,8 +256,8 @@ def test_prune_unused(self, tmp_path):
# pruning everything not current

current_prebuilds = ArtefactSet.CURRENT_PREBUILDS
with BuildConfig(project_label=PROJECT_LABEL, mpi=False, openmp=False,
tool_box=ToolBox(), fab_workspace=tmp_path,
with BuildConfig(project_label=PROJECT_LABEL, tool_box=ToolBox(),
fab_workspace=tmp_path,
multiprocessing=False) as config:
config._artefact_store = {current_prebuilds: {
tmp_path / PROJECT_LABEL / BUILD_OUTPUT / PREBUILD / 'a.123.foo',
Expand Down
3 changes: 1 addition & 2 deletions tests/system_tests/prebuild/test_prebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def build_config(self, fab_workspace, grab_prebuild_folder=None):

with BuildConfig(
project_label='test_prebuild', tool_box=ToolBox(),
mpi=False, openmp=False, fab_workspace=fab_workspace,
multiprocessing=False) as config:
fab_workspace=fab_workspace, multiprocessing=False) as config:
grab_folder(config, Path(__file__).parent / 'project-source',
dst_label='src')
# insert a prebuild grab step or don't insert anything
Expand Down
11 changes: 4 additions & 7 deletions tests/system_tests/psyclone/test_psyclone_system_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def test_make_parsable_x90(tmp_path):
parsable_x90_path = make_parsable_x90(input_x90_path)

x90_analyser = X90Analyser()
with BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path) as config:
with BuildConfig('proj', ToolBox(), fab_workspace=tmp_path) as config:
x90_analyser._config = config # todo: code smell
x90_analyser.run(parsable_x90_path)

Expand All @@ -74,8 +73,7 @@ class TestX90Analyser:
def run(self, tmp_path):
parsable_x90_path = self.expected_analysis_result.fpath
x90_analyser = X90Analyser()
with BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path) as config:
with BuildConfig('proj', ToolBox(), fab_workspace=tmp_path) as config:
x90_analyser._config = config
analysed_x90, _ = x90_analyser.run(parsable_x90_path) # type: ignore
# don't delete the prebuild
Expand All @@ -101,7 +99,6 @@ class Test_analysis_for_x90s_and_kernels:

def test_analyse(self, tmp_path):
with BuildConfig('proj', fab_workspace=tmp_path,
mpi=False, openmp=False,
tool_box=ToolBox()) as config:
analysed_x90 = _analyse_x90s(config, x90s=[SAMPLE_X90])
all_kernel_hashes = _analyse_kernels(config, kernel_roots=[Path(__file__).parent])
Expand Down Expand Up @@ -130,8 +127,8 @@ class TestPsyclone:
"""
@pytest.fixture
def config(self, tmp_path):
config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path, multiprocessing=False)
config = BuildConfig('proj', ToolBox(), fab_workspace=tmp_path,
multiprocessing=False)
return config

def steps(self, config, psyclone_lfric_api):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/parse/fortran/test_fortran_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class TestAnalyser:
@pytest.fixture
def fortran_analyser(self, tmp_path):
fortran_analyser = FortranAnalyser()
fortran_analyser._config = BuildConfig('proj', ToolBox(), mpi=False,
openmp=False,
fortran_analyser._config = BuildConfig('proj', ToolBox(),
fab_workspace=tmp_path)
return fortran_analyser

Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/steps/test_analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def test_exceptions(self, tmp_path):
pytest.warns(UserWarning, match="deprecated 'DEPENDS ON:'"):
# The warning "deprecated 'DEPENDS ON:' comment found in fortran
# code" is in "def _parse_files" in "source/steps/analyse.py"
config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path)
config = BuildConfig('proj', ToolBox(), fab_workspace=tmp_path)

# the exception should be suppressed (and logged) and this step
# should run to completion
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/steps/test_archive_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_for_exes(self):
'''
targets = ['prog1', 'prog2']

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
for target in targets:
config.artefact_store.update_dict(
ArtefactSet.OBJECT_FILES, target,
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_for_library(self):
a shared library.
'''

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
config.artefact_store.update_dict(
ArtefactSet.OBJECT_FILES, None, {'util1.o', 'util2.o'})

Expand All @@ -81,7 +81,7 @@ def test_incorrect_tool(self):
'''Test that an incorrect archive tool is detected
'''

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
tool_box = config.tool_box
cc = tool_box.get_tool(Category.C_COMPILER, config.mpi)
# And set its category to C_COMPILER
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/steps/test_compile_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def fixture_content(tmp_path, tool_box):
analysed file and expected hash.'''

config = BuildConfig('proj', tool_box, multiprocessing=False,
mpi=False, openmp=False, fab_workspace=tmp_path)
fab_workspace=tmp_path)

analysed_file = AnalysedC(fpath=Path(f'{config.source_root}/foo.c'), file_hash=0)
config._artefact_store[ArtefactSet.BUILD_TREES] = \
Expand Down
9 changes: 4 additions & 5 deletions tests/unit_tests/steps/test_compile_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def fixture_artefact_store(analysed_files):
def test_compile_cc_wrong_compiler(tool_box):
'''Test if a non-C compiler is specified as c compiler.
'''
config = BuildConfig('proj', tool_box, mpi=False, openmp=False)
config = BuildConfig('proj', tool_box)
# Take the Fortran compiler
cc = tool_box[Category.C_COMPILER]
# And set its category to C_COMPILER
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_vanilla(self, analysed_files, tool_box: ToolBox):
# this gets filled in
mod_hashes: Dict[str, int] = {}

config = BuildConfig('proj', tool_box, mpi=False, openmp=False)
config = BuildConfig('proj', tool_box)
mp_common_args = MpCommonArgs(config, FlagsConfig(), {}, True)
with mock.patch('fab.steps.compile_fortran.run_mp', return_value=run_mp_results):
with mock.patch('fab.steps.compile_fortran.get_mod_hashes'):
Expand Down Expand Up @@ -161,8 +161,7 @@ def fixture_content(tool_box):
obj_combo_hash = '17ef947fd'
mods_combo_hash = '10867b4f3'
mp_common_args = MpCommonArgs(
config=BuildConfig('proj', tool_box, mpi=False, openmp=False,
fab_workspace=Path('/fab')),
config=BuildConfig('proj', tool_box, fab_workspace=Path('/fab')),
flags=flags_config,
mod_hashes={'mod_dep_1': 12345, 'mod_dep_2': 23456},
syntax_only=False,
Expand Down Expand Up @@ -463,7 +462,7 @@ def test_vanilla(self, tool_box):
mock.Mock(module_defs=['foo', 'bar']),
}

config = BuildConfig('proj', tool_box, mpi=False, openmp=False,
config = BuildConfig('proj', tool_box,
fab_workspace=Path('/fab_workspace'))

with mock.patch('pathlib.Path.exists', side_effect=[True, True]):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/steps/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class Test_preprocess_fortran:
def test_big_little(self, tmp_path):
# ensure big F90s are preprocessed and little f90s are copied

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False,
fab_workspace=tmp_path)
config = BuildConfig('proj', ToolBox(), fab_workspace=tmp_path)
big_f90 = Path(config.source_root / 'big.F90')
little_f90 = Path(config.source_root / 'little.f90')

Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/steps/test_root_inc_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_vanilla(self):
# ensure it copies the inc file
inc_files = [Path('/foo/source/bar.inc')]

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
config.artefact_store[ArtefactSet.INITIAL_SOURCE] = inc_files

with mock.patch('fab.steps.root_inc_files.shutil') as mock_shutil:
Expand All @@ -29,7 +29,7 @@ def test_vanilla(self):

def test_skip_output_folder(self):
# ensure it doesn't try to copy a file in the build output
config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
inc_files = [Path('/foo/source/bar.inc'),
config.build_output / 'fab.inc']
config.artefact_store[ArtefactSet.INITIAL_SOURCE] = inc_files
Expand All @@ -47,7 +47,7 @@ def test_name_clash(self):
# ensure raises an exception if there is a name clash
inc_files = [Path('/foo/source/bar.inc'), Path('/foo/sauce/bar.inc')]

config = BuildConfig('proj', ToolBox(), mpi=False, openmp=False)
config = BuildConfig('proj', ToolBox())
config.artefact_store[ArtefactSet.INITIAL_SOURCE] = inc_files

with pytest.raises(FileExistsError):
Expand Down
Loading

0 comments on commit 2617322

Please sign in to comment.