This is an archive of the discontinued LLVM Phabricator instance.

[libc] automemcpy - result analyzer
ClosedPublic

Authored by gchatelet on Oct 12 2021, 2:37 AM.

Details

Reviewers
courbet
Summary

"automemcpy: A framework for automatic generation of fundamental memory operations"
https://research.google/pubs/pub50338/

This patch implements the concepts presented in the paper, the overall approach is the following:

  • Makes use of constraint programming to model the implementation of a memory function (memcpy, memset, memcmp, bzero, bcmp).
  • Generate the code for all valid implementations
  • Compile the implementations and benchmark them on a set of machines. The benchmark makes use of representative distributions for the function's arguments.
  • Analyze the result and pick "the best" performing function according to the specific environement.

This patch in particular implements the code that reads the result of the benchmark and produce an analysis of the performance of each autogenerated function.

Diff Detail

Event Timeline

gchatelet created this revision.Oct 12 2021, 2:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2021, 2:37 AM
gchatelet requested review of this revision.Oct 12 2021, 2:37 AM
gchatelet updated this revision to Diff 379691.Oct 14 2021, 6:15 AM
  • Move analyzer to subdirectory

This could really use some doc.

libc/benchmarks/automemcpy/lib/ResultAnalyzer.cpp
161–163

any reason not to group {Throughput,Score,GradeAttribution} to avoid the 3 parallel maps ?

Will update the patch with more comments shortly.

libc/benchmarks/automemcpy/lib/ResultAnalyzer.cpp
161–163

Yes, Throughputs is currently move constructed (see line 185).
I can extract the distribution data into its own data structure with 3 fields, but then I'll have to iterate the map to construct Throughputs instead of moving it.
I'll update the patch with the new version so you can judge.

gchatelet updated this revision to Diff 380959.Oct 20 2021, 8:02 AM
  • Add documentation, unify three maps as a single one.

As discussed, this is complex enough to warrant unit tests.

libc/benchmarks/automemcpy/lib/ResultAnalyzer.cpp
12

You have not defined distribution in this file yet. Give a pointer ?

161–163

I think it's better grouped.

196

std::nth_element, given that you're not using the values for anything else ?

212

Normalize ?

gchatelet updated this revision to Diff 381261.Oct 21 2021, 7:38 AM
  • Add tests for result analyzer
gchatelet updated this revision to Diff 381264.Oct 21 2021, 7:55 AM
gchatelet marked 5 inline comments as done.
  • Address comments
courbet accepted this revision.Oct 25 2021, 4:21 AM
courbet added inline comments.
libc/benchmarks/automemcpy/lib/ResultAnalyzerMain.cpp
2

Missing header

This revision is now accepted and ready to land.Oct 25 2021, 4:21 AM
gchatelet updated this revision to Diff 382967.Oct 28 2021, 2:48 AM
  • Fix file headers
gchatelet closed this revision.Oct 28 2021, 4:33 AM

Submitted within D111801.