Fails to realize reduction when a variable is initialized within the loop
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
When we initialize the variable x within the kernel as shown below, an error is generated indicating that it has failed to realize reduction.
void foo(double step, int steps, double *sum) {
for (int i = 0; i < steps; i++) {
double x = (i + 0.5) * step;
sum[0] += 4.0 / (1.0 + x * x);
}
}
The following error is generated when the kernel is run in loopy_api.py.
Traceback (most recent call last):
File "/home/xenon/projects/nomp/libnomp/python/loopy_api.py", line 813, in <module>
lp_knl = realize_reduction(lp_knl, "sum")
File "/home/xenon/projects/nomp/libnomp/python/reduction.py", line 113, in realize_reduction
tunit = lp.make_kernel(
File "/home/xenon/mambaforge/envs/libnomp/lib/python3.10/site-packages/loopy/kernel/creation.py", line 2569, in make_kernel
tunit = make_function(*args, **kwargs)
File "/home/xenon/mambaforge/envs/libnomp/lib/python3.10/site-packages/loopy/kernel/creation.py", line 2497, in make_function
check_for_duplicate_insn_ids(knl)
File "/home/xenon/mambaforge/envs/libnomp/lib/python3.10/site-packages/loopy/translation_unit.py", line 703, in _collective_transform
return transform(kernel, *args, **kwargs)
File "/home/xenon/mambaforge/envs/libnomp/lib/python3.10/site-packages/loopy/check.py", line 417, in check_for_duplicate_insn_ids
raise LoopyError("duplicate instruction id: '%s'" % insn.id)
loopy.diagnostic.LoopyError: duplicate instruction id: '_nomp_insn'
However, the following kernel works as expected.
void foo(double step, int steps, double *sum) {
for (int i = 0; i < steps; i++) {
sum[0] += 4.0 / (1.0 + (i + 0.5) * step * (i + 0.5) * step);
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in libnomp/python/reduction.py at realize_reduction and reproduce the failure from loopy_api.py using the kernel with the loop-local x initialization. Compare it with the working inline-expression kernel and trace the duplicate _nomp_insn reported by Loopy. Done means the initialized-variable kernel realizes the sum reduction without that error while the existing working case remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- compilers, hpc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100