From a34610b8d69d68c16a7029a1608e577a90ad5e1f Mon Sep 17 00:00:00 2001 From: Andrew Reisner Date: Tue, 12 Dec 2023 08:40:41 -0700 Subject: [PATCH] Update hypre tests. This updates the hypre tests to hypre v2.28. --- CMakeLists.txt | 1 - raptor/ruge_stuben/tests/test_hypre.cpp | 38 ++++------ .../tests/test_hypre_interpolation.cpp | 73 ++++++++----------- .../tests/test_hypre_splitting.cpp | 44 ++++++----- .../ruge_stuben/tests/test_hypre_unknown.cpp | 60 +++++++-------- raptor/tests/hypre_compare.hpp | 27 ++++--- 6 files changed, 108 insertions(+), 135 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e7b2d59..b292551a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) enable_language(CXX) set(CMAKE_CXX_STANDARD 11) -set(CMAKE_BUILD_TYPE Release) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wredundant-decls -Wcast-align -Wshadow") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -funroll-loops") diff --git a/raptor/ruge_stuben/tests/test_hypre.cpp b/raptor/ruge_stuben/tests/test_hypre.cpp index f6aaa6b6..613513ba 100644 --- a/raptor/ruge_stuben/tests/test_hypre.cpp +++ b/raptor/ruge_stuben/tests/test_hypre.cpp @@ -16,7 +16,7 @@ void form_hypre_weights(double** weight_ptr, int n_rows) int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); hypre_SeedRand(2747 + rank); - double* weights; + double* weights = nullptr; if (n_rows) { weights = new double[n_rows]; @@ -39,17 +39,14 @@ int main(int argc, char** argv) } // end of main() // TEST(TestHypre, TestsInRuge_Stuben) -{ +{ int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - FILE* f; - int cf; - double strong_threshold = 0.25; - int hyp_coarsen_type = 0; // CLJP - int hyp_interp_type = 0; // ModClassical + int hyp_coarsen_type = 0; // CLJP + int hyp_interp_type = 0; // ModClassical int p_max_elmts = 0; int agg_num_levels = 0; ParCSRMatrix* A; @@ -63,7 +60,7 @@ TEST(TestHypre, TestsInRuge_Stuben) /************************************ - **** Test Laplacian + **** Test Laplacian ***********************************/ n = 25; grid.resize(3); @@ -91,27 +88,27 @@ TEST(TestHypre, TestsInRuge_Stuben) HYPRE_IJVectorGetObject(b_h_ij, (void **) &b_hyp); // Setup Hypre Hierarchy - HYPRE_Solver solver_data = hypre_create_hierarchy(A_hyp, x_hyp, b_hyp, - hyp_coarsen_type, hyp_interp_type, p_max_elmts, agg_num_levels, + HYPRE_Solver solver_data = hypre_create_hierarchy(A_hyp, x_hyp, b_hyp, + hyp_coarsen_type, hyp_interp_type, p_max_elmts, agg_num_levels, strong_threshold, 0.0); hypre_ParCSRMatrix** A_array = hypre_ParAMGDataAArray((hypre_ParAMGData*) solver_data); hypre_ParCSRMatrix** P_array = hypre_ParAMGDataPArray((hypre_ParAMGData*) solver_data); - for (int level = 0; level < ml->num_levels - 1; level++) + for (int level = 0; level < ml->num_levels - 1; level++) { compare(ml->levels[level]->P, P_array[level]); compare(ml->levels[level+1]->A, A_array[level+1]); } - hypre_BoomerAMGDestroy(solver_data); + hypre_BoomerAMGDestroy(solver_data); HYPRE_IJMatrixDestroy(Aij); delete ml; delete A; /************************************ - **** Test Anisotropic Diffusion + **** Test Anisotropic Diffusion ***********************************/ n = 100; grid.resize(2); @@ -137,30 +134,23 @@ TEST(TestHypre, TestsInRuge_Stuben) HYPRE_IJVectorGetObject(b_h_ij, (void **) &b_hyp); // Setup Hypre Hierarchy - solver_data = hypre_create_hierarchy(A_hyp, x_hyp, b_hyp, - hyp_coarsen_type, hyp_interp_type, p_max_elmts, agg_num_levels, + solver_data = hypre_create_hierarchy(A_hyp, x_hyp, b_hyp, + hyp_coarsen_type, hyp_interp_type, p_max_elmts, agg_num_levels, strong_threshold, 0.0); A_array = hypre_ParAMGDataAArray((hypre_ParAMGData*) solver_data); P_array = hypre_ParAMGDataPArray((hypre_ParAMGData*) solver_data); - for (int level = 0; level < ml->num_levels - 1; level++) + for (int level = 0; level < ml->num_levels - 1; level++) { compare(ml->levels[level]->P, P_array[level]); compare(ml->levels[level+1]->A, A_array[level+1]); } - hypre_BoomerAMGDestroy(solver_data); + hypre_BoomerAMGDestroy(solver_data); HYPRE_IJMatrixDestroy(Aij); delete ml; delete A; } // end of TEST(TestHypre, TestsInRuge_Stuben) // - - - - - - - diff --git a/raptor/ruge_stuben/tests/test_hypre_interpolation.cpp b/raptor/ruge_stuben/tests/test_hypre_interpolation.cpp index 5252ac68..3c9b9629 100644 --- a/raptor/ruge_stuben/tests/test_hypre_interpolation.cpp +++ b/raptor/ruge_stuben/tests/test_hypre_interpolation.cpp @@ -11,22 +11,16 @@ using namespace raptor; -void form_hypre_weights(double** weight_ptr, int n_rows) +void form_hypre_weights(std::vector & weights, int n_rows) { int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); hypre_SeedRand(2747 + rank); - double* weights; - if (n_rows) + weights.resize(n_rows); + for (int i = 0; i < n_rows; i++) { - weights = new double[n_rows]; - for (int i = 0; i < n_rows; i++) - { - weights[i] = hypre_Rand(); - } + weights[i] = hypre_Rand(); } - - *weight_ptr = weights; } int main(int argc, char** argv) @@ -39,16 +33,14 @@ int main(int argc, char** argv) } // end of main() // TEST(TestHypreInterpolation, TestsInRuge_Stuben) -{ +{ int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - FILE* f; std::vector states; std::vector off_proc_states; - double* weights; - int cf; + std::vector weights; ParCSRMatrix* A; ParCSRMatrix* S; @@ -57,9 +49,10 @@ TEST(TestHypreInterpolation, TestsInRuge_Stuben) hypre_ParCSRMatrix* A_hyp; hypre_ParCSRMatrix* S_hyp; hypre_ParCSRMatrix* P_hyp; - int* states_hypre; - int* coarse_dof_func; - int* coarse_pnts_gbl; + hypre_IntArray* states_hypre = NULL; + hypre_IntArray* coarse_dof_func = NULL; + std::vector coarse_pnts_gbl; + coarse_pnts_gbl.resize(num_procs + 1); const char* A0_fn = "../../../../test_data/rss_A0.pm"; const char* A1_fn = "../../../../test_data/rss_A1.pm"; @@ -67,82 +60,74 @@ TEST(TestHypreInterpolation, TestsInRuge_Stuben) // TEST LEVEL 0 A = readParMatrix(A0_fn); - form_hypre_weights(&weights, A->local_num_rows); + form_hypre_weights(weights, A->local_num_rows); Aij = convert(A); HYPRE_IJMatrixGetObject(Aij, (void**) &A_hyp); S = A->strength(Classical, 0.25); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, 1, NULL, &S_hyp); compareS(S, S_hyp); - split_pmis(S, states, off_proc_states, false, weights); + split_pmis(S, states, off_proc_states, false, weights.data()); hypre_BoomerAMGCoarsenPMIS(S_hyp, A_hyp, 0, 0, &states_hypre); compare_states(A->local_num_rows, states, states_hypre); - + // Modified Classical Interpolation hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, 1, NULL, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + &coarse_dof_func, coarse_pnts_gbl.data()); P = mod_classical_interpolation(A, S, states, off_proc_states, false); - hypre_BoomerAMGBuildInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, 1, NULL, 0, 0.0, 0.0, NULL, &P_hyp); + hypre_BoomerAMGBuildInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), 1, NULL, 0, 0.0, 0, &P_hyp); compare(P, P_hyp); hypre_ParCSRMatrixDestroy(P_hyp); delete P; - + // Extended+i Interpolation hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, 1, NULL, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + &coarse_dof_func, coarse_pnts_gbl.data()); P = extended_interpolation(A, S, states, off_proc_states, 0.3, false); - hypre_BoomerAMGBuildExtPIInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, 1, NULL, 0, 0.3, 0, NULL, &P_hyp); + hypre_BoomerAMGBuildExtPIInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), 1, NULL, 0, 0.3, 0, &P_hyp); compare(P, P_hyp); hypre_ParCSRMatrixDestroy(P_hyp); delete P; - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); + states_hypre = NULL; HYPRE_IJMatrixDestroy(Aij); hypre_ParCSRMatrixDestroy(S_hyp); - delete[] weights; delete S; delete A; // TEST LEVEL 1 A = readParMatrix(A1_fn); - form_hypre_weights(&weights, A->local_num_rows); + form_hypre_weights(weights, A->local_num_rows); Aij = convert(A); HYPRE_IJMatrixGetObject(Aij, (void**) &A_hyp); S = A->strength(Classical, 0.25); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, 1, NULL, &S_hyp); - split_pmis(S, states, off_proc_states, false, weights); + split_pmis(S, states, off_proc_states, false, weights.data()); hypre_BoomerAMGCoarsenPMIS(S_hyp, A_hyp, 0, 0, &states_hypre); - + // Modified Classical Interpolation hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, 1, NULL, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + &coarse_dof_func, coarse_pnts_gbl.data()); P = mod_classical_interpolation(A, S, states, off_proc_states, false); - hypre_BoomerAMGBuildInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, 1, NULL, 0, 0.0, 0, NULL, &P_hyp); + hypre_BoomerAMGBuildInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), 1, NULL, 0, 0.0, 0, &P_hyp); compare(P, P_hyp); hypre_ParCSRMatrixDestroy(P_hyp); delete P; - + // Extended+i Interpolation hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, 1, NULL, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + &coarse_dof_func, coarse_pnts_gbl.data()); P = extended_interpolation(A, S, states, off_proc_states, 0.3, false); - hypre_BoomerAMGBuildExtPIInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, 1, NULL, 0, 0.3, 0, NULL, &P_hyp); + hypre_BoomerAMGBuildExtPIInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), 1, NULL, 0, 0.3, 0, &P_hyp); compare(P, P_hyp); hypre_ParCSRMatrixDestroy(P_hyp); delete P; - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); HYPRE_IJMatrixDestroy(Aij); hypre_ParCSRMatrixDestroy(S_hyp); - delete[] weights; delete S; delete A; - - - } // end of TEST(TestParSplitting, TestsInRuge_Stuben) // - - - - diff --git a/raptor/ruge_stuben/tests/test_hypre_splitting.cpp b/raptor/ruge_stuben/tests/test_hypre_splitting.cpp index 020d05b3..85f714d4 100644 --- a/raptor/ruge_stuben/tests/test_hypre_splitting.cpp +++ b/raptor/ruge_stuben/tests/test_hypre_splitting.cpp @@ -16,7 +16,7 @@ void form_hypre_weights(double** weight_ptr, int n_rows) int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); hypre_SeedRand(2747 + rank); - double* weights; + double* weights = nullptr; if (n_rows) { weights = new double[n_rows]; @@ -39,23 +39,21 @@ int main(int argc, char** argv) } // end of main() // TEST(TestParSplitting, TestsInRuge_Stuben) -{ +{ int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - FILE* f; std::vector states; std::vector off_proc_states; double* weights; - int cf; ParCSRMatrix* A; ParCSRMatrix* S_rap; HYPRE_IJMatrix Aij; hypre_ParCSRMatrix* A_hyp; hypre_ParCSRMatrix* S_hyp; - int* states_hypre; + hypre_IntArray * states_hypre = NULL; const char* A0_fn = "../../../../test_data/rss_A0.pm"; const char* A1_fn = "../../../../test_data/rss_A1.pm"; @@ -69,7 +67,7 @@ TEST(TestParSplitting, TestsInRuge_Stuben) compare(A, A_hyp); S_rap = A->strength(Classical, 0.25); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, 1, NULL, &S_hyp); - + // Ruge // p @@ -81,15 +79,16 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } } - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); + states_hypre = NULL; // Falgout // TODO --Ruge stuben doesnt match hypre @@ -117,15 +116,16 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } } - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); + states_hypre = NULL; // HMIS -- TODO // TODO --Ruge stuben doesnt match hypre @@ -163,7 +163,7 @@ TEST(TestParSplitting, TestsInRuge_Stuben) compare(A, A_hyp); S_rap = A->strength(Classical, 0.25); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, 1, NULL, &S_hyp); - + // Ruge // TODO - implementation doesnt match hypre @@ -175,15 +175,16 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } } - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); + states_hypre = NULL; // Falgout // TODO - RS implementation doesnt match hypre @@ -196,20 +197,20 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } } - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); // HMIS // TODO - RS implementation doesnt match hypre - + HYPRE_IJMatrixDestroy(Aij); hypre_ParCSRMatrixDestroy(S_hyp); @@ -219,6 +220,3 @@ TEST(TestParSplitting, TestsInRuge_Stuben) } // end of TEST(TestParSplitting, TestsInRuge_Stuben) // - - - diff --git a/raptor/ruge_stuben/tests/test_hypre_unknown.cpp b/raptor/ruge_stuben/tests/test_hypre_unknown.cpp index 9c475625..ff106a68 100644 --- a/raptor/ruge_stuben/tests/test_hypre_unknown.cpp +++ b/raptor/ruge_stuben/tests/test_hypre_unknown.cpp @@ -47,7 +47,7 @@ int* create_unknown_variables(int local_n, int first_n, int num_var) { variables[idx++] = k++; } - + return variables; } @@ -56,7 +56,7 @@ void form_hypre_weights(double** weight_ptr, int n_rows) int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); hypre_SeedRand(2747 + rank); - double* weights; + double* weights = nullptr; if (n_rows) { weights = new double[n_rows]; @@ -70,14 +70,11 @@ void form_hypre_weights(double** weight_ptr, int n_rows) } TEST(TestParSplitting, TestsInRuge_Stuben) -{ +{ int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - FILE* f; - int cf; - ParCSRMatrix* A; ParCSRMatrix* S; ParCSRMatrix* P; @@ -87,9 +84,10 @@ TEST(TestParSplitting, TestsInRuge_Stuben) hypre_ParCSRMatrix* S_hyp; hypre_ParCSRMatrix* P_hyp; - int* states_hypre; - int* coarse_dof_func; - int* coarse_pnts_gbl; + hypre_IntArray *states_hypre = NULL; + hypre_IntArray *coarse_dof_func = NULL; + std::vector coarse_pnts_gbl; + coarse_pnts_gbl.resize(num_procs + 1); std::vector states; std::vector off_proc_states; @@ -109,7 +107,7 @@ TEST(TestParSplitting, TestsInRuge_Stuben) compare(A, A_hyp); // Create strength with unknown approach - var = create_unknown_variables(A->local_num_rows, + var = create_unknown_variables(A->local_num_rows, A->partition->first_local_row, num_variables); S = A->strength(Classical, 0.25, false, num_variables, var); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, num_variables, var, &S_hyp); @@ -122,31 +120,35 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1 || states[i] == -3) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } } std::vector coarse_variables; + auto * hypre_var = hypre_IntArrayCreate(A->local_num_rows); + hypre_IntArrayInitialize(hypre_var); for (int i = 0; i < A->local_num_rows; i++) { - if (states[i] == 1) + if (states[i] == 1) coarse_variables.push_back(var[i]); + hypre_IntArrayData(hypre_var)[i] = var[i]; } - hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, num_variables, var, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + + hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, num_variables, hypre_var, states_hypre, + &coarse_dof_func, coarse_pnts_gbl.data()); for (int i = 0; i < coarse_variables.size(); i++) { - ASSERT_EQ(coarse_variables[i], coarse_dof_func[i]); + ASSERT_EQ(coarse_variables[i], hypre_IntArrayData(coarse_dof_func)[i]); } P = mod_classical_interpolation(A, S, states, off_proc_states, false, num_variables, var); - hypre_BoomerAMGBuildInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, num_variables, var, 0, 0.0, 0.0, NULL, &P_hyp); + hypre_BoomerAMGBuildInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), num_variables, var, 0, 0.0, 0.0, &P_hyp); compare(P, P_hyp); ParCSRMatrix* APtmp = A->mult(P); @@ -163,11 +165,12 @@ TEST(TestParSplitting, TestsInRuge_Stuben) delete P; - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); + states_hypre = NULL; hypre_ParCSRMatrixDestroy(S_hyp); delete S; delete[] var; - + HYPRE_IJMatrixDestroy(Aij); delete A; @@ -180,7 +183,7 @@ TEST(TestParSplitting, TestsInRuge_Stuben) compare(A, A_hyp); num_variables = 2; - var = create_unknown_variables(A->local_num_rows, + var = create_unknown_variables(A->local_num_rows, A->partition->first_local_row, num_variables); S = A->strength(Classical, 0.25, false, num_variables, var); hypre_BoomerAMGCreateS(A_hyp, 0.25, 1.0, num_variables, var, &S_hyp); @@ -193,27 +196,29 @@ TEST(TestParSplitting, TestsInRuge_Stuben) { if (states[i] == 1 || states[i] == -3) { - ASSERT_EQ(states[i], states_hypre[i]); + ASSERT_EQ(states[i], hypre_IntArrayData(states_hypre)[i]); } else { ASSERT_EQ(states[i], 0); - ASSERT_EQ(states_hypre[i], -1); + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); } + hypre_IntArrayData(hypre_var)[i] = var[i]; } - hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, num_variables, var, states_hypre, - &coarse_dof_func, &coarse_pnts_gbl); + hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, A->local_num_rows, num_variables, hypre_var, states_hypre, + &coarse_dof_func, coarse_pnts_gbl.data()); P = mod_classical_interpolation(A, S, states, off_proc_states, false, num_variables, var); - hypre_BoomerAMGBuildInterp(A_hyp, states_hypre, S_hyp, coarse_pnts_gbl, num_variables, var, 0, 0.0, 0.0, NULL, &P_hyp); + hypre_BoomerAMGBuildInterp(A_hyp, hypre_IntArrayData(states_hypre), S_hyp, coarse_pnts_gbl.data(), num_variables, var, 0, 0.0, 0.0, &P_hyp); compare(P, P_hyp); hypre_ParCSRMatrixDestroy(P_hyp); delete P; - hypre_TFree(states_hypre, HYPRE_MEMORY_HOST); + hypre_IntArrayDestroy(states_hypre); hypre_ParCSRMatrixDestroy(S_hyp); delete S; delete[] var; + hypre_IntArrayDestroy(hypre_var); HYPRE_IJMatrixDestroy(Aij); delete A; @@ -222,6 +227,3 @@ TEST(TestParSplitting, TestsInRuge_Stuben) } // end of TEST(TestParSplitting, TestsInRuge_Stuben) // - - - diff --git a/raptor/tests/hypre_compare.hpp b/raptor/tests/hypre_compare.hpp index 2be409c8..4651d16b 100644 --- a/raptor/tests/hypre_compare.hpp +++ b/raptor/tests/hypre_compare.hpp @@ -6,7 +6,8 @@ #include "raptor/external/hypre_wrapper.hpp" #include "gtest/gtest.h" -void compare_dimensions(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, +namespace raptor { +inline void compare_dimensions(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, std::vector& new_off_proc_map) { int rank, num_procs; @@ -14,10 +15,8 @@ void compare_dimensions(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, MPI_Comm_size(MPI_COMM_WORLD, &num_procs); hypre_CSRMatrix* A_h_diag = hypre_ParCSRMatrixDiag(A_h); - hypre_CSRMatrix* A_h_offd = hypre_ParCSRMatrixOffd(A_h); HYPRE_Int diag_rows = hypre_CSRMatrixNumRows(A_h_diag); HYPRE_Int diag_cols = hypre_CSRMatrixNumCols(A_h_diag); - HYPRE_Int offd_cols = hypre_CSRMatrixNumCols(A_h_offd); HYPRE_Int first_local_row = hypre_ParCSRMatrixFirstRowIndex(A_h); HYPRE_Int first_local_col = hypre_ParCSRMatrixFirstColDiag(A_h); HYPRE_Int global_rows = hypre_ParCSRMatrixGlobalNumRows(A_h); @@ -76,13 +75,12 @@ void compare_dimensions(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, ASSERT_EQ(A->on_proc_num_cols, diag_cols); } -void compare(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, double tol = 1e-05) +inline void compare(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, double tol = 1e-05) { int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - int first_row, first_col; int start, end; int ctrA, endA; @@ -187,13 +185,12 @@ void compare(ParCSRMatrix* A, hypre_ParCSRMatrix* A_h, double tol = 1e-05) } } -void compareS(ParCSRMatrix* S, hypre_ParCSRMatrix* S_h) +inline void compareS(ParCSRMatrix* S, hypre_ParCSRMatrix* S_h) { int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); - int first_row, first_col; int start, end; int ctrA, endA; @@ -270,17 +267,19 @@ void compareS(ParCSRMatrix* S, hypre_ParCSRMatrix* S_h) } -void compare_states(int n, std::vector& states, int* states_hypre) +inline void compare_states(int n, std::vector& states, hypre_IntArray* states_hypre) { for (int i = 0; i < n; i++) { - if (states[i] == Selected) - ASSERT_EQ(states_hypre[i], 1); - else if (states[i] == Unselected) - ASSERT_EQ(states_hypre[i], -1); - else if (states[i] == NoNeighbors) - ASSERT_EQ(states_hypre[i], -3); + if (states[i] == Selected) { + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], 1); + } else if (states[i] == Unselected) { + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -1); + } else if (states[i] == NoNeighbors) { + ASSERT_EQ(hypre_IntArrayData(states_hypre)[i], -3); + } } } +} #endif