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

cppcore: implement memoization once for all features #323

Merged
merged 11 commits into from
Oct 17, 2023

Conversation

anilbey
Copy link
Contributor

@anilbey anilbey commented Oct 16, 2023

Part of #321.

Memoization previously was done n_features times hence it was very hard to test.
There are ~150 C++ features. Each was performing a separate checking and retrieval of the cached results. Now there is only one implementation.
The responsibility of memoization is moved to cfeature. It became testable.
Does not introduce behavioural changes.
Scientists writing features (or reading them) do not have to worry about the underlying memoization mechanisms.
Uses C++17 for the if constexpr (std::is_same_v<T, int>) that allows conditional compilation of templates.

Note: CI image is updated to become ubuntu-22.04 since it uses gcc-11 by default. Otherwise we have to explicitly install gcc-11in each ci task. This change does not affect the users installing the wheels. They don't need to have a C++17 capable compiler. They'll be using the pre-compiled binaries we provide in the wheels.

@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2023

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (eb8c8a5) 55.65% compared to head (049b112) 57.39%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
+ Coverage   55.65%   57.39%   +1.73%     
==========================================
  Files          29       29              
  Lines        8046     7820     -226     
  Branches     3423     3235     -188     
==========================================
+ Hits         4478     4488      +10     
+ Misses        955      847     -108     
+ Partials     2613     2485     -128     
Files Coverage Δ
efel/cppcore/LibV1.cpp 43.67% <100.00%> (+2.54%) ⬆️
efel/cppcore/LibV3.cpp 36.95% <ø> (+26.61%) ⬆️
efel/cppcore/LibV5.cpp 39.09% <100.00%> (+1.39%) ⬆️
efel/cppcore/mapoperations.cpp 24.27% <ø> (-5.36%) ⬇️
tests/test_cppcore.py 100.00% <100.00%> (ø)
efel/cppcore/LibV2.cpp 20.28% <0.00%> (-0.08%) ⬇️
efel/cppcore/cppcore.cpp 55.34% <0.00%> (-4.84%) ⬇️
efel/cppcore/efel.cpp 6.25% <0.00%> (-0.65%) ⬇️
efel/cppcore/cfeature.cpp 22.69% <57.14%> (+0.47%) ⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anilbey anilbey force-pushed the cache branch 6 times, most recently from 0782e88 to da0e37e Compare October 17, 2023 11:06
@anilbey anilbey changed the title cppcore: implement memoization once for all features [draft] cppcore: implement memoization once for all features Oct 17, 2023
vector<double>& getmapDoubleData(string strName);

template <typename T>
const vector<T> getMapData(const string& strName, const map<string, vector<T>>& mapData) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very familiar with c++ good practices, but shouldn't these three functions be in cfeature.cpp? With just their name declaration here in cfeature.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let me do it that way to be consistent with the rest of the methods of cFeature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the last commit. Now the header file looks neat.

Copy link
Collaborator

@AurelienJaquier AurelienJaquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thank you!

Copy link
Collaborator

@ilkilic ilkilic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

@anilbey anilbey merged commit 8ce1476 into BlueBrain:master Oct 17, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants