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

Serialize/deserialize preconditioner? #141

Open
DABH opened this issue Jan 13, 2020 · 3 comments
Open

Serialize/deserialize preconditioner? #141

DABH opened this issue Jan 13, 2020 · 3 comments

Comments

@DABH
Copy link
Contributor

DABH commented Jan 13, 2020

I have a program that I run multiple times. Each time the program runs it uses the same linear system A and solves Ax=b (using AMGCL) with a different right-hand side. Therefore, every time my program runs it's recomputing the preconditioner for the system with AMGCL. Is there any way to serialize the preconditioner to disk (some binary file etc.), and then deserialize the preconditioner (or solver object?) on a subsequent run? It would save a significant amount of time if this were possible since constructing the preconditioner is slow. Thanks for any tips or ideas you might have!

@ddemidov
Copy link
Owner

ddemidov commented Jan 13, 2020

Serialization is not currently possible in amgcl. I am not even sure it is possible to implement it in a generic way: amgcl moves preconditioner data (matrices and vectors) to the backend selected by the user as soon as it does not need the internal structures. Some of the backends (such as CUDA/CUSPARSE) store the data in opaque, non-serializable, formats.

I guess it could be implemented for the builtin backend, using something like boost::serialization, but I am not sure how much time/effort that would take.

What kind of preconditioner do you use? Does setup really take much longer than the solution? I would make sure that compiler optimizations are enabled during compilation, as C++ can be really slow in debug mode.

@DABH
Copy link
Contributor Author

DABH commented Jan 14, 2020

I guess the way to do it would be to serialize whatever internal structures are built right before sending them to the backend.

I'm using the MPI+AMG preconditioner with Chebyshev, and VexCL backend (using CUDA/GPUs). Compiler optimizations (-O3 etc.) are definitely enabled. For a very large (few billion degrees of freedom) and distributed system, with a sufficiently strong preconditioner, constructing the preconditioner can take 3-5min while solving the system is like 2min. So I think there would be a legitimate benefit to being able to quickly load a pre-computed preconditioner rather than rebuilding the same preconditioner every time. But not sure how common my use case is :)

@ddemidov
Copy link
Owner

I guess the way to do it would be to serialize whatever internal structures are built right before sending them to the backend.

Yes, that is a viable idea.

Each time the program runs it uses the same linear system A and solves Ax=b (using AMGCL) with a different right-hand side

By the way, is it possible to setup the preconditioner once and then use it with different right-hand-sides within a single run of the program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants