Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler customization schema #156

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Pennycook
Copy link
Contributor

@Pennycook Pennycook commented Jan 22, 2025

Related issues

  • Part of Support custom compiler arguments #145; the modified schema allows a configuration file to define custom implicit compiler behavior (i.e., macro definitions, include paths and include files) based on compiler arguments.

Proposed changes

  • Extend the schema to support:
    • alias_of: Defines that a compiler is an alias of another (e.g., icpx is an alias of icx)
    • [[compiler."compiler name".parser]]: A table of arguments for argparse.
    • [[compiler."compiler name".modes]]: A table of "modes", each of which is a collection of compiler behaviors that can later be enabled by a flag (e.g., -fopenmp enables the "openmp" mode, which in turn defines _OPENMP, etc).
    • [[compiler."compiler name".passes]]: A table of "passes", each of which is a collection of compiler behaviors associated with a separate pass over a source file (e.g., -fsycl-targets=spir64,nvidia-ptx-cuda will compile the source file to SPIR-V and PTX, with different macros defined).
  • Add new tests for the proposed schema.

I appreciate that JSON schema can be really difficult to read, so I've tried extra hard to improve the readability of the tests here. Each call to _test_toml_string without an assertRaises demonstrates the syntax of a valid use-case. Each call with an assertRaises is intended to test either a oneOf, additionalProperties or required clause in the schema.

The new schema adds ways to define:
- Compiler aliases
- Custom argument parsers
- Custom compiler modes
- Custom compiler passes

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook added the enhancement New feature or request label Jan 22, 2025
@Pennycook Pennycook added this to the 2.0.0 milestone Jan 22, 2025
@Pennycook Pennycook requested a review from laserkelvin January 22, 2025 14:28
This is required to emulate the behavior of more complex flags, where:
- There is a default value;
- The default value must be overridden if the flag is provided; and
- The flag can be supplied more than once, and extends a list.

Signed-off-by: John Pennycook <[email protected]>
It is common for a compiler pass to imply one or more modes.

For example, enabling any SYCL device pass implies SYCL mode.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook
Copy link
Contributor Author

While working on fixing a bug in a later stage of this, I realized that some of the compiler definition files I'd written were failing validation. I've added the missing keys to the schema.

@Pennycook Pennycook closed this Jan 31, 2025
@Pennycook Pennycook reopened this Jan 31, 2025
@Pennycook Pennycook closed this Jan 31, 2025
@Pennycook Pennycook reopened this Jan 31, 2025
@Pennycook Pennycook closed this Jan 31, 2025
@Pennycook Pennycook reopened this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant