-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ARROW-9453: [Rust] Wasm32 compilation support #7767
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,7 @@ members = [ | |
"integration-testing", | ||
"benchmarks", | ||
] | ||
default-members= [ | ||
"arrow", | ||
"datafusion" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ use crate::buffer::Buffer; | |
#[cfg(feature = "simd")] | ||
use crate::buffer::MutableBuffer; | ||
use crate::compute::util::apply_bin_op_to_option_bitmap; | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
use crate::compute::util::simd_load_set_invalid; | ||
use crate::datatypes; | ||
use crate::datatypes::ToByteSlice; | ||
|
@@ -99,8 +99,8 @@ where | |
} | ||
|
||
/// SIMD vectorized version of `math_op` above. | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
fn simd_math_op<T, F>( | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
pub fn simd_math_op<T, F>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These don't need to be public, they are internally selected based on feature gates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I made this modification to explicitly test that simd op call was not failing in WASM. Forgot to revert while pushing |
||
left: &PrimitiveArray<T>, | ||
right: &PrimitiveArray<T>, | ||
op: F, | ||
|
@@ -158,7 +158,7 @@ where | |
/// SIMD vectorized version of `divide`, the divide kernel needs it's own implementation as there | ||
/// is a need to handle situations where a divide by `0` occurs. This is complicated by `NULL` | ||
/// slots and padding. | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
fn simd_divide<T>( | ||
left: &PrimitiveArray<T>, | ||
right: &PrimitiveArray<T>, | ||
|
@@ -234,7 +234,7 @@ where | |
+ Div<Output = T::Native> | ||
+ Zero, | ||
{ | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
return simd_math_op(&left, &right, |a, b| a + b); | ||
|
||
#[allow(unreachable_code)] | ||
|
@@ -255,7 +255,7 @@ where | |
+ Div<Output = T::Native> | ||
+ Zero, | ||
{ | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
return simd_math_op(&left, &right, |a, b| a - b); | ||
|
||
#[allow(unreachable_code)] | ||
|
@@ -276,7 +276,7 @@ where | |
+ Div<Output = T::Native> | ||
+ Zero, | ||
{ | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
return simd_math_op(&left, &right, |a, b| a * b); | ||
|
||
#[allow(unreachable_code)] | ||
|
@@ -299,7 +299,7 @@ where | |
+ Zero | ||
+ One, | ||
{ | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), feature = "simd"))] | ||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch="wasm32"), feature = "simd"))] | ||
return simd_divide(&left, &right); | ||
|
||
#[allow(unreachable_code)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this? is this related to the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just so that wasm builds by default at the top level? If so, I'd rather not do this either. i.e. it's enough to just say that we can build the sub-crates on wasm instead of changing this global default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This was add as I did not try and port the Flight and Parquet submodules as I believe their core functionality uses file and sockets which don't have stable support in WASM yet.
I'll try out the individual submodule build, add details to readme and revert the Cargo.toml change.