Skip to content

Commit

Permalink
Move CalculationMacros to CodeGenCactus.m
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Jan 27, 2012
1 parent 7cfe4ec commit 2146cd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 15 additions & 1 deletion Tools/CodeGen/CodeGenCactus.m
Expand Up @@ -79,7 +79,7 @@
DataType::usage = "DataType[] returns a string for the grid function data type (e.g. CCTK_REAL)";
SetDataType::usage = "SetDataType[type] sets a string for the grid function data type (e.g. CCTK_REAL)";
CCLBlock;

CalculationMacros;

Begin["`Private`"];

Expand Down Expand Up @@ -701,6 +701,20 @@
CBlock[contents],
If[comment === "", "", Quote[comment]],"\n"}];

CalculationMacros[vectorise_:False] :=
CommentedBlock["Define macros used in calculations",
Map[{"#define ", #, "\n"} &,
{"INITVALUE (42)",
"QAD(x) (SQR(SQR(x)))"} ~Join~
If[vectorise,
{"INV(x) (kdiv(ToReal(1.0),x))",
"SQR(x) (kmul(x,x))",
"CUB(x) (kmul(x,SQR(x)))"},
{"INV(x) ((1.0) / (x))",
"SQR(x) ((x) * (x))",
"CUB(x) ((x) * (x) * (x))"}]
]];

End[];

EndPackage[];
15 changes: 1 addition & 14 deletions Tools/CodeGen/Thorn.m
Expand Up @@ -478,19 +478,6 @@
optional LoopPreIncludes -> {include file list},
Equations -> {{K11_rhs -> 2 A K11, ...}...}} *)

calculationMacros[vectorise_] :=
CommentedBlock["Define macros used in calculations",
Map[{"#define ", #, "\n"} &,
{"INITVALUE (42)",
"QAD(x) (SQR(SQR(x)))"} ~Join~
If[vectorise,
{"INV(x) (kdiv(ToReal(1.0),x))",
"SQR(x) (kmul(x,x))",
"CUB(x) (kmul(x,SQR(x)))"},
{"INV(x) ((1.0) / (x))",
"SQR(x) ((x) * (x))",
"CUB(x) ((x) * (x) * (x))"}]
]];

(* Given a list of Calculation structures as defined above, create a
CodeGen representation of a source file that defines a function for
Expand Down Expand Up @@ -524,7 +511,7 @@
{"cctk_Loop.h", "loopcontrol.h"},
If[OptionValue[UseOpenCL], {"OpenCLRunTime.h"}, {}],
If[OptionValue[UseVectors], {"vectors.h"}, {}]]],
calculationMacros[OptionValue[UseVectors]],
CalculationMacros[OptionValue[UseVectors]],

(* For each function structure passed, create the function and
insert it *)
Expand Down

0 comments on commit 2146cd5

Please sign in to comment.