Skip to content
Open
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
12 changes: 6 additions & 6 deletions include/LinearAlgebra/Matrix/coo_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ SparseMatrixCOO<T>::SparseMatrixCOO(const SparseMatrixCOO& other)
, values_("COO values", nnz_)
, is_symmetric_(other.is_symmetric_)
{
Kokkos::deep_copy(row_indices_, other.row_indices_);
Kokkos::deep_copy(column_indices_, other.column_indices_);
Kokkos::deep_copy(values_, other.values_);
copy_vector(row_indices_, ConstVector<int>(other.row_indices_));
copy_vector(column_indices_, ConstVector<int>(other.column_indices_));
copy_vector(values_, ConstVector<T>(other.values_));
}

// copy assignment
Expand All @@ -166,9 +166,9 @@ SparseMatrixCOO<T>& SparseMatrixCOO<T>::operator=(const SparseMatrixCOO& other)
columns_ = other.columns_;
nnz_ = other.nnz_;
is_symmetric_ = other.is_symmetric_;
Kokkos::deep_copy(row_indices_, other.row_indices_);
Kokkos::deep_copy(column_indices_, other.column_indices_);
Kokkos::deep_copy(values_, other.values_);
copy_vector(row_indices_, ConstVector<int>(other.row_indices_));
copy_vector(column_indices_, ConstVector<int>(other.column_indices_));
copy_vector(values_, ConstVector<T>(other.values_));
return *this;
}

Expand Down
14 changes: 7 additions & 7 deletions include/LinearAlgebra/Matrix/csr_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SparseMatrixCSR
AllocatableVector<int> column_indices_;
AllocatableVector<int> row_start_indices_;

bool is_sorted_entries(const std::vector<std::tuple<int, int, T>>& entries)
bool is_sorted_entries(const std::vector<triplet_type>& entries)
{
for (size_t i = 1; i < entries.size(); ++i) {
const auto& prev = entries[i - 1];
Expand Down Expand Up @@ -116,9 +116,9 @@ SparseMatrixCSR<T>::SparseMatrixCSR(const SparseMatrixCSR& other)
, column_indices_("CSR column indices", nnz_)
, row_start_indices_("CSR row start indices", rows_ + 1)
{
Kokkos::deep_copy(values_, other.values_);
Kokkos::deep_copy(column_indices_, other.column_indices_);
Kokkos::deep_copy(row_start_indices_, other.row_start_indices_);
copy_vector(values_, ConstVector<T>(other.values_));
copy_vector(column_indices_, ConstVector<int>(other.column_indices_));
copy_vector(row_start_indices_, ConstVector<int>(other.row_start_indices_));
}

// copy assignment
Expand All @@ -139,9 +139,9 @@ SparseMatrixCSR<T>& SparseMatrixCSR<T>::operator=(const SparseMatrixCSR& other)
rows_ = other.rows_;
columns_ = other.columns_;
nnz_ = other.nnz_;
Kokkos::deep_copy(values_, other.values_);
Kokkos::deep_copy(column_indices_, other.column_indices_);
Kokkos::deep_copy(row_start_indices_, other.row_start_indices_);
copy_vector(values_, ConstVector<T>(other.values_));
copy_vector(column_indices_, ConstVector<int>(other.column_indices_));
copy_vector(row_start_indices_, ConstVector<int>(other.row_start_indices_));
return *this;
}

Expand Down
6 changes: 6 additions & 0 deletions include/LinearAlgebra/Vector/vector_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void assign(Vector<T> lhs, const T& value)
}
}

template <typename T>
void copy_vector(Vector<T> dst, ConstVector<T> src)
{
Kokkos::deep_copy(dst, src);
}

