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

Mpi omp support #336

Open
wants to merge 322 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
322 commits
Select commit Hold shift + click to select a range
302d58b
#3 Added get_hash function to compiler.
hiker Apr 19, 2024
4068505
#3 Added conftest.py file (with a fixture to create a C-compiler).
hiker Apr 22, 2024
f24d939
#3 Introduce fixtures for Fortran compiler and tool_box.
hiker Apr 22, 2024
075ed40
#3 Remove explicit compiler information from MpCommonArgs (since it's…
hiker Apr 22, 2024
15fca77
Merge branch 'master' into bom_master
hiker Apr 22, 2024
d862762
Merge branch 'bom_master' of github.com:hiker/fab into bom_master
hiker Apr 22, 2024
880355a
Merge branch 'create_artefact_store' into add_standard_artefacts
hiker Apr 22, 2024
e999cd1
Merge branch 'master' into 3_better_compiler_support
hiker Apr 22, 2024
fdc402c
#3 Added linker as tool.
hiker Apr 23, 2024
b50b3df
#3 Added test for linking shared libraries.
hiker Apr 23, 2024
b3806f1
#3 Pass compiler flags to the linker if a compiler was specified.
hiker Apr 23, 2024
2cf63d3
#3 Remove unused function.
hiker Apr 23, 2024
2fffe56
#3 Removed more unused code.
hiker Apr 23, 2024
7a8c293
#3 Automatically add a linker for each compiler.
hiker Apr 24, 2024
555de52
#3 Fixed typo.
hiker Apr 24, 2024
abec46d
#3 Support vendor for compiler and linker.
hiker Apr 24, 2024
d4ad3f0
#3 Make linker having a vendor, too.
hiker Apr 24, 2024
a64c9b7
#3 Add set_default_vendor method to tool repository.
hiker Apr 24, 2024
8a8781d
Ignore build directory for git.
hiker Apr 29, 2024
d967f7f
Merge branch 'master' into add_standard_artefacts
hiker Apr 29, 2024
5472d7d
Updated test.
hiker Apr 29, 2024
4c2f0d8
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Apr 29, 2024
ccbe839
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Apr 29, 2024
227a153
# Fix some mypy errors and warnings.
hiker Apr 29, 2024
b8c64b9
Avoid using get() for singleton, instead use __new__ which makes mypy…
hiker Apr 30, 2024
e309c15
Changed the transformation_script parameter of function psyclone to a…
Apr 30, 2024
31a4877
Make mypy happy by using patch.object.
hiker Apr 30, 2024
fbb15ea
Remove more comments and confusion about mypy :)
hiker Apr 30, 2024
7f52d40
Try to make mypy happy on older python versions.
hiker Apr 30, 2024
ca58d67
Make flake8 happy.
hiker Apr 30, 2024
c218bcd
Sort imported name alphabetically.
hiker Apr 30, 2024
e14d5b3
Try to fix failing hash test (and add some additional improvements in…
hiker Apr 30, 2024
0986b43
Removed fpath= for input transformation_script function to pass mypy …
Apr 30, 2024
2e15f19
Fix mypy typing check errors for psyclone unit test
Apr 30, 2024
1eeaa35
Fix config typing issue with mypy in psyclone unit test
Apr 30, 2024
a45d62b
Fix flake8 issues; Revert Config mypy typing fix
Apr 30, 2024
a4a9aab
Add comment to ignore typing check for fpath parameter of input trans…
Apr 30, 2024
5978e80
Fix assert check after transformation_script function is changed from…
Apr 30, 2024
e70885d
Filter out 'no transformation script' warning for psyclone system test
Apr 30, 2024
d2c6db0
Replace 'ignore' typing of fpath of transformation_script with removi…
Apr 30, 2024
a2ac207
#3 Support proper tests to check if tools are available.
hiker Apr 30, 2024
3a5e86a
1. Updated transformation_script description; 2. Modified mock_transf…
May 3, 2024
4ab3737
Updated lfric/atm.py and lfric/gungho.py examples to pass in transfor…
May 3, 2024
92545f8
Added description for the psyclone step to instructions on writing a …
May 3, 2024
f7cbf39
#3 Added git as a tool.
hiker May 6, 2024
632fa8c
#3 Fix incorrect | usage in typing.
hiker May 6, 2024
e0261c7
#3 Added unit tests for git.
hiker May 7, 2024
f6357a1
#3 Renamed git.py to versioning.py, to avoid name clash with the corr…
hiker May 7, 2024
042e8d8
#3 Converted svn and fcm to tools.
hiker May 8, 2024
87bce71
#3 Fixed missing whitespace.
hiker May 8, 2024
14e4f7c
Modified the documentation for writing a config with PSyclone
May 9, 2024
d38f020
Add config as a parameter for run_psyclone for the transformation_scr…
May 10, 2024
672bb9c
#3 Replaced ar with tool object.
hiker May 10, 2024
8987f99
#3 Added tests for ar.py.
hiker May 13, 2024
eee5043
#3 Removed debug output.
hiker May 13, 2024
f9fdbbb
#3 Converted PSyclone to be a tool.
hiker May 13, 2024
be36931
#3 Removed debug print, fixed python 3.7 typing information.
hiker May 13, 2024
8c790ce
#3 Updated comments.
hiker May 13, 2024
ade5f67
Modified the get_optimisation_script function examples and updated th…
May 13, 2024
15212ae
#3 Add Rsync tool.
hiker May 13, 2024
48c7543
#3 Removed now unused function.
hiker May 13, 2024
664c89c
#3 Added test for rsync.
hiker May 13, 2024
44756f7
#3 Fixed all mypy warnings about functions not checked.
hiker May 13, 2024
064ea35
#3 Replace all mock-tests to use subprocess so the name of the execut…
hiker May 13, 2024
22a1b91
#3 Remove duplicated flags.
hiker May 13, 2024
2e1b0a1
#3 Fixed changed order of linking.
hiker May 13, 2024
921daa8
#3 Removed run_command function.
hiker May 13, 2024
fc668cd
#3 Fixed 3.8 typing error.
hiker May 13, 2024
47a0a70
#3 Fixed unused imports.
hiker May 13, 2024
4389374
#3 Move flags checksum into Flags, and remove now unused tools.py file.
hiker May 14, 2024
3a015d2
#3 Renamed newtools to tools.
hiker May 14, 2024
202e274
#3 Made custom function for all git functions called (instead of just…
hiker May 14, 2024
3667030
#3 Updated and fixed comments.
hiker May 14, 2024
860d5a3
#3 Fixed errors in comments.
hiker May 14, 2024
25a1f58
Fixed minor errors in documentation.
hiker May 15, 2024
2562c22
Merge pull request #19 from hiker/18_optimisation_script
hiker May 15, 2024
72f7ab5
#3 Make it easier to create wrapper around standard compiler.
hiker May 15, 2024
53aeb62
#3 Added documentation for all tool related classes and their usage.
hiker May 15, 2024
8723a4e
#3 Added MISC category.
hiker May 21, 2024
358ae23
Addressed reviewer's comments.
hiker May 29, 2024
71e0b2f
Updated cli to properly use ToolBox etc, removing hard-coded gnu comm…
hiker May 29, 2024
b33b8b5
Merge remote-tracking branch 'origin/bom_master' into 3_better_compil…
hiker May 29, 2024
1109a88
Fixed mypy failures, including changes to import statement to avoid c…
hiker May 29, 2024
8e303f5
#3 Fix circular import.
hiker May 30, 2024
393f98a
Added #TODO so that this can be removed once fparser supports sentinels.
hiker Jun 2, 2024
2464e99
Fix typing problems by ignoring fparser.
hiker Jun 2, 2024
cce68e9
Merge pull request #21 from hiker/3_better_compiler_support
jasonjunweilyu Jun 3, 2024
8d9b5c5
Merge remote-tracking branch 'origin/bom_master' into 13_omp_sentinels
hiker Jun 3, 2024
572055a
Merge pull request #24 from hiker/13_omp_sentinels
jasonjunweilyu Jun 3, 2024
01558a2
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 3, 2024
4d85e70
Replaced more string names for artefacts with enums.
hiker Jun 4, 2024
10067a1
Removed EXECUTABLES from constants.
hiker Jun 4, 2024
137eb84
Moved Artefact class out of ArtefactStore and renamed it to ArtefactSet.
hiker Jun 4, 2024
b95611f
Moved OBJECT_FILES from constants into ArtefactSet.
hiker Jun 4, 2024
5f6625c
Moved OBJECT_ARCHIVES from constants to ArtefactSet.
hiker Jun 4, 2024
3d58184
Moved PRAGMAD_C from constants to ArtefactSet.
hiker Jun 4, 2024
f2942b1
Turned 'all_source' into an enum.
hiker Jun 4, 2024
d005c47
Allow integer as revision.
hiker Jun 4, 2024
73f91d4
Fixed flake8 error.
hiker Jun 4, 2024
6d5e82e
Removed specific functions to add/get fortran source files etc.
hiker Jun 5, 2024
37f7adc
Removed non-existing and unneccessary collections.
hiker Jun 5, 2024
ac93579
Try to fix all run_configs.
hiker Jun 4, 2024
2f633b9
Fixed rebase issues.
hiker Jun 6, 2024
03c6076
Added replace functionality to ArtefactStore, updated test_artefacts …
hiker Jun 6, 2024
499c9b5
Started to replace artefacts when files are pre-processed.
hiker Jun 6, 2024
7570696
Removed linker argument from linking step in all examples.
hiker Jun 7, 2024
41d9273
Try to get jules to link.
hiker Jun 7, 2024
56f001a
Fixed build_jules.
hiker Jun 7, 2024
8fb2be1
Fixed other issues raised in reviews.
hiker Jun 7, 2024
71cd141
Merge pull request #26 from hiker/3_better_compiler_support
jasonjunweilyu Jun 7, 2024
5b959c3
Merge branch '3_better_compiler_support' into add_standard_artefacts
hiker Jun 7, 2024
0f6c1a5
Try to get jules to link.
hiker Jun 7, 2024
588f647
Fixed other issues raised in reviews.
hiker Jun 7, 2024
cd81ce3
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 7, 2024
e857c94
Simplify handling of X90 files by replacing the X90 with x90, meaning…
hiker Jun 7, 2024
e024824
Make OBJECT_ARCHIVES also a dict, migrate more code to replace/add fi…
hiker Jun 11, 2024
a1346cf
Merge branch '3_better_compiler_support' into improve_artefact_workflow
hiker Jun 11, 2024
a0c2b98
Fixed some examples.
hiker Jun 11, 2024
169ff69
Merge branch 'master' into 3_better_compiler_support
hiker Jun 11, 2024
a34febc
Fix flake8 error.
hiker Jun 11, 2024
df893d6
Fixed failing tests.
hiker Jun 11, 2024
a2a8a54
Support empty comments.
hiker Jun 11, 2024
f03bc37
Fix preprocessor to not unnecessary remove and add files that are alr…
hiker Jun 12, 2024
7632775
Allow find_soure_files to be called more than once by adding files (n…
hiker Jun 12, 2024
e73179f
Updated lfric_common so that files created by configurator are writte…
hiker Jun 12, 2024
f7919ce
Use c_build_files instead of pragmad_c.
hiker Jun 12, 2024
50f4a42
Removed unnecessary str.
hiker Jun 12, 2024
36fa57b
Documented the new artefact set handling.
hiker Jun 13, 2024
77b2b97
Fixed typo.
hiker Jun 13, 2024
07e86d4
Make the PSyclone API configurable.
hiker Jun 13, 2024
5c895ba
Fixed formatting of documentation, properly used ArtefactSet names.
hiker Jun 13, 2024
e556115
Merge branch 'improve_artefact_workflow' into generalisation
hiker Jun 13, 2024
8a552f0
Support .f and .F Fortran files.
hiker Jun 14, 2024
f0e660d
Removed setter for tool.is_available, which was only used for testing.
hiker Jun 17, 2024
9f1ffc3
#3 Fix documentation and coding style issues from review.
hiker Jun 17, 2024
a0531a2
Renamed Categories into Category.
hiker Jun 17, 2024
4ff887c
Minor coding style cleanup.
hiker Jun 17, 2024
8a3b02d
Removed more unnecessary ().
hiker Jun 17, 2024
10ae159
Re-added (invalid) grab_pre_build call.
hiker Jun 17, 2024
622d0bd
Fixed typo.
hiker Jun 17, 2024
3f48703
Renamed set_default_vendor to set_default_compiler_suite.
hiker Jun 18, 2024
ba9245d
Renamed VendorTool to CompilerSuiteTool.
hiker Jun 18, 2024
f8c4418
Also accept a Path as exec_name specification for a tool.
hiker Jun 18, 2024
6a7aef8
Move the check_available function into the base class.
hiker Jun 18, 2024
0b73089
Fixed some types and documentation.
hiker Jun 18, 2024
7796246
Fix typing error.
hiker Jun 18, 2024
412a136
Added explanation for meta-compiler.
hiker Jun 18, 2024
8ec2227
Improved error handling and documentation.
hiker Jun 18, 2024
6d1a1ee
Replace mpiifort with mpifort to be a tiny bit more portable.
hiker Jun 18, 2024
8d4c66f
Use classes to group tests for git/svn/fcm together.
hiker Jun 18, 2024
46bc4ef
Fixed issue in get_transformation script, and moved script into lfric…
hiker Jun 18, 2024
ffdfd1a
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 18, 2024
4f436f3
Code improvement as suggested by review.
hiker Jun 19, 2024
52d5751
Fixed run config
hiker Jun 19, 2024
562d56f
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 20, 2024
ca7e477
Merge pull request #28 from hiker/add_standard_artefacts
jasonjunweilyu Jun 20, 2024
1150318
Merge branch 'improve_artefact_workflow' into generalisation
hiker Jun 20, 2024
516ec34
Added reference to ticket.
hiker Jun 20, 2024
c17545a
Merge branch 'bom_master' into improve_artefact_workflow
hiker Jun 20, 2024
19005e3
Merge branch 'improve_artefact_workflow' into generalisation
hiker Jun 20, 2024
ee2fc85
Updated type information.
hiker Jun 20, 2024
5912e59
More typing fixes.
hiker Jun 20, 2024
83ba6a1
Fixed typing warnings.
hiker Jun 21, 2024
7e66eca
As requested by reviewer removed is_working_copy functionality.
hiker Jun 21, 2024
ddd3cf2
Issue a warning (which can be silenced) when a tool in a toolbox is r…
hiker Jun 21, 2024
68bc218
Fixed flake8.
hiker Jun 21, 2024
2bdcb8c
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 21, 2024
c02729c
Fixed flake8.
hiker Jun 21, 2024
a29be95
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 21, 2024
03bed8e
Merge branch 'master' into 3_better_compiler_support
hiker Jun 24, 2024
9ccdefd
Merge branch '3_better_compiler_support' into bom_master
hiker Jun 24, 2024
00fa8b2
Merge branch '3_better_compiler_support' into improve_artefact_workflow
hiker Jun 24, 2024
c21d34f
Merge branch '3_better_compiler_support' into add_standard_artefacts
hiker Jun 24, 2024
d8fe42b
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 24, 2024
2f069c8
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 24, 2024
9abfc1d
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 24, 2024
772e79c
Merge branch 'improve_artefact_workflow' into generalisation
hiker Jun 24, 2024
c04ab9e
Fixed failing test.
hiker Jun 24, 2024
87b8012
Addressed issues raised in review.
hiker Jun 24, 2024
523e876
Removed now unnecessary operations.
hiker Jun 24, 2024
538e4da
Updated some type information.
hiker Jun 24, 2024
e3114c7
Merge pull request #29 from hiker/improve_artefact_workflow
jasonjunweilyu Jun 24, 2024
88cf3ea
Merge branch 'bom_master' into generalisation
hiker Jun 24, 2024
0f1ead3
Fixed all references to APIs to be consistent with PSyclone 2.5.
hiker Jun 25, 2024
8ab8c40
Added api to the checksum computation.
hiker Jun 25, 2024
674575e
Fixed type information.
hiker Jun 25, 2024
c980e7e
Added test to verify that changing the api changes the checksum.
hiker Jun 28, 2024
0a61359
Merge pull request #30 from hiker/generalisation
jasonjunweilyu Jul 1, 2024
ff306da
Make compiler version a tuple of integers
Jul 16, 2024
c5b1b02
Update some tests to use tuple versions
Jul 16, 2024
ccf4ad8
Explicitly test handling of bad version format
Jul 16, 2024
fd02c8c
Fix formatting
Jul 16, 2024
10eb726
Tidying up
Jul 16, 2024
ea18256
Make compiler raise an error for any invalid version string
Jul 18, 2024
6e6579a
Merge remote-tracking branch 'origin/master' into bom_master
hiker Jul 19, 2024
932f401
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Jul 19, 2024
120116c
Check compiler version string for compiler name
Jul 22, 2024
5a24c24
Fix formatting
Jul 23, 2024
dbc3d73
Add compiler.get_version_string() method
Jul 24, 2024
90adcca
Add mpi and openmp settings to BuildConfig, made compiler MPI aware.
hiker Jul 24, 2024
150dc37
Looks like the circular dependency has been fixed.
hiker Jul 24, 2024
db34597
Revert "Looks like the circular dependency has been fixed." ...
hiker Jul 24, 2024
7c347c8
Don't even try to find a C compiler if no C files are to be compiled.
hiker Jul 24, 2024
ff71393
Updated gitignore to ignore (recently renamed) documentation.
hiker Jul 25, 2024
5dc01f3
Fixed failing test.
hiker Jul 25, 2024
2b5c4bd
Return from compile Fortran early if there are no files to compiles. …
hiker Jul 25, 2024
46706c5
Add MPI enables wrapper for intel and gnu compiler.
hiker Jul 25, 2024
d55344f
Fixed test.
hiker Jul 25, 2024
d00c187
Automatically add openmp flag to compiler and linker based on BuildCo…
hiker Jul 25, 2024
e9333fd
Removed enforcement of keyword parameters, which is not supported in …
hiker Jul 25, 2024
a85bc7a
Fixed failing test.
hiker Jul 25, 2024
6c8e8df
Support more than one tool of a given suite by sorting them.
hiker Jul 26, 2024
3bb726e
Use different version checkout for each compiler vendor with mixins
Jul 26, 2024
286d457
Refactoring, remove unittest compiler class
Jul 26, 2024
dae9102
Fix some mypy errors
Jul 28, 2024
cdcc023
Use 'Union' type hint to fix build checks
Jul 28, 2024
0bdb734
Return run_version_command to base Compiler class
Jul 29, 2024
b97ec50
Add a missing type hint
Jul 29, 2024
b1b4057
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Jul 29, 2024
5b51aa1
Merge pull request #13 from hiker/update_bom_master_to_upstream_master
jasonjunweilyu Jul 30, 2024
19eab9f
Remove inheritance from mixins and use protocol
Aug 2, 2024
cbe1cb8
Simplify compiler inheritance
Aug 2, 2024
bf81dee
Merge pull request #9 from hiker/version_tuples
hiker Aug 2, 2024
196e034
Merge branch 'bom_master' into mpi_omp_support
hiker Aug 2, 2024
3076715
Simplify usage of compiler-specific parsing mixins.
hiker Aug 7, 2024
7a50859
Test for missing mixin.
hiker Aug 7, 2024
749fa2d
Fixed test.
hiker Aug 7, 2024
20fef2c
Merge branch 'version_tuples' into mpi_omp_support
hiker Aug 8, 2024
9598c09
Added more tests for invalid version numbers.
hiker Aug 9, 2024
5c6f99f
Added more test cases for invalid version number, improved regex to w…
hiker Aug 9, 2024
c1eb158
Fixed typo in test.
hiker Aug 9, 2024
1524777
Merge branch 'version_tuples' into mpi_omp_support
hiker Aug 9, 2024
02fbb7b
Fixed test.
hiker Aug 12, 2024
955befc
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Aug 12, 2024
552e4cc
Merge pull request #18 from hiker/version_tuples
lukehoffmann Aug 12, 2024
b38cdb8
Merge remote-tracking branch 'upstream/master' into mpi_omp_support
hiker Aug 12, 2024
6826c85
Merge remote-tracking branch 'upstream/master' into version_tuples
hiker Aug 13, 2024
e5aca3b
Merge branch 'version_tuples' into mpi_omp_support
hiker Aug 13, 2024
ccbe810
Split tests into smaller individual ones, fixed missing asssert in test.
hiker Aug 14, 2024
f8f8ab0
Parameterised compiler version tests to also test wrapper.
hiker Aug 14, 2024
1543841
Added missing MPI parameter when getting the compiler.
hiker Aug 14, 2024
cd8ec62
Fixed comments.
hiker Aug 14, 2024
13935c0
Order parameters to be in same order for various compiler classes.
hiker Aug 14, 2024
de80c44
Merge branch 'bom_master' into mpi_omp_support
hiker Aug 14, 2024
009478f
Merge remote-tracking branch 'origin/bom_master' into mpi_omp_support
hiker Aug 14, 2024
7887d24
Remove stray character
Aug 16, 2024
83836e7
Merge pull request #14 from hiker/mpi_omp_support
lukehoffmann Aug 16, 2024
a79b41d
Merge remote-tracking branch 'MetOffice/master' into bom_master
Aug 21, 2024
2617322
Made mpi and openmp default to False in the BuildConfig constructor.
hiker Oct 21, 2024
f165e46
Removed white space.
hiker Oct 21, 2024
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
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ __pycache__/
*$py.class

# Build directory for documentation
docs/build
docs/source/api
docs/source/apidoc
Documentation/build
Documentation/source/api
Documentation/source/apidoc

# C extensions
*.so
Expand Down
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',
tool_box=ToolBox()) as state:
mpi=False, 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)
4 changes: 2 additions & 2 deletions 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',
tool_box=ToolBox()) as state:
mpi=False, openmp=False, tool_box=ToolBox()) as state:
common_build_steps(state, fpic=True)
link_shared_object(state, output_fpath='$output/libgcom.so'),
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}',
tool_box=ToolBox())
mpi=False, openmp=False, tool_box=ToolBox())


