On Jan 14, 2015, at 6:02 , Simon Danisch <[email protected]> wrote:
> 
> You could in addition use ImmutableArrays:
> 
> immutable Packet{T}
>         ID::{T}
>         position::Vector3{T}
>         direction::Vector3{T}
>         energy::{T}
>         time::{T}
> end
> Which makes Packet a bitstype, with efficient memory layout.

Thanks for the pointer to Vector3.

This memory layout is efficient in the sense that there is no memory allocation 
to create a new Packet. However, if there are loops over multiple Packets, then 
these would most likely not be SIMD vectorized, whereas they migh if you use 
separate arrays for each packet element.

-erik

> If you need to mutate these, there are actually ways, when the Packets are 
> stored in an array. I'm implementing FixedSizeArrays at the moment, which 
> would have this feature. Otherwise, you need to replace the whole struct in 
> the array, which can be reasonable, considering the benefits.
> Other benefit? If you want to Visualize this in OpenGL, it should be fairly 
> easy to upload, as it has a dense memory layout =) (With T= Float32, you 
> wouldn't even need conversions)
> 
> 
> 
> Am Mittwoch, 14. Januar 2015 05:34:55 UTC+1 schrieb [email protected]:
> I am writing a monte carlo radiation transport code (for applications in 
> astrophysics), where I follow the temporal and spacial evolution of millions 
> of whats called "monte-carlo packets". And I am wondering whether if I should 
> use the Julia's type system, if so how should I implement it and also if 
> there is any performance loss/gain.
> 
> Let's say I define a type like following (based on this example tutorial):
> 
> type Packet{T}
>         ID::{T}
>         position::Vector{T}
>         direction::Vector{T}
>         energy::{T}
>         time::{T}
> end
> 
> obviously this could make the code much more easier to read than a version 
> with all information represented in separate arrays. But beside this 
> elegance, is there anything else I should know about types? when I apply this 
> to millions of objects will there be any effect to the performance?
> 
> thanks,

--
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to