Commit 97c07f31 authored by Marcel Koch's avatar Marcel Koch
Browse files

update timing names

parent c9b98f55
......@@ -138,7 +138,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
const walberla::uint_t level ) override
{
const auto& timingTree = x.getStorage()->getTimingTree();
timingTree->start( "Ginkgo CG Solver" );
timingTree->start( "Ginkgo Block Solver" );
const auto num_local_dofs = numberOfLocalDoFs< typename FunctionType::Tag >( *storage_, level );
const auto num_global_dofs = numberOfGlobalDoFs< typename FunctionType::Tag >( *storage_, level, comm_->get() );
......@@ -164,20 +164,20 @@ class GinkgoBlockSolver : public Solver< OperatorType >
hyteg::petsc::createVectorFromFunction(
b, num_, std::make_shared< GinkgoVectorProxy >( b_gko.get(), gko::dim< 2 >{ num_global_dofs, 1 }, part_ ), level, All );
if(!host_monolithic_matrix_ || reassembleMatrix_)
if ( !host_monolithic_matrix_ || reassembleMatrix_ )
{
this->setup_ginkgo(A, x, level, b_gko.get());
this->setup_ginkgo( A, x, level, b_gko.get() );
}
auto rhs = dir_handler_->get_rhs( b_gko.get(), x_gko.get() );
auto x0 = dir_handler_->get_initial_guess( x_gko.get() );
timingTree->start( "Ginkgo CG Solver Gather vectors" );
timingTree->start( "Ginkgo Block Solver Gather vectors" );
auto global_rhs = dense::create( host_exec_ );
auto global_x0 = dense::create( host_exec_ );
rhs->convert_to( gko::lend( global_rhs ) );
x0->convert_to( gko::lend( global_x0 ) );
timingTree->stop( "Ginkgo CG Solver Gather vectors" );
timingTree->stop( "Ginkgo Block Solver Gather vectors" );
auto log = gko::share( gko::log::Convergence< valueType >::create( solver_exec_ ) );
if ( monolithic_matrix_->get_size() )
......@@ -185,7 +185,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
auto factory = gko::clone( solver_->get_stop_criterion_factory() );
factory->add_logger( log );
solver_->set_stop_criterion_factory( gko::share( factory ) );
timingTree->start( "Ginkgo CG Solver Apply" );
timingTree->start( "Ginkgo Block Solver Apply" );
if ( comm_->size() > 1 )
{
auto permuted_global_rhs = gko::as< dense >( global_rhs->row_permute( &perm_ ) );
......@@ -197,14 +197,14 @@ class GinkgoBlockSolver : public Solver< OperatorType >
{
solver_->apply( gko::lend( global_rhs ), gko::lend( global_x0 ) );
}
timingTree->stop( "Ginkgo CG Solver Apply" );
timingTree->stop( "Ginkgo Block Solver Apply" );
}
WALBERLA_MPI_BARRIER(); // only necessary to get correct timings
WALBERLA_MPI_BARRIER(); // only necessary to get correct timings
timingTree->start( "Ginkgo CG Solver Scatter vectors" );
timingTree->start( "Ginkgo Block Solver Scatter vectors" );
gather_idxs_ = compute_gather_idxs( part_ );
scatter_global_vector( global_x0.get(), x0, gather_idxs_, comm_ );
timingTree->stop( "Ginkgo CG Solver Scatter vectors" );
timingTree->stop( "Ginkgo Block Solver Scatter vectors" );
dir_handler_->update_solution( x0 );
......@@ -214,12 +214,12 @@ class GinkgoBlockSolver : public Solver< OperatorType >
if ( printInfo_ && comm_->rank() == 0 )
{
WALBERLA_LOG_INFO_ON_ROOT(
"[Ginkgo CG]" << ( !log->has_converged() ? " NOT " : " " ) << "converged after " << log->get_num_iterations()
"[Ginkgo Block]" << ( !log->has_converged() ? " NOT " : " " ) << "converged after " << log->get_num_iterations()
<< " iterations, residual norm: "
<< solver_exec_->copy_val_to_host(
gko::as< gko::matrix::Dense< valueType > >( log->get_residual_norm() )->get_const_values() ) );
}
timingTree->stop( "Ginkgo CG Solver" );
timingTree->stop( "Ginkgo Block Solver" );
}
void setPrintInfo( bool printInfo ) { printInfo_ = printInfo; }
......@@ -227,21 +227,22 @@ class GinkgoBlockSolver : public Solver< OperatorType >
void setReassembleMatrix( bool reassembleMatrix ) { reassembleMatrix_ = reassembleMatrix; }
private:
void setup_ginkgo( const OperatorType& A,
const typename OperatorType::srcType& x,
const walberla::uint_t level,
const vec* b_gko){
void setup_ginkgo( const OperatorType& A,
const typename OperatorType::srcType& x,
const walberla::uint_t level,
const vec* b_gko )
{
const auto& timingTree = x.getStorage()->getTimingTree();
const auto num_global_dofs = b_gko->get_size()[0];
std::vector< int32_t > bcIndices;
hyteg::petsc::applyDirichletBC( num_, bcIndices, level );
std::sort( std::begin( bcIndices ), std::end( bcIndices ) );
timingTree->start( "Ginkgo CG Solver Set-up distributed matrix" );
timingTree->start( "Ginkgo Block Solver Set-up distributed matrix" );
host_monolithic_matrix_ = gko::share( mtx::create( host_exec_, comm_ ) );
dir_handler_ = std::make_unique< ZeroRowsDirichletHandler >( bcIndices, b_gko, host_monolithic_matrix_, true );
dir_handler_ = std::make_unique< ZeroRowsDirichletHandler >( bcIndices, b_gko, host_monolithic_matrix_, true );
{
auto proxy = std::make_shared< GinkgoSparseMatrixProxy< mtx > >(
host_monolithic_matrix_.get(), gko::dim< 2 >{ num_global_dofs, num_global_dofs }, part_ );
......@@ -249,31 +250,30 @@ class GinkgoBlockSolver : public Solver< OperatorType >
proxy->finalize();
dir_handler_->update_matrix();
}
timingTree->stop( "Ginkgo CG Solver Set-up distributed matrix" );
timingTree->stop( "Ginkgo Block Solver Set-up distributed matrix" );
timingTree->start( "Ginkgo CG Solver Set-up distributed preconditioner" );
timingTree->start( "Ginkgo Block Solver Set-up distributed preconditioner" );
auto monolithic_preconditioner_ = gko::share( mtx::create( host_exec_, comm_ ) );
{
auto proxy = std::make_shared< GinkgoSparseMatrixProxy< mtx > >(
monolithic_preconditioner_.get(), gko::dim< 2 >{ num_global_dofs, num_global_dofs }, part_ );
hyteg::petsc::createMatrix( blockPreconditioner_, num_, num_, proxy, level, All );
proxy->finalize();
auto dir_handler_p =
std::make_unique< ZeroRowsDirichletHandler >( bcIndices, b_gko, monolithic_preconditioner_, true );
auto dir_handler_p = std::make_unique< ZeroRowsDirichletHandler >( bcIndices, b_gko, monolithic_preconditioner_, true );
dir_handler_p->update_matrix();
}
timingTree->stop( "Ginkgo CG Solver Set-up distributed preconditioner" );
timingTree->stop( "Ginkgo Block Solver Set-up distributed preconditioner" );
std::vector< int32_t > vIndices;
std::vector< int32_t > pIndices;
timingTree->start( "Ginkgo CG Solver Gather index sets" );
timingTree->start( "Ginkgo Block Solver Gather index sets" );
gatherIndices( vIndices, pIndices, *storage_, level, num_ );
std::sort( vIndices.begin(), vIndices.end() );
std::sort( pIndices.begin(), pIndices.end() );
timingTree->stop( "Ginkgo CG Solver Gather index sets" );
timingTree->stop( "Ginkgo Block Solver Gather index sets" );
timingTree->start( "Ginkgo CG Solver Set-up permutation" );
timingTree->start( "Ginkgo Block Solver Set-up permutation" );
std::vector< int32_t > perm_vec;
std::vector< int32_t > recv_sizes( comm_->size() );
......@@ -295,7 +295,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
pIndices.data(), local_size, perm_vec.data() + global_v_size, recv_sizes.data(), recv_offsets.data(), 0, comm_ );
perm_ = gko::Array< gko::int32 >{ solver_exec_, perm_vec.begin(), perm_vec.end() };
timingTree->stop( "Ginkgo CG Solver Set-up permutation" );
timingTree->stop( "Ginkgo Block Solver Set-up permutation" );
auto [p_v_min, p_v_max] = std::minmax_element( std::begin( vIndices ), std::end( vIndices ) );
auto [p_p_min, p_p_max] = std::minmax_element( std::begin( pIndices ), std::end( pIndices ) );
......@@ -306,35 +306,35 @@ class GinkgoBlockSolver : public Solver< OperatorType >
WALBERLA_ABORT( "Indices are NOT blocked: v" << v_span << ", p" << p_span )
}
timingTree->start( "Ginkgo CG Solver Gather matrix" );
timingTree->start( "Ginkgo Block Solver Gather matrix" );
monolithic_matrix_ = gko::share( csr::create( solver_exec_ ) );
gko::as< mtx >( host_monolithic_matrix_ )->convert_to( monolithic_matrix_.get() );
timingTree->stop( "Ginkgo CG Solver Gather matrix" );
timingTree->stop( "Ginkgo Block Solver Gather matrix" );
if ( comm_->size() > 1 && monolithic_matrix_->get_size() )
{
timingTree->start( "Ginkgo CG Solver Permute matrix" );
timingTree->start( "Ginkgo Block Solver Permute matrix" );
monolithic_matrix_ = gko::as< csr >( monolithic_matrix_->permute( &perm_ ) );
timingTree->stop( "Ginkgo CG Solver Permute matrix" );
timingTree->stop( "Ginkgo Block Solver Permute matrix" );
}
{
timingTree->start( "Ginkgo CG Solver Gather preconditioner" );
timingTree->start( "Ginkgo Block Solver Gather preconditioner" );
auto device_monolithic_pre = gko::share( csr::create( solver_exec_ ) );
monolithic_preconditioner_->convert_to( device_monolithic_pre.get() );
timingTree->stop( "Ginkgo CG Solver Gather preconditioner" );
timingTree->stop( "Ginkgo Block Solver Gather preconditioner" );
if ( device_monolithic_pre->get_size() && device_monolithic_pre->get_size() )
{
gko::span block_v_span{ 0, global_v_size };
gko::span block_p_span{ global_v_size, global_v_size + global_p_size };
timingTree->start( "Ginkgo CG Solver Permute preconditioner" );
timingTree->start( "Ginkgo Block Solver Permute preconditioner" );
device_monolithic_pre = gko::as< csr >( device_monolithic_pre->permute( &perm_ ) );
timingTree->stop( "Ginkgo CG Solver Permute preconditioner" );
timingTree->stop( "Ginkgo Block Solver Permute preconditioner" );
std::shared_ptr< gko::LinOp > b_pre_v;
std::shared_ptr< gko::LinOp > b_pre_p;
timingTree->start( "Ginkgo CG Solver Build block preconditioner" );
timingTree->start( "Ginkgo Block Solver Build block preconditioner" );
auto jac_gen =
gko::share( gko::preconditioner::Jacobi< valueType >::build().with_max_block_size( 1u ).on( solver_exec_ ) );
if ( velocityPreconditionerType_ == 0 )
......@@ -398,7 +398,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
}
else
{
WALBERLA_ABORT( "Invalid velocity preconditioner for Ginkgo block prec BiCGStab solver." );
WALBERLA_ABORT( "Invalid velocity preconditioner for Ginkgo block preconditioner solver." );
}
if ( pressurePreconditionerType_ == 0 )
......@@ -413,7 +413,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
}
else
{
WALBERLA_ABORT( "Invalid pressure preconditioner for Ginkgo block prec BiCGStab solver." );
WALBERLA_ABORT( "Invalid pressure preconditioner for Ginkgo block preconditioner solver." );
}
auto b_pre_vp = gko::share(
......@@ -426,7 +426,7 @@ class GinkgoBlockSolver : public Solver< OperatorType >
gko::dim< 2 >{ global_v_size + global_p_size, global_v_size + global_p_size },
std::vector< std::vector< std::shared_ptr< gko::LinOp > > >{ { b_pre_v, b_pre_vp }, { b_pre_pv, b_pre_p } },
std::vector< gko::span >{ block_v_span, block_p_span } ) );
timingTree->stop( "Ginkgo CG Solver Build block preconditioner" );
timingTree->stop( "Ginkgo Block Solver Build block preconditioner" );
}
WALBERLA_MPI_BARRIER();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment