- removed comment
Pass CCTK_ARGUMENTS more efficiently in Fortran
CCTK_ARGUMENTS is passed differently in C and in Fortran. In C, only a single pointer is passed, pointing to cctkGH. The cctk_... variables and pointers to grid functions are defined locally from cctkGH. This is efficient, because (a) only a single variable is passed, and (b) the compiler can eliminate unused definitions.
In Fortran, all the cctk_... variables and all grid functions are passed explicitly. This is expensive for the caller, because hundreds of arguments have to be set up and passed to the subroutine. The compiler cannot eliminate any unused variables.
I suggest to change the Fortran calling convention to be the same as the one for C. Since regular Fortran pointers differ significantly from C pointers, I suggest to use "Cray pointers" instead, which are very similar to C pointers. Cray pointers are an extension to the Fortran standard, and are supported by all Fortran compilers I know of.
I attach sample code that shows how to declare, define, and use this convention.
Keyword:
Comments (3)
-
repo owner -
repo owner - removed comment
Erik suggested trying cctk_ash[123] instead of cctk_lsh([123]) which is (a) the correct thing to do since we introduced allocated sizes (in cctk_ash) local shapes (cctk_lsh) and (b) actually does not crash the compiler. So this no longers blocks using Cray pointers.
-
- changed component to Cactus
- removed comment
- Log in to comment
I did some experiments with Cray pointers on my own and found that adding
CCTK_REAL, DIMENSION(cctk_lsh(1),cctk_lsh(2),cctk_lsh(3)) :: evolution_mask CCTK_POINTER_TO_CONST :: evolution_mask_ptr pointer (evolution_mask_ptr, evolution_mask) to EinsteinEvolve/GRHydro/src/GRHydro_Con2Prim.F90/check_GRHydro_C2P_failed around line 2238 leads to an internal compiler error with intel ifort 11.1 20100414
COMPILING arrangements/Zelmani/GRHydro/src/GRHydro_Con2Prim.F90 0_1855
: catastrophic error: Internal compiler error: internal abort Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. in file arrangements/Zelmani/GRHydro/src/GRHydro_Con2Prim.F90, line 2220, column 12
compilation aborted for configs/bns_all/build/GRHydro/GRHydro_Con2Prim.f90 (code 3)
Note that I do not actually access the pointer at all. The ICE goes away if I comment out the OpenMP pragmas further down in the routine or if instead of cctk_lsh(1...2) I hard-code the pointee dimensions (say to 1,2,3 which of course is wrong).
So unless a workaround is found or CCTK_ARGUMENTS somehow does not trigger this then using Cray pointers (while a good idea I think) is not possible right now.