if __name__ == '__main__':
Expand Down
19 changes: 12 additions & 7 deletions run_configs/jules/build_jules.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ def __init__(self):
tool_box.add_tool(Linker(compiler=fc))

with BuildConfig(project_label=f'jules {revision} $compiler',
tool_box=tool_box) as state:
# grab the source. todo: use some checkouts instead of exports in these configs.
fcm_export(state, src='fcm:jules.xm_tr/src', revision=revision, dst_label='src')
fcm_export(state, src='fcm:jules.xm_tr/utils', revision=revision, dst_label='utils')
mpi=False, openmp=False, tool_box=tool_box) as state:
# grab the source. todo: use some checkouts instead of exports
# in these configs.
fcm_export(state, src='fcm:jules.xm_tr/src', revision=revision,
dst_label='src')
fcm_export(state, src='fcm:jules.xm_tr/utils', revision=revision,
dst_label='utils')

grab_pre_build(state, path='/not/a/real/folder', allow_fail=True),
grab_pre_build(state, path='/not/a/real/folder', allow_fail=True)

# find the source files
find_source_files(state, path_filters=[
Expand All @@ -61,9 +64,11 @@ def __init__(self):
# move inc files to the root for easy tool use
root_inc_files(state)

preprocess_fortran(state, common_flags=['-P', '-DMPI_DUMMY', '-DNCDF_DUMMY', '-I$output'])
preprocess_fortran(state, common_flags=['-P', '-DMPI_DUMMY',
'-DNCDF_DUMMY', '-I$output'])

analyse(state, root_symbol='jules', unreferenced_deps=['imogen_update_carb'])
analyse(state, root_symbol='jules',
unreferenced_deps=['imogen_update_carb'])

compile_fortran(state)

Expand Down
2 changes: 1 addition & 1 deletion run_configs/lfric/atm.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def file_filtering(config):
gpl_utils_source = gpl_utils_source_config.source_root / 'gpl_utils'

with BuildConfig(project_label='atm $compiler $two_stage',
tool_box=ToolBox()) as state:
mpi=False, openmp=False, tool_box=ToolBox()) as state:

# todo: use different dst_labels because they all go into the same folder,
# making it hard to see what came from where?
Expand Down
10 changes: 6 additions & 4 deletions run_configs/lfric/grab_lfric.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
# these configs are interrogated by the build scripts
# todo: doesn't need two separate configs, they use the same project workspace
tool_box = ToolBox()
lfric_source_config = BuildConfig(project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box)
gpl_utils_source_config = BuildConfig(project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box)
lfric_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
mpi=False, openmp=False, tool_box=tool_box)
gpl_utils_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
mpi=False, openmp=False, tool_box=tool_box)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion 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',
tool_box=ToolBox()) as state:
mpi=False, openmp=False, 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
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',
tool_box=ToolBox()) as state:
mpi=False, 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
14 changes: 7 additions & 7 deletions run_configs/tiny_fortran/build_tiny_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def __init__(self):
tool_box.add_tool(Linker(compiler=fc))

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

