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

Generator based template for reproducing issues. #7999

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mcourteaux
Copy link
Contributor

Added a README as well on how I envision this being used. With this, I think I can quickly and efficiently open a few issues demonstrating some stuff.

I was a bit confused as to how the folder actually ever gets any files committed to. You make a PR demonstrating the issue, without solving it? In the readme it kinda looks pointless to first copy and rename the directory and reference the issue number.

Also, is the place where I put this fine?
Note, I did not yet attempt any CMake-based build for this template.

Feedback welcome!

@abadams
Copy link
Member

abadams commented Dec 8, 2023

For reference, here's the way I like to disagnose instruction selection issues, because I believe that's one reason you want this:

To figure out issue #7972 I placed the following file and called it test/correctness/scratch.cpp

#include "Halide.h"

using namespace Halide;

int main(int argc, char **argv) {
    Func f, g;
    Var x;

    g(x) = cast<float>(x);
    g.compute_root();

    f(x) = saturating_cast<uint8_t>(g(x));
    f.vectorize(x, 16, TailStrategy::RoundUp);

    Buffer<uint8_t> buf = f.realize({512});
    for (int i = 0; i < 512; i++) {
        printf("%d\n", buf(i));
    }

    f.compile_to_llvm_assembly("/dev/stdout", {}, "f", Target{"wasm-32-wasmrt-wasm_simd128-no_runtime-no_bounds_query-no_asserts-wasm_sat_float_to_int"});
    f.compile_to_assembly("/dev/stdout", {}, "f", Target{"wasm-32-wasmrt-wasm_simd128-no_runtime-no_bounds_query-no_asserts-wasm_sat_float_to_int"});

    return 0;
}

It dumps both llvm IR and raw assembly to stdout. I always use the target flags -no_runtime-no_bounds_query-no_asserts just to cut down on the size of the generated code.

I then ran make correctness_scratch. Not sure what the cmake equivalent would be - I think you would have to also add the file to test/correctness/CMakeLists.txt

@mcourteaux
Copy link
Contributor Author

I then ran make correctness_scratch.

But it's not necessarily a correctness test, right?

A few things I can remember on top of my head I want this for is to demonstrate stuff involving:

  • inefficient PTX code being generated.
  • bounds inference bug (clearly visible in conceptual stmt (html))
  • redundant checks in lowered stmt
  • add_requirements() not being used by simplifier.

I haven't tried your approach, but it seems cumbersome to try to read the generated code from stdout, instead of using the nice tools we already have (like the Stmt HTML) etc.

@abadams
Copy link
Member

abadams commented Dec 8, 2023

No, it's not a correctness test. I just put it there to put it somewhere the build system knows about. I prefer to just read stdout for small things.

I'm not saying the PR isn't useful, I'm just letting you know my approach in case it's helpful.

@mcourteaux
Copy link
Contributor Author

I always use the target flags -no_runtime-no_bounds_query-no_asserts just to cut down on the size of the generated code.

Good point. I updated the Makefile to also do this, and generate a separate runtime to reduce the code size.

Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate this effort, but as a reminder, CMake is the only Fully Supported way to build Halide; Make is still provided on a best-effort approach, but it breaks frequently (and indeed isn't building properly on my OSX laptop at present). We should really do everything we can to encourage people to work in CMake rather than Make.

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

Successfully merging this pull request may close these issues.

3 participants