[vector] question - should vectors be long lived?

Adam Pocock adam.pocock at oracle.com
Tue Feb 20 13:30:45 UTC 2018


Hi everyone,

I've written a SIMD RNG, which can generate me a float or int 
pseudo-random number for each lane. Currently it stores the seeds (half 
a long per lane) as a LongVector field in the RNG class. This RNG is 
sampled from hundreds or thousands of times before it's thrown away and 
recreated at the start of the next iteration. As a consequence this 
LongVector is quite long lived, which probably means it's being boxed 
and unboxed.

I've got a few questions along these lines:
- Is it sensible to have a long lived vector in the current implementation?
- Is it sensible to do this in the future when Vector is a value and so 
shouldn't have boxing issues?
- If it's never a good idea to do this, is there any way to make it 
obvious it's a bad idea?

The reason my code has an RNG like this is that it allows me to 
essentially treat the AVX unit the way I treat a GPU in CUDA, as a 
fairly wide multithreaded computation engine. It's not the best idea to 
do this in CUDA (the same way it's not a great idea to do it in the 
Vector API) without realising it's just a big SIMD underneath, but it 
does make some programming tasks simpler. Having the SIMD accelerate a 
single thread of computation rather than running multiple "threads" 
essentially independently is a lot harder for certain classes of algorithms.

Thanks,

Adam

-- 
Adam Pocock
Principal Member of Technical Staff
Machine Learning Research Group
Oracle Labs, Burlington, MA



More information about the panama-dev mailing list