find_source_files(state),
find_source_files(state)

preprocess_fortran(state),
preprocess_fortran(state)

analyse(state, root_symbol='my_prog'),
analyse(state, root_symbol='my_prog')

compile_fortran(state),
link_exe(state),
compile_fortran(state)
link_exe(state)
5 changes: 3 additions & 2 deletions run_configs/um/build_um.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def replace_in_file(inpath, outpath, find, replace):
revision = 'vn12.1'
um_revision = revision.replace('vn', 'um')

state = BuildConfig(project_label=f'um atmos safe {revision} $compiler $two_stage',
tool_box=ToolBox())
state = BuildConfig(
project_label=f'um atmos safe {revision} $compiler $two_stage',
mpi=False, openmp=False, tool_box=ToolBox())

# compiler-specific flags
compiler = state.tool_box[Category.FORTRAN_COMPILER]
Expand Down
105 changes: 74 additions & 31 deletions source/fab/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

from fab.artefacts import ArtefactSet, ArtefactStore
from fab.constants import BUILD_OUTPUT, SOURCE_ROOT, PREBUILD
from fab.metrics import send_metric, init_metrics, stop_metrics, metrics_summary
from fab.metrics import (send_metric, init_metrics, stop_metrics,
metrics_summary)
from fab.tools.category import Category
from fab.tools.tool_box import ToolBox
from fab.steps.cleanup_prebuilds import CLEANUP_COUNT, cleanup_prebuilds
Expand All @@ -41,36 +42,50 @@ class BuildConfig():
"""
def __init__(self, project_label: str,
tool_box: ToolBox,
multiprocessing: bool = True, n_procs: Optional[int] = None,
mpi: bool,
openmp: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an argument for making these optional with a default to False but that is not an argument we need to have now. It's always possible to make an interface more permissive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in our meeting, I've made False the default, and updated tests and run_configs.

multiprocessing: bool = True,
n_procs: Optional[int] = None,
reuse_artefacts: bool = False,
fab_workspace: Optional[Path] = None, two_stage=False,
verbose=False):
fab_workspace: Optional[Path] = None,
two_stage: bool = False,
verbose: bool = False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general observation that this argument list is getting pretty unwieldy. Something to consider at a future date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that seems unavoidable - in a complex build systems there are a lot of things to be defined :) Now that mpi/openmp are optional, it might be better? Also, this mostly will be handled by the command line tool in the end, which should have an appropriate man page/help command.

"""
:param project_label:
Name of the build project. The project workspace folder is created from this name, with spaces replaced
by underscores.
Name of the build project. The project workspace folder is
created from this name, with spaces replaced by underscores.
:param tool_box: The ToolBox with all tools to use in the build.
:param mpi: whether the project uses MPI or not. This is used to
pick a default compiler (if not explicitly set in the ToolBox),
and controls PSyclone parameters.
:param openmp: whether the project should use OpenMP or not.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument presumably has the same caveats as the previous one. Is there a way to cover this without repeating boiler plate? Either group them and have some group documentation or with suitable wording.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. We looked at all compiolers to be reasonably expected to be used (intel-classic, intel-llvm, gnu, clang, cray, nvidia) all of which support openmp.

