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

Refactor ghosts.cpp #3216

Merged
merged 40 commits into from
Oct 18, 2019
Merged

Refactor ghosts.cpp #3216

merged 40 commits into from
Oct 18, 2019

Conversation

hirschsn
Copy link
Contributor

@hirschsn hirschsn commented Sep 26, 2019

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?

@jngrad jngrad added this to the Espresso 5 milestone Sep 26, 2019
@codecov
Copy link

codecov bot commented Sep 27, 2019

Codecov Report

Merging #3216 into python will increase coverage by <1%.
The diff coverage is 98%.

Impacted file tree graph

@@           Coverage Diff           @@
##           python   #3216    +/-   ##
=======================================
+ Coverage      85%     85%   +<1%     
=======================================
  Files         528     528            
  Lines       25790   25733    -57     
=======================================
- Hits        22148   22116    -32     
+ Misses       3642    3617    -25
Impacted Files Coverage Δ
src/utils/tests/Span_test.cpp 100% <100%> (ø) ⬆️
src/core/nsquare.cpp 100% <100%> (ø) ⬆️
src/core/domain_decomposition.cpp 94% <100%> (-1%) ⬇️
src/utils/include/utils/Span.hpp 100% <100%> (ø) ⬆️
src/core/ghosts.hpp 100% <100%> (ø) ⬆️
src/core/layered.cpp 78% <50%> (ø) ⬆️
src/core/ghosts.cpp 99% <99%> (+8%) ⬆️
src/core/particle_data.cpp 96% <0%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b7b357...f21d717. Read the comment docs.

@hirschsn hirschsn changed the title More ghost cleanup Refactor ghosts.cpp Sep 27, 2019
@hirschsn
Copy link
Contributor Author

@RudolfWeeber Sure! Just propose a time and date.

@fweik
Copy link
Contributor

fweik commented Oct 1, 2019

I'll have a look at the changes today, and then we can decide how to proceed with this.

@fweik fweik self-assigned this Oct 1, 2019
@fweik
Copy link
Contributor

fweik commented Oct 1, 2019

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 fweik requested a review from KaiSzuttor October 1, 2019 14:53
@RudolfWeeber
Copy link
Contributor

@hirschsn, @fweik, either during the summer school or the week after. Letś organize it offline, once Iḿ back on the 7th.

@hirschsn
Copy link
Contributor Author

hirschsn commented Oct 1, 2019

@fweik Feel free to hijack any PR you like. :) I'm totally fine with your changes, they definitely improve this PR. Thanks!
@RudolfWeeber just ping me when you're back.

max_s_buffer = n_s_buffer;
s_buffer = Utils::realloc(s_buffer, max_s_buffer);
}
s_buffer.resize(calc_transmit_size(gc, data_parts));
Copy link
Member

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 of s_buffer,
  • rec_buffer instead of r_buffer,
  • ghost_comm instead of gc,
  • archiver instead of ar,
  • bond_archiver instead of bar,
  • bond_list instead of bl,
  • part instead of pt,
  • part_list instead of cur_list

static int max_s_buffer = 0;
/** send buffer. Just grows, which should be ok */
static char *s_buffer = nullptr;
struct CommBuf {
Copy link
Member

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

Copy link
Member

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

/* 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(
Copy link
Member

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

@hirschsn
Copy link
Contributor Author

hirschsn commented Oct 2, 2019

@KaiSzuttor Thanks for the suggestions. Done.

I now implemented the following convention in both, ghosts.hpp and ghosts.cpp:

  • "GhostCommunication" variables are always "ghost_comm".
  • "GhostCommunicator" variables are always named "gcr".

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?

@jngrad
Copy link
Member

jngrad commented Oct 18, 2019

bors r=KaiSzuttor

bors bot added a commit that referenced this pull request Oct 18, 2019
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]>
@jngrad jngrad modified the milestones: Espresso 5, Espresso 4.2 Oct 18, 2019
@bors
Copy link
Contributor

bors bot commented Oct 18, 2019

Build succeeded

@bors bors bot merged commit f21d717 into espressomd:python Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants