1from collections
import OrderedDict
5 "reuse-memory-allocations",
6 "fuse-memory-allocations",
7 "imperfect-nested-loops-to-perfect",
8 "nested-parallel-ops-to-multidimensional",
9 "nested-parallel-ops-to-for-ops",
10 "scf-parallel-loop-fusion",
11 "convert-scf-to-omp-tasks"
42 if passes[pass_name] =={}:
46 for argument
in passes[pass_name].keys():
47 arguments.append(f
"{argument}={passes[pass_name][argument]}")
48 return f
"{pass_name}{{{' '.join(arguments)}}}"
51 passes = OrderedDict()
54 passes.update({
"reuse-memory-allocations" : {
"max-allocation-size": str(self.
max_patch_size)}})
57 passes.update({
"cse": {}})
58 passes.update({
"scf-parallel-loop-fusion": {
"cell_local_callees":
"sourceTerm_bridge,flux_bridge,nonconservativeProduct_bridge,maxEigenvalue_bridge"}})
61 passes.update({
"control-flow-sink" : {}})
62 passes.update({
"imperfect-nested-loops-to-perfect" :{}})
65 raise Exception(
"These passes are contradictory")
67 passes.update({
"nested-parallel-ops-to-multidimensional" : {}})
72 passes.update({
"dslhype-linearize-nested-memrefs" : {}})
73 passes.update({
"canonicalize" : {}})
76 passes.update({
"fuse-memory-allocations": {}})
79 passes.update({f
"""canonicalize,cse,loop-invariant-code-motion,dslhype-host-to-device-memspace{{mem-space=global}},dslhype-include-physics{{physics-file={self.polygeist_function_source_file} mem-space=global}},dslhype-host-to-device-memspace{{mem-space=global}},inline,expand-strided-metadata,fold-memref-alias-ops,symbol-dce,canonicalize,func.func(gpu-map-parallel-loops),convert-parallel-loops-to-gpu,fold-memref-alias-ops,lower-affine,gpu-kernel-outlining,func.func(gpu-async-region),canonicalize,convert-arith-to-llvm{{index-bitwidth=64}},convert-scf-to-cf,convert-cf-to-llvm{{index-bitwidth=64}},nvvm-attach-target{{chip={self.gpu_architecture}}},gpu.module(inline,convert-gpu-to-nvvm,canonicalize,cse),gpu-to-llvm,gpu-module-to-binary,finalize-memref-to-llvm{{index-bitwidth=64}},reconcile-unrealized-casts""": {}})
85 task_args.update({
"mode":
"taskloop"})
87 task_args.update({
"mode":
"task"})
88 task_args.update({
"depend":
"true"})
89 task_args.update({
"chunk":
"8"})
91 task_args.update({
"single_region":
"true"})
92 passes.update({
"convert-scf-to-omp-tasks" : task_args})
94 passes.update({
"convert-scf-to-openmp" : {}})
98 passes.update({
"inline" : {}})
99 passes.update({
"canonicalize" : {}})
102 passes.update({
"cse" : {}})
103 passes.update({
"loop-invariant-code-motion" : {}})
104 passes.update({
"canonicalize" : {}})
105 passes.update({
"expand-strided-metadata" : {}})
106 passes.update({
"fold-memref-alias-ops" : {}})
107 passes.update({
"lower-affine" : {}})
108 passes.update({
"loop-invariant-code-motion" : {}})
109 passes.update({
"canonicalize" : {}})
110 passes.update({
"cse" : {}})
111 passes.update({
"convert-scf-to-cf" : {}})
114 passes.update({
"convert-openmp-to-llvm" : {}})
116 passes.update({
"convert-cf-to-llvm" : {}})
117 passes.update({
"convert-arith-to-llvm" : {}})
118 passes.update({
"convert-math-to-llvm" : {}})
119 passes.update({
"convert-func-to-llvm" : {}})
120 passes.update({
"finalize-memref-to-llvm" : {
"index-bitwidth":
"64"}})
121 passes.update({
"reconcile-unrealized-casts" : {}})
122 passes.update({
"canonicalize" : {}})
123 passes.update({
"cse" : {}})
125 pass_names = list(passes.keys())
126 initial_dslhype_opt_passes = []
129 for pass_name
in pass_names:
130 if pass_name
in PipelineBuilder.xdsl_passes:
135 xdsl_passes_processed =
False
136 pipeline_command = f
"""dslhype-opt --mlir-print-op-generic --pass-pipeline="builtin.module({",".join(initial_dslhype_opt_passes)})" $<"""
137 while index < len(pass_names):
138 next_set_of_passes = []
139 if xdsl_passes_processed:
140 for pass_name
in pass_names[index:]:
141 if pass_name
in PipelineBuilder.xdsl_passes:
145 pipeline_command = f
"""{pipeline_command} | dslhype-opt --mlir-print-op-generic --pass-pipeline="builtin.module({",".join(next_set_of_passes)})" """
146 xdsl_passes_processed =
False
148 for pass_name
in pass_names[index:]:
149 if pass_name
not in PipelineBuilder.xdsl_passes:
153 pipeline_command = f
"""{pipeline_command} | xdsl-opt -p {",".join(next_set_of_passes)},strip-visibility-property"""
154 xdsl_passes_processed =
True
156 return pipeline_command
158 def enable_gpu(self, gpu_vendor, gpu_architecture, polygeist_function_source_file):
167 def enable_omp(self, use_tasks=False, omp_task_version="taskloop", omp_single_region=False):
generate_opt_commands(self)
polygeist_function_source_file
enable_nested_parallel_ops_to_multidimensional(self)
enable_flatten_memrefs(self)
enable_memory_fusion(self)
enable_nested_parallel_ops_to_for_ops(self, max_nested_parallel_count=-1)
nested_parallel_ops_to_multidimensional
inline_polygeist_functions
max_nested_parallel_count
enable_imperfect_nested_loops_to_perfect(self)
enable_gpu(self, gpu_vendor, gpu_architecture, polygeist_function_source_file)
nested_parallel_ops_to_for_ops
enable_inline_polygeist_functions(self, polygeist_function_source_file)
generate_pass_string(self, passes, pass_name)
imperfect_nested_loops_to_perfect
enable_omp(self, use_tasks=False, omp_task_version="taskloop", omp_single_region=False)
enable_memory_reuse(self, max_patch_size)