:param multiprocessing:
An option to disable multiprocessing to aid debugging.
:param n_procs:
The number of cores to use for multiprocessing operations. Defaults to the number of available cores.
The number of cores to use for multiprocessing operations.
Defaults to the number of available cores.
:param reuse_artefacts:
A flag to avoid reprocessing certain files on subsequent runs.
WARNING: Currently unsophisticated, this flag should only be used by Fab developers.
The logic behind flag will soon be improved, in a work package called "incremental build".
WARNING: Currently unsophisticated, this flag should only be
used by Fab developers. The logic behind flag will soon be
improved, in a work package called "incremental build".
:param fab_workspace:
Overrides the FAB_WORKSPACE environment variable.
If not set, and FAB_WORKSPACE is not set, the fab workspace defaults to *~/fab-workspace*.
If not set, and FAB_WORKSPACE is not set, the fab workspace
defaults to *~/fab-workspace*.
:param two_stage:
Compile .mod files first in a separate pass. Theoretically faster in some projects..
Compile .mod files first in a separate pass. Theoretically faster
in some projects.
:param verbose:
DEBUG level logging.

"""
self._tool_box = tool_box
self._mpi = mpi
self._openmp = openmp
self.two_stage = two_stage
self.verbose = verbose
compiler = tool_box[Category.FORTRAN_COMPILER]
compiler = tool_box.get_tool(Category.FORTRAN_COMPILER, mpi=mpi)
project_label = Template(project_label).safe_substitute(
compiler=compiler.name,
two_stage=f'{int(two_stage)+1}stage')
Expand All @@ -83,7 +98,8 @@ def __init__(self, project_label: str,
logger.info(f"fab workspace is {fab_workspace}")

self.project_workspace: Path = fab_workspace / self.project_label
self.metrics_folder: Path = self.project_workspace / 'metrics' / self.project_label
self.metrics_folder: Path = (self.project_workspace / 'metrics' /
self.project_label)

# source config
self.source_root: Path = self.project_workspace / SOURCE_ROOT
Expand All @@ -93,7 +109,8 @@ def __init__(self, project_label: str,
self.multiprocessing = multiprocessing

# turn off multiprocessing when debugging
# todo: turn off multiprocessing when running tests, as a good test runner will run using mp
# todo: turn off multiprocessing when running tests, as a good test
# runner will run using mp
if 'pydevd' in str(sys.gettrace()):
logger.info('debugger detected, running without multiprocessing')
self.multiprocessing = False
Expand Down Expand Up @@ -129,7 +146,8 @@ def __enter__(self):
self._start_time = datetime.now().replace(microsecond=0)
self._run_prep()

with TimerLogger(f'running {self.project_label} build steps') as build_timer:
with TimerLogger(f'running {self.project_label} '
f'build steps') as build_timer:
# this will return to the build script
self._build_timer = build_timer
return self
Expand All @@ -138,10 +156,12 @@ def __exit__(self, exc_type, exc_val, exc_tb):

if not exc_type: # None if there's no error.
if CLEANUP_COUNT not in self.artefact_store:
logger.info("no housekeeping step was run, using a default hard cleanup")
logger.info("no housekeeping step was run, using a "
"default hard cleanup")
cleanup_prebuilds(config=self, all_unused=True)

logger.info(f"Building '{self.project_label}' took {datetime.now() - self._start_time}")
logger.info(f"Building '{self.project_label}' took "
f"{datetime.now() - self._start_time}")

# always
self._finalise_metrics(self._start_time, self._build_timer)
Expand All @@ -164,9 +184,20 @@ def build_output(self) -> Path:
'''
return self.project_workspace / BUILD_OUTPUT

@property
def mpi(self) -> bool:
''':returns: whether MPI is requested or not in this config.'''
return self._mpi

@property
def openmp(self) -> bool:
''':returns: whether OpenMP is requested or not in this config.'''
return self._openmp

def add_current_prebuilds(self, artefacts: Iterable[Path]):
"""
Mark the given file paths as being current prebuilds, not to be cleaned during housekeeping.
Mark the given file paths as being current prebuilds, not to be
cleaned during housekeeping.

