mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Reuse amgcl parameters
This commit is contained in:
parent
47e2899ba8
commit
a23d881817
@ -51,7 +51,7 @@ void amgclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doubl
|
|||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "Initializing amgclSolverBackend, matrix size: " << N << " blocks, nnzb: " << nnzb << "\n";
|
out << "Initializing amgclSolverBackend, matrix size: " << N << " blocks, nnzb: " << nnzb << "\n";
|
||||||
out << "Maxit: " << maxit << std::scientific << ", tolerance: " << tolerance << "\n";
|
out << "Maxit: " << maxit << std::scientific << ", tolerance: " << tolerance << "\n";
|
||||||
out << "PlatformID: " << platformID << ", deviceID: " << deviceID << "\n";
|
out << "DeviceID: " << deviceID << "\n";
|
||||||
OpmLog::info(out.str());
|
OpmLog::info(out.str());
|
||||||
out.str("");
|
out.str("");
|
||||||
out.clear();
|
out.clear();
|
||||||
@ -63,14 +63,22 @@ void amgclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doubl
|
|||||||
x.resize(N);
|
x.resize(N);
|
||||||
|
|
||||||
#if AMGCL_CUDA
|
#if AMGCL_CUDA
|
||||||
|
cudaDeviceProp prop;
|
||||||
|
cudaGetDeviceProperties(&prop, deviceID);
|
||||||
|
std::cout << prop.name << std::endl;
|
||||||
cusparseCreate(&bprm.cusparse_handle);
|
cusparseCreate(&bprm.cusparse_handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set amgcl parameters
|
||||||
|
prm.precond.damping = 0.9;
|
||||||
|
prm.solver.maxiter = maxit;
|
||||||
|
prm.solver.tol = tolerance;
|
||||||
|
prm.solver.verbose = (verbosity >= 2);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
} // end initialize()
|
} // end initialize()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
void amgclSolverBackend<block_size>::convert_sparsity_pattern(int *rows, int *cols) {
|
void amgclSolverBackend<block_size>::convert_sparsity_pattern(int *rows, int *cols) {
|
||||||
Timer t;
|
Timer t;
|
||||||
@ -99,6 +107,7 @@ void amgclSolverBackend<block_size>::convert_sparsity_pattern(int *rows, int *co
|
|||||||
}
|
}
|
||||||
} // end convert_sparsity_pattern()
|
} // end convert_sparsity_pattern()
|
||||||
|
|
||||||
|
|
||||||
template <unsigned int block_size>
|
template <unsigned int block_size>
|
||||||
void amgclSolverBackend<block_size>::convert_data(double *vals, int *rows) {
|
void amgclSolverBackend<block_size>::convert_data(double *vals, int *rows) {
|
||||||
Timer t;
|
Timer t;
|
||||||
@ -136,23 +145,12 @@ void amgclSolverBackend<block_size>::solve_system(double *b, WellContributions &
|
|||||||
// create matrix object
|
// create matrix object
|
||||||
auto A = std::tie(N, A_rows, A_cols, A_vals);
|
auto A = std::tie(N, A_rows, A_cols, A_vals);
|
||||||
|
|
||||||
// set parameters
|
// create solver and construct preconditioner
|
||||||
typename Solver::params prm;
|
// don't reuse this unless the preconditioner can be reused
|
||||||
prm.precond.damping = 0.9;
|
|
||||||
prm.solver.maxiter = maxit;
|
|
||||||
prm.solver.tol = tolerance;
|
|
||||||
prm.solver.verbose = (verbosity >= 2);
|
|
||||||
|
|
||||||
// create solver
|
|
||||||
Solver solve(A, prm, bprm);
|
Solver solve(A, prm, bprm);
|
||||||
|
|
||||||
// print info (once)
|
// print info (once)
|
||||||
std::call_once(print_info, [&](){
|
std::call_once(print_info, [&](){
|
||||||
#if AMGCL_CUDA
|
|
||||||
cudaDeviceProp prop;
|
|
||||||
cudaGetDeviceProperties(&prop, deviceID);
|
|
||||||
std::cout << prop.name << std::endl;
|
|
||||||
#endif
|
|
||||||
// print solver structure
|
// print solver structure
|
||||||
std::cout << solve << std::endl;
|
std::cout << solve << std::endl;
|
||||||
});
|
});
|
||||||
|
@ -89,6 +89,7 @@ private:
|
|||||||
std::vector<double> x;
|
std::vector<double> x;
|
||||||
std::once_flag print_info;
|
std::once_flag print_info;
|
||||||
|
|
||||||
|
typename Solver::params prm;
|
||||||
typename Backend::params bprm; // amgcl backend parameters, only used for cusparseHandle
|
typename Backend::params bprm; // amgcl backend parameters, only used for cusparseHandle
|
||||||
|
|
||||||
/// Initialize GPU and allocate memory
|
/// Initialize GPU and allocate memory
|
||||||
|
Loading…
Reference in New Issue
Block a user