ianhinder / Kranc

A Mathematica package for generating code for solving time dependent partial differential equations
http://kranccode.org
GNU General Public License v2.0
28 stars 10 forks source link

Emit (crude) intermediate code for Chemora. #121

Open dmkoppelman opened 9 years ago

dmkoppelman commented 9 years ago

Currently, Kranc can generate Cactus thorns compatible with CaKernel. For the Kranc trunk version it generates thorns compatible with template gpu_cuda/3dblock, for my branch it generates thorns compatible with gpu_cuda_dc/3dblock2.

In this issue modify Kranc so that it generates thorns compatible both with the gpu_cuda_dc/3dblock2 template and with the new Chemora code generation system (see GBS12 Ticket 128).

The generated thorn will have a new file, Chemora.h, in the src directory. Chemora.h contains intermediate-form code corresponding to the EDL or Kranc script. When the Startup.cc code is executed (something which is currently placed in the thorn's src directory) the intermediate-form code in Chemora.h will be passed to Chemora.

The intermediate-form code is passed to Chemora by a series of function calls. Crude but quick.

Here are the major changes to Kranc:

Most of the generation of intermediate form code is performed in CodeGenCalculation.m. Pre-definitions, grid function loads and stores, and differencing operations are converted into C function calls (what I'll all intermediate form) and collected on Calculation key reference ChemoraContents. In KrancThorn.m ChemoraContents is written to new file Chemora.h, where the intermediate code is wrapped in a procedure named chemora_cg_thorn_startup. The Startup.cc file is modified to call chemora_cg_thorn_startup.

Differencing Operations (changes to Differencing.m) DifferencingProcessCode will now provide the differencing operations in two forms, as strings (the current method), for existing key PreDefinitions; and as MMA expressions, for new key PreDefinitionsExpr.

New function chemoraPrecomputeDerivatives provides information about each use of a differencing operation.

Consider this a quick-and-dirty first try. I expect that as I understand Kranc better I'll generate the intermediate code for Chemora at places that are more appropriate.