-
Notifications
You must be signed in to change notification settings - Fork 188
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
Refactor ghosts.cpp #3216
Refactor ghosts.cpp #3216
Conversation
GhostCommunicator::mpi_comm does not appear in ghosts.cpp. Function ghosts_communicator() uses only global comm_cart, so not even the comment of this field is correct anymore.
- Remove static buffers - Group data and bond buffers together - Factor out memory handling
This is now handled by sending the bond buffer as std::vector and boost::mpi.
Removes one level on indentation from ghost_communicator()
Codecov Report
@@ Coverage Diff @@
## python #3216 +/- ##
=======================================
+ Coverage 85% 85% +<1%
=======================================
Files 528 528
Lines 25790 25733 -57
=======================================
- Hits 22148 22116 -32
+ Misses 3642 3617 -25
Continue to review full report at Codecov.
|
@RudolfWeeber Sure! Just propose a time and date. |
I'll have a look at the changes today, and then we can decide how to proceed with this. |
This looks good to me. I'd plan to do something similar in the future but did not get around to it yet, so thank you :-). I've made some cosmetic changes and made a clearer separation between the two archiver classes so that they can be tested better in the future. Please let me now if you are d'accord with this, I did not mean to hijack your PR. |
@fweik Feel free to hijack any PR you like. :) I'm totally fine with your changes, they definitely improve this PR. Thanks! |
src/core/ghosts.cpp
Outdated
max_s_buffer = n_s_buffer; | ||
s_buffer = Utils::realloc(s_buffer, max_s_buffer); | ||
} | ||
s_buffer.resize(calc_transmit_size(gc, data_parts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of the code would be easier to read if the variable names would be just a little more descriptive: e.g.:
send_buffer
instead ofs_buffer
,rec_buffer
instead ofr_buffer
,ghost_comm
instead ofgc
,archiver
instead ofar
,bond_archiver
instead ofbar
,bond_list
instead ofbl
,part
instead ofpt
,part_list
instead ofcur_list
src/core/ghosts.cpp
Outdated
static int max_s_buffer = 0; | ||
/** send buffer. Just grows, which should be ok */ | ||
static char *s_buffer = nullptr; | ||
struct CommBuf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a docstring for the struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also think about using class
instead of struct
here. core guideline
src/core/ghosts.cpp
Outdated
/* send op; write back delayed data from last recv, when this was a | ||
* prefetch send. */ | ||
/* find previous action where we recv and which has PSTSTORE set */ | ||
auto postst_gcn = std::find_if( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please find a readable name for this variable
@KaiSzuttor Thanks for the suggestions. Done. I now implemented the following convention in both, ghosts.hpp and ghosts.cpp:
The latter one is not very descriptive but that is by choice. Otherwise there would be too much similarity to ghost_communication/ghost_comm/... which is also irritating. If anyone can think of a better combination of names, please tell me. Also, I sneaked in two more changes: Another pointer->reference conversion and the removal of two superfluous pointer variables in cell_cell_transfer. Could you please take another look at these? |
bors r=KaiSzuttor |
3216: Refactor ghosts.cpp r=KaiSzuttor a=hirschsn More refactoring that builds upon #3212 Description of *major* changes: - remove GhostCommunication::mpi_comm as it is not used in ghosts.cpp, - make GhostCommunication::part_lists a std::vector, - remove static variables s_buffer and r_buffer, - factor out memory handling, - change loops to range based for, - use boost::mpi. - Replace the manual poststore and prefetch loops by find_ifs Mainly, ghosts.cpp now defines CommBuf, which is a container for the data to be sent or received as well as two classes (Archiver and BondArchiver), that insert and extract the memory from CommBuf. Some of these changes, like the removal of static variables, is necessary for my implementation of asynchronous ghost communication. PR Checklist ------------ - [ ] Tests? - [ ] Interface - [ ] Core - [ ] Docs? 3239: Added test criteria for the charged_system-2 tutorial r=RudolfWeeber,jngrad a=reinaual 3253: Refactor NpT public interface r=fweik a=jngrad Description of changes: - remove the silent conversion of the incorrect input parameter `dimension=[0,0,0]` to `[1,1,1]` in the core (bypassing sanity checks), now the checks will throw an exception for fixed-volume NpT; the original behavior was counter-intuitive and undocumented until 2 days ago - remove the automatic decay of NpT to NVT upon initialization of NpT with incorrect parameters - remove unused `p_inst_av` variable (average instantaneous pressure) - cleanup integrator documentation 3258: CMake minor fixes r=fweik a=jngrad Description of changes: - change next milestone to 4.2 - load `GNUInstallDirs` to make standard GNU paths accessible from CMake variables - simplify CMake logic and install in `python3.X` folder instead of the deprecated `python3` folder - add extra check to make sure install paths are correctly configured (all python and shared object files must be inside the package `espressomd`) Co-authored-by: Steffen Hirschmann <[email protected]> Co-authored-by: Florian Weik <[email protected]> Co-authored-by: Alexander Reinauer <[email protected]> Co-authored-by: Jean-Noël Grad <[email protected]>
Build succeeded |
More refactoring that builds upon #3212
Description of major changes:
Mainly, ghosts.cpp now defines CommBuf, which is a container for the data to be sent or received as well as two classes (Archiver and BondArchiver), that insert and extract the memory from CommBuf.
Some of these changes, like the removal of static variables, is necessary for my implementation of asynchronous ghost communication.
PR Checklist