template <typename T>
void add(Vector<T> result, ConstVector<T> x)
{
Expand Down
2 changes: 1 addition & 1 deletion src/GMGPolar/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void IGMGPolar::initializeSolution()
Level& coarsest_level = levels_[coarsest_depth];

// Solve directly on the coarsest level
Kokkos::deep_copy(coarsest_level.solution(), coarsest_level.rhs());
copy_vector(coarsest_level.solution(), ConstVector<double>(coarsest_level.rhs()));
coarsest_level.directSolveInPlace(coarsest_level.solution()); // Direct solve on coarsest grid

// Prolongate the solution from the coarsest level up to the finest, while applying Multigrid Cycles on each level
Expand Down
2 changes: 1 addition & 1 deletion src/Residual/ResidualGive/residualGive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void ResidualGive::computeResidual(Vector<double> result, ConstVector<double> rh
{
assert(result.size() == x.size());

Kokkos::deep_copy(result, rhs);
copy_vector(result, rhs);

/* Single-threaded execution */
if (num_omp_threads_ == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/Smoother/SmootherGive/smootherGive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void SmootherGive::smoothing(Vector<double> x, ConstVector<double> rhs, Vector<d
assert(x.size() == rhs.size());
assert(temp.size() == rhs.size());

Kokkos::deep_copy(temp, rhs);
copy_vector(temp, rhs);

/* Multi-threaded execution */
const int num_smoother_circles = grid_.numberSmootherCircles();
Expand Down
48 changes: 24 additions & 24 deletions tests/DirectSolver/directSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ TEST(DirectSolverTest_CircularGeometry, SequentialDirectSolverDirBC_Interior_Cir

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -238,7 +238,7 @@ TEST(DirectSolverTest_CircularGeometry, ParallelDirectSolverDirBC_Interior_Circu

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -282,7 +282,7 @@ TEST(DirectSolverTest_CircularGeometry, SequentialDirectSolverAcrossOrigin_Circu

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -326,7 +326,7 @@ TEST(DirectSolverTest_CircularGeometry, ParallelDirectSolverAcrossOrigin_Circula

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -375,7 +375,7 @@ TEST(DirectSolverTest_ShafranovGeometry, DirectSolverDirBC_Interior_ShafranovGeo

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -420,7 +420,7 @@ TEST(DirectSolverTest_ShafranovGeometry, DirectSolverAcrossOrigin_ShafranovGeome

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -470,7 +470,7 @@ TEST(DirectSolverTest_CzarnyGeometry, DirectSolverDirBC_Interior_CzarnyGeometry)

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -516,7 +516,7 @@ TEST(DirectSolverTest_CzarnyGeometry, DirectSolverAcrossOrigin_CzarnyGeometry)

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -564,7 +564,7 @@ TEST(DirectSolverTest_CulhamGeometry, DirectSolverDirBC_Interior_CulhamGeometry)

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -608,7 +608,7 @@ TEST(DirectSolverTest_CulhamGeometry, DirectSolverAcrossOrigin_CulhamGeometry)

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -664,7 +664,7 @@ TEST(DirectSolverTest_CircularGeometry, DirectSolverAcrossOriginHigherPrecision_

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -708,7 +708,7 @@ TEST(DirectSolverTest_CircularGeometry, DirectSolverAcrossOriginHigherPrecision2

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -753,7 +753,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, SequentialDirectSolverDirBC_Interior

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -797,7 +797,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, ParallelDirectSolverDirBC_Interior_C

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -841,7 +841,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, SequentialDirectSolverAcrossOrigin_C

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -885,7 +885,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, ParallelDirectSolverAcrossOrigin_Cir

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -934,7 +934,7 @@ TEST(DirectSolverTakeTest_ShafranovGeometry, DirectSolverDirBC_Interior_Shafrano

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -979,7 +979,7 @@ TEST(DirectSolverTakeTest_ShafranovGeometry, DirectSolverAcrossOrigin_ShafranovG

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1029,7 +1029,7 @@ TEST(DirectSolverTakeTest_CzarnyGeometry, DirectSolverDirBC_Interior_CzarnyGeome

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1075,7 +1075,7 @@ TEST(DirectSolverTakeTest_CzarnyGeometry, DirectSolverAcrossOrigin_CzarnyGeometr

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1123,7 +1123,7 @@ TEST(DirectSolverTakeTest_CulhamGeometry, DirectSolverDirBC_Interior_CulhamGeome

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1167,7 +1167,7 @@ TEST(DirectSolverTakeTest_CulhamGeometry, DirectSolverAcrossOrigin_CulhamGeometr

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1221,7 +1221,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, DirectSolverAcrossOriginHigherPrecis

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down Expand Up @@ -1265,7 +1265,7 @@ TEST(DirectSolverTakeTest_CircularGeometry, DirectSolverAcrossOriginHigherPrecis

ConstVector<double> rhs = generate_random_sample_data(level.grid(), 42);
Vector<double> solution("sol", rhs.size());
Kokkos::deep_copy(solution, rhs);
copy_vector(solution, rhs);
solver_op.solveInPlace(solution);

Vector<double> residuum("residuum", level.grid().numberOfNodes());
Expand Down
Loading