From 700c372f3fde605f18b8004b3ec5fba61ecb4a68 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 12 Sep 2013 10:21:36 +0200 Subject: KrancThorn.m: Add more section comments --- Tools/CodeGen/KrancThorn.m | 68 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 50dd4a3..7ab3341 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -240,31 +240,43 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ calcs = SplitCalculations[calcs]; + (* ------------------------------------------------------------------------ + Add MoL groups to declaredGroups + ------------------------------------------------------------------------ *) + rhsGroups = Map[groupName, rhsGroupDefinitions]; rhsODEGroups = Map[groupName, rhsODEGroupDefinitions]; declaredGroups = Join[declaredGroups, rhsGroups, odeGroups, rhsODEGroups]; + (* ------------------------------------------------------------------------ + Add options to calculations + ------------------------------------------------------------------------ *) + calcs = Map[Append[#, ODEGroups -> Join[odeGroups, rhsODEGroups]] &, calcs]; calcs = Map[Append[#, Parameters -> AllNumericParameters[parameters]] &, calcs]; calcs = Map[If[!lookup[#,UseCaKernel,False], #, If[mapContains[#,ExecuteOn], #, Append[#,ExecuteOn->Device]]] &, calcs]; - (* Construct the startup file *) + (* ------------------------------------------------------------------------ + Startup source file + ------------------------------------------------------------------------ *) + InfoMessage[Terse, "Creating startup file"]; startup = CreateStartupFile[thornName, thornName]; - (* Construct the configuration file *) + (* ------------------------------------------------------------------------ + Create CCL files + ------------------------------------------------------------------------ *) + InfoMessage[Terse, "Creating configuration file"]; configuration = CreateConfiguration[opts]; - (* Construct the interface file *) InfoMessage[Terse, "Creating interface file"]; interface = CreateKrancInterface[declaredGroups, groups, implementation, inheritedImplementations, includeFiles, opts]; - (* Construct the param file *) InfoMessage[Terse, "Creating param file"]; param = CreateKrancParam[declaredGroups, groups, @@ -274,13 +286,11 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ defaultEvolutionTimelevels, calcs, opts]; - (* Construct the schedule file *) InfoMessage[Terse, "Creating schedule file"]; schedule = CreateKrancScheduleFile[calcs, groups, Join[evolvedGroups,evolvedODEGroups], Join[rhsGroups,rhsODEGroups], Join[nonevolvedGroups,nonevolvedODEGroups], thornName, evolutionTimelevels,opts]; - (* Construct the cakernel file *) If[OptionValue[UseCaKernel], InfoMessage[Terse, "Creating CaKernel file"]; cakernel = CaKernelCCL[calcs, opts]; @@ -288,22 +298,36 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ cakernel = None; ]; + (* ------------------------------------------------------------------------ + Create Boundary source files + ------------------------------------------------------------------------ *) + boundarySources = CactusBoundary`GetSources[evolvedGroups, groups, implementation, thornName]; - (* Create the MoL registration file (we do this for every thorn, - even if it does not evolve any variables). This could be fixed - later. *) + (* ------------------------------------------------------------------------ + Create MoL registration source file + ------------------------------------------------------------------------ *) + + (* TODO: only do this for thorns with evolved variables *) + InfoMessage[Terse, "Creating MoL registration file"]; molregister = CreateKrancMoLRegister[evolvedGroups, nonevolvedGroups, evolvedODEGroups, nonevolvedODEGroups, groups, implementation, thornName]; + (* ------------------------------------------------------------------------ + Create symmetry registration source file + ------------------------------------------------------------------------ *) + Module[{allGFs = Join[variablesFromGroups[evolvedGroups, groups], variablesFromGroups[nonevolvedGroups, groups]]}, InfoMessage[Terse, "Creating symmetry registration file"]; symregister = CreateSymmetriesRegistrationSource[thornName, implementation, allGFs, reflectionSymmetries, False]]; - (* Write the differencing header file *) + (* ------------------------------------------------------------------------ + Create finite differencing header file + ------------------------------------------------------------------------ *) + InfoMessage[Terse, "Creating differencing header file"]; {pDefs, diffHeader} = CreateDifferencingHeader[partialDerivs, OptionValue[ZeroDimensions], OptionValue[UseVectors], OptionValue[IntParameters]]; diffHeader = Join[ @@ -314,20 +338,29 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ {}], diffHeader]; + (* ------------------------------------------------------------------------ + Process finite differencing header file for OpenCL + ------------------------------------------------------------------------ *) + If[OptionValue[UseOpenCL], diffHeader = OpenCLProcessDifferencingHeader[diffHeader]]; - (* Add the predefinitions into the calcs *) + (* ------------------------------------------------------------------------ + Add predefinitions to calculations + ------------------------------------------------------------------------ *) + calcs = Map[Join[#, {PreDefinitions -> pDefs}] &, calcs]; - ext = CodeGenC`SOURCESUFFIX; + (* ------------------------------------------------------------------------ + Create calculation source files + ------------------------------------------------------------------------ *) + ext = CodeGenC`SOURCESUFFIX; InfoMessage[Terse, "Creating calculation source files"]; hostCalcs = Select[calcs, !CalculationOnDevice[#] &]; deviceCalcs = Select[calcs, CalculationOnDevice]; - (* Construct a source file for each calculation *) calcSources = Join[Map[CreateSetterSource[{#}, False, {}, opts] &, hostCalcs], Map[CaKernelCode[#,opts] &, deviceCalcs]]; @@ -336,13 +369,20 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ incFilenames = Map[lookup[#, Name] <> ext &, hostCalcs]; - (* Makefile *) + (* ------------------------------------------------------------------------ + Create Makefile + ------------------------------------------------------------------------ *) + InfoMessage[Terse, "Creating make file"]; make = CreateMakefile[Join[{"Startup.cc", "RegisterSymmetries.cc"}, {"RegisterMoL.cc"}, If[Length[OptionValue[ParameterConditions]] > 0, {"ParamCheck.cc"}, {}], incFilenames, Map[lookup[#, Filename] &, boundarySources]]]; + (* ------------------------------------------------------------------------ + Create thorn + ------------------------------------------------------------------------ *) + (* Put all the above together and generate the Cactus thorn *) thornspec = {Name -> thornName, Directory -> parentDirectory, -- cgit v1.2.3