Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

using reductions instead of handcrafted resolutions #466

Merged
merged 4 commits into from
Jun 15, 2020
Merged

Conversation

JensWehner
Copy link
Member

@JensWehner JensWehner commented Jun 13, 2020

Openmp is now required in version 4.5

this is not a big problem for gcc and icc but clang is a bit stupid, so you have to have clang-10 to use it properly. This seems to be a bug in the clang package.

@JensWehner JensWehner requested a review from felipeZ June 13, 2020 21:51
@ghost
Copy link

ghost commented Jun 13, 2020

DeepCode failed to analyze this pull request

Something went wrong despite trying multiple times, sorry about that.
Please comment this pull request with "Retry DeepCode" to manually retry, or contact us so that a human can look into the issue.

@JensWehner
Copy link
Member Author

So clang is problematic. Hmmm...

@JensWehner JensWehner requested a review from junghans June 15, 2020 16:57
@@ -10,7 +10,11 @@ list(REMOVE_ITEM VOTCA_SOURCES ${NOT_VOTCA_SOURCES})
add_library(votca_xtp ${VOTCA_SOURCES})
set_target_properties(votca_xtp PROPERTIES SOVERSION ${SOVERSION})
add_dependencies(votca_xtp gitversion-xtp)
target_link_libraries(votca_xtp PUBLIC VOTCA::votca_csg VOTCA::votca_tools Boost::boost Eigen3::Eigen ${HDF5_LIBRARIES} PRIVATE LIBXC::LIBXC Boost::program_options Boost::filesystem Boost::system Boost::timer )
target_link_libraries(votca_xtp PUBLIC VOTCA::votca_csg VOTCA::votca_tools Boost::boost Eigen3::Eigen ${HDF5_LIBRARIES} PRIVATE LIBXC::LIBXC Boost::program_options Boost::filesystem Boost::system Boost::timer )
Copy link
Member

Choose a reason for hiding this comment

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

Why that extra space? ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

ups

Copy link
Member

@felipeZ felipeZ left a comment

Choose a reason for hiding this comment

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

My comments are mostly for my own education :D I think that the reduction makes the code easier to read

@@ -45,6 +45,13 @@ class Mat_p_Energy {
Mat_p_Energy(double e, Eigen::MatrixXd&& mat)
: _energy(e), _matrix(std::move(mat)){};

Mat_p_Energy operator+(const Mat_p_Energy& other) const {
Copy link
Member

Choose a reason for hiding this comment

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

Really nice!

@@ -51,8 +51,6 @@ Eigen::MatrixXd ReadMatrixFromString(const std::string& matrix) {

BOOST_AUTO_TEST_CASE(small_basis) {

OPENMP::setMaxThreads(1);
Copy link
Member

Choose a reason for hiding this comment

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

Why is it now possible to use multiple threads here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure why it was disabled before.


const Eigen::VectorXd& fourc_vector = _fourcenter.get_4c_vector();

Index dftBasisSize = DMAT.rows();
Index vectorSize = (dftBasisSize * (dftBasisSize + 1)) / 2;
#pragma omp parallel for
#pragma omp parallel for reduction(+ : EXX)
Copy link
Member

Choose a reason for hiding this comment

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

The readability has improved significantly!

#pragma omp parallel for schedule(guided)
Eigen::MatrixXd result = Eigen::MatrixXd::Zero(dst.rows(), dst.cols());

#pragma omp declare reduction (+: Eigen::MatrixXd: omp_out=omp_out+omp_in)\
Copy link
Member

Choose a reason for hiding this comment

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

I don't fully understand this snippet, could you please tell me how it works?

Copy link
Member

Choose a reason for hiding this comment

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

omp_out=omp_out+omp_in is the communicative operation to perform and omp_priv is the "zero" element, right?

Copy link
Member

Choose a reason for hiding this comment

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

if the reduction for MatrixXd has been declared in eigen.h why don't you use it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is in the eigen::internal namespace, so I had to do it again.

target_link_libraries(votca_xtp PUBLIC VOTCA::votca_csg VOTCA::votca_tools Boost::boost Eigen3::Eigen ${HDF5_LIBRARIES} PRIVATE LIBXC::LIBXC Boost::program_options Boost::filesystem Boost::system Boost::timer )

if(TARGET OpenMP::OpenMP_CXX)
target_link_libraries(votca_xtp PUBLIC OpenMP::OpenMP_CXX)
Copy link
Member

Choose a reason for hiding this comment

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

We are planning on any consumers for xtp if so we might need to add this to CMake exported target as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not think there is a library which uses xtp but yeah.

@codecov
Copy link

codecov bot commented Jun 15, 2020

Codecov Report

Merging #466 into master will decrease coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #466     +/-   ##
========================================
- Coverage    63.3%   63.3%   -0.1%     
========================================
  Files         279     279             
  Lines       22795   22784     -11     
========================================
- Hits        14434   14423     -11     
  Misses       8361    8361             
Flag Coverage Δ
#gcc 63.3% <100.0%> (-0.1%) ⬇️
Impacted Files Coverage Δ
include/votca/xtp/orbitals.h 70.0% <ø> (ø)
include/votca/xtp/qmtool.h 0.0% <ø> (ø)
include/votca/xtp/dipoledipoleinteraction.h 94.1% <100.0%> (-0.2%) ⬇️
include/votca/xtp/eigen.h 84.6% <100.0%> (-4.3%) ⬇️
include/votca/xtp/matrixfreeoperator.h 85.7% <100.0%> (-1.0%) ⬇️
src/libxtp/dftengine/ERIs.cc 97.8% <100.0%> (+0.9%) ⬆️
src/libxtp/gwbse/rpa.cc 92.5% <100.0%> (-0.2%) ⬇️
...ibxtp/numerical_integration/density_integration.cc 70.4% <100.0%> (-2.5%) ⬇️
src/libxtp/numerical_integration/vxc_potential.cc 79.7% <100.0%> (-0.8%) ⬇️

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 a332e47...e7c4f29. Read the comment docs.

@JensWehner JensWehner merged commit 4dac3da into master Jun 15, 2020
@JensWehner JensWehner deleted the openmp_rework branch June 15, 2020 19:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants