Overview

Adding a new solver to Exahype2 does not require touching any of the core code of the package. The technology to provide is a code generation infrastructure. At the moment, this is heavily based on python3 and jinja templating. All meta logic will be absorbed in the python module for the new solver. It has the following structure:

class MyNewSolver(ASolverBaseClass):
  def __init__(self,....):
    super init..
  def set_implementation(self,...):
    ...
  def add_implementation_files_to_project(self, ...)
  ...
from peano4.toolbox.blockstructured.ReconstructPatchAndApplyFunctor import ReconstructPatchAndApplyFunctor

class UpdateCell(ReconstructPatchAndApplyFunctor):
  mytemplate_ = """
  ...
  """
  
  def __init__(self, solver):
    super(init) ...
  def get_includes(self):
    ...

Solvers with enclave tasks also need task templates.

Files

write ././AbstractEulerOnGPUAdaptive.h (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithAcceleratorAbstract.template.h)
write ././AbstractEulerOnGPUAdaptive.cpp (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithAcceleratorAbstract.template.cpp)
write ./tasks/EulerOnGPUAdaptiveEnclaveTask.h (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithEnclaves.EnclaveTask.template.h)
write ./tasks/EulerOnGPUAdaptiveEnclaveTask.cpp (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithEnclaves.EnclaveTask.template.cpp)
write ./tasks/EulerOnGPUAdaptiveGPUEnclaveTaskAdaptive.h (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithAccelerator.GPUEnclaveTask.template.h)
write ./tasks/EulerOnGPUAdaptiveGPUEnclaveTaskAdaptive.cpp (generated from template /home/gcgt96/Exa/Peano_ccz4_cpp_again2/python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithAccelerator.GPUEnclaveTask.template.cpp)

Concrete python classes

This new file (based on the fixed timestep version):

python/exahype2/solvers/fv/GenericRusanovAdaptiveTimeStepSizeWithAccelerator.py

Structure:

class GenericRusanovAdaptiveTimeStepSizeWithAccelerator( GenericRusanovAdaptiveTimeStepSizeWithEnclaves ):
  ...
  
  def _GPU_enclave_task_name(self):
    return self._name + "GPUEnclaveTaskAdaptive"
  

class UpdateCellWithEnclavesOnAccelerator(ReconstructPatchAndApplyFunctor):
  TemplateUpdateCell_ = """
  ::exahype2::fv::validatePatch(
    ...
        
        double maxEigvenvalue = ::exahype2::fv::maxEigenvalue_AoS(
      [] (
        const double * __restrict__                  Q,
        const tarch::la::Vector<Dimensions,double>&  faceCentre,
        const tarch::la::Vector<Dimensions,double>&  volumeH,
        double                                       t,
        double                                       dt,
        int                                          normal
      ) -> double {
        return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, volumeH, t, normal);
      },
      ...
    """

Euler example

EulerOnGPUAdaptive.cpp
EulerOnGPUAdaptive.h
AbstractEulerOnGPUAdaptive.cpp
AbstractEulerOnGPUAdaptive.h

Insane