From aea4d202870381b2fbf34872915d67c6e3a495c9 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 15:29:40 +0100 Subject: Schedule.m: Reformat some code --- Tools/CodeGen/Schedule.m | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 9ac7ca4..41c6832 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -283,14 +283,19 @@ 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[ + Module[ + {tl}, + tl = NonevolvedTimelevels[groupFromName[#, groups]]; + If[tl===1, + simpleGroupStruct[#, tl, evolutionTimelevels], + evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels]]] &, + (* over *) + nonevolvedGroups], + Map[evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, evolvedGroups], + Map[rhsGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, rhsGroups]]; -- cgit v1.2.3 From 3682e2950acbf4bf48151bf24055bdea6876a205 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 15:35:13 +0100 Subject: Schedule.m: Remove unused maxtimelevels argument --- Tools/CodeGen/Schedule.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 41c6832..3cb14e5 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -28,21 +28,21 @@ Begin["`Private`"]; Scheduling -------------------------------------------------------------------------- *) -simpleGroupStruct[groupName_, timelevels_, maxtimelevels_] := +simpleGroupStruct[groupName_, timelevels_] := { Group -> groupName, Timelevels -> timelevels, MaxTimelevels -> "other_timelevels" }; -evolvedGroupStruct[groupName_, timelevels_, maxtimelevels_] := +evolvedGroupStruct[groupName_, timelevels_] := { Group -> groupName, Timelevels -> timelevels, MaxTimelevels -> "timelevels" }; -rhsGroupStruct[groupName_, timelevels_, maxtimelevels_] := +rhsGroupStruct[groupName_, timelevels_] := { Group -> groupName, Timelevels -> timelevels, @@ -288,15 +288,15 @@ CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG {tl}, tl = NonevolvedTimelevels[groupFromName[#, groups]]; If[tl===1, - simpleGroupStruct[#, tl, evolutionTimelevels], - evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels]]] &, + simpleGroupStruct[#, tl], + evolvedGroupStruct[#, evolutionTimelevels]]] &, (* over *) nonevolvedGroups], - Map[evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, + Map[evolvedGroupStruct[#, evolutionTimelevels] &, evolvedGroups], - Map[rhsGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, + Map[rhsGroupStruct[#, evolutionTimelevels] &, rhsGroups]]; (* Schedule groups defined in calculations *) -- cgit v1.2.3 From 92386da2119859fffae3bddc2f59a24a4df082a5 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 15:43:13 +0100 Subject: Schedule.m: Replace GroupStruct functions with storageStructure function This simplifies and clarifies the code. --- Tools/CodeGen/Schedule.m | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 3cb14e5..8b6ef5e 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -28,25 +28,11 @@ Begin["`Private`"]; Scheduling -------------------------------------------------------------------------- *) -simpleGroupStruct[groupName_, timelevels_] := +storageStructure[groupName_, timelevels_, param_String] := { Group -> groupName, Timelevels -> timelevels, - MaxTimelevels -> "other_timelevels" -}; - -evolvedGroupStruct[groupName_, timelevels_] := -{ - Group -> groupName, - Timelevels -> timelevels, - MaxTimelevels -> "timelevels" -}; - -rhsGroupStruct[groupName_, timelevels_] := -{ - Group -> groupName, - Timelevels -> timelevels, - MaxTimelevels -> "rhs_timelevels" + MaxTimelevels -> param }; groupsSetInCalc[calc_, groups_] := @@ -288,15 +274,15 @@ CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG {tl}, tl = NonevolvedTimelevels[groupFromName[#, groups]]; If[tl===1, - simpleGroupStruct[#, tl], - evolvedGroupStruct[#, evolutionTimelevels]]] &, + storageStructure[#, tl, "other_timelevels"], + storageStructure[#, evolutionTimelevels, "timelevels"]]] &, (* over *) nonevolvedGroups], - Map[evolvedGroupStruct[#, evolutionTimelevels] &, + Map[storageStructure[#, evolutionTimelevels, "timelevels"] &, evolvedGroups], - Map[rhsGroupStruct[#, evolutionTimelevels] &, + Map[storageStructure[#, evolutionTimelevels, "rhs_timelevels"] &, rhsGroups]]; (* Schedule groups defined in calculations *) -- cgit v1.2.3 From 540adbc183c84385c78cd8337c08b1a437362a5e Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 15:49:38 +0100 Subject: Thorn.m: Remove unused params argument from groupStorage function --- Tools/CodeGen/Thorn.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 47c50eb..3eb2bad 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -363,7 +363,7 @@ 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_] := +groupStorage[spec_] := If[mapContains[spec, MaxTimelevels], Flatten[Table[{"if (", lookup[spec, MaxTimelevels], " == ", i, ")\n", "{\n", @@ -501,7 +501,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]}; -- cgit v1.2.3 From 2d7502d4f7cb0dba0b52640de4bb624946460775 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 15:52:24 +0100 Subject: Rename internal MaxTimelevels as TimelevelsParameter The old name was confusing --- Tools/CodeGen/Kranc.m | 2 +- Tools/CodeGen/Schedule.m | 2 +- Tools/CodeGen/Thorn.m | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/CodeGen/Kranc.m b/Tools/CodeGen/Kranc.m index fa2263d..024f85d 100644 --- a/Tools/CodeGen/Kranc.m +++ b/Tools/CodeGen/Kranc.m @@ -107,7 +107,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 8b6ef5e..56af53e 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -32,7 +32,7 @@ storageStructure[groupName_, timelevels_, param_String] := { Group -> groupName, Timelevels -> timelevels, - MaxTimelevels -> param + TimelevelsParameter -> param }; groupsSetInCalc[calc_, groups_] := diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 3eb2bad..39bcee8 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -364,8 +364,8 @@ CreateInterface[implementation_, inheritedImplementations_, includeFiles_, structure for inclusion in the schedule.ccl file to allocate storage for this group. *) groupStorage[spec_] := - If[mapContains[spec, MaxTimelevels], - Flatten[Table[{"if (", lookup[spec, MaxTimelevels], " == ", i, ")\n", + If[mapContains[spec, TimelevelsParameter], + Flatten[Table[{"if (", lookup[spec, TimelevelsParameter], " == ", i, ")\n", "{\n", " STORAGE: ", lookup[spec, Group], "[", i, "]\n", "}\n"}, {i, 1, lookup[spec, Timelevels]}], 1], -- cgit v1.2.3 From 7a654b106b7c29cf5c9522d586478f68ab47657d Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 16:17:43 +0100 Subject: Change format of internal data structure for group storage --- Tools/CodeGen/Schedule.m | 13 ++++++------- Tools/CodeGen/Thorn.m | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 56af53e..c2ce5fa 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -28,11 +28,10 @@ Begin["`Private`"]; Scheduling -------------------------------------------------------------------------- *) -storageStructure[groupName_, timelevels_, param_String] := +storageStructure[groupName_, timelevels_] := { Group -> groupName, - Timelevels -> timelevels, - TimelevelsParameter -> param + Timelevels -> timelevels }; groupsSetInCalc[calc_, groups_] := @@ -274,15 +273,15 @@ CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG {tl}, tl = NonevolvedTimelevels[groupFromName[#, groups]]; If[tl===1, - storageStructure[#, tl, "other_timelevels"], - storageStructure[#, evolutionTimelevels, "timelevels"]]] &, + storageStructure[#, {"other_timelevels", tl}], + storageStructure[#, {"timelevels", evolutionTimelevels}]]] &, (* over *) nonevolvedGroups], - Map[storageStructure[#, evolutionTimelevels, "timelevels"] &, + Map[storageStructure[#, {"timelevels", evolutionTimelevels}] &, evolvedGroups], - Map[storageStructure[#, evolutionTimelevels, "rhs_timelevels"] &, + Map[storageStructure[#, {"rhs_timelevels", evolutionTimelevels}] &, rhsGroups]]; (* Schedule groups defined in calculations *) diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 39bcee8..74259c4 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -364,12 +364,26 @@ CreateInterface[implementation_, inheritedImplementations_, includeFiles_, structure for inclusion in the schedule.ccl file to allocate storage for this group. *) groupStorage[spec_] := - If[mapContains[spec, TimelevelsParameter], - Flatten[Table[{"if (", lookup[spec, TimelevelsParameter], " == ", i, ")\n", - "{\n", - " STORAGE: ", lookup[spec, Group], "[", i, "]\n", - "}\n"}, {i, 1, lookup[spec, Timelevels]}], 1], - {"STORAGE: ", lookup[spec, Group], "[", lookup[spec, Timelevels], "]\n"}] + 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 -- cgit v1.2.3 From e2d5691840a25800f77b970768e495cbfeb6d21c Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 16:23:43 +0100 Subject: Schedule.m: Add comment --- Tools/CodeGen/Schedule.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index c2ce5fa..2688314 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -271,6 +271,7 @@ CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG 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}], -- cgit v1.2.3 From 9d2954eaab73769f6814b4ca050b9a0bf9411548 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 21 Nov 2012 18:16:19 +0100 Subject: Thorn.m: Eliminate some code in the case that no symmetries need to be registered This avoids a compiler warning about an unused variable --- Tools/CodeGen/Thorn.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 74259c4..a86d969 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -679,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]]}, + {}] ] }; -- cgit v1.2.3 From ee0ce24b44c7419cc6ed20c51c3c81a2adbb6980 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 24 Nov 2012 22:27:27 -0500 Subject: Correct translating Max and Min to C --- Tools/CodeGen/CodeGenCactus.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/CodeGen/CodeGenCactus.m b/Tools/CodeGen/CodeGenCactus.m index 83d7e3c..2e73554 100644 --- a/Tools/CodeGen/CodeGenCactus.m +++ b/Tools/CodeGen/CodeGenCactus.m @@ -822,8 +822,8 @@ DefFn[ replacement via the preprocessor for C, so we do it here *) (* Note: Mathematica simplifies Max[xx_] -> xx automatically *) - rhs = rhs //. Max[xx_, yy__] -> fmax[xx, Max[yy]]; - rhs = rhs //. Min[xx_, yy__] -> fmin[xx, Min[yy]]; + rhs = rhs //. Max[xx_, yy__] :> fmax[xx, Max[yy]]; + rhs = rhs //. Min[xx_, yy__] :> fmin[xx, Min[yy]]; rhs = rhs //. Abs[x_] -> fabs[x]; rhs = rhs //. Sign[x_] -> isgn[x]; rhs = rhs //. IntAbs[x_] -> abs[x]; -- cgit v1.2.3 From 008feafaaa39f0cfc81258191994bdc1a6ee646e Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Mon, 26 Nov 2012 19:11:03 +0100 Subject: GenericFD.c: Remove unused GenericFD_PenaltyPrim2Char --- .../KrancNumericalTools/GenericFD/src/GenericFD.c | 47 ---------------------- 1 file changed, 47 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]) { -- cgit v1.2.3