Open allaffa opened 1 year ago
The difference between using shared_ptr
and not is just a matter of convenience. Look closely into what's happening in the example on your first link: the solver is constructed inside the function and is returned outside for further use. Shared pointer allows to convenientrly transfer ownership in this case, so that the solver is properly destroyed and no memory is leaked when it is no longer used. Also, it makes sure that just the pointer to the solver is copied around instead of the large structure. Internaly, the two options are completely equivalent.
Re-partitioning is the more beneficial the larger the number of your MPI processes. You can get away with naive partitioning (just reading chunks of consecutive rows of the input system) for a small (probably up to 8-16) number of processes. When the number of processes grows, the ratio of boundary-to-internal points on the subdomains grows, so that the communication becomes the bottleneck of the solution. Also, using proper partitioning improves the convergence speed and reduces the number of required iterations. This is briefly discussed around Fig. 3 here: https://amgcl.readthedocs.io/en/latest/tutorial/poisson3DbMPI.html.
I see that there are different options proposed to solve a linear system with a distributed matrix in different examples.
Option 1 is described in this example: https://github.com/ddemidov/amgcl/blob/master/examples/mpi/mpi_solver.cpp
Option 2 is described in this example: https://amgcl.readthedocs.io/en/latest/tutorial/poisson3DbMPI.html
make_shared
anymore:I have two questions to ask:
Question 1: Are the two options equivalent, or should one be preferable over the other depending on the situation (e.g., scale, sparsity pattern, ...)? Question 2: In the example https://amgcl.readthedocs.io/en/latest/tutorial/poisson3DbMPI.html, the matrix is re-partitioned before being passed as argument to the solver's constructor. Is this repartition needed, or can one use the original partition as well?
Thank you again for your support and timely response to the questions :-)