Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparse - Gauss Seidel: moving GS out of experimental namespace #2494

Merged
merged 4 commits into from
Feb 6, 2025
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
10 changes: 4 additions & 6 deletions example/wiki/sparse/KokkosSparse_wiki_gauss_seidel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ int main() {
Handle handle;
handle.create_gs_handle(KokkosSparse::GS_DEFAULT);
// Set up Gauss-Seidel for the graph (matrix sparsity pattern)
KokkosSparse::Experimental::gauss_seidel_symbolic(&handle, numRows, numRows, A.graph.row_map, A.graph.entries,
false);
KokkosSparse::gauss_seidel_symbolic(&handle, numRows, numRows, A.graph.row_map, A.graph.entries, false);
// Set up Gauss-Seidel for the matrix values (numeric)
// Another matrix with the same sparsity pattern could re-use the handle and
// symbolic phase, and only call numeric.
KokkosSparse::Experimental::gauss_seidel_numeric(&handle, numRows, numRows, A.graph.row_map, A.graph.entries,
A.values, false);
KokkosSparse::gauss_seidel_numeric(&handle, numRows, numRows, A.graph.row_map, A.graph.entries, A.values, false);
// Now, preconditioner is ready to use. Set up an unknown vector
// (uninitialized) and randomized right-hand-side vector.
Vector x(Kokkos::view_alloc(Kokkos::WithoutInitializing, "x"), numRows);
Expand All @@ -87,8 +85,8 @@ int main() {
// * to zero out x (it was uninitialized)
// * that b has changed since the previous apply (since there was no
// previous apply)
KokkosSparse::Experimental::forward_sweep_gauss_seidel_apply(
&handle, numRows, numRows, A.graph.row_map, A.graph.entries, A.values, x, b, firstIter, firstIter, one, 1);
KokkosSparse::forward_sweep_gauss_seidel_apply(&handle, numRows, numRows, A.graph.row_map, A.graph.entries,
A.values, x, b, firstIter, firstIter, one, 1);
firstIter = false;
// Now, compute the new residual norm using SPMV
Kokkos::deep_copy(res, b);
Expand Down
26 changes: 13 additions & 13 deletions perf_test/sparse/KokkosSparse_gs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ void runGS(const GS_Parameters& params) {
for (int i = 0; i < params.nstreams; i++) {
auto blk_A = DiagBlks[i];
auto blk_nrows = blk_A.numRows();
KokkosSparse::Experimental::gauss_seidel_symbolic(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, params.graph_symmetric);
KokkosSparse::gauss_seidel_symbolic(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, params.graph_symmetric);
}
symbolicLaunchTimeTotal = timer.seconds();
timer.reset();
Expand All @@ -256,8 +256,8 @@ void runGS(const GS_Parameters& params) {
for (int i = 0; i < params.nstreams; i++) {
auto blk_A = DiagBlks[i];
auto blk_nrows = blk_A.numRows();
KokkosSparse::Experimental::gauss_seidel_numeric(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, blk_A.values, params.graph_symmetric);
KokkosSparse::gauss_seidel_numeric(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, blk_A.values, params.graph_symmetric);
}
numericLaunchTimeTotal = timer.seconds();
timer.reset();
Expand All @@ -272,19 +272,19 @@ void runGS(const GS_Parameters& params) {
// Last two parameters are damping factor (should be 1) and sweeps
switch (params.direction) {
case GS_SYMMETRIC:
KokkosSparse::Experimental::symmetric_gauss_seidel_apply(instances[i], &kh[i], blk_nrows, blk_nrows,
blk_A.graph.row_map, blk_A.graph.entries, blk_A.values,
x[i], b[i], true, true, 1.0, params.sweeps);
KokkosSparse::symmetric_gauss_seidel_apply(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, blk_A.values, x[i], b[i], true, true, 1.0,
params.sweeps);
break;
case GS_FORWARD:
KokkosSparse::Experimental::forward_sweep_gauss_seidel_apply(
instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map, blk_A.graph.entries, blk_A.values, x[i],
b[i], true, true, 1.0, params.sweeps);
KokkosSparse::forward_sweep_gauss_seidel_apply(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, blk_A.values, x[i], b[i], true, true, 1.0,
params.sweeps);
break;
case GS_BACKWARD:
KokkosSparse::Experimental::backward_sweep_gauss_seidel_apply(
instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map, blk_A.graph.entries, blk_A.values, x[i],
b[i], true, true, 1.0, params.sweeps);
KokkosSparse::backward_sweep_gauss_seidel_apply(instances[i], &kh[i], blk_nrows, blk_nrows, blk_A.graph.row_map,
blk_A.graph.entries, blk_A.values, x[i], b[i], true, true, 1.0,
params.sweeps);
break;
}
}
Expand Down
30 changes: 17 additions & 13 deletions perf_test/sparse/KokkosSparse_pcg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,18 @@ void block_pcgsolve(KernelHandle_t &kh, const crsMatrix_t &point_crsMat, const c
// timer.reset();

// block_kh.set_verbose(true);
block_gauss_seidel_numeric(&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size,
_block_crsMat.graph.row_map, _block_crsMat.graph.entries, _block_crsMat.values);
KokkosSparse::block_gauss_seidel_numeric(&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size,
_block_crsMat.graph.row_map, _block_crsMat.graph.entries,
_block_crsMat.values);

precond_init_time += timer.seconds();

z = y_vector_t("pcg::z", count_total);
Space().fence();
timer.reset();
symmetric_block_gauss_seidel_apply(&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size,
_block_crsMat.graph.row_map, _block_crsMat.graph.entries, _block_crsMat.values,
z, r, true, true, 1.0, apply_count);
KokkosSparse::symmetric_block_gauss_seidel_apply(
&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size, _block_crsMat.graph.row_map,
_block_crsMat.graph.entries, _block_crsMat.values, z, r, true, true, 1.0, apply_count);

// symmetric_gauss_seidel_apply
// (&kh, count_total, count_total, point_crsMat.graph.row_map,
Expand Down Expand Up @@ -185,9 +186,9 @@ void block_pcgsolve(KernelHandle_t &kh, const crsMatrix_t &point_crsMat, const c
if (use_sgs) {
Space().fence();
timer.reset();
symmetric_block_gauss_seidel_apply(&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size,
_block_crsMat.graph.row_map, _block_crsMat.graph.entries, _block_crsMat.values,
z, r, true, true, 1.0, apply_count);
KokkosSparse::symmetric_block_gauss_seidel_apply(
&block_kh, _block_crsMat.numRows(), _block_crsMat.numCols(), block_size, _block_crsMat.graph.row_map,
_block_crsMat.graph.entries, _block_crsMat.values, z, r, true, true, 1.0, apply_count);

// symmetric_gauss_seidel_apply(
// &kh,
Expand Down Expand Up @@ -318,16 +319,18 @@ void pcgsolve(KernelHandle_t &kh, const crsMatrix_t &crsMat, const y_vector_t &y
timer.reset();
z = y_vector_t("pcg::z", count_total);
if (use_par_sgs) {
gauss_seidel_numeric(&kh, count_total, count_total, crsMat.graph.row_map, crsMat.graph.entries, crsMat.values);
KokkosSparse::gauss_seidel_numeric(&kh, count_total, count_total, crsMat.graph.row_map, crsMat.graph.entries,
crsMat.values);

Space().fence();

precond_init_time += timer.seconds();
Space().fence();
timer.reset();

symmetric_gauss_seidel_apply(&kh, count_total, count_total, crsMat.graph.row_map, crsMat.graph.entries,
crsMat.values, z, r, true, true, 1.0, apply_count);
KokkosSparse::symmetric_gauss_seidel_apply(&kh, count_total, count_total, crsMat.graph.row_map,
crsMat.graph.entries, crsMat.values, z, r, true, true, 1.0,
apply_count);

Space().fence();
} else if (use_sequential_sgs) {
Expand Down Expand Up @@ -402,8 +405,9 @@ void pcgsolve(KernelHandle_t &kh, const crsMatrix_t &crsMat, const y_vector_t &y
Space().fence();
timer.reset();
if (use_par_sgs) {
symmetric_gauss_seidel_apply(&kh, count_total, count_total, crsMat.graph.row_map, crsMat.graph.entries,
crsMat.values, z, r, true, true, 1.0, apply_count);
KokkosSparse::symmetric_gauss_seidel_apply(&kh, count_total, count_total, crsMat.graph.row_map,
crsMat.graph.entries, crsMat.values, z, r, true, true, 1.0,
apply_count);
} else if (use_sequential_sgs) {
// z = LHS (aka x), r RHS (aka y or b)
Kokkos::deep_copy(z, 0.0);
Expand Down
Loading
Loading