Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 4 additions & 56 deletions source/source_hsolver/diago_dav_subspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#ifdef __MPI
#include <mpi.h>
#include "source_base/parallel_comm.h"
#endif

using namespace hsolver;
Expand Down Expand Up @@ -583,62 +584,9 @@ void Diago_DavSubspace<T, Device>::cal_elem(const int& dim,
// Only on dsp hardware need an extra space to reduce data
mtfunc::dsp_dav_subspace_reduce(hcc, scc, nbase, this->nbase_x, this->notconv, this->diag_comm.comm);
#else
auto* swap = new T[notconv * this->nbase_x];

syncmem_complex_op()(swap, hcc + nbase * this->nbase_x, notconv * this->nbase_x);

if (std::is_same<T, double>::value)
{
Parallel_Reduce::reduce_pool(hcc + nbase * this->nbase_x, notconv * this->nbase_x);
Parallel_Reduce::reduce_pool(scc + nbase * this->nbase_x, notconv * this->nbase_x);
}
else
{
if (base_device::get_current_precision(swap) == "single")
{
MPI_Reduce(swap,
hcc + nbase * this->nbase_x,
notconv * this->nbase_x,
MPI_COMPLEX,
MPI_SUM,
0,
this->diag_comm.comm);
}
else
{
MPI_Reduce(swap,
hcc + nbase * this->nbase_x,
notconv * this->nbase_x,
MPI_DOUBLE_COMPLEX,
MPI_SUM,
0,
this->diag_comm.comm);
}

syncmem_complex_op()(swap, scc + nbase * this->nbase_x, notconv * this->nbase_x);

if (base_device::get_current_precision(swap) == "single")
{
MPI_Reduce(swap,
scc + nbase * this->nbase_x,
notconv * this->nbase_x,
MPI_COMPLEX,
MPI_SUM,
0,
this->diag_comm.comm);
}
else
{
MPI_Reduce(swap,
scc + nbase * this->nbase_x,
notconv * this->nbase_x,
MPI_DOUBLE_COMPLEX,
MPI_SUM,
0,
this->diag_comm.comm);
}
}
delete[] swap;
assert(this->diag_comm.comm == POOL_WORLD);
Parallel_Reduce::reduce_pool(hcc + nbase * this->nbase_x, notconv * this->nbase_x);
Parallel_Reduce::reduce_pool(scc + nbase * this->nbase_x, notconv * this->nbase_x);
#endif
Comment thread
Cstandardlib marked this conversation as resolved.
}
#endif
Expand Down
22 changes: 3 additions & 19 deletions source/source_hsolver/diago_david.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "source_hsolver/kernels/hegvd_op.h"
#include "source_base/kernels/math_kernel_op.h"
#include "source_base/parallel_comm.h"


using namespace hsolver;
Expand Down Expand Up @@ -613,25 +614,8 @@ void DiagoDavid<T, Device>::cal_elem(const int& dim,
{
ModuleBase::matrixTranspose_op<T, Device>()(nbase_x, nbase_x, hcc, hcc);

auto* swap = new T[notconv * nbase_x];
syncmem_complex_op()(swap, hcc + nbase * nbase_x, notconv * nbase_x);
if (std::is_same<T, double>::value)
{
Parallel_Reduce::reduce_pool(hcc + nbase * nbase_x, notconv * nbase_x);
}
else
{
if (base_device::get_current_precision(swap) == "single") {
MPI_Reduce(swap, hcc + nbase * nbase_x, notconv * nbase_x, MPI_COMPLEX, MPI_SUM, 0, diag_comm.comm);
}
else {
MPI_Reduce(swap, hcc + nbase * nbase_x, notconv * nbase_x, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, diag_comm.comm);
}

}
delete[] swap;

// Parallel_Reduce::reduce_complex_double_pool( hcc + nbase * nbase_x, notconv * nbase_x );
assert(diag_comm.comm == POOL_WORLD);
Parallel_Reduce::reduce_pool(hcc + nbase * nbase_x, notconv * nbase_x);

Comment thread
Cstandardlib marked this conversation as resolved.
ModuleBase::matrixTranspose_op<T, Device>()(nbase_x, nbase_x, hcc, hcc);
}
Expand Down
3 changes: 2 additions & 1 deletion source/source_hsolver/test/diago_david_float_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include"source_hsolver/diago_david.h"
#include"source_hsolver/diago_iter_assist.h"
#include "source_base/parallel_comm.h"
#include"source_pw/module_pwdft/hamilt_pw.h"
#include"diago_mock.h"
#include "source_psi/psi.h"
Expand Down Expand Up @@ -85,7 +86,7 @@ class DiagoDavPrepare
phm = new hamilt::HamiltPW<std::complex<float>>(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);

#ifdef __MPI
const hsolver::diag_comm_info comm_info = {MPI_COMM_WORLD, mypnum, nprocs};
const hsolver::diag_comm_info comm_info = {POOL_WORLD, mypnum, nprocs};
#else
const hsolver::diag_comm_info comm_info = {mypnum, nprocs};
#endif
Expand Down
3 changes: 2 additions & 1 deletion source/source_hsolver/test/diago_david_real_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include"source_hsolver/diago_david.h"
#include"source_hsolver/diago_iter_assist.h"
#include "source_base/parallel_comm.h"
#include"source_pw/module_pwdft/hamilt_pw.h"
#include"diago_mock.h"
#include "source_psi/psi.h"
Expand Down Expand Up @@ -84,7 +85,7 @@ class DiagoDavPrepare
phm = new hamilt::HamiltPW<double>(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);

#ifdef __MPI
const hsolver::diag_comm_info comm_info = {MPI_COMM_WORLD, mypnum, nprocs};
const hsolver::diag_comm_info comm_info = {POOL_WORLD, mypnum, nprocs};
#else
const hsolver::diag_comm_info comm_info = {mypnum, nprocs};
#endif
Expand Down
3 changes: 2 additions & 1 deletion source/source_hsolver/test/diago_david_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include"source_hsolver/diago_david.h"
#include"source_hsolver/diago_iter_assist.h"
#include "source_base/parallel_comm.h"
#include"source_pw/module_pwdft/hamilt_pw.h"
#include"diago_mock.h"
#include "source_psi/psi.h"
Expand Down Expand Up @@ -89,7 +90,7 @@ class DiagoDavPrepare
phm = new hamilt::HamiltPW<std::complex<double>>(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);

#ifdef __MPI
const hsolver::diag_comm_info comm_info = {MPI_COMM_WORLD, mypnum, nprocs};
const hsolver::diag_comm_info comm_info = {POOL_WORLD, mypnum, nprocs};
#else
const hsolver::diag_comm_info comm_info = {mypnum, nprocs};
#endif
Expand Down
Loading