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] Particle variables and functions handling #654

Closed
wants to merge 66 commits into from

Conversation

kks32
Copy link
Contributor

@kks32 kks32 commented Jun 29, 2020

Describe the PR
This is an alternative implementation of particle refactor.

After some more consideration, I am wondering about the possibility to derive particle types, but only keep the common particle functions within the class, and merge all independent/specialized functions to be outside the class. This will help to initialize the classes with the right types, and also in MPI transfer, as the type is known. We derived data of individual Particle types but keep specialized particle functions separately. Maybe the particle functions may have to stay in the same namespace.

Related Issues/PRs
#637 and #650

Additional context
Specialized functions will be still separate.

Following are the run-times for 3D hydrostatic column 10k steps on Stampede2

Branch TACC runtime (s)
develop 742.6
prop map + free fn 1280
vector + free fn map 865
flatmap + free fn 972

@codecov
Copy link

codecov bot commented Jun 29, 2020

Codecov Report

Merging #654 into develop will increase coverage by 0.00%.
The diff coverage is 97.45%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop     #654    +/-   ##
=========================================
  Coverage    96.66%   96.66%            
=========================================
  Files          123      124     +1     
  Lines        25375    25641   +266     
=========================================
+ Hits         24527    24785   +258     
- Misses         848      856     +8     
Impacted Files Coverage Δ
include/node_base.h 100.00% <ø> (ø)
include/particles/particle_base.h 100.00% <ø> (ø)
include/solvers/mpm_base.tcc 73.21% <50.00%> (-0.48%) ⬇️
include/particles/particle.tcc 93.24% <95.56%> (-0.89%) ⬇️
include/node.tcc 95.12% <96.18%> (-0.86%) ⬇️
include/mesh.tcc 83.94% <100.00%> (+0.04%) ⬆️
include/node.h 100.00% <100.00%> (ø)
include/particles/particle.h 100.00% <100.00%> (ø)
include/particles/particle_base.tcc 100.00% <100.00%> (ø)
include/particles/particle_functions.tcc 100.00% <100.00%> (ø)
... and 8 more

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 3b20da5...a0bbd15. Read the comment docs.

@kks32 kks32 mentioned this pull request Jul 4, 2020
@bodhinandach bodhinandach self-assigned this Jul 9, 2020
@kks32
Copy link
Contributor Author

kks32 commented Jul 22, 2020

After considering the speed-ups and different approaches, the use of scalar and vector properties still is 30% slower than using private variables. The advantage of scalar/vector properties is we'll have fewer functions and less repetition of code. On the other hand, defining private variables and deriving particle classes has more function definitions and repeating code, but is faster. I'd like to propose a vote, use emojis to vote between different options, please use comments below if you like to elaborate on your thoughts. @bodhinandach @tianchiTJ @thiagordonho @cw646 @ezrayst @jgiven100 @WeijianLiang

  1. Use derived particle types with private variables (:rocket:)
  2. Solid particles will remain as is, while we add scalar and vector properties to derived particle types (:smile:) PR [Refactor] Adding particles properties #673
  3. Cleaner but slower design with free functions and scalar/vector properties for all particle types (:heart:) PR [Refactor] Particle variables and functions handling #654
  4. Go back to the drawing board (:eyes:)

@WeijianLiang
Copy link

Thanks Krishna, I would prefer the use of scalar and vector properties which has a more clear structure.

@kks32
Copy link
Contributor Author

kks32 commented Jul 22, 2020

@WeijianLiang is that option 2 or 3? Could you please vote with a reaction emoji 😄 for option 2 and ❤️ for option 3. Thanks!

@yliang-sn
Copy link
Contributor

After considering the speed-ups and different approaches, the use of scalar and vector properties still is 30% slower than using private variables. The advantage of scalar/vector properties is we'll have fewer functions and less repetition of code. On the other hand, defining private variables and deriving particle classes has more function definitions and repeating code, but is faster. I'd like to propose a vote, use emojis to vote between different options, please use comments below if you like to elaborate on your thoughts. @bodhinandach @tianchiTJ @thiagordonho @cw646 @ezrayst @jgiven100 @WeijianLiang

  1. Use derived particle types with private variables (🚀)
  2. Solid particles will remain as is, while we add scalar and vector properties to derived particle types (😄)
  3. Cleaner but slower design with free functions and scalar/vector properties for all particle types (❤️)
  4. Go back to the drawing board (👀)

For 2, are we just dealing with the scalar and vector properties to the derived particle types? If we have other types of quantities, do we still use the private variables?

@kks32
Copy link
Contributor Author

kks32 commented Jul 22, 2020

@yliang-sn everything will be held within scalar/vector/tensor/boolean

@yliang-sn
Copy link
Contributor

@yliang-sn everything will be held within scalar/vector/tensor/boolean

Can I vote, too? If the private variables have the best efficiency, I prefer to 1. The structure is also clear enough to be read and extended. However, 2 is also fine for me.

@kks32
Copy link
Contributor Author

kks32 commented Jul 22, 2020

@yliang-sn yes, I couldn't find your handle, please vote.

@kks32
Copy link
Contributor Author

kks32 commented Jul 23, 2020

@thiagordonho @tianchiTJ @cw646 @WeijianLiang could you please use emoji reactions to vote on this comment please: #654 (comment)

@ezrayst
Copy link
Contributor

ezrayst commented Jul 23, 2020

Both @kks32 and @bodhinandach have been working hard on this issue so appreciate your work. I think it has been about 2 months now.

However, I feel that we need a unanimous decision on this refactor, or at least a 2/3 decision. The reason being is I don't want us to be in this position within 6 months where we are thinking to refactor again. I think the timeline on this issue has shown that this is a lot of work and everyone's progress is halted. Personally, if we are not even sure on (2) or (3), or anyone still has reservation on them, wouldn't it better to keep it as is (1)? Yes, particle_base will be messy because of the many functions from two_phase particles, but at least we get the speedup. Yes we might need to refactor in the future, but isn't that the assumption that we will refactor again? Lastly, if you are sure for (2), might as well go for (3) so we don't come back to it again later. So my vote will be (3) now!

@WeijianLiang
Copy link

@kks32 Thanks, I also vote for (2)

@bodhinandach
Copy link
Contributor

bodhinandach commented Jul 24, 2020

After considering @ezrayst comment, I changed my vote to option (3). I know that the code will be slower, but the code is structurally way better and tidier. Also, if currently by moving to (3) causing us to be 30% slower than develop, I think we should rethink any other way to improve the speed. For instance, PR #677 has already improved the speed by 4% (thanks to @kks32). I think we can regain the current performance in short time by improving efficiency in other parts.

@yliang-sn
Copy link
Contributor

After talking with Ezra and Nanda, I think i will change to vote for 3 if we can improve the efficiency in other aspects.

@bodhinandach bodhinandach changed the title Refactor/particles [Refactor] Particle variables and functions handling Jul 28, 2020
@kks32
Copy link
Contributor Author

kks32 commented Jul 28, 2020

Other containers like Abseil, folly, vector of vectors, static_vector, and small_vector implementations all gave slower or almost identical performance as the flat_map. Due to the 30% reduction in performance we are closing this issue. https://trello.com/c/fGF3MrKg/110-plan-for-next-week-notes

@kks32 kks32 closed this Jul 28, 2020
@kks32 kks32 deleted the refactor/particles branch July 28, 2020 22:06
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.

Refactor particle to handle different types
9 participants