Add initial benchmarking features to WebAssembly experiments. (#9100)

### Background

I'm working towards identifying and quantifying key metrics for our web platform support. Metrics of interest thus far include:
* runtime binary size
* program binary size
* runtime startup time
* program load time
* total function call time (as seen from a JavaScript application)
* no-overhead function call time (`iree_runtime_call_invoke()`)

Once we have baselines for those, we can start deeper analysis and optimization work. Some optimization work may be purely in the IREE compiler (e.g. codegen, Flow/Stream/HAL dialects, etc.), while other work may be in the web port itself (e.g. Emscripten flags, use of web APIs, runtime JS bindings).

### Current Status

This is still all experimental, but I'd like to checkpoint what I've built so far and let other people try it out. Expect rough edges (e.g. some Windows/Linux paths specific to my setup that can be overwritten).

Summary of changes:

* `sample_dynamic/index.html` now supports interactive benchmarking
  * a "benchmark iterations" form input drives a loop around `iree_runtime_call_invoke()` down in C/Wasm
  * timing information is rendered onto the page itself, instead of being logged to stdout / the console
  * sample screenshot: https://user-images.githubusercontent.com/4010439/167958736-228a1541-8ed6-4b2c-9af9-55ef0b10bf74.png
* `generate_web_metrics.sh` imports and compiles programs from our existing benchmark suite, preserving all sorts of artifacts for further manual inspection or automated use
* `run_native_benchmarks.sh` executes the compiled native programs from `generate_web_metrics.sh`
* `sample_dynamic/benchmarks.html` loads and runs each compiled Wasm program from `generate_web_metrics.sh`
  * Sample output: https://gist.github.com/ScottTodd/f2bb1f274c5895c8f979400abd6d2b67

Also of note: I haven't really looked at the browser profiling tools yet. I expect those will help with detailed analysis while the general scaffolding and `performance.now()` measurements will help with comparisons between frameworks and across browsers/devices.
12 files changed
tree: 9a8d78dc57df924f2292f9efb33f0bc0343b0d36
  1. .github/
  2. benchmarks/
  3. build_tools/
  4. compiler/
  5. docs/
  6. experimental/
  7. integrations/
  8. iree/
  9. llvm-external-projects/
  10. runtime/
  11. samples/
  12. third_party/
  13. .bazelignore
  14. .bazelrc
  15. .bazelversion
  16. .clang-format
  17. .gitignore
  18. .gitmodules
  19. .pylintrc
  20. .style.yapf
  21. .yamllint.yml
  22. AUTHORS
  23. BUILD.bazel
  24. CMakeLists.txt
  25. configure_bazel.py
  26. CONTRIBUTING.md
  27. LICENSE
  28. README.md
  29. WORKSPACE
README.md

IREE: Intermediate Representation Execution Environment

IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.

See our website for project details, user guides, and instructions on building from source.

Project Status

IREE is still in its early phase. We have settled down on the overarching infrastructure and are actively improving various software components as well as project logistics. It is still quite far from ready for everyday use and is made available without any support at the moment. With that said, we welcome any kind of feedback on any communication channels!

Communication Channels

Related Project Channels

  • MLIR topic within LLVM Discourse: IREE is enabled by and heavily relies on MLIR. IREE sometimes is referred to in certain MLIR discussions. Useful if you are also interested in MLIR evolution.

Build Status

CI SystemBuild SystemPlatformArchitectureConfiguration / ComponentStatus
KokoroBazelLinuxx86-64kokoro status bazel/linux/x86-swiftshader/core
KokoroCMake & BazelLinuxx86-64 (swiftshader)Integrationskokoro status cmake-bazel/linux/x86-swiftshader
KokoroCMake & BazelLinuxx86-64 (turing)Integrationskokoro status cmake-bazel/linux/x86-turing
KokoroCMakeLinuxx86-64 (swiftshader)kokoro status cmake/linux/x86-swiftshader
KokoroCMakeLinuxx86-64 (swiftshader)asankokoro status cmake/linux/x86-swiftshader-asan
KokoroCMakeLinuxx86-64 (turing)kokoro status cmake/linux/x86-turing
KokoroCMakeAndroidarm64-v8aRuntime (build only)kokoro status cmake/android/arm64-v8a
KokoroCMakeBare Metalrisc-v-32Runtimekokoro status cmake/baremetal/riscv32
KokoroCMakeLinuxrisc-v-64Runtimekokoro status cmake/linux/riscv64
BuildkiteCMakeAndroidarm64-v8aRuntimebuildkite status iree-android-arm64-v8a
BuildKiteCMakeAndroidarm64-v8aRuntime Benchmarksbuildkite status iree-benchmark
BuildKiteCMakeLinuxx86-64Tracing + Standalone Runtimebuildkite status iree-build-configurations

Architecture Overview

IREE Architecture

See our website for more information.

Presentations and Talks

  • 2021-06-09: IREE Runtime Design Tech Talk (recording and slides)
  • 2020-08-20: IREE CodeGen: MLIR Open Design Meeting Presentation (recording and slides)
  • 2020-03-18: Interactive HAL IR Walkthrough (recording)
  • 2020-01-31: End-to-end MLIR Workflow in IREE: MLIR Open Design Meeting Presentation (recording and slides)

License

IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.