Skip to content

Commit

Permalink
Restore progress bar behavior during solve
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarbier committed Dec 9, 2024
1 parent ce0c73e commit 9d82162
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/c_default_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ void hmat_factorization_context_init(hmat_factorization_context_t *context) {

void hmat_solve_context_init(hmat_solve_context_t * context) {
memset(context, 0, sizeof(*context));
context->progress = DefaultProgress::getInstance();
}

void hmat_delete_procedure(hmat_procedure_t* proc) {
Expand Down
8 changes: 8 additions & 0 deletions src/c_wrapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ int solve_generic(hmat_matrix_t* holder, const struct hmat_solve_context_t* cont
"lower and upper cannot both be true in hmat_solve_context_t");
DECLARE_CONTEXT;
hmat::HMatInterface<T>* hmat = (hmat::HMatInterface<T>*)holder;
// Solve functions do not receive a progress bar as argument, they use the one
// stored in HMatInterface. Temporarily modify progress bar.
hmat_progress_t * saved_progress = hmat->engine().progress();
hmat->progress(context->progress);
try {
if (context->nr_rhs == 0) {
// B is an HMatrix
Expand All @@ -530,8 +534,12 @@ int solve_generic(hmat_matrix_t* holder, const struct hmat_solve_context_t* cont
}
} catch (const std::exception& e) {
fprintf(stderr, "%s\n", e.what());
// Restore progress bar
hmat->progress(saved_progress);
return 1;
}
// Restore progress bar
hmat->progress(saved_progress);
return 0;
}

Expand Down

0 comments on commit 9d82162

Please sign in to comment.