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

More Realistic Benchmark #67

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

Conversation

ewanwm
Copy link
Owner

@ewanwm ewanwm commented Jan 7, 2025

Now randomise the osc parameters at each step in the benchmark rather than the energies. This more closely matches the real life usage pattern for an oscillation calculator.

This seems to be a lot slower than previously when testing locally...

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Cpp-linter Review

Used clang-tidy v14.0.0

Have any feedback or feature suggestions? Share it here.

const float m1 = 0.1;
const float m2 = 0.2;
const float m3 = 0.3;
const std::complex<float> i(0.0, 1.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-tidy diagnostic

benchmarks/benchmarks.cpp:11:27: warning: [readability-identifier-length]

variable name 'i' is too short, expected at least 3 characters

const std::complex<float> i(0.0, 1.0);
                          ^

_m3 = Tensor::zeros({1, 3, 3}, NTdtypes::kComplexFloat).requiresGrad(false);
}

void build(const Tensor &theta12, const Tensor &theta13, const Tensor &theta23, const Tensor &deltaCP)
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-tidy diagnostic

benchmarks/benchmarks.cpp:24:62: warning: [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'build' of similar type ('const Tensor &') are easily swapped by mistake

    void build(const Tensor &theta12, const Tensor &theta13, const Tensor &theta23, const Tensor &deltaCP)
                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:24:76: note: the first parameter in the range is 'theta23'
    void build(const Tensor &theta12, const Tensor &theta13, const Tensor &theta23, const Tensor &deltaCP)
                                                                           ^~~~~~~
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:24:99: note: the last parameter in the range is 'deltaCP'
    void build(const Tensor &theta12, const Tensor &theta13, const Tensor &theta23, const Tensor &deltaCP)
                                                                                                  ^~~~~~~


const float dcp = 0.5;
Tensor matrix;
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-tidy diagnostic

benchmarks/benchmarks.cpp:56:12: warning: [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'matrix' has public visibility

    Tensor matrix;
           ^


static void batchedOscProbs(const Propagator &prop, long batchSize, long nBatches)
static void batchedOscProbs(Propagator &prop, PMNSmatrix &matrix, Tensor &theta23, Tensor &theta13, Tensor &theta12,
Tensor &deltaCP, Tensor &masses, const Tensor &energies, long batchSize, long nBatches)
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-tidy diagnostic

benchmarks/benchmarks.cpp:65:86: warning: [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'batchedOscProbs' of similar type ('long') are easily swapped by mistake

                            Tensor &deltaCP, Tensor &masses, const Tensor &energies, long batchSize, long nBatches)
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:65:91: note: the first parameter in the range is 'batchSize'
                            Tensor &deltaCP, Tensor &masses, const Tensor &energies, long batchSize, long nBatches)
                                                                                          ^~~~~~~~~
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:65:107: note: the last parameter in the range is 'nBatches'
                            Tensor &deltaCP, Tensor &masses, const Tensor &energies, long batchSize, long nBatches)
                                                                                                          ^~~~~~~~
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:79:64: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        deltaCP.setValue({0}, Tensor::scale(Tensor::rand({1}), 2.0 * 3.1415));
                                                               ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:79:70: warning: 3.1415 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        deltaCP.setValue({0}, Tensor::scale(Tensor::rand({1}), 2.0 * 3.1415));
                                                                     ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:97:102: warning: 10000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        Tensor::scale(Tensor::rand({state.range(0), 1}).dType(NTdtypes::kFloat).requiresGrad(false), 10000.0) +
                                                                                                     ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:111:30: warning: 295000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
    Propagator vacuumProp(3, 295000.0);
                             ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:130:102: warning: 10000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        Tensor::scale(Tensor::rand({state.range(0), 1}).dType(NTdtypes::kFloat).requiresGrad(false), 10000.0) +
                                                                                                     ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:145:30: warning: 295000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
    Propagator matterProp(3, 295000.0);
                             ^
/home/runner/work/nuTens/nuTens/benchmarks/benchmarks.cpp:149:100: warning: 2.6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
    std::shared_ptr<BaseMatterSolver> matterSolver = std::make_shared<ConstDensityMatterSolver>(3, 2.6);
                                                                                                   ^

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

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.

2 participants