-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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++] What's the difference between ARROW_SIMD_LEVEL
and ARROW_RUNTIME_SIMD_LEVEL
#40333
Comments
Hi @mapleFU , maybe you can see if this section [1] in arrow doc answers your question. [1] https://arrow.apache.org/docs/cpp/env_vars.html#envvar-ARROW_USER_SIMD_LEVEL |
I guess it doesn't 🤔?
|
Oh I got your point. |
After some research on the code history, it appears to me that:
@pitrou I'm not familiar with the full story so please correct me if I get anything wrong. |
The wording could probably be improved, but there are two categories of SIMD optimizations in Arrow:
|
Also, For example, if you compiled with (why it's called "user" I don't remember...) |
Aha I got to understand this, so for some user like pyarrow, x86 lib might compile with avx2 avx512 but only uses avx2, and arm compiles with neon? And other user compile C++ directly might define them themselves? |
No, it's as I explained in #40333 (comment) |
Oh, sorry seems I just regard it as |
Ideally, all CPU-specific optimizations should be selected at runtime. It's just more work. |
Thanks! Close this first. (Reopen because you want to enhance this) |
Perhaps we can find a way to better explain / document these variables? @amoeba @wjones127 Would you have an idea? |
This is very clear. Thank you. IIUC, macro family For example, function
and its call site arrow/cpp/src/arrow/compute/kernels/aggregate_basic.cc Lines 1063 to 1067 in 2b194ad
seem to be completely controlled by the "runtime" family. Does it mean that, theoretically, all the simd code in arrow can be fully managed by ARROW_RUNTIME_SIMD_LEVEL ?
|
I'm not sure what you mean by "theoretically"? It would require implementing runtime selection for the optimizations that are currently enabled statically. |
I think "theoretically" in this context means "there is no technical reason, outside of implementing the runtime selection, for this not to be managed by Which I guess you answered with your previous comment :D
|
Precisely!
Also precisely! Thank you both @assignUser @pitrou ! |
It seems like the only thing that is missing from the docs at https://arrow.apache.org/docs/cpp/env_vars.html#envvar-ARROW_USER_SIMD_LEVEL is an explanation of what Perhaps something like:
|
What's the real use case for |
The use case is being able to compare performance with or without those specific code paths if you have a machine that supports them. In some (very?) rare cases it might also help to work around issues with bad CPU support. (I think we had bugs where some CPU instruction set was supposed to be supported, but the kernel/VM hypervisor didn't handle it correctly) |
Yes, but SSE4 goes back to 2008. AVX2 was available in 2013 on Haswell. I'm not sure it would be that surprising you need a custom build to run on a machine built in 2005. |
Thanks @pitrou, I'll put up a PR with this and @wjones127's idea for us to look at.
Fair point :) |
I agree this is useful. Previous days I meet a problem that pdep is slow on amd zen2. |
The code is there to help you. See arrow/cpp/src/arrow/util/cpu_info.h Lines 101 to 104 in 3ba6d28
|
Hi all, I put up a PR to improve the docs around these variables at #40374. Please have a look and leave any and all feedback. |
ARROW_SIMD_LEVEL
and ARROW_RUNTIME_SIMD_LEVEL
ARROW_SIMD_LEVEL
and ARROW_RUNTIME_SIMD_LEVEL
### Rationale for this change Conversation in #40333. ### What changes are included in this PR? Just tweaks to the text in docs/source/cpp/env_vars.rst. ### Are these changes tested? I rendered them locally. ### Are there any user-facing changes? Just docs here. * GitHub Issue: #40333 Lead-authored-by: Bryce Mecum <petridish@gmail.com> Co-authored-by: Antoine Pitrou <antoine@python.org> Co-authored-by: Rossi Sun <zanmato1984@gmail.com> Co-authored-by: Will Jones <willjones127@gmail.com> Signed-off-by: mwish <maplewish117@gmail.com>
Issue resolved by pull request 40374 |
Describe the usage question you have. Please include as many useful details as possible.
In Arrow, we have two SIMD flag in CMake listed below:
They're added in the two patches:
However,
ARROW_RUNTIME_SIMD_LEVEL
would also be checked in compile time. So, what's the difference between these two flags? Or do I misunderstand the meaning of "runtime" here(I mean dynamicly checking it when runing the program)?Component(s)
C++
The text was updated successfully, but these errors were encountered: