diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2013-09-06 23:52:36 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2013-09-06 23:52:36 +0200 |
commit | e69ab5bd00ff28547a68031815a20ad6bc6aa4f5 (patch) | |
tree | 1f9ab24854fe2753a92adc4589caeaf4cafd487c /Tools/CodeGen | |
parent | ff6d8a0a9c94483d5818835bef95ebd4325407d9 (diff) |
CalculationFunction.m: Move OpenCL epilogue to OpenCL.m
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 27 | ||||
-rw-r--r-- | Tools/CodeGen/OpenCL.m | 27 |
2 files changed, 28 insertions, 26 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index d8948cd..27e65c0 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -367,31 +367,8 @@ DefFn[ }], (* OpenCL kernel epilogue *) - If[OptionValue[UseOpenCL], - { - ";\n\n", - Module[ - {ignoreGroups, groupsNames, groupNameList}, - ignoreGroups = {"TmunuBase::stress_energy_scalar", - "TmunuBase::stress_energy_vector", - "TmunuBase::stress_energy_tensor"}; - groupNames = GroupsInCalculation[cleancalc, imp]; - groupNames = Select[groupNames, !MemberQ[ignoreGroups, #] &]; - { - "const char* const groups[] = {\n ", - Riffle[Join[Map[Quote, groupNames], {"NULL"}], ",\n "], - "};\n\n" - } - ], - "static struct OpenCLKernel *kernel = NULL;\n", - "const char* const sources[] = {differencing, source, NULL};\n", - "OpenCLRunTime_CallKernel(cctkGH, CCTK_THORNSTRING, \"" <> functionName <> "\",\n", - " sources, groups, NULL, NULL, NULL, -1,\n", - " imin, imax, &kernel);\n\n" - }, - { - }] - }], + If[OptionValue[UseOpenCL], OpenCLEpilogue[cleancalc, imp, functionName], {}] + }], (* <BodyFunction *) If[lookup[calcp,CallerFunction], DefineCCTKSubroutine[functionName, diff --git a/Tools/CodeGen/OpenCL.m b/Tools/CodeGen/OpenCL.m index 8619b2b..0f267d0 100644 --- a/Tools/CodeGen/OpenCL.m +++ b/Tools/CodeGen/OpenCL.m @@ -18,9 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) -BeginPackage["OpenCL`", {"Errors`", "Helpers`", "Kranc`"}]; +BeginPackage["OpenCL`", {"Errors`", "Helpers`", "Kranc`", "Calculation`", "CodeGen`"}]; OpenCLPrologue; +OpenCLEpilogue; Begin["`Private`"]; @@ -28,6 +29,30 @@ DefFn[ OpenCLPrologue[] := "const char* const source =\n"]; +DefFn[ + OpenCLEpilogue[cleancalc_List, imp_String, functionName_String] := + { + ";\n\n", + Module[ + {ignoreGroups, groupsNames, groupNameList}, + ignoreGroups = {"TmunuBase::stress_energy_scalar", + "TmunuBase::stress_energy_vector", + "TmunuBase::stress_energy_tensor"}; + groupNames = GroupsInCalculation[cleancalc, imp]; + groupNames = Select[groupNames, !MemberQ[ignoreGroups, #] &]; + { + "const char* const groups[] = {\n ", + Riffle[Join[Map[Quote, groupNames], {"NULL"}], ",\n "], + "};\n\n" + } + ], + "static struct OpenCLKernel *kernel = NULL;\n", + "const char* const sources[] = {differencing, source, NULL};\n", + "OpenCLRunTime_CallKernel(cctkGH, CCTK_THORNSTRING, \"" <> functionName <> "\",\n", + " sources, groups, NULL, NULL, NULL, -1,\n", + " imin, imax, &kernel);\n\n" + }]; + End[]; EndPackage[]; |