From 3a5e73e4c8e2871f7912f7525c8b5d997803d3d3 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Wed, 14 Jun 2023 14:05:42 +0200 Subject: [PATCH] adjust NTH in samples/pdegen --- .../{amg_d_pde2d.f90 => amg_d_pde2d.F90} | 18 ++++++++++++++++-- .../{amg_d_pde3d.f90 => amg_d_pde3d.F90} | 16 +++++++++++++++- .../{amg_s_pde2d.f90 => amg_s_pde2d.F90} | 18 ++++++++++++++++-- .../{amg_s_pde3d.f90 => amg_s_pde3d.F90} | 16 +++++++++++++++- 4 files changed, 62 insertions(+), 6 deletions(-) rename samples/advanced/pdegen/{amg_d_pde2d.f90 => amg_d_pde2d.F90} (98%) rename samples/advanced/pdegen/{amg_d_pde3d.f90 => amg_d_pde3d.F90} (98%) rename samples/advanced/pdegen/{amg_s_pde2d.f90 => amg_s_pde2d.F90} (98%) rename samples/advanced/pdegen/{amg_s_pde3d.f90 => amg_s_pde3d.F90} (98%) diff --git a/samples/advanced/pdegen/amg_d_pde2d.f90 b/samples/advanced/pdegen/amg_d_pde2d.F90 similarity index 98% rename from samples/advanced/pdegen/amg_d_pde2d.f90 rename to samples/advanced/pdegen/amg_d_pde2d.F90 index c036aa6d..37e9fcd6 100644 --- a/samples/advanced/pdegen/amg_d_pde2d.f90 +++ b/samples/advanced/pdegen/amg_d_pde2d.F90 @@ -73,6 +73,9 @@ program amg_d_pde2d use amg_d_pde2d_exp_mod use amg_d_pde2d_box_mod use amg_d_genpde_mod +#if defined(OPENMP) + use omp_lib +#endif implicit none ! input parameters @@ -93,7 +96,7 @@ program amg_d_pde2d type(psb_d_vect_type) :: x,b,r ! parallel environment type(psb_ctxt_type) :: ctxt - integer(psb_ipk_) :: iam, np + integer(psb_ipk_) :: iam, np, nth ! solver parameters integer(psb_ipk_) :: iter, itmax,itrace, istopc, irst, nlv @@ -197,6 +200,15 @@ program amg_d_pde2d call psb_init(ctxt) call psb_info(ctxt,iam,np) +#if defined(OPENMP) + !$OMP parallel shared(nth) + !$OMP master + nth = omp_get_num_threads() + !$OMP end master + !$OMP end parallel +#else + nth = 1 +#endif if (iam < 0) then ! This should not happen, but just in case @@ -451,7 +463,9 @@ program amg_d_pde2d call psb_sum(ctxt,precsize) call prec%descr(info,iout=psb_out_unit) if (iam == psb_root_) then - write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Number of threads : ",i12)') nth + write(psb_out_unit,'("Total number of tasks : ",i12)') nth*np write(psb_out_unit,'("Linear system size : ",i12)') system_size write(psb_out_unit,'("PDE Coefficients : ",a)') trim(pdecoeff) write(psb_out_unit,'("Krylov method : ",a)') trim(s_choice%kmethd) diff --git a/samples/advanced/pdegen/amg_d_pde3d.f90 b/samples/advanced/pdegen/amg_d_pde3d.F90 similarity index 98% rename from samples/advanced/pdegen/amg_d_pde3d.f90 rename to samples/advanced/pdegen/amg_d_pde3d.F90 index 1f6118ca..a1ceea84 100644 --- a/samples/advanced/pdegen/amg_d_pde3d.f90 +++ b/samples/advanced/pdegen/amg_d_pde3d.F90 @@ -74,6 +74,9 @@ program amg_d_pde3d use amg_d_pde3d_exp_mod use amg_d_pde3d_gauss_mod use amg_d_genpde_mod +#if defined(OPENMP) + use omp_lib +#endif implicit none ! input parameters @@ -94,7 +97,7 @@ program amg_d_pde3d type(psb_d_vect_type) :: x,b,r ! parallel environment type(psb_ctxt_type) :: ctxt - integer(psb_ipk_) :: iam, np + integer(psb_ipk_) :: iam, np, nth ! solver parameters integer(psb_ipk_) :: iter, itmax,itrace, istopc, irst, nlv @@ -198,6 +201,15 @@ program amg_d_pde3d call psb_init(ctxt) call psb_info(ctxt,iam,np) +#if defined(OPENMP) + !$OMP parallel shared(nth) + !$OMP master + nth = omp_get_num_threads() + !$OMP end master + !$OMP end parallel +#else + nth = 1 +#endif if (iam < 0) then ! This should not happen, but just in case @@ -456,6 +468,8 @@ program amg_d_pde3d call prec%descr(info,iout=psb_out_unit) if (iam == psb_root_) then write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Number of threads : ",i12)') nth + write(psb_out_unit,'("Total number of tasks : ",i12)') nth*np write(psb_out_unit,'("Linear system size : ",i12)') system_size write(psb_out_unit,'("PDE Coefficients : ",a)') trim(pdecoeff) write(psb_out_unit,'("Krylov method : ",a)') trim(s_choice%kmethd) diff --git a/samples/advanced/pdegen/amg_s_pde2d.f90 b/samples/advanced/pdegen/amg_s_pde2d.F90 similarity index 98% rename from samples/advanced/pdegen/amg_s_pde2d.f90 rename to samples/advanced/pdegen/amg_s_pde2d.F90 index a81d16ff..eb8a8d63 100644 --- a/samples/advanced/pdegen/amg_s_pde2d.f90 +++ b/samples/advanced/pdegen/amg_s_pde2d.F90 @@ -73,6 +73,9 @@ program amg_s_pde2d use amg_s_pde2d_exp_mod use amg_s_pde2d_box_mod use amg_s_genpde_mod +#if defined(OPENMP) + use omp_lib +#endif implicit none ! input parameters @@ -93,7 +96,7 @@ program amg_s_pde2d type(psb_s_vect_type) :: x,b,r ! parallel environment type(psb_ctxt_type) :: ctxt - integer(psb_ipk_) :: iam, np + integer(psb_ipk_) :: iam, np, nth ! solver parameters integer(psb_ipk_) :: iter, itmax,itrace, istopc, irst, nlv @@ -197,6 +200,15 @@ program amg_s_pde2d call psb_init(ctxt) call psb_info(ctxt,iam,np) +#if defined(OPENMP) + !$OMP parallel shared(nth) + !$OMP master + nth = omp_get_num_threads() + !$OMP end master + !$OMP end parallel +#else + nth = 1 +#endif if (iam < 0) then ! This should not happen, but just in case @@ -451,7 +463,9 @@ program amg_s_pde2d call psb_sum(ctxt,precsize) call prec%descr(info,iout=psb_out_unit) if (iam == psb_root_) then - write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Number of threads : ",i12)') nth + write(psb_out_unit,'("Total number of tasks : ",i12)') nth*np write(psb_out_unit,'("Linear system size : ",i12)') system_size write(psb_out_unit,'("PDE Coefficients : ",a)') trim(pdecoeff) write(psb_out_unit,'("Krylov method : ",a)') trim(s_choice%kmethd) diff --git a/samples/advanced/pdegen/amg_s_pde3d.f90 b/samples/advanced/pdegen/amg_s_pde3d.F90 similarity index 98% rename from samples/advanced/pdegen/amg_s_pde3d.f90 rename to samples/advanced/pdegen/amg_s_pde3d.F90 index 7542c3a2..da5cd173 100644 --- a/samples/advanced/pdegen/amg_s_pde3d.f90 +++ b/samples/advanced/pdegen/amg_s_pde3d.F90 @@ -74,6 +74,9 @@ program amg_s_pde3d use amg_s_pde3d_exp_mod use amg_s_pde3d_gauss_mod use amg_s_genpde_mod +#if defined(OPENMP) + use omp_lib +#endif implicit none ! input parameters @@ -94,7 +97,7 @@ program amg_s_pde3d type(psb_s_vect_type) :: x,b,r ! parallel environment type(psb_ctxt_type) :: ctxt - integer(psb_ipk_) :: iam, np + integer(psb_ipk_) :: iam, np, nth ! solver parameters integer(psb_ipk_) :: iter, itmax,itrace, istopc, irst, nlv @@ -198,6 +201,15 @@ program amg_s_pde3d call psb_init(ctxt) call psb_info(ctxt,iam,np) +#if defined(OPENMP) + !$OMP parallel shared(nth) + !$OMP master + nth = omp_get_num_threads() + !$OMP end master + !$OMP end parallel +#else + nth = 1 +#endif if (iam < 0) then ! This should not happen, but just in case @@ -456,6 +468,8 @@ program amg_s_pde3d call prec%descr(info,iout=psb_out_unit) if (iam == psb_root_) then write(psb_out_unit,'("Computed solution on ",i8," processors")') np + write(psb_out_unit,'("Number of threads : ",i12)') nth + write(psb_out_unit,'("Total number of tasks : ",i12)') nth*np write(psb_out_unit,'("Linear system size : ",i12)') system_size write(psb_out_unit,'("PDE Coefficients : ",a)') trim(pdecoeff) write(psb_out_unit,'("Krylov method : ",a)') trim(s_choice%kmethd)