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

Replace loop with explicit formula #705

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MadCatX
Copy link
Contributor

@MadCatX MadCatX commented Sep 10, 2020

Iterative calculation of the number of bins in Parallel2DExecutor can be replaced by an explicit formula.

Test code:

#include <cmath>
#include <iostream>

int main()
{
        for (int nCpus = 2; nCpus < 513; nCpus++) {
                int levels = 1;
                while (1 << levels < nCpus)
                        levels++;
                levels++;
                int bins = 1 << levels;

                int levelsNew = std::ceil(std::log2(nCpus)) + 1;
                int binsNew = 1 << levelsNew;
                if (bins != binsNew)
                        throw std::runtime_error(std::string("MISMATCH ") + std::to_string(bins) + " " + std::to_string(binsNew));
                std::cout << nCpus << "(" << levels << ", " << bins << ") - " << "(" << levelsNew << ", " << binsNew << ")" << std::endl;
        }
}

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2020

Codecov Report

Merging #705 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #705      +/-   ##
==========================================
- Coverage   49.35%   49.35%   -0.01%     
==========================================
  Files         556      556              
  Lines       71298    71295       -3     
==========================================
- Hits        35188    35186       -2     
+ Misses      36110    36109       -1     
Impacted Files Coverage Δ
SimTKcommon/src/Parallel2DExecutor.cpp 88.07% <100.00%> (+0.57%) ⬆️

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 320bbe9...a5cb4dc. Read the comment docs.

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.

None yet

2 participants