From cd846335f5afd751f7cfea9855efc52b0331cc30 Mon Sep 17 00:00:00 2001 From: eschnett Date: Thu, 27 Oct 2011 22:21:49 +0000 Subject: Improve performance of Fortran index calculations In Fortran, Cactus currently declares grid functions e.g. as (this is the expansion of DECLARE_CCTK_ARGUMENTS) REAL*8 gxx (X0metric,X1metric,X2metric) where X0metric etc. are integers passed into the routine. Each grid function group has its own, independent size. This has two disadvantages: - The compiler does not know that all grid functions have the same size (namely cctk_lsh), and thus has to perform array index calculations separately for each group - The argument list is longer than neded The enclosed patch declares grid functions via cctk_lsh. Grid arrays are still declared independently. This reduces the code size of e.g. GRHydro/GRHydro_Tmunu.F90 from 6836 to 6241 bytes on my system. I have not attempted to measure a performance difference. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4763 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/include/cctk.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/include/cctk.h') diff --git a/src/include/cctk.h b/src/include/cctk.h index a258dc4d..32bcac79 100644 --- a/src/include/cctk.h +++ b/src/include/cctk.h @@ -37,7 +37,8 @@ cctk_dim,cctk_gsh,cctk_lsh,cctk_lbnd,cctk_ubnd,cctk_lssh,cctk_from,cctk_to,\ cctk_bbox,cctk_delta_time,cctk_time,cctk_delta_space,cctk_origin_space,\ cctk_levfac,cctk_levoff,cctk_levoffdenom,cctk_timefac,cctk_convlevel,\ -cctk_convfac,cctk_nghostzones,cctk_iteration,cctkGH +cctk_convfac,cctk_nghostzones,cctk_iteration,cctkGH,\ +cctk_lsh1,cctk_lsh2,cctk_lsh3 #define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_FARGUMENTS #define _DECLARE_CCTK_FARGUMENTS &&\ @@ -62,7 +63,10 @@ cctk_convfac,cctk_nghostzones,cctk_iteration,cctkGH CCTK_DECLARE(INTEGER,cctk_convfac,)&&\ CCTK_DECLARE(INTEGER,cctk_nghostzones,(cctk_dim))&&\ CCTK_DECLARE(INTEGER,cctk_iteration,)&&\ - CCTK_DECLARE(CCTK_POINTER,cctkGH,)&& + CCTK_DECLARE(CCTK_POINTER,cctkGH,)&&\ + CCTK_DECLARE(INTEGER,cctk_lsh1,)&&\ + CCTK_DECLARE(INTEGER,cctk_lsh2,)&&\ + CCTK_DECLARE(INTEGER,cctk_lsh3,)&& #define CCTK_WARN(a,b) CCTK_Warn(a,__LINE__,__FORTRANFILE__,CCTK_THORNSTRING,b) @@ -164,6 +168,9 @@ cctk_convfac,cctk_nghostzones,cctk_iteration,cctkGH /* Include prototypes for scheduled functions */ #include "cctk_ScheduleFunctions.h" +/* Include prototypes for scheduled functions */ +#include "cctk_ScheduleFunctions.h" + /* Include definitions provided by capabilities */ #include "cctk_Capabilities.h" @@ -479,7 +486,10 @@ static inline int CCTK_VECTGFINDEX4D (const cGH *GH, &((xGH)->cctk_convfac),\ (xGH)->cctk_nghostzones,\ &((xGH)->cctk_iteration),\ - &(xGH) + &(xGH),\ + &(xGH)->cctk_lsh[0],\ + &(xGH)->cctk_lsh[1],\ + &(xGH)->cctk_lsh[2] #define _CCTK_C2F_PROTO int *,\ int *,\ int *,int *, int *, int *, int *,int *,int *,\ @@ -493,7 +503,10 @@ static inline int CCTK_VECTGFINDEX4D (const cGH *GH, int *,\ int *,\ int *,\ - cGH ** + cGH **,\ + int *,\ + int *,\ + int * #define CCTK_EQUALS(a,b) (CCTK_Equals((a),(b))) -- cgit v1.2.3