From 4f7d99154de1e5a7161adb074278df8880c6fcaf Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Wed, 26 Jul 2017 17:08:07 +0100 Subject: [PATCH] Cache ICTXT, IAM and NP --- base/modules/psi_penv_mod.F90 | 23 +++++++++++++++++------ test/pargen/Makefile | 10 +++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/base/modules/psi_penv_mod.F90 b/base/modules/psi_penv_mod.F90 index 4ddb1543..afff8ee1 100644 --- a/base/modules/psi_penv_mod.F90 +++ b/base/modules/psi_penv_mod.F90 @@ -515,18 +515,29 @@ contains integer(psb_mpik_), intent(in) :: ictxt integer(psb_mpik_), intent(out) :: iam, np integer(psb_mpik_) :: info - + ! Cache the values for the most recent CTXT to speed + ! up subsequent queries + integer(psb_mpik_), save :: lctxt=-1, lam, lnp + #if defined(SERIAL_MPI) iam = 0 np = 1 #else iam = -1 np = -1 - if (ictxt /= mpi_comm_null) then - call mpi_comm_size(ictxt,np,info) - if (info /= mpi_success) np = -1 - call mpi_comm_rank(ictxt,iam,info) - if (info /= mpi_success) iam = -1 + if (ictxt == lctxt) then + iam = lam + np = lnp + else + if (ictxt /= mpi_comm_null) then + call mpi_comm_size(ictxt,np,info) + if (info /= mpi_success) np = -1 + call mpi_comm_rank(ictxt,iam,info) + if (info /= mpi_success) iam = -1 + end if + lctxt = ictxt + lam = iam + lnp = np end if #endif diff --git a/test/pargen/Makefile b/test/pargen/Makefile index 415e8cfe..86dc0523 100644 --- a/test/pargen/Makefile +++ b/test/pargen/Makefile @@ -15,25 +15,25 @@ FINCLUDES=$(FMFLAG)$(INCDIR) $(FMFLAG). EXEDIR=./runs -all: psb_s_pde2d psb_s_pde2d psb_d_pde2d psb_d_pde3d +all: psb_s_pde2d psb_s_pde3d psb_d_pde2d psb_d_pde3d psb_d_pde3d: psb_d_pde3d.o - $(F90LINK) psb_d_pde3d.o -o psb_d_pde3d $(PSBLAS_LIB) $(LDLIBS) + $(FLINK) psb_d_pde3d.o -o psb_d_pde3d $(PSBLAS_LIB) $(LDLIBS) /bin/mv psb_d_pde3d $(EXEDIR) psb_s_pde3d: psb_s_pde3d.o - $(F90LINK) psb_s_pde3d.o -o psb_s_pde3d $(PSBLAS_LIB) $(LDLIBS) + $(FLINK) psb_s_pde3d.o -o psb_s_pde3d $(PSBLAS_LIB) $(LDLIBS) /bin/mv psb_s_pde3d $(EXEDIR) psb_d_pde2d: psb_d_pde2d.o - $(F90LINK) psb_d_pde2d.o -o psb_d_pde2d $(PSBLAS_LIB) $(LDLIBS) + $(FLINK) psb_d_pde2d.o -o psb_d_pde2d $(PSBLAS_LIB) $(LDLIBS) /bin/mv psb_d_pde2d $(EXEDIR) psb_s_pde2d: psb_s_pde2d.o - $(F90LINK) psb_s_pde2d.o -o psb_s_pde2d $(PSBLAS_LIB) $(LDLIBS) + $(FLINK) psb_s_pde2d.o -o psb_s_pde2d $(PSBLAS_LIB) $(LDLIBS) /bin/mv psb_s_pde2d $(EXEDIR)