"""
self.artefact_store[ArtefactSet.CURRENT_PREBUILDS].update(artefacts)
Expand All @@ -193,7 +224,8 @@ def _prep_folders(self):
def _init_logging(self):
# add a file logger for our run
self.project_workspace.mkdir(parents=True, exist_ok=True)
log_file_handler = RotatingFileHandler(self.project_workspace / 'log.txt', backupCount=5, delay=True)
log_file_handler = RotatingFileHandler(
self.project_workspace / 'log.txt', backupCount=5, delay=True)
log_file_handler.doRollover()
logging.getLogger('fab').addHandler(log_file_handler)

Expand All @@ -207,9 +239,11 @@ def _init_logging(self):
def _finalise_logging(self):
# remove our file logger
fab_logger = logging.getLogger('fab')
log_file_handlers = list(by_type(fab_logger.handlers, RotatingFileHandler))
log_file_handlers = list(by_type(fab_logger.handlers,
RotatingFileHandler))
if len(log_file_handlers) != 1:
warnings.warn(f'expected to find 1 RotatingFileHandler for removal, found {len(log_file_handlers)}')
warnings.warn(f'expected to find 1 RotatingFileHandler for '
f'removal, found {len(log_file_handlers)}')
fab_logger.removeHandler(log_file_handlers[0])

def _finalise_metrics(self, start_time, steps_timer):
Expand Down Expand Up @@ -249,14 +283,16 @@ def __init__(self, match: str, flags: List[str]):
# For source in the um folder, add an absolute include path
AddFlags(match="$source/um/*", flags=['-I$source/include']),

# For source in the um folder, add an include path relative to each source file.
# For source in the um folder, add an include path relative to
# each source file.
AddFlags(match="$source/um/*", flags=['-I$relative/include']),

"""
self.match: str = match
self.flags: List[str] = flags

