-
Notifications
You must be signed in to change notification settings - Fork 58
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
migration of mprans to xtensor #1068
Conversation
875e15f
to
39cc52f
Compare
Codecov Report
@@ Coverage Diff @@
## master #1068 +/- ##
==========================================
- Coverage 50.21% 50.2% -0.01%
==========================================
Files 528 528
Lines 101550 101588 +38
==========================================
+ Hits 50993 51004 +11
- Misses 50557 50584 +27
Continue to review full report at Codecov.
|
2905dfa
to
d69e1cf
Compare
@cekees @tridelat @zhang-alvin This PR is almost ready to go. I think it could be nice to merge it as soon as possible to avoid having a lot of conflicts, since we're changing a lot the APIs. There is still an issue with the hdist build: the file RANS3PF takes too long to build, leading to a travis timeout. Splitting the file does not fix the problem. I am pretty sure that it is due to the high number of arguments of the functions exposed to the Python. Notice that the conda build is fine. We have three options here: we can pass the hdist biuld as "allow to fail" until we have replaced the list of arguments with a dictionnary of arguments. Or I can start to implement the dictionnary of arguments in this PR and use it in this problematic file. Or I can revert the changes in RANS3PF and keep the cython implementation for now. I prefer the first option since it allows this PR to get merged faster and avoid potential conflicts in the future. Let me know what you prefer. |
@JohanMabille the main source of the long compile times is the c++ compile of our template instances at high optimization levels. On the hashdist side we turn off optimization by default in the setup file as per below. I think this was commented out for conda because we weren't carefully replacing the "-Wl,-O*" options, but I've fixed that below and tested that conda compiles proteus without problems (and quickly) on my laptop. I think generally we want the conda binary on conda forge to use optimization but turn it off and enable debugging of our travis builds.
|
I will try to disable optimizations and see what it says, I agree that it would be more helpful to have the API with EDIT: I think we should enable these optimizations again as soon as possible since some errors can be caught in Release mode only) |
@JohanMabille note that you can't just uncomment the old setup modifications. You need to use what I posted above, particularly Otherwise the conda build will likely fail. |
@tridelat @zhang-alvin @ejtovar This PR swaps out cython wrapping for pybind11 and xtensor arrays for double*. As @JohanMabille mentioned, it doesn't yet reduce the size of the call signatures by directly passing the q, ebqe, etc. dict structures into C++, which is the objective. I do think the pybind11 and xtensor array approach is a signficant improvement as long as you guys can verify that we're not suffering a performance hit on some real problems. In this interim approach, to use a new array in C++ you'll still need to modify the .py, .h, and .cpp file of a model (the latter takes the place of the pyx file in cython), roughly the equivalent amount of your time as currently modifying .py, .h, and .pyx file. However, you can use multi-dimensional array indexing in c++ and other nice features of xtensor arrays. If are happy with this approach and can verify that you're ready to start using it moving forward, then I agree we should go ahead and merge this. On the other hand, going the next step of replacing the multiple xtensor arrays with some kind of dictionary/dataframe would compete the full task but make the differences a bit larger. @SylvainCorlay could you update us on the status of xframe or similar (xrecord?) which we discussed early on? Our q, ebqe, etc., dictionaries are essentially named dataframes with the last (inner) dimension being variable (e.g. scalar, vector, tensor). I don't think that works with a pandas dataframe at present, though perhaps we could define our on vector and tensor types. Just directly using the existing dictionaries via pybind11 objects seems the simplest path forward. |
This is now ready to go! |
Apologies for not looking into this sooner. I've recently completed the repository cleanup so all of the commits on the feature branch need to be rebased on-top of the revised master branch. |
It is unfortunate that we need to rebase so many files with the repository cleanup! Hopefully this will remain a mechanical update. @cekees this PR already removes a lot of code by avoiding the Cython signature duplication. As we did not want to change everything at once, we figured moving to xtensor structures would be a good intermediary step. Regarding xframe, the choice to use xframe directly or another "dict of tensors" approach may depend on whether you want to use axes and named dimensions in proteus. We should definitely discuss this further. |
I'm going to ahead and merge this, so we can move forward. |
Thanks @zhang-alvin ! Out of curiosity, why merging the master branch into the PR's branch (in genral) when there is no conflict instead of directly merging the PR into master? I think this (merging master into the PR) makes the history more complex and makes the rebasing of other PRs more difficult. If there are conflicts, I think rebasing the PR is a better option since it keeps the history clean. |
I had just merged #1075 before merging this PR which introduced a conflict, which was resolved through the merge with master. As for why not rebasing in this case, I felt like it would be another unnecessary detour to get this merged: you'd need to be alerted of the conflict, then you'd rebase, then the tests run, then we can merge. With the time zone differences, it appears to be a lot of effort when the PR will just be squash merged anyway. This probably merits a proper discussion among the developers. |
* Added xtensor-python to environment.yaml * AddedMass based on xtensor * xtensor * SedClosure based on xtensor * VOF3P based on xtensor * NCLS3P based on xtensor * Moved mprans2/setup.py into proteus/setup.py * MCorr3P based on xtensor * Install xtensor for hashdist * Add PROTEUS_OPT compilation options for xtensor-based extensions * mprans.RANS3PSed * mprans.RANS3PSed2D * Moved RANS3PSed to mprans * Add calculateVelocityAverage * Dissipation2D * VOS3P * PresInc * Dissipation * CLSVOF * NCLS * MCorr * RANS2P * RANS2P2D * RANS2P_IB * Travis parallel compilation disabled * RDLS * VOF * MoveMesh * MoveMesh2D * SW2D * SW2DCV * GN_SW2DCV * Fixed AddedMass * Fixed VOF3P * Fixed NCLS3P * Fixed MCorr3P * Kappa and Kappa2D * RANS3PF * SedClosure.h * Splitted RANS3PF.h and RANS3PF2D.h * Disabled optimizations * Fixed build after rebase * Reverted RANS3PF and enabled optimizations again Co-authored-by: David Brochart <[email protected]> Co-authored-by: Alvin Zhang <[email protected]>
Based on #1054 to trigger the CI. Both PRs will be merged in the end.