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

Allow asynchronous building of gtscript stencils. (gt4py.cartesian) #1242

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gronerl
Copy link
Contributor

@gronerl gronerl commented Apr 24, 2023

Fixes #83

This PR implements asynchronous building of stencils in cartesian gtscript (PR affects only gt4py.cartesian)

API:

  • The eager keyword to the lazy_stencil decorator is extended. It can now be set to "async" which will schedule compilation immediately asynchronously. Wait is triggered by accessing LazyStencil.implementation (e.g. by means of __call__)
  • There is also a wait_all() function in gt4py.cartesian.stencil_builder that is a barrier that can be used
  • The maximum number of building processes is controlled through basically this:
build_settings: Dict[str, Any] = {
 # some more options omitted   
 "max_async_build_proc": os.environ.get("GT_MAX_ASYNC_BUILD_PROC", mp.cpu_count()),
}

ToDo:

  • stress-test e.g. by means of use in pace
  • update docs

Note that since StencilObject can not be pickled, it can't be returned from multiprocessing / result of concurrent.future with a ProcessPoolExecutor. In the implementation at hand, instead the load step is run multiple times (once in the building child process and once in the main process). If this is ok is to be seen (e.g. from `pace).

@gronerl
Copy link
Contributor Author

gronerl commented Apr 24, 2023

Implements #83

@gronerl
Copy link
Contributor Author

gronerl commented Jun 30, 2023

Since lazy_stencil is undocumented outside of the docstring, I just updated the docstring, without adding additional files.

@gronerl gronerl marked this pull request as ready for review June 30, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asynchronous (non-blocking) compilation of multiple stencils
1 participant