arch = useArchitectureIdentifiedBy(cmdLineArgs.arch) equationsSpec = importlib.util.find_spec(cmdLineArgs.equations) try: equations = equationsSpec.loader.load_module() except: raise RuntimeError('Could not find kernels for ' + cmdLineArgs.equations) adgArgs = inspect.getargspec(equations.ADERDG.__init__).args[1:] cmdArgsDict = vars(cmdLineArgs) args = [cmdArgsDict[key] for key in adgArgs] adg = equations.ADERDG(*args) g = Generator(arch) # Equation-specific kernels adg.addInit(g) adg.addLocal(g) adg.addNeighbor(g) adg.addTime(g) # Common kernels DynamicRupture.addKernels(g, adg, cmdLineArgs.matricesDir, cmdLineArgs.dynamicRuptureMethod) Plasticity.addKernels(g, adg, cmdLineArgs.matricesDir, cmdLineArgs.PlasticityMethod) SurfaceDisplacement.addKernels(g, adg) Point.addKernels(g, adg) # Generate code gemmTools = GeneratorCollection([LIBXSMM(arch), PSpaMM(arch)]) g.generate(cmdLineArgs.outputDir, 'seissol', gemmTools)
# Common kernels include_tensors |= DynamicRupture.addKernels( NamespacedGenerator(g, namespace="dynamicRupture"), adg, cmdLineArgs.matricesDir, cmdLineArgs.dynamicRuptureMethod) Plasticity.addKernels(g, adg, cmdLineArgs.matricesDir, cmdLineArgs.PlasticityMethod) NodalBoundaryConditions.addKernels(g, adg, include_tensors, cmdLineArgs.matricesDir, cmdLineArgs) SurfaceDisplacement.addKernels(g, adg) Point.addKernels(g, adg) # pick up the user's defined gemm tools gemm_tool_list = cmdLineArgs.gemm_tools.replace(" ", "").split(",") generators = [] for tool in gemm_tool_list: if hasattr(gemm_configuration, tool): specific_gemm_class = getattr(gemm_configuration, tool) generators.append(specific_gemm_class(arch)) else: print("YATETO::ERROR: unknown \"{}\" GEMM tool. " "Please, refer to the documentation".format(tool)) sys.exit("failure") # Generate code gemmTools = GeneratorCollection(generators) g.generate(outputDir=cmdLineArgs.outputDir, namespace='seissol', gemm_cfg=gemmTools, include_tensors=include_tensors)
elif cmdLineArgs.app == 'elasticity': elasticity.add(g, options['dim'], options['numFacetBasisFunctions'], options['numElementBasisFunctions'], options['numFacetQuadPoints'], options['numElementQuadPoints'], petsc_alignment) elif cmdLineArgs.app == 'poisson_adapter': poisson_adapter.add(g, options['dim'], options['numFaultBasisFunctions'], options['numFacetQuadPoints']) elif cmdLineArgs.app == 'elasticity_adapter': elasticity_adapter.add(g, options['dim'], options['numFaultBasisFunctions'], options['numFacetQuadPoints']) gemmgen_list = [] if cmdLineArgs.with_libxsmm and cmdLineArgs.app == 'elasticity': gemmgen_list.append(LIBXSMM(arch, cmd=cmdLineArgs.with_libxsmm)) gemmgen_list.append(Eigen(arch)) # Generate code g.generate(outputDir=cmdLineArgs.outputDir, gemm_cfg=GeneratorCollection(gemmgen_list), namespace='tndm::{}'.format(cmdLineArgs.app)) for kernel in g.kernels(): title = 'AST of {}'.format(kernel.name) print(title) print('=' * len(title)) for ast in kernel.ast: PrettyPrinter().visit(ast) print(' ')