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

[C++] Add support to GetRuntimeInfo for reporting ASIMD/NEON #40806

Closed
amoeba opened this issue Mar 26, 2024 · 4 comments · Fixed by #40857
Closed

[C++] Add support to GetRuntimeInfo for reporting ASIMD/NEON #40806

amoeba opened this issue Mar 26, 2024 · 4 comments · Fixed by #40857

Comments

@amoeba
Copy link
Member

amoeba commented Mar 26, 2024

Describe the enhancement requested

PyArrow and R arrow have user-facing functions that call into Arrow C++'s arrow::GetRuntimeInfo() to report on build and runtime SIMD support:

RuntimeInfo GetRuntimeInfo() {
RuntimeInfo info;
auto cpu_info = CpuInfo::GetInstance();
info.simd_level =
MakeSimdLevelString([&](int64_t flags) { return cpu_info->IsSupported(flags); });
info.detected_simd_level =
MakeSimdLevelString([&](int64_t flags) { return cpu_info->IsDetected(flags); });

GetRuntimeInfo calls into MakeSimdLevelString to populate a RuntimeInfo object.
On ARM-based systems, "none" is reported for both SIMD levels which I think is caused by a there being no branch for CpuInfo::ASIMD:

std::string MakeSimdLevelString(QueryFlagFunction&& query_flag) {
if (query_flag(CpuInfo::AVX512)) {
return "avx512";
} else if (query_flag(CpuInfo::AVX2)) {
return "avx2";
} else if (query_flag(CpuInfo::AVX)) {
return "avx";
} else if (query_flag(CpuInfo::SSE4_2)) {
return "sse4_2";
} else {
return "none";
}
}

  1. Should we add a branch for CpuInfo::ASIMD?
  2. If so, would it make more sense to call it ASIMD or NEON? They're related but slightly different concepts and I'm not sure what language users will be most familiar with and which makes more sense alongside other values.

Component(s)

C++

@mapleFU
Copy link
Member

mapleFU commented Mar 27, 2024

Nice catch! Also cc @cyb70289 for that. Do we have some dynamically enabled instr here?

@cyb70289
Copy link
Contributor

Nice catch! Also cc @cyb70289 for that. Do we have some dynamically enabled instr here?

Looks no dynamically chosen code for Arm now. But I agree we should add NEON.

@amoeba
Copy link
Member Author

amoeba commented Mar 27, 2024

Thanks! I'll file a PR later today.

cyb70289 pushed a commit that referenced this issue Mar 28, 2024
### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes #40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: #40806
@amoeba amoeba added this to the 16.0.0 milestone Mar 28, 2024
@amoeba amoeba reopened this Apr 3, 2024
@amoeba
Copy link
Member Author

amoeba commented Apr 3, 2024

I re-opened this but I'm going to close it and file a new issue since this one is too narrow.

@amoeba amoeba closed this as completed Apr 3, 2024
pitrou added a commit that referenced this issue Apr 4, 2024
Revert changes from #40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
tolleybot pushed a commit to tmct/arrow that referenced this issue May 2, 2024
…pache#40857)

### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes apache#40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40806
tolleybot pushed a commit to tmct/arrow that referenced this issue May 2, 2024
Revert changes from apache#40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
tolleybot pushed a commit to tmct/arrow that referenced this issue May 4, 2024
…pache#40857)

### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes apache#40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40806
tolleybot pushed a commit to tmct/arrow that referenced this issue May 4, 2024
Revert changes from apache#40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
…pache#40857)

### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes apache#40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40806
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
Revert changes from apache#40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
…pache#40857)

### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes apache#40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40806
rok pushed a commit to tmct/arrow that referenced this issue May 8, 2024
Revert changes from apache#40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
vibhatha pushed a commit to vibhatha/arrow that referenced this issue May 25, 2024
…pache#40857)

### What changes are included in this PR?

New case to conditional in `MakeSimdLevelString` which makes
`GetRuntimeInfo` report correctly on respective CPUs. I chose to have it
report "neon". Lowercase to match other strings and "neon" instead of
"asimd" because I think that makes more sense to users. I'm not 100%
sure which is more correct.

Fixes apache#40806

### Are these changes tested?

We don't have automated tests for this. I did install the R package and,
on my M1 laptop it reports 'neon' now instead of 'none' before:

```r
> arrow_info()
...
SIMD Level          neon
Detected SIMD Level neon
```

### Are there any user-facing changes?

No.
* GitHub Issue: apache#40806
vibhatha pushed a commit to vibhatha/arrow that referenced this issue May 25, 2024
Revert changes from apache#40857.

`GetRuntimeInfo` returns the SIMD level for dynamic dispatch, but Neon currently does not participate in dynamic dispatch (actually, Neon should be available by default on all modern Arm CPUs AFAIU).

Authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: Antoine Pitrou <antoine@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants