Peano 4
Loading...
Searching...
No Matches
limiterModel.py
Go to the documentation of this file.
22
23
24from .abstractModelBaseClass import AbstractModelBaseClass
25
26from ..utils import MatmulConfig
27
28
30
31 def generateCode(self):
32 self.render(("limiter", "limiter_cpp.template"), "limiter.cpp")
33 # generates gemms
34 if(self.context["useLibxsmm"]):
35 self.controller.generateGemms("asm_limiter.c", self.context["matmulConfigs"].values())
36
37
39 # define a sequence of matmul configs
40 self.context["matmulConfigs"] = {}
41 # shortcut
42 nVar = self.context["nVar"]
43 nVarPad = self.context["nVarPad"]
44 nData = self.context["nData"]
45 nDataPad = self.context["nDataPad"]
46 nDof = self.context["nDof"]
47 nDof2 = nDof*nDof
48 nDofPad = self.context["nDofPad"]
49 nDofLim = self.context["nDofLim"]
50 nDofLim2 = nDofLim*nDofLim
51 nDofLimPad = self.context["nDofLimPad"]
52 nDim = self.context["nDim"]
53
54 # Always overwrite input (no need to set to 0)
55 # Project to FV
56 self.context["matmulConfigs"]["dg2fv_x"] = MatmulConfig(nData , nDofLim, nDof, nData , nDofPad, nDataPad , 1, 0, 0, 1, "dg2fv_x", "nopf", "gemm") # input slice not aligned
57 if(nDim==3):
58 self.context["matmulConfigs"]["dg2fv_y"] = MatmulConfig(nDataPad, nDofLim, nDof, nDofLim*nDataPad , nDofPad, nDofLim*nDataPad , 1, 0, 1, 1, "dg2fv_y", "nopf", "gemm") #M is padded in both input and output
59 self.context["matmulConfigs"]["dg2fv_z"] = MatmulConfig(nData , nDofLim, nDof, nDofLim2*nDataPad, nDofPad, nDofLim2*nData , 1, 0, 1, 0, "dg2fv_z", "nopf", "gemm") # output slice not aligned
60 else:
61 self.context["matmulConfigs"]["dg2fv_y"] = MatmulConfig(nData , nDofLim, nDof, nDofLim*nDataPad , nDofPad, nDofLim*nData , 1, 0, 1, 0, "dg2fv_y", "nopf", "gemm") # output slice not aligned
62
63 # Project to DG
64 self.context["matmulConfigs"]["fv2dg_x"] = MatmulConfig(nData , nDof, nDofLim, nData , nDofLimPad, nDataPad , 1, 0, 0, 1, "fv2dg_x", "nopf", "gemm") # input slice not aligned
65 if(nDim==3):
66 self.context["matmulConfigs"]["fv2dg_y"] = MatmulConfig(nDataPad, nDof, nDofLim, nDof*nDataPad , nDofLimPad, nDof*nDataPad , 1, 0, 1, 1, "fv2dg_y", "nopf", "gemm") #M is padded in both input and output
67 self.context["matmulConfigs"]["fv2dg_z"] = MatmulConfig(nData , nDof, nDofLim, nDof2*nDataPad, nDofLimPad, nDof2*nData , 1, 0, 1, 0, "fv2dg_z", "nopf", "gemm") # output slice not aligned
68 else:
69 self.context["matmulConfigs"]["fv2dg_y"] = MatmulConfig(nData , nDof, nDofLim, nDof*nDataPad , nDofLimPad, nDof*nData , 1, 0, 1, 0, "fv2dg_y", "nopf", "gemm") # output slice not aligned
70
71 # Project to Lobatto for Min/Max
72 self.context["matmulConfigs"]["uh2lob_x"] = MatmulConfig(nData , nDof, nDof, nData , nDofPad, nDataPad , 1, 0, 0, 1, "uh2lob_x", "nopf", "gemm") # input slice not aligned
73 if(nDim==3):
74 self.context["matmulConfigs"]["uh2lob_y"] = MatmulConfig(nDataPad, nDof, nDof, nDof*nDataPad , nDofPad, nDof*nDataPad , 1, 0, 1, 1, "uh2lob_y", "nopf", "gemm") #M is padded in both input and output
75 self.context["matmulConfigs"]["uh2lob_z_slice"] = MatmulConfig(nDataPad, nDof, nDof, nDof2*nDataPad, nDofPad, nDataPad , 1, 0, 1, 1, "uh2lob_z_slice", "nopf", "gemm") # will only write a slice, overwrite
76 else:
77 self.context["matmulConfigs"]["uh2lob_y_slice"] = MatmulConfig(nDataPad, nDof, nDof, nDof*nDataPad , nDofPad, nDataPad , 1, 0, 1, 1, "uh2lob_y_slice", "nopf", "gemm") # will only write a slice, overwrite
78
79 # Project to FV for Min/Max, reuse previous gem except last one for slice
80 if(nDim==3):
81 self.context["matmulConfigs"]["dg2fv_z_slice"] = MatmulConfig(nDataPad , nDofLim, nDof, nDofLim2*nDataPad, nDofPad, nDataPad , 1, 0, 1, 1, "dg2fv_z_slice", "nopf", "gemm") # will only write a slice, overwrite
82 else:
83 self.context["matmulConfigs"]["dg2fv_y_slice"] = MatmulConfig(nDataPad , nDofLim, nDof, nDofLim*nDataPad , nDofPad, nDataPad , 1, 0, 1, 1, "dg2fv_y_slice", "nopf", "gemm") # will only write a slice, overwrite
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ our matrix elements will nabla phi_i dx f By this will be a sparse as these basis functions are chosen to not overlap with each other almost everywhere In other they have only local support We can read off the right hand side values
Specification of a dense matrix-matrix multiplication.