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

Divide Util.hpp and fix some bugs there #228

Merged
merged 10 commits into from
Feb 8, 2022
Merged

Conversation

chaeyeunpark
Copy link
Contributor

@chaeyeunpark chaeyeunpark commented Feb 8, 2022

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context: After several recent commits, Util.hpp file becomes >1000 lines, and some hidden bugs are found. This PR (1) divides this file into smaller files and (2) fix bugs.

Description of the Change: Divide Util.hpp into LinearAlgebra.hpp, ConstantUtil.hpp, and BitUtil.hpp. Also fixes bugs in second_elts_of and matrixMatProd. Also changed CMakeLists.txt and Makefile.

Benefits: Slightly better compile time.

Possible Drawbacks:

Related GitHub Issues:
Closes #227

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2022

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #228 (59705e8) into master (3f64ac4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #228   +/-   ##
=======================================
  Coverage   99.71%   99.71%           
=======================================
  Files           4        4           
  Lines         351      351           
=======================================
  Hits          350      350           
  Misses          1        1           
Impacted Files Coverage Δ
pennylane_lightning/_version.py 100.00% <100.00%> (ø)

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 3f64ac4...59705e8. Read the comment docs.

} else if constexpr (std::is_same_v<T, double>) {
cblas_zgemm(CblasRowMajor, CblasNoTrans, tr, m, n, k, &co, m_left,
k, m_right, transpose ? n : k, &cz, m_out, n);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, the previous code was

if constexpr (std::is_same_v<T, float>) {
cblas_cgemm(CblasRowMajor, tr, CblasNoTrans, m, n, k, &co, m_left,
k, m_right, n, &cz, m_out, n);
} else if constexpr (std::is_same_v<T, double>) {
cblas_zgemm(CblasRowMajor, tr, CblasNoTrans, m, n, k, &co, m_left,
k, m_right, n, &cz, m_out, n);
}

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2022

Test Report (C++) on Ubuntu

       1 files  ±  0         1 suites  ±0   0s ⏱️ ±0s
   296 tests +  2     296 ✔️ +  2  0 💤 ±0  0 ±0 
2 749 runs  +72  2 749 ✔️ +72  0 💤 ±0  0 ±0 

Results for commit 59705e8. ± Comparison against base commit 3f64ac4.

♻️ This comment has been updated with latest results.

res[i] = std::get<1>(arr[i]);
}
return res;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, this function was the same as fist_elts_of previously. Besides these two functions, every other functions are the same.

@chaeyeunpark chaeyeunpark requested review from mlxd and maliasadi and removed request for mlxd February 8, 2022 14:26
Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Great job on this @chaeyeunpark
That refactor was definitely needed (and nice work on the bug fixes too!)

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Nice work! Also, thanks for fixing those bugs 🙂

@chaeyeunpark chaeyeunpark merged commit a01bf62 into master Feb 8, 2022
@chaeyeunpark chaeyeunpark deleted the fix_cblas_util branch February 8, 2022 20:51
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.

Util::matrixMatrixProduct produces a wrong result with BLAS
3 participants