diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 311b63ff..8c257d73 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -135,7 +135,7 @@ Thorn generation (main entry point for non-tensorial thorns) CheckGroups[groupsOrig]; - groups = Join[groupsOrig, {coordGroup}]; + groups = Union[Join[groupsOrig, {coordGroup}]]; includeFiles = Join[includeFiles, {"GenericFD.h", "Symmetry.h", "sbp_calc_coeffs.h"}]; inheritedImplementations = Join[inheritedImplementations, {"Grid", diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index 08aa00ad..3bd64394 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -55,11 +55,20 @@ eqs = lookup[calc, Equations]; lhss = Map[First, eqs]; gfsInLHS = Union[Cases[lhss, _ ? (MemberQ[gfs,#] &), Infinity]]; - lhsGroupNames = containingGroups[gfsInLHS, groups]; Return[lhsGroupNames] ]; +groupsReadInCalc[calc_, groups_] := + Module[{gfs, eqs, lhss, gfsInLHS, lhsGroupNames}, + gfs = allGroupVariables[groups]; + eqs = lookup[calc, Equations]; + rhss = Map[Last, eqs]; + gfsInRHS = Union[Cases[rhss, _ ? (MemberQ[gfs,#] &), Infinity]]; + rhsGroupNames = containingGroups[gfsInRHS, groups]; + Return[rhsGroupNames] + ]; + (* Each calculation can be scheduled at multiple points, so this function returns a LIST of schedule structures for each calculation *) @@ -100,19 +109,13 @@ (* TODO: Pass this as {keyword,value} pair instead of a string, once Thorn.m understands this format *) - (* TODO: This doesn't work -- I don't know how to access - OptionValue[] in this file. tags = If[OptionValue[UseOpenCL], "OpenCL=1", ""]; - *) - tags = "OpenCL=1"; prefixWithScope[group_] := If[StringMatchQ[ToString[group], __~~"::"~~__], ToString[group], thornName <> "::" <> ToString[group]]; - (* TODO: Don't blindly require/provide all groups, check the - equations instead *) - groupsToRequire = prefixWithScope /@ Map[First, groups]; + groupsToRequire = prefixWithScope /@ groupsReadInCalc[calc, groups]; groupsToProvide = prefixWithScope /@ groupsSetInCalc[calc, groups]; before = lookupDefault[calc, Before, None];