diff options
author | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-10-25 20:39:06 +0000 |
---|---|---|
committer | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-10-25 20:39:06 +0000 |
commit | f24223d812d93fd52ec371cca6056d86a35d8526 (patch) | |
tree | 491487b23b9fabfbcef82324d135e1cb805ccdc3 /lib | |
parent | 3866a3e8cce355175a1710717c91b3015fc4c921 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbin/GridFuncStuff.pl | 17 |
1 files changed, 11 insertions, 6 deletions
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; |