summaryrefslogtreecommitdiff
path: root/lib/sbin
diff options
context:
space:
mode:
authoreschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-10-27 22:21:49 +0000
committereschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-10-27 22:21:49 +0000
commitcd846335f5afd751f7cfea9855efc52b0331cc30 (patch)
treedf1ec872291fcaeb0bdfa9c1cb4e2799138f5c48 /lib/sbin
parent34457bea62fffbb9e73edfafe315d4434dd043cc (diff)
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
Diffstat (limited to 'lib/sbin')
-rw-r--r--lib/sbin/GridFuncStuff.pl32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl
index d12831ed..f564d954 100644
--- a/lib/sbin/GridFuncStuff.pl
+++ b/lib/sbin/GridFuncStuff.pl
@@ -381,19 +381,37 @@ sub GetThornArguments
{
# FIXME: quick hack to shorten argument names
# $type .= "${sep}cctkv$dim$group";
- $type .= "${sep}X$dim$group";
- $sep = ',';
- if($block eq 'PRIVATE')
+ if ($gtype ne 'GF')
{
-# FIXME: quick hack to shorten argument names
-# $arguments{"cctkv$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))";
- $arguments{"X$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))";
+ $type .= "${sep}X$dim$group";
}
else
{
+ my $dim1=$dim+1;
+ if ($dim<3)
+ {
+ $type .= "${sep}cctk_lsh$dim1";
+ }
+ else
+ {
+ $type .= "${sep}cctk_lsh($dim1)";
+ }
+ }
+ $sep = ',';
+ if ($gtype ne 'GF')
+ {
+ if($block eq 'PRIVATE')
+ {
+# FIXME: quick hack to shorten argument names
+# $arguments{"cctkv$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))";
+ $arguments{"X$dim$group"} = "(STORAGESIZE($thorn\::$group, $dim))";
+ }
+ else
+ {
# FIXME: quick hack to shorten argument names
# $arguments{"cctkv$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))";
- $arguments{"X$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))";
+ $arguments{"X$dim$group"} = "(STORAGESIZE($imp\::$group, $dim))";
+ }
}
}
if(defined($vararraysize) && $compactgroup == 0)