Skip to content

Commit

Permalink
Use explicit update_from instead of swap
Browse files Browse the repository at this point in the history
  • Loading branch information
greole committed Jun 7, 2024
1 parent 06650ae commit 1e55ad0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DevicePersistent/HostMatrixAdapter/HostMatrixAdapter.H
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ struct lduMatrixInitFunctor {
interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_,
solver_controls_, field_name_, verbose_);

persistent_device_matrix.swap(ret);
persistent_device_matrix->update_from(ret);

}

std::shared_ptr<HostMatrixWrapper> init() const
Expand Down
7 changes: 0 additions & 7 deletions MatrixWrapper/Distributed/Distributed.H
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,10 @@ public:
label nrows = host_A->get_local_nrows();
label local_matrix_nnz = host_A->get_local_matrix_nnz();
// size + padding has to be local_matrix_nnz
std::cout << __FILE__ << ":" << __LINE__ << " rank " << rank
<< "update_impl 0\n";
auto diag_comm_pattern = compute_send_recv_counts(
exec_handler, ranks_per_gpu, nrows, local_matrix_nnz,
local_matrix_nnz - nrows, 0);

std::cout << __FILE__ << ":" << __LINE__ << " rank " << rank
<< "update_impl 1\n";

label upper_nnz = host_A->get_upper_nnz();
auto upper_comm_pattern = compute_send_recv_counts(
Expand All @@ -328,9 +324,6 @@ public:
compute_send_recv_counts(exec_handler, ranks_per_gpu, upper_nnz,
local_matrix_nnz, upper_nnz, nrows);

std::cout << __FILE__ << ":" << __LINE__ << " rank " << rank
<< "update_impl 2\n";

scalar *local_ptr;

// update main values
Expand Down
30 changes: 27 additions & 3 deletions MatrixWrapper/LDUMatrix/HostMatrix.H
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ private:

const lduAddressing &addr_;

const scalar *diag_;
mutable const scalar *diag_;

const scalar *upper_;
mutable const scalar *upper_;

const scalar *lower_;
mutable const scalar *lower_;

// multiply the complete system by this factor, ie sAx=sb
// NOTE this needed to avoid negative diagonal matrix entries, but
Expand Down Expand Up @@ -364,6 +364,23 @@ public:
fieldName, verbose);
};

void update_from(std::shared_ptr<HostMatrixWrapper> in) {
diag_ = in->get_diag();
upper_ = in->get_upper();
lower_ = in->get_lower();

interface_ptr_.clear();
auto interfaces = in->get_interfaces();
for (label i = 0; i < interfaces.size(); i++) {
if (interface_getter(interfaces, i) == nullptr) {
continue;
}
const auto iface{interface_getter(interfaces, i)};
interface_ptr_.push_back(in->get_interfaceBouCoeffs()[i].begin());
}

}


/** Based on OpenFOAMs ldu matrix format this function computes two
** consecutive index arrays (local_sparsisty_.row_idxs and col_idxs) in row
Expand Down Expand Up @@ -401,6 +418,13 @@ public:
return interface_ptr_[i];
};

const FieldField<Field, scalar> & get_interfaceBouCoeffs()
const {return interfaceBouCoeffs_;};

const lduInterfaceFieldPtrsList &get_interfaces() const {
return interfaces_;
};

bool get_verbose() const { return verbose_; }

label get_local_nrows() const { return nrows_; }
Expand Down
2 changes: 0 additions & 2 deletions lduLduBase/lduLduBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ public:
solver_controls_(solverControls),
field_name_(fieldName),
verbose_(solverControls.lookupOrDefault<label>("verbose", 0)),
// FIXME NOTE the underlying exec_handler is invalid in the next call but the
// exec isnt
exec_handler_{db_, solver_controls_, fieldName},
host_A_{
db_, exec_handler_, solver_controls_, fieldName,
Expand Down

0 comments on commit 1e55ad0

Please sign in to comment.