This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Update bitreverse benchmark.
ClosedPublic

Authored by MaskRay on Oct 16 2017, 10:28 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Oct 16 2017, 10:28 AM
nemanjai requested changes to this revision.Oct 18 2017, 12:13 AM
nemanjai added a subscriber: nemanjai.

With the above changes to the test case (and the corresponding changes to the reference output), the problem would have been blatantly obvious from the start and we wouldn't have to jump through hoops to ensure opt isn't just giving us the right answer.

SingleSource/Benchmarks/Misc/revertBits.c
42 ↗(On Diff #119174)

I believe the focus in a test case such as this should be not only on ensuring the faster code-gen, but on functional correctness.
To that end, it would be preferable to have 4 print statements here that will reverse a rather obvious pattern in various ways.
For example:

unsigned int Rev32 = strtoll("0x11223344", NULL, 16);
unsigned long long Rev64 = strtoll("0x1122334455667788", NULL, 16);
printf("0x%X -> 0x%X\n", Rev32, ReverseBits32(Rev32));
printf("0x%llX -> 0x%llX\n", Rev64, ReverseBits64(Rev64));
45 ↗(On Diff #119174)

Here' we'd just print the expected values:

printf("0x%X -> 0x%X\n", Rev32, ReverseBits32(Rev32));
printf("0x%llX -> 0x%llX\n", Rev64, ReverseBits64(Rev64));
48 ↗(On Diff #119174)

And here, we'd generate the values using the builtin:

printf("0x%X -> 0x%X\n", Rev32, __builtin_bitreverse32(Rev32));
printf("0x%llX -> 0x%llX\n", Rev64, __builtin_bitreverse64(Rev64));
SingleSource/Benchmarks/Misc/revertBits.reference_output
1 ↗(On Diff #119174)

As I mentioned before, I would very much prefer that this test case include an obvious, easily verifiable functional test. See above.

This revision now requires changes to proceed.Oct 18 2017, 12:13 AM
MaskRay updated this revision to Diff 119489.Oct 18 2017, 8:19 AM
MaskRay edited edge metadata.

Add an easily verifiable functional test.

MaskRay marked 4 inline comments as done.Oct 18 2017, 8:20 AM
jtony added a subscriber: jtony.Oct 18 2017, 8:29 AM
jtony added inline comments.
SingleSource/Benchmarks/Misc/revertBits.c
36 ↗(On Diff #119489)

Changing the type from long long to int here is probably not safe. Since we are calculating the summation of 0x1000000 reversed numbers. Without reversing them, the total sum would definitely overflow an integer ((1+0x1000000)* 0x1000000/2). With reversing, I don't calculate, but we'd better leave it to long long for safety.

42 ↗(On Diff #119174)

I agree with Nemanja here. Some obvious functional testing is necessary.

MaskRay updated this revision to Diff 119495.Oct 18 2017, 9:10 AM

Change int -> unsigned

MaskRay marked an inline comment as done.Oct 18 2017, 9:11 AM
MaskRay added inline comments.
SingleSource/Benchmarks/Misc/revertBits.c
42 ↗(On Diff #119174)

There is another issue. ReverseBits32/64 should use unsigned types.

Updated

nemanjai accepted this revision.Oct 30 2017, 7:46 AM

LGTM.

This revision is now accepted and ready to land.Oct 30 2017, 7:46 AM
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.
MatzeB added a subscriber: MatzeB.Oct 30 2017, 9:59 AM

While the change itself makes sense:

  • Please give some more descriptions than "update test" in the future.
  • Also give a warning in the commit message as this changes performance and will show up in the LNT numbers.

While the change itself makes sense:

  • Please give some more descriptions than "update test" in the future.
  • Also give a warning in the commit message as this changes performance and will show up in the LNT numbers.

Thanks! I did not know LNT ( http://llvm.org/docs/lnt/quickstart.html ) before.

We also have a live installation at http://lnt.llvm.org
A few of our buildbots submit data there.