Skip to content

Commit

Permalink
Fix a performance issue in mpi::schur_pressure_correction
Browse files Browse the repository at this point in the history
  • Loading branch information
ddemidov committed Aug 6, 2018
1 parent 386cac0 commit 4a2fb52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions amgcl/mpi/distributed_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class distributed_matrix {
}

void move_to_backend(const backend_params &bprm = backend_params()) {
AMGCL_TIC("move to backend");
if (!A_loc) {
A_loc = Backend::copy_matrix(a_loc, bprm);
}
Expand All @@ -450,6 +451,7 @@ class distributed_matrix {

a_loc.reset();
a_rem.reset();
AMGCL_TOC("move to backend");
}

template <class A, class VecX, class B, class VecY>
Expand Down
10 changes: 7 additions & 3 deletions amgcl/mpi/schur_pressure_correction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,22 @@ class schur_pressure_correction {
tmp = backend_type::create_vector(nu, bprm);

if (prm.approx_schur) {
M = backend_type::create_vector(nu, bprm);

AMGCL_TIC("approx_schur");
auto m = std::make_shared<backend::numa_vector<value_type>>(nu, false);
#pragma omp parallel
for(ptrdiff_t i = 0; i < nu; ++i) {
value_type v = math::zero<value_type>();
for(ptrdiff_t j = Kuu_loc->ptr[i], e = Kuu_loc->ptr[i+1]; j < e; ++j) {
if (Kuu_loc->col[j] == i) {
v = math::inverse(Kuu_loc->val[j]);
break;
}
}
(*M)[i] = v;
(*m)[i] = v;
}

M = Backend::copy_vector(m, bprm);
AMGCL_TOC("approx_schur");
}
AMGCL_TOC("other");

Expand Down

0 comments on commit 4a2fb52

Please sign in to comment.