firedrakeproject / loopy Goto Github PK
View Code? Open in Web Editor NEWFiredrake project mirror of loopy from https://github.com/inducer/loopy
License: MIT License
Firedrake project mirror of loopy from https://github.com/inducer/loopy
License: MIT License
I get the following error when I try to execute a pytential operator with fmm_order=False
/home/bensepan/inducer/pytential/pytential/symbolic/primitives.py:1571: UserWarning: specified the name of the direction vector
return DirectionalSourceDerivative(
/home/bensepan/firedrake/lib/python3.9/site-packages/sumpy/kernel.py:1020: UserWarning: specified the name of the direction vector
return type(kernel)(
Traceback (most recent call last):
File "/home/bensepan/firedrake/lib/python3.9/site-packages/pytools/__init__.py", line 682, in wrapper
return getattr(obj, cache_dict_name)[key]
AttributeError: 'PyOpenCLKernelExecutor' object has no attribute '_memoize_dic_program_info'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bensepan/nonlocal-firedrake-examples/HelmholtzSommerfeldProblem/run_trial.py", line 545, in <module>
true_sol, comp_sol, snes_or_ksp = run_method.run_method(
File "/home/bensepan/nonlocal-firedrake-examples/HelmholtzSommerfeldProblem/methods/run_method.py", line 202, in run_method
ksp, comp_sol = nonlocal_integral_eq(
File "/home/bensepan/nonlocal-firedrake-examples/HelmholtzSommerfeldProblem/methods/nonlocal_integral_eq.py", line 327, in nonlocal_integral_eq
f_grad_convoluted_mm = rhs_grad_op(actx, sigma=true_sol_grad_mm, k=wave_number)
File "/home/bensepan/inducer/pytential/pytential/symbolic/execution.py", line 1062, in __call__
return self.eval(kwargs, array_context=array_context)
File "/home/bensepan/inducer/pytential/pytential/symbolic/execution.py", line 1037, in eval
return self.code.execute(exec_mapper)
File "/home/bensepan/inducer/pytential/pytential/symbolic/compiler.py", line 385, in execute
self.get_exec_function(insn, exec_mapper)(
File "/home/bensepan/inducer/pytential/pytential/symbolic/execution.py", line 343, in exec_compute_potential_insn
source.exec_compute_potential_insn(
File "/home/bensepan/inducer/pytential/pytential/qbx/__init__.py", line 458, in exec_compute_potential_insn
return self._dispatch_compute_potential_insn(
File "/home/bensepan/inducer/pytential/pytential/qbx/__init__.py", line 520, in _dispatch_compute_potential_insn
return func(actx, insn, bound_expr, evaluate, **extra_args)
File "/home/bensepan/inducer/pytential/pytential/qbx/__init__.py", line 808, in exec_compute_potential_insn_direct
evt, output_for_each_kernel = p2p(queue,
File "/home/bensepan/firedrake/lib/python3.9/site-packages/sumpy/p2p.py", line 216, in __call__
return knl(queue, sources=sources, targets=targets, strength=strength,
File "/home/bensepan/firedrake/src/loopy/loopy/program.py", line 396, in __call__
return pex(*args, **kwargs)
File "/home/bensepan/firedrake/src/loopy/loopy/target/pyopencl_execution.py", line 353, in __call__
program_info = self.program_info(self.arg_to_dtype_set(kwargs))
File "/home/bensepan/firedrake/lib/python3.9/site-packages/pytools/__init__.py", line 684, in wrapper
result = function(obj, *args, **kwargs)
File "/home/bensepan/firedrake/src/loopy/loopy/target/pyopencl_execution.py", line 285, in program_info
codegen_result = generate_code_v2(program)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/__init__.py", line 601, in generate_code_v2
generate_code_for_a_single_kernel(in_knl_callable.subkernel,
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/__init__.py", line 524, in generate_code_for_a_single_kernel
codegen_result = generate_host_or_device_program(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/result.py", line 293, in generate_host_or_device_program
codegen_result = build_loop_nest(codegen_state, schedule_index)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 552, in build_loop_nest
insn_group = build_insn_group(sched_index_info_entries, codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 545, in build_insn_group
result = gen_code(new_codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 486, in gen_code
inner = generate_code_for_sched_index(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 114, in generate_code_for_sched_index
codegen_result = generate_host_or_device_program(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/result.py", line 288, in generate_host_or_device_program
codegen_result = set_up_hw_parallel_loops(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/loop.py", line 336, in set_up_hw_parallel_loops
inner = set_up_hw_parallel_loops(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/loop.py", line 253, in set_up_hw_parallel_loops
return next_func(codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 552, in build_loop_nest
insn_group = build_insn_group(sched_index_info_entries, codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 547, in build_insn_group
return result + build_insn_group(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 545, in build_insn_group
result = gen_code(new_codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 486, in gen_code
inner = generate_code_for_sched_index(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 158, in generate_code_for_sched_index
return func(codegen_state, sched_index)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/loop.py", line 441, in generate_sequential_loop_dim_code
inner = build_loop_nest(new_codegen_state, sched_index+1)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 552, in build_loop_nest
insn_group = build_insn_group(sched_index_info_entries, codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 547, in build_insn_group
return result + build_insn_group(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 545, in build_insn_group
result = gen_code(new_codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 486, in gen_code
inner = generate_code_for_sched_index(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 158, in generate_code_for_sched_index
return func(codegen_state, sched_index)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/loop.py", line 441, in generate_sequential_loop_dim_code
inner = build_loop_nest(new_codegen_state, sched_index+1)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 552, in build_loop_nest
insn_group = build_insn_group(sched_index_info_entries, codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 547, in build_insn_group
return result + build_insn_group(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 545, in build_insn_group
result = gen_code(new_codegen_state)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 486, in gen_code
inner = generate_code_for_sched_index(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 198, in generate_code_for_sched_index
return codegen_state.try_vectorized(
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/__init__.py", line 342, in try_vectorized
return func(self)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/control.py", line 200, in <lambda>
lambda inner_cgs: generate_instruction_code(inner_cgs, insn))
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/instruction.py", line 83, in generate_instruction_code
ast = generate_assignment_instruction_code(codegen_state, insn)
File "/home/bensepan/firedrake/src/loopy/loopy/codegen/instruction.py", line 157, in generate_assignment_instruction_code
result = codegen_state.ast_builder.emit_assignment(codegen_state, insn)
File "/home/bensepan/firedrake/src/loopy/loopy/target/c/__init__.py", line 960, in emit_assignment
ecm(insn.expression, prec=PREC_NONE,
File "/home/bensepan/firedrake/src/loopy/loopy/target/c/codegen/expression.py", line 115, in __call__
self.rec(expr, type_context, needed_dtype))
File "/home/bensepan/firedrake/src/loopy/loopy/target/c/codegen/expression.py", line 105, in rec
RecursiveMapper.rec(self, expr, type_context))
File "/home/bensepan/firedrake/lib/python3.9/site-packages/pymbolic/mapper/__init__.py", line 134, in __call__
return method(expr, *args, **kwargs)
File "/home/bensepan/firedrake/src/loopy/loopy/target/opencl.py", line 468, in map_product
real_prd = p.flattened_product(
NameError: name 'p' is not defined
inducer/loopy#222 is now main. ๐ Ready to reset this to track upstream? :)
Kaushik and me are going to work through this together and I will use this issue to keep track of the state of the vectorisation merge a bit more publicly here.
The History
There are two branches https://github.com/firedrakeproject/loopy/commits/cvec was ready to be merged I believe, but it was not good enough and it was suggested to go through the already existing tag for vectorisation rather than constructing a specialised one for the CTarget.
There was a big discussion on how to implement this well in inducer/loopy#130.
My last attempt on a neat implementation was this one https://github.com/firedrakeproject/loopy/commits/cvec-restructure-checks (and in loopy https://github.com/firedrakeproject/loopy/commits/cvec-restructure-checks) and the corresponding branch on PyOP2 side is here https://github.com/OP2/PyOP2/tree/vectorisation-restructure-checks.
I think one of the last results of the discussion about it was this:
The interface (in https://github.com/inducer/loopy/blob/814612b63fe14dd94af12d4238c387a9929b97b9/loopy/codegen/loop.py#L166-L221) is still a bit complicated than I was imagining. I was hoping on the PyOP2 end we do no more than spliting iname -> privatizing -> tagging arrays axes, tagging inames. So the changes that would be needed on the loopy end would be to generalize the vectorization end of codegen so that it does not always fallback to unrolling.
Loopy and PyOP2 have changed
Both PyOP2 and loopy have changed since the last time I looked at this. I updated to the new PyOP2 in https://github.com/OP2/PyOP2/tree/vectorisation-restructure-checks-updatedpyop2, but this still needs to be updated to the new loopy. I was about to update the loopy branch but there were 23 merge conflict and I would need help to get through those. Potentially it would be easier to get pick the right changes on top of a fresh branch.
An application
An application script to see if nothing is breaking (we still vectorise correctly if specified) is here https://github.com/sv2518/MatrixFreeHybridisation/blob/main/test_vectorisation.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.