Comments (2)
Currently, the @avx
macro won't work either.
vmap
and @avx
call VectorizationBase.vectorizable
and VectorizationBase.stridedpointer
on each of the arrays, respectively.
These return structs holding the pointer (and in the case of stridedpointer
, also the array's strides so that we can use CartesianIndexing).
I've not updated PaddedMatrices for the new VectorizationBase and LoopVectorization yet (I'll register it once I do), but in the link you can see the workaround I used for the static array type that library defines.
The problem, as the error says, is that we can't get pointers to struct
s.
If at all possible, pointers are preferable to that workaround I linked. Instead of defining a vector loads using LLVM intrinsics, it just uses a bunch of @inbounds
getindexes and wishes the compiler luck.
When the loads are masked, the compiler almost always generates suboptimal code.
More importantly, we need a pointer to be able to store.
Possible solutions that come to mind:
- One of the libraries adds the other as a dependency to define a
SArray
specific overload of some base function, like in the linked example. This will be required by every library implementing an Array type without implementingpointer
. - I make a method like the above the default, specifically overloading
Array
and other types that define pointers to have the current behavior. This requires adding dependencies for every library implementing their own mutable array type. - Combine
1.
and2.
usingismutable(x) = typeof(x).mutable
to choose between default methods. This will reduce the number of needed overloads by a little. Notably, this fails for anystruct
wrapping a mutable array, soLinearAlgebra.Adjoint
,Base.SubArray
, etc will all still need to be special-cased. - Dispatch on StridedArray to make the default decision, because the
StridedArrays
interface requiresBase.unsafe_convert(::Type{Ptr{T}}, A)
. - PR to Julia to add a query about whether pointers are defined to the AbstractArray interface.
I like 4.
We are making memory layout assumptions via using raw pointers. Someone's AbstractArray type following those assumptions hopefully subtypes DenseArray
. Alternatively, option 1.
of providing a specific overload is still open to them.
Currently MArray
is not a StridedArray (nor is LinearAlgebra.Adjoint{T,A} where {T,A<:StridedArray{T}}
, but I can provide special methods for that).
To support writing to MArray
s, StaticArrays.jl
would then need to either make MArray
a subtype of DenseArray
, or follow approach 1.
.
EDIT:
https://github.com/JuliaArrays/StaticArrays.jl/blob/master/src/MArray.jl#L20
MArray
is already a subtype of StaticArray
. This means to make it a subtype of DenseArray
, while SArray
isn't, they'd have to make StaticArray
a union, which then would make it so that other libraries can't define their own types to be a subtype of StaticArray
-- a big drawback the authors may be unenthusiastic about.
from loopvectorization.jl.
It is worth watching ArrayInterface.jl.
That may be very useful for supporting StaticVectors, as well as other array types like struct of arrays and arrays of structs.
from loopvectorization.jl.
Related Issues (20)
- Error caused by `Static.StaticInt` not being an `Integer` HOT 5
- Segmentation fault for `PermutedDimsArray` with `ndims > 8` HOT 3
- `@turbo` and destructuring assignments HOT 1
- vmapreduce: no method matching reduce_to_onevec HOT 1
- Julia keyword `local` not supported by `@turbo`
- Slowdown with views in 0.12.119 HOT 26
- LoopVectorization fails with Tullio and HybridArrays HOT 2
- Preventing `StackOverflowError` automatically with a `@safe_turbo`? HOT 6
- LLVM error when using PackageCompiler HOT 9
- no method matching `add_constant!(::LoopSet, ::Val{2}, ::Int)` HOT 1
- Document `safe=true` and make it the default? HOT 1
- Regression in version 0.12.130 HOT 4
- Using @turbo with FowardDiff.Dual for logsumexp HOT 6
- [email protected] and up warns about `check_args` for the same code HOT 4
- Unexpected `NaN` result HOT 1
- A possible typo in `cdot_swizzle` HOT 2
- Can you see the complete assembly-code for a function? HOT 14
- LV keeps crushing during benchmarking HOT 5
- Plain for loop faster than @turbo HOT 5
- Error with large number of array references HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loopvectorization.jl.