StaticArrays vs FixedSizeArrays

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

StaticArrays vs FixedSizeArrays

Petr Hlavenka
Hi,
With Julia 0.5 I'm little bit confused what is the best approach for high speed array access. I'm writing a simulation where particles move in the field interpolated from an irregular mesh of tetrahedrons in 3D.
So i basically have a points array of MyPoint (= 3xFloat64, stands for x,y,z) and elements array of MyElement(= 4xUInt32,  stands for indexes to points forming a tetrahedron) and some lookup arrays.
I often access the points by direct indexing  - defining own getindex(::MyPoint, ::Integer) for the custom types, such as this example: 

points[elements[tetrahedron_id][vertex_id]][axis_ix]

or in loops where i prefer treating the arrays as types such as 

for el in elements
  point1
= el[1]
  point2
= el[2]
  r
= (point1[1]+point2[1])/2 + (point1[2]+point2[2])/2
end


or even calling specialized functions on MyElement type

for el in elements
  myfunc
(el)
end

I'm considering StaticArrays.jl and FixedSizeArrays to use for the definition of MyPoint and MyElement, but I'm little bit confused what is the actual difference between the two implementation. Could please someone explain to me, what is the difference between this two packages? Is one of them superseding the other one on 0.5+? What is the difference in memory layout and performance consequences?

Thank you very much.
Cheers 
Petr

 

Reply | Threaded
Open this post in threaded view
|

Re: StaticArrays vs FixedSizeArrays

Kristoffer Carlsson
See https://github.com/SimonDanisch/FixedSizeArrays.jl/issues/159

On Friday, October 7, 2016 at 8:10:56 AM UTC+2, Petr Hlavenka wrote:
Hi,
With Julia 0.5 I'm little bit confused what is the best approach for high speed array access. I'm writing a simulation where particles move in the field interpolated from an irregular mesh of tetrahedrons in 3D.
So i basically have a points array of MyPoint (= 3xFloat64, stands for x,y,z) and elements array of MyElement(= 4xUInt32,  stands for indexes to points forming a tetrahedron) and some lookup arrays.
I often access the points by direct indexing  - defining own getindex(::MyPoint, ::Integer) for the custom types, such as this example: 

points[elements[tetrahedron_id][vertex_id]][axis_ix]

or in loops where i prefer treating the arrays as types such as 

for el in elements
  point1
= el[1]
  point2
= el[2]
  r
= (point1[1]+point2[1])/2 + (point1[2]+point2[2])/2
end


or even calling specialized functions on MyElement type

for el in elements
  myfunc
(el)
end

I'm considering StaticArrays.jl and FixedSizeArrays to use for the definition of MyPoint and MyElement, but I'm little bit confused what is the actual difference between the two implementation. Could please someone explain to me, what is the difference between this two packages? Is one of them superseding the other one on 0.5+? What is the difference in memory layout and performance consequences?

Thank you very much.
Cheers 
Petr

 

Reply | Threaded
Open this post in threaded view
|

Re: StaticArrays vs FixedSizeArrays

Simon Danisch
In reply to this post by Petr Hlavenka
You might enjoy: GeometryTypes.jl
Especially the Face type should be convenient:
https://github.com/JuliaGeometry/GeometryTypes.jl/blob/master/src/faces.jl

Its currently based on FixedSizeArrays, but I want to port it to StaticArrays whenever it's sensible (and I have time :P ).
So in the ideal case, you won't notice any change in the low-level implementation.
I've made sure that most operations needed in Graphics are fast and supported in FixedSizeArrays. This doesn't seem to be fully the case for StaticArrays yet.
On the other hand, StaticArrays is more fit for general fixed array code.

I'm tracking porting GeometryTypes to StaticArrays in this issue:
https://github.com/JuliaArrays/StaticArrays.jl/issues/45

Best,
Simon


Am Freitag, 7. Oktober 2016 08:10:56 UTC+2 schrieb Petr Hlavenka:
Hi,
With Julia 0.5 I'm little bit confused what is the best approach for high speed array access. I'm writing a simulation where particles move in the field interpolated from an irregular mesh of tetrahedrons in 3D.
So i basically have a points array of MyPoint (= 3xFloat64, stands for x,y,z) and elements array of MyElement(= 4xUInt32,  stands for indexes to points forming a tetrahedron) and some lookup arrays.
I often access the points by direct indexing  - defining own getindex(::MyPoint, ::Integer) for the custom types, such as this example: 

points[elements[tetrahedron_id][vertex_id]][axis_ix]

or in loops where i prefer treating the arrays as types such as 

for el in elements
  point1
= el[1]
  point2
= el[2]
  r
= (point1[1]+point2[1])/2 + (point1[2]+point2[2])/2
end


or even calling specialized functions on MyElement type

for el in elements
  myfunc
(el)
end

I'm considering StaticArrays.jl and FixedSizeArrays to use for the definition of MyPoint and MyElement, but I'm little bit confused what is the actual difference between the two implementation. Could please someone explain to me, what is the difference between this two packages? Is one of them superseding the other one on 0.5+? What is the difference in memory layout and performance consequences?

Thank you very much.
Cheers 
Petr

 

Reply | Threaded
Open this post in threaded view
|

Re: StaticArrays vs FixedSizeArrays

Christoph Ortner
I've used FixedSizeArrays in the past but switch to StaticArrays, they seem more convenient in a few of ways, but for 90% of use cases they seem to be comparable. To protect myself against a possible move to yet another package, I added a layer of `typealias`.