<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Mehdi Amini via llvm-dev" <llvm-dev@lists.llvm.org><br><b>To: </b>"Alina Sbirlea" <alina.sbirlea@gmail.com><br><b>Cc: </b>"llvm-dev" <llvm-dev@lists.llvm.org><br><b>Sent: </b>Monday, February 29, 2016 7:06:51 PM<br><b>Subject: </b>Re: [llvm-dev] RFC: Add bitcode tests to test-suite<br><br>
<div><br><br>Sent from my iPhone</div><div><br>On Feb 29, 2016, at 3:39 PM, Alina Sbirlea <<a href="mailto:alina.sbirlea@gmail.com" target="_blank">alina.sbirlea@gmail.com</a>> wrote:<br><br></div><blockquote><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 2:06 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><br><div><div><div class="h5"><blockquote><div>On Feb 29, 2016, at 1:50 PM, Alina Sbirlea <<a href="mailto:alina.sbirlea@gmail.com" target="_blank">alina.sbirlea@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 12:18 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><br><div><span><blockquote><div>On Feb 29, 2016, at 11:40 AM, Mehdi Amini via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote><div><br>On Feb 29, 2016, at 11:16 AM, Alina Sbirlea via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr">All,<div><br></div><div>To get the discussion going in a focused manner, here is an initial patch with a running test. The test is from the Halide suite and is checking the correctness of several simd operations.</div><div>(Notes: the patch is large due to the number of operations being tested; </div><div>I expect a lot of changes before actually landing it, this is simply to continue the discussion using a concrete example.)<br></div><div><a href="http://reviews.llvm.org/D17726" target="_blank">http://reviews.llvm.org/D17726</a><br></div></div></div></blockquote><div><br></div><div>I can't figure how to download the patch *with the bitcode files* from Phabricator. Can you push this on github (or somewhere else)? (or if I missed how to proceed...).</div></div></div></blockquote><div><br></div></span>I was able to figure how get them "one by one", it would still be more convenient to have an archive or a repo to clone somewhere.</div><div><span><br><blockquote><div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote><div><div dir="ltr"><div>A few questions/todos to start the discussion:</div><div>1. What is a good location for these tests? They are in a separate Bitcode directory atm, but using the llvm_multisource. This may change to more closely model the approach for external tests (see next item). </div></div></div></blockquote></div></div></blockquote><div><br></div></span><div>A good location would be their own external repository IMO :)</div><span><div><br></div><blockquote><div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote><div><div dir="ltr"><div>2. There is a single .cpp file testing all operations provided by individual bitcode files. I expect this to change. Instead of using llvm_multisource to have the same test run with specific arguments, each run testing a single operation.</div><div>3. The building approach I took is to first link all bitcode files into a single one, then obtain the assembly for it, which cmake knows to take as an input source. </div></div></div></blockquote></div></div></blockquote><div><br></div></span><div>Yeah, so I'd rather have a split-build model, with a split execution model. Having a gigantic bitcode file to debug an issue is not friendly.</div><div>I'd expect to have a .cpp file that contains the main and the logic to run test, and then every test that is linked-in to be executed, a bit like gtests is doing (there are multiple registering mechanisms that would avoid to declare explicitly a test in the header).</div><div>-> filters.h and filter_headers.h should just go away.</div></div></div></blockquote><div><br></div><div>I agree, this is related to point 2. The plan here is to update the current test .cpp file to test each operation individually. In this model it will be enough to link with a single bitcode file per test.</div><div> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div><br></div><div>Also on the test in general: we should have an idea for each test what it is doing and how.</div><div>I was expecting your tests to be on the pattern of having an implementation in C++ and an implementation in Halide bitcode of a filters (or whatever) and run both on random data and verifies that the result is matching.</div><div>Unfortunately from what I can see you are feeding the tests with random data, and the tests are "blackboxes" that set an error flag if they detect an error. </div><div>This is not super robust: the compiler can mess with the error checking and eliminate it for instance, making any error undetected. </div></div></div></blockquote><div><br></div><div>The Halide bitcode filters compare the result of vectorized operations vs scalar runs of the same code. The error code against which we compare the output will be set to loose tolerance - it is currently 0. We're interested in codegen bugs that return the wrong value entirely, not accuracy differences (especially for floating point tests).</div><div>With the new error threshold, the data fed into may be random or read from provided input files, I can do either.</div><div>The filters will still look somewhat like blackboxes, though the name of the filter says what operation it's being tested and the disassembled bitcode files are reasonably readable.</div><div>Using your suggestion, the driver .cpp file will test one operation at a time (argvs set accordingly) and return right away once an error is found. Sound about right?</div></div></div></div></div></blockquote><div><br></div></div></div><div>All of this is great. </div><div>The part that is not clear to me is why isn't it to have (what does it buy us over, or why is it better for us compared to) a possible a C/C++ reference implementation of the filter, and hoisting (and refactor) all the logic to feed the tests and validate the output *out* of the filters. A filter would be just the mathematical function performed and nothing more (separation of concerns, more robust framework, easier debugging when things-go-wrong, etc.).</div></div></div></blockquote><div><br></div><div>I believe the answer is that Halide generates vectorized code in a way that is not generated by llvm when starting from C/C++. </div></div></div></div></div></blockquote><div><br></div><div>I don't really see how *this* addresses my point. This is justifying why your bitcode is interesting and why we are having this conversation at all :)</div><div>It does not say why we can't have a scalar naive C/C++ impl along with the bitcode for filter.</div><div><br></div><br><blockquote><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Having a C/C++ scalar reference would involve quite a bit of effort for all tests. The primary reason Halide is being used is that you don't need to write a lot of C/C++ code to get different optimizations for the same code (e.g. vectorized vs scalar is a one line difference). </div></div></div></div></div></blockquote><div><br></div><div>Yes, this is what is nice with Halide: "write once, codegen multiple variant". But it does not mean you can't write a c++ reference for every Halide filter (not for every codegen variant of a filter!)</div><div><br></div><div>It's been 2 years since my last experiments with Halide, but my memories were that there was a C backend?</div><div>I had in mind for each test to have (possibly in a separate directory for each test):</div><div> - the halide source for the filter.</div><div> - the c/c++ (maybe generated?) for the filter.</div><div> - the bitcode generated for the filter (potentially multiple variant depending on the CPU support and/or the schedule).</div><div><br></div><div>Then some common code/infrastructure to interact with the individual filters, loading them, executing the variants for a filter, and checking results.</div><div><br></div><div>If the reference c/c++ can't be generated by halide (or obtained somehow), and we can't do better than the current tests infrastructure you have, then I'm worried about the cost/benefit for this test-suite.</div><div id="DWT15394"><br></div></blockquote><br>I think that a C/C++ version would be nice to have, but not necessary. IR generated by non-Clang frontends and/or IR going through alternate optimization pipelines tend to hit bugs that are much harder to hit with Clang alone. It would help to have a description of what each test does, but including, for example, the Halide source code for each test will hopefully be enough of a guide.<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div></div><br><blockquote><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>So we can get really fast test coverage for possible codegen bugs by comparing that different layout optimizations in Halide give the same result. </div><div>I think having each filter tested separately should give a good separation of concerns and easy debugging for each particular test.</div></div></div></div></div></blockquote><div><br></div><div id="DWT15395">This is great for halide validation, we are all agreeing with this I think. The question is where is the tradeoff for the LLVM project. I'm trying to make sure that the extra coverage doesn't come with a burden to debug and triage issues when something will break: i.e. the tests need to be very friendly to interact with. </div></blockquote><br>I don't think that any non-trivial tests are truly "friendly" to interact with. Tracking down self-hosting bugs is not friendly, and those aren't anywhere near the worst ;) -- These tests with their simple driver seem like good input that bugpoint can reduce (assuming the tests runtimes are not too long), and that's friendlier than most of the other multisource tests.<br><br> -Hal<br><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div>This is the motivation for my comments so far.</div><div>Other people in the community may have a different opinion/appreciation of the situation, this just represents my current thoughts.</div><div><br></div><div>Hope it makes sense.</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><br><blockquote><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><span class=""><div><br></div><blockquote><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div>Also, just looking quickly at one IR I'm surprised by things like:</div><div><br></div><div>"assert succeeded165": ; preds = %"assert succeeded146"<br> %buf_host181 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %error_op_pcmpeqq_272.buffer, i64 0, i32 1<br> %23 = bitcast i8** %buf_host181 to double**<br> %error_op_pcmpeqq_272.host226227232 = load double*, double** %23, align 8<br> %24 = icmp eq %struct.buffer_t* %error_op_pcmpeqq_272.buffer, null<br> br i1 %24, label %"assert failed183", label %"assert succeeded184", !prof !4<br><br></div><div>Here you have as check for nullptr at %24, but you already loaded %error_op_pcmpeqq_272.host226227232 from this pointer just before!</div></div></div></blockquote><div><br></div><div>It's checking that the host value loaded from buffer_t is not null. I don't see what's wrong with this. What am I missing?</div></div></div></div></blockquote><div><br></div></span><div>I may be misreading it, my impression when skimming through the code was that it seems equivalent to:</div><div><br></div><div>foo(buffer_t *out) {</div><div> auto value = out->host;</div><div> if (!out) {</div><div> error("nullptr");</div><div> }</div><div>}</div><div><br></div><div><br></div><div>In case I haven't been clear: I think this work is valuable for the project, and thank you for putting some effort into it :)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><div><div class="h5"><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><blockquote><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><span><div><br></div><div><br></div><blockquote><div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote><div><div dir="ltr"><div>A separate discussion is on reading metadata (mcpu and mattr) in llc. I added a script to work around that for now.</div></div></div></blockquote></div></div></blockquote><div><br></div></span><div>The generic way of doing it in llvm is (I think) to use function attributes:</div><div><br></div><div>attributes #0 = { "target-cpu"="x86-64" "target-features"="+avx2" }<br><br></div><div>You shouldn't need it on the command line I think?</div></div></div></blockquote><div><br></div><div>Yes, I believe so too. Currently these are set in mcpu and mattr by Halide and not read in by llc, hence the need for feeding them as parameters. It's a separate issue that we'll need to go into in depth, but I don't want it to interfere with getting feedback on how to best publish these tests.</div><div> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><span><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><span><div><br></div><div><br></div><br><blockquote><div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><blockquote><div><div dir="ltr"><div><br></div><div>Looking forward to your feedback!</div><div><br></div><div>Thanks,<br></div><div>Alina</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 19, 2016 at 6:50 AM, Kristof Beyls<span> </span><span dir="ltr"><<a href="mailto:kristof.beyls@arm.com" target="_blank">kristof.beyls@arm.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><span><br><br><div>On 18/02/2016 19:12, Alina Sbirlea via llvm-dev wrote:<br></div><blockquote><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>I have more questions for Alina. What kind of tests do you have:<br><br>- "the compiler takes the bitcode and generates code without crashing"<br>- "the compiled test runs without crashing"<br>- "the compiled test will produce an output that be checked against a reference"<br>- "the compiled test is meaningful as a benchmarks"<br></blockquote><div><br></div><div>We have all 4 kinds of tests in Halide. The bitcode files for the first category is already available and I'm working on building the ones for the next 3. We'd like to include all incrementally.</div><div> </div><br></div></div></div></blockquote></span>It seems to me that the first category ("the compiler takes the bitcode and generates code without crashing") are tests that should be added to the "make check-all" tests in the LLVM subproject, rather than the test-suite subproject?<br>Or if these tests currently don't crash the compiler anymore, the bugs must have been fixed, and there should already be equivalent tests?<br></div></blockquote></div><br></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="mailto:llvm-dev@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></span></div><br></div></blockquote></div><br></div></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>
</div></blockquote><br>_______________________________________________<br>LLVM Developers mailing list<br>llvm-dev@lists.llvm.org<br>http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>