diff options
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c | 47 | ||||
-rw-r--r-- | Tools/CodeGen/Kranc.m | 2 | ||||
-rw-r--r-- | Tools/CodeGen/Schedule.m | 41 | ||||
-rw-r--r-- | Tools/CodeGen/Thorn.m | 34 |
4 files changed, 42 insertions, 82 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c index 47618f2..35c5a92 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c @@ -447,53 +447,6 @@ void GenericFD_LoopOverInterior(cGH const * restrict const cctkGH, Kranc_Calcula return; } - -static -void GenericFD_PenaltyPrim2Char(cGH const * restrict const cctkGH, int const dir, - int const face, - CCTK_REAL const * restrict const base, - int const * restrict const lbnd, - int const * restrict const lsh, - int const * restrict const from, - int const * restrict const to, - int const rhs_flag, - int const num_modes, - CCTK_POINTER const * restrict const modes, - CCTK_POINTER const * restrict const speeds, - Kranc_Calculation calc) -{ - DECLARE_CCTK_ARGUMENTS - - CCTK_REAL normal[] = {0,0,0}; - CCTK_REAL tangentA[] = {0,0,0}; - CCTK_REAL tangentB[] = {0,0,0}; - int bmin[] = {0,0,0}; - int bmax[] = {cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]}; - CCTK_REAL **all_vars; - int i = 0; - - all_vars = malloc(num_modes*2*sizeof(CCTK_REAL *)); - assert(all_vars != NULL); - - for (i = 0; i < num_modes; i++) - { - all_vars[i] = (CCTK_REAL *) modes[i]; - all_vars[num_modes + i] = (CCTK_REAL *) speeds[i]; - } - - for (int d=0; d<3; ++d) { - normal[d] = base[d]; /* A covector, index down */ - tangentA[d] = base[d+3]; /* A vector, index up */ - tangentB[d] = base[d+6]; /* A vector, index up */ - } - - calc(cctkGH, dir, face, normal, tangentA, tangentB, bmin, bmax, num_modes * 2, all_vars); - - free(all_vars); - - return; -} - void GenericFD_AssertGroupStorage(cGH const * restrict const cctkGH, const char *calc, int ngroups, const char *const group_names[ngroups]) { diff --git a/Tools/CodeGen/Kranc.m b/Tools/CodeGen/Kranc.m index d01dd88..d620cc7 100644 --- a/Tools/CodeGen/Kranc.m +++ b/Tools/CodeGen/Kranc.m @@ -108,7 +108,7 @@ LocalGroups; {AccumulatorBase, ThornImplementation, Name, Type, Extend, Default, Comment, Range, Implementation, Group, SchedulePoint, Language, RequiredGroups, ProvidedGroups, -SynchronizedGroups, StorageGroups, Timelevels, MaxTimelevels, +SynchronizedGroups, StorageGroups, Timelevels, TimelevelsParameter, VariableType, GridType, Dim, Size, Visibility, Variables, Implementations, Value, AllowedValues, UsedParameters, Description, ExtendedParameters, NewParameters, diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 9ac7ca4..2688314 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -28,25 +28,10 @@ Begin["`Private`"]; Scheduling -------------------------------------------------------------------------- *) -simpleGroupStruct[groupName_, timelevels_, maxtimelevels_] := +storageStructure[groupName_, timelevels_] := { Group -> groupName, - Timelevels -> timelevels, - MaxTimelevels -> "other_timelevels" -}; - -evolvedGroupStruct[groupName_, timelevels_, maxtimelevels_] := -{ - Group -> groupName, - Timelevels -> timelevels, - MaxTimelevels -> "timelevels" -}; - -rhsGroupStruct[groupName_, timelevels_, maxtimelevels_] := -{ - Group -> groupName, - Timelevels -> timelevels, - MaxTimelevels -> "rhs_timelevels" + Timelevels -> timelevels }; groupsSetInCalc[calc_, groups_] := @@ -283,15 +268,21 @@ CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG globalStorageGroups = Join[ - Map[Module[{tl}, - tl = NonevolvedTimelevels[groupFromName[#, groups]]; - If[tl===1, - simpleGroupStruct[#, tl, evolutionTimelevels], - evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels]]] &, - nonevolvedGroups], - Map[evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, + Map[ + Module[ + {tl}, + (* Number of timelevels requested for this group, or 1 if no request made *) + tl = NonevolvedTimelevels[groupFromName[#, groups]]; + If[tl===1, + storageStructure[#, {"other_timelevels", tl}], + storageStructure[#, {"timelevels", evolutionTimelevels}]]] &, + (* over *) + nonevolvedGroups], + + Map[storageStructure[#, {"timelevels", evolutionTimelevels}] &, evolvedGroups], - Map[rhsGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, + + Map[storageStructure[#, {"rhs_timelevels", evolutionTimelevels}] &, rhsGroups]]; (* Schedule groups defined in calculations *) diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 47c50eb..a86d969 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -363,13 +363,27 @@ CreateInterface[implementation_, inheritedImplementations_, includeFiles_, (* Given a storage group structure defined above, return a CodeGen structure for inclusion in the schedule.ccl file to allocate storage for this group. *) -groupStorage[spec_, params_] := - If[mapContains[spec, MaxTimelevels], - Flatten[Table[{"if (", lookup[spec, MaxTimelevels], " == ", i, ")\n", - "{\n", - " STORAGE: ", lookup[spec, Group], "[", i, "]\n", - "}\n"}, {i, 1, lookup[spec, Timelevels]}], 1], - {"STORAGE: ", lookup[spec, Group], "[", lookup[spec, Timelevels], "]\n"}] +groupStorage[spec_] := + Module[ + {tls = lookup[spec,Timelevels], + group = lookup[spec, Group]}, + Which[ + IntegerQ[tls], + {"STORAGE: ", group, "[", tls, "]\n"}, + + ListQ[tls], + If[!MatchQ[tls, {_String, _Integer}], + Error["Unrecognized Timelevels value "<>ToString[tls]]]; + Module[ + {param,max}, + {param,max} = tls; + Flatten[ + Table[{"if (", param, " == ", i, ")\n", + "{\n", + " STORAGE: ", group, "[", i, "]\n", + "}\n"}, {i, 1, max}], 1]], + + True, Error["Unrecognized Timelevels value "<>ToString[tls]]]]; (* Given a function scheduling specification as defined above, return @@ -501,7 +515,7 @@ scheduleGroup[spec_,params_] := return a CodeGen block representing a schedule.ccl file. *) CreateSchedule[globalStorageGroups_, scheduledGroups_, scheduledFunctions_, params_] := {whoWhen["CCL"], - Map[SeparatedBlock[groupStorage[#,params]] &, globalStorageGroups], + Map[SeparatedBlock[groupStorage[#]] &, globalStorageGroups], Map[SeparatedBlock[scheduleFunction[#,params]] &, scheduledFunctions], Map[SeparatedBlock[scheduleGroup[#,params]] &, scheduledGroups]}; @@ -665,13 +679,15 @@ CreateSymmetriesRegistrationSource[thornName_, implementationName_, GFs_, reflec {"cctk.h", "cctk_Arguments.h", "cctk_Parameters.h", "Symmetry.h"}], DefineCCTKFunction[ thornName <> "_RegisterSymmetries", "void", + If[Length[spec] > 0, {CommentedBlock["array holding symmetry definitions", "CCTK_INT sym[3];\n\n"], CommentedBlock["Register symmetries of grid functions", - Map[SymmetriesBlock, spec]]} + Map[SymmetriesBlock, spec]]}, + {}] ] }; |