[Feature] Two-way python bridge with limited MAPL support in Python#4369
[Feature] Two-way python bridge with limited MAPL support in Python#4369FlorianDeconinck wants to merge 18 commits intodevelopfrom
Conversation
|
We will have a meeting this afternoon to take a quick look. A deeper dive will wait until next week. |
Restrict it to known SIGFPE issue on numpy import
|
Python API updated to simplify retrieving memory. Now you can do MAPLPy = get_MAPLPy()
T = MAPLPy.get_pointer("T", state=import_state, dtype=np.float32, dims=MAPLPy.grid_dims)and you get Fortran memory mapping in |
|
Well, that coupled CI failure is weird. I'm re-running it. |
|
With the latest round of Python work I believe we have reached MVP - review away! |
|
I tested with NAG by hand and it's happy too. |
Replace GridComp by MaplComp
Add a larger bypass IEEE importer with other packages used in DSL
| @@ -0,0 +1,142 @@ | |||
| #include "MAPL_Generic.h" | |||
There was a problem hiding this comment.
Drop MAPL_ from the file name.
tclune
left a comment
There was a problem hiding this comment.
There are a few naming convention changes that I think would be good. (There will be more for MAPL3 issues, but we can handle those later.)
Biggest question is where the bridge is initialized?
|
@tclune aptly pointed out the file naming is a bit random, I am going to a pass to clarify it all |
Types of change(s)
Checklist
make tests)Description
This PR aims at solving the "90%" case of Python integration has it as been seen lately at GMAO. The main features are:
The entire API is heavily
#ifdefby a flag at compile timeBUILD_PYTHONBRIDGE- by default the functions are passthroughs.Review points
@tclune / @atrayano: it was non-trivial for me to find a spot where I could initialize the system with the atmospheric grid. I ended up calling in
GEOSAgcm_GridComp(see sister PR). This is only needed because right now the bridge back to MAPL gives me the pointer "blind", without sizes and rank. So I am giving the GRID to users so we can tool down.A better version would be to augment the "MAPLpy" bridge to get shape and ranks, but I'd like to see that in a subsequent version so we can stress test this bridge first.
@mathomp4: I ended up not feeding the
add_definitionsupstream like we talked about. I kept it within theMAPL.python_bridgecmakelist and forwarded the API there. This looks cleaner and achieve the "opt-in by default" behavior we wanted.@pchakraborty: You should find the design quite familiar. It's a CFFI bridge, like we've done before. The trick relies in the
_get_code_object_from_package_namewhere I dynamically load the user given module and search for aCODEobject. The README spells it out with some code. The rest is marshalling up & down memory viavoid*.