KhronosGroup / KhronosGroup/SPIRV-Tools

spirv-opt needs a 'do-everything' option

Open
#772 22 comments 2 reactions 0 assignees View on GitHub
component:optimization enhancement
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

At present, spirv-opt with no arguments simply emits the input SPIR-V unmodified. This is not particularly useful. While the command line interface is quite programmable and configurable, it is also not accessible. An engineer without any compiler expertise probably does not have the required knowledge to set this up, and is likely to copy some switches verbatim from a google search (the same applies to the programmatic interface in optimizer.hpp)

The interface is burdensome even for a knowledgeable user. In order to select the right configuration, the user needs to understand exactly what the available passes do, and how their results of one pass might interact with another. The user must think through the entire optimization pipeline in order to select the right set of switches, and may need to repeat this process every time new optimizations are introduced.

As with other compilers, there is going to be a universal set of things that a user would want done (for example, constant folding and DCE), and an obvious, correct order in which to do them (constant folding comes before DCE). It would be valuable to provide a single interface to enable all of the desirable transforms, with suitable default parameters, and run them in the right order, similar to the --do-everything switch in SPIRV-remap, or the -O switches in clang/gcc. This would make opt much more useful, and would also provide forward-compatibility for scripts and tools, without requiring manual intervention every time a new optimization comes online.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the spirv-opt command-line interface and the programmatic interface in optimizer.hpp, then compare the requested behavior with SPIRV-remap's --do-everything switch and clang/gcc -O options. Done means defining a single option with suitable defaults and ordering for desirable transforms, while preserving forward compatibility as new optimizations are added.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.