From f24223d812d93fd52ec371cca6056d86a35d8526 Mon Sep 17 00:00:00 2001 From: eschnett Date: Thu, 25 Oct 2012 20:39:06 +0000 Subject: Optimise DECLARE_CCTK_ARGUMENTS Remember variable indices in local static variables. Use these indices to obtain variable pointers. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4896 17b73243-c579-4c4c-a9d2-2d5706c11dac --- lib/sbin/GridFuncStuff.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sbin/GridFuncStuff.pl b/lib/sbin/GridFuncStuff.pl index 38863506..ec25def7 100644 --- a/lib/sbin/GridFuncStuff.pl +++ b/lib/sbin/GridFuncStuff.pl @@ -526,19 +526,24 @@ sub CreateCArgumentDeclarations my $implementation = "\U\"$3\""; my $ntimelevels = $5; my $var = "\"$varname$6\""; + my $fullvar = "\"$3::$varname$6\""; + + if(! $type =~ /^(BYTE|INT|INT1|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) + { + CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); + } + + my $varname0 = $varname; + push(@declarations, "static int cctki_vi_$varname0 = -1;"); + push(@declarations, "if (cctki_vi_$varname0 < 0) cctki_vi_$varname0 = CCTK_VarIndex($fullvar);"); for(my $level = 0; $level < $ntimelevels; $level++) { - push(@declarations, "CCTK_DECLARE_INIT (CCTK_$type * restrict const, $varname, (CCTK_$type *) CCTKi_VarDataPtr(cctkGH, $level, $implementation, $var));"); + push(@declarations, "CCTK_DECLARE_INIT (CCTK_$type * restrict const, $varname, (CCTK_$type *) CCTK_VarDataPtrI(cctkGH, $level, cctki_vi_$varname0));"); # Modify the name for the time level $varname .= '_p'; } - - if(! $type =~ /^(BYTE|INT|INT1|INT2|INT4|INT8|REAL|REAL4|REAL8|REAL16|COMPLEX|COMPLEX8|COMPLEX16|COMPLEX32)$/) - { - CST_error(0,"Unknown argument type $type","",__LINE__,__FILE__); - } } return @declarations; -- cgit v1.2.3