# todo: we don't need the project_workspace, we could just pass in the output folder
# todo: we don't need the project_workspace, we could just pass in the
# output folder
def run(self, fpath: Path, input_flags: List[str], config):
"""
Check if our filter matches a given file. If it does, add our flags.
Expand All @@ -269,12 +305,16 @@ def run(self, fpath: Path, input_flags: List[str], config):
Contains the folders for templating `$source` and `$output`.

"""
params = {'relative': fpath.parent, 'source': config.source_root, 'output': config.build_output}
params = {'relative': fpath.parent,
'source': config.source_root,
'output': config.build_output}

# does the file path match our filter?
if not self.match or fnmatch(str(fpath), Template(self.match).substitute(params)):
if not self.match or fnmatch(str(fpath),
Template(self.match).substitute(params)):
# use templating to render any relative paths in our flags
add_flags = [Template(flag).substitute(params) for flag in self.flags]
add_flags = [Template(flag).substitute(params)
for flag in self.flags]

# add our flags
input_flags += add_flags
Expand All @@ -284,15 +324,18 @@ class FlagsConfig():
"""
Return command-line flags for a given path.

Simply allows appending flags but may evolve to also replace and remove flags.
Simply allows appending flags but may evolve to also replace and
remove flags.

"""
def __init__(self, common_flags: Optional[List[str]] = None, path_flags: Optional[List[AddFlags]] = None):
def __init__(self, common_flags: Optional[List[str]] = None,
path_flags: Optional[List[AddFlags]] = None):
"""
:param common_flags:
List of flags to apply to all files. E.g `['-O2']`.
:param path_flags:
List of :class:`~fab.build_config.AddFlags` objects which apply flags to selected paths.
List of :class:`~fab.build_config.AddFlags` objects which apply
flags to selected paths.

"""
self.common_flags = common_flags or []
Expand All @@ -311,8 +354,8 @@ def flags_for_path(self, path: Path, config):

"""
# We COULD make the user pass these template params to the constructor
# but we have a design requirement to minimise the config burden on the user,
# so we take care of it for them here instead.
# but we have a design requirement to minimise the config burden on
# the user, so we take care of it for them here instead.
params = {'source': config.source_root, 'output': config.build_output}
flags = [Template(i).substitute(params) for i in self.common_flags]

Expand Down
Loading