Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong results with PredicateStores and RoundUp combinations #7892

Closed
TH3CHARLie opened this issue Oct 10, 2023 · 2 comments · Fixed by #7895
Closed

Wrong results with PredicateStores and RoundUp combinations #7892

TH3CHARLie opened this issue Oct 10, 2023 · 2 comments · Fixed by #7895
Assignees
Labels

Comments

@TH3CHARLie
Copy link
Contributor

A repro:

#include "Halide.h"
#include <iostream>
using namespace Halide;

int main() {
    Func input("input");
    Func local_sum("local_sum");
    Func blurry("blurry");
    Var x("x"), y("y");
    RVar yryf;
    input(x, y) = 2 * x + 5 * y;
    RDom r(-2, 5, -2, 5, "rdom_r");
    local_sum(x, y) = 0;
    local_sum(x, y) += input(x + r.x, y + r.y);
    blurry(x, y) = cast<int32_t>(local_sum(x, y) / 25);
    Buffer<int> buf1, buf2;
    {
        Pipeline p({blurry});
        buf1 = p.realize({128, 128});
    }
    {
        Var xo, xi, xoo, xoi, yo, yi;
        local_sum.vectorize(x).split(x, xo, xi, 2, TailStrategy::PredicateStores).split(xo, xoo, xoi, 4, TailStrategy::RoundUp).unroll(xoi);
        local_sum.update(0).unscheduled();
        Pipeline p({blurry});
        buf2 = p.realize({128, 128});
    }
    for (int i = 0; i < 128; ++i) {
        for (int j = 0; j < 128; ++j) {
            if (buf1(i, j) != buf2(i, j)) {
                std::cout << "Error incorrect result at i: " << i << " j: " << j << " expected: " << buf1(i, j) << " actual: " << buf2(i, j) << std::endl;
            }
        }
    }
    return 0;
}
@TH3CHARLie TH3CHARLie added the bug label Oct 10, 2023
@abadams abadams self-assigned this Oct 11, 2023
@abadams
Copy link
Member

abadams commented Oct 12, 2023

Somehow the simplifier is being presented with unpredicated out-of-bounds stores after vectorization and dead-stripping the whole pipeline. Possibly a bug in vectorization.

@abadams
Copy link
Member

abadams commented Oct 12, 2023

Nope, subtle simplifer bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants