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

[FMV] Document feature dependencies and detect at selection. #368

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions main/acle.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
* Unified Function Multi Versioning features sve2-aes and sve2-pmull128.
* Removed Function Multi Versioning features ebf16, memtag3, and rpres.
* Removed Function Multi Versioning feature dgh.
* Document Function Multi Versioning feature dependencies.
* Fixed range of operand `o0` (too small) in AArch64 system register designations.
* Fixed SVE2.1 quadword gather load/scatter store intrinsics.
* Removed unnecessary Zd argument from `svcvtnb_mf8[_f32_x2]_fpm`.
Expand Down Expand Up @@ -2674,8 +2675,6 @@ The following attributes trigger the multi version code generation:
* The `default` version means the version of the function that would
be generated without these attributes.
* `name` is the dependent features from the tables below.
* If a feature depends on another feature as defined by the Architecture
Reference Manual then no need to explicitly state in the attribute[^fmv-note-names].
* The dependent features could be joined by the `+` sign.
* None of these attributes will enable the corresponding ACLE feature(s)
associated to the `name` expressed in the attribute.
Expand All @@ -2685,9 +2684,6 @@ The following attributes trigger the multi version code generation:
* FMV may be disabled in compile time by a compiler flag. In this
case the `default` version shall be used.

[^fmv-note-names]: For example the `sve_bf16` feature depends on `sve`
but it is enough to say `target_version("sve_bf16")` in the code.

The attribute `__attribute__((target_version("name")))` expresses the
following:

Expand Down Expand Up @@ -2830,6 +2826,50 @@ The following table lists the architectures feature mapping for AArch64
| 580 | `FEAT_SME2` | sme2 | ```ID_AA64PFR1_EL1.SMEver >= 0b0001``` |
| 650 | `FEAT_MOPS` | mops | ```ID_AA64ISAR2_EL1.MOPS >= 0b0001``` |

### Dependencies

If a feature depends on another feature as defined by the table below then:

* the depended-on feature *need not* be specified in the attribute,
* the depended-on feature *may* be specified in the attribute.

These dependencies are taken into account transitively when selecting the
most appropriate version of a function (see section [Selection](#selection)).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this - while it's unlikely to come up in practice, I think the selection algorithm would be simpler to understand if it were based solely upon the attribute strings and the feature priorities, without trying to detect and ignore any redundant dependencies.

The following table lists the feature dependencies for AArch64.

| **Feature** | **Depends on** |
| ---------------- | ----------------- |
| flagm2 | flagm |
| simd | fp |
| dotprod | simd |
| sm4 | simd |
| rdm | simd |
| sha2 | simd |
| sha3 | sha2 |
| aes | simd |
| fp16 | fp |
| fp16fml | simd, fp16 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I checked, I don't think any part of the toolchains has an fp16fml->simd dependency for command line arguments, so this seems inconsistent.

| dpb2 | dpb |
| jscvt | fp |
| fcma | simd |
| rcpc2 | rcpc |
| rcpc3 | rcpc2 |
| frintts | fp |
| i8mm | simd |
| bf16 | simd |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In GCC+Bintuils we only have bf16 depending on fp, and in LLVM it depends on nothing at all. I think fp is more appropriate than simd.

| sve | fp16 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably have a simd dependency, and perhaps also an fcma dependency?

| f32mm | sve |
| f64mm | sve |
| sve2 | sve |
| sve2-aes | sve2, aes |
| sve2-bitperm | sve2 |
| sve2-sha3 | sve2, sha3 |
| sve2-sm4 | sve2, sm4 |
| sme | fp16, bf16 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't currently match existing command line options, but those should probably be adjusted. Should this also have a simd and perhaps fcma dependency?

| sme-f64f64 | sme |
| sme-i16i64 | sme |
| sme2 | sme |

### Selection

The following rules shall be followed by all implementations:
Expand Down
Loading