Commit 197ff2eb authored by Jean-Matthieu Gallard's avatar Jean-Matthieu Gallard
Browse files

KernelGen - simplified abstractmodel

parent dfdb9cd3
...@@ -47,6 +47,9 @@ class Configuration: ...@@ -47,6 +47,9 @@ class Configuration:
# path to markupsafe # path to markupsafe
pathToMarkupsafe = os.path.abspath(os.path.join(pathToExaHyPERoot, "Submodules", "markupsafe", "src")) pathToMarkupsafe = os.path.abspath(os.path.join(pathToExaHyPERoot, "Submodules", "markupsafe", "src"))
# internal path to templates
pathToTemplate = os.path.abspath(os.path.join(os.path.dirname(__file__), "templates"))
# simd size of the accepted architectures # simd size of the accepted architectures
simdWidth = { "noarch" : 1, simdWidth = { "noarch" : 1,
......
...@@ -267,7 +267,7 @@ class Controller: ...@@ -267,7 +267,7 @@ class Controller:
model.generateCode() model.generateCode()
if self.config["runtimeDebug"]: if self.config["runtimeDebug"]:
t = time.perf_counter() - start t = time.perf_counter() - start
print(name+": "+str(value)) print(name+": "+str(t))
def generateGemms(self, outputFileName, matmulConfigList): def generateGemms(self, outputFileName, matmulConfigList):
"""Generate the gemms with the given config list using LIBXSMM""" """Generate the gemms with the given config list using LIBXSMM"""
......
...@@ -71,18 +71,15 @@ class AbstractModelBaseClass(): ...@@ -71,18 +71,15 @@ class AbstractModelBaseClass():
sys.exit("Abstract method") # needs to be overriden sys.exit("Abstract method") # needs to be overriden
# render a template to outputFilename using the given context (default = local context) # render a template to outputFilename using the local context
# templateName can either be a string if the template is at the root of the template folder # templateName can either be a string if the template is at the root of the template folder
# or a tuple/list with the path from here (e.g. ["a", "b.tmp"] for a/b.tmp) # or a tuple/list with the path from here (e.g. ["a", "b.tmp"] for a/b.tmp)
def render(self, templateName, outputFilename, context=None): def render(self, templateName, outputFilename):
# set default context to local context if none given loader = jinja2.FileSystemLoader(Configuration.pathToTemplate)
if context == None:
context = self.context
loader = jinja2.FileSystemLoader(os.path.realpath(os.path.join(os.path.dirname(__file__),"..","templates")))
env = jinja2.Environment(loader=loader, trim_blocks=True, lstrip_blocks=True) env = jinja2.Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
if isinstance(templateName, str): if isinstance(templateName, str):
template = env.get_template(templateName) template = env.get_template(templateName)
else: else:
template = env.get_template(os.path.join(*templateName)) template = env.get_template(os.path.join(*templateName))
with open(os.path.join(context["pathToOutputDirectory"],outputFilename), "w") as output: with open(os.path.join(self.context["pathToOutputDirectory"],outputFilename), "w") as output:
output.write(template.render(context)) output.write(template.render(self.context))
...@@ -50,11 +50,10 @@ class FusedSpaceTimePredictorVolumeIntegralModel(AbstractModelBaseClass): ...@@ -50,11 +50,10 @@ class FusedSpaceTimePredictorVolumeIntegralModel(AbstractModelBaseClass):
self.render(("aderdg", template), "fusedSpaceTimePredictorVolumeIntegral.cpp") self.render(("aderdg", template), "fusedSpaceTimePredictorVolumeIntegral.cpp")
if self.context["usePointSources"]: if self.context["usePointSources"]:
localContext = copy.copy(self.context) self.context["usePointSources"] = False
localContext["usePointSources"] = False self.context["nameSuffix"] = "_WithoutPS"
localContext["nameSuffix"] = "_WithoutPS"
self.render(("aderdg", template), "fusedSpaceTimePredictorVolumeIntegral_WithoutPS.cpp", localContext) self.render(("aderdg", template), "fusedSpaceTimePredictorVolumeIntegral_WithoutPS.cpp")
else: else:
# size of the tmpArray # size of the tmpArray
...@@ -64,11 +63,10 @@ class FusedSpaceTimePredictorVolumeIntegralModel(AbstractModelBaseClass): ...@@ -64,11 +63,10 @@ class FusedSpaceTimePredictorVolumeIntegralModel(AbstractModelBaseClass):
self.render(("aderdg", "fusedSPTVI_linear_cpp.template"), "fusedSpaceTimePredictorVolumeIntegral.cpp") self.render(("aderdg", "fusedSPTVI_linear_cpp.template"), "fusedSpaceTimePredictorVolumeIntegral.cpp")
if self.context["usePointSources"]: if self.context["usePointSources"]:
localContext = copy.copy(self.context) self.context["usePointSources"] = False
localContext["usePointSources"] = False self.context["nameSuffix"] = "_WithoutPS"
localContext["nameSuffix"] = "_WithoutPS"
self.render(("aderdg", "fusedSPTVI_linear_cpp.template"), "fusedSpaceTimePredictorVolumeIntegral_WithoutPS.cpp", localContext) self.render(("aderdg", "fusedSPTVI_linear_cpp.template"), "fusedSpaceTimePredictorVolumeIntegral_WithoutPS.cpp")
else: #nonlinear else: #nonlinear
self.context["nDof_seq"] = range(0,self.context["nDof"]) self.context["nDof_seq"] = range(0,self.context["nDof"])
......
...@@ -25,7 +25,7 @@ void {{codeNamespace}}::boundaryConditions( ...@@ -25,7 +25,7 @@ void {{codeNamespace}}::boundaryConditions(
double* stateOut, double* stateOut,
const double* const fluxIn, const double* const fluxIn,
const double* const stateIn, const double* const stateIn,
const double* const gradStateIn, const double* const gradStateIn,
const double* const cellCentre, const double* const cellCentre,
const double* const cellSize, const double* const cellSize,
const double t,const double dt, const double t,const double dt,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment