Small Vectors Proposal

Benji Smith dlanguage at benjismith.net
Wed Feb 7 16:32:47 PST 2007


Chad J wrote:
> I think we should have array operations for dynamic arrays 
> (n-dimensional vectors) as well, but distinct from lo-D static arrays. 
> The reason is the same as others state: hi-D arrays can spend some fixed 
> overhead setting things up before jumping into a gigantic loop, whereas 
> lo-D arrays get optimized much differently with no fixed overhead and 
> possibly higher running overhead or less generality.  They are two 
> different beasts.

The more I think about it, the more I agree.

Hi-D vectors are almost always sparse, so the feature/magnitude pairs 
are usually stored in a HashMap (or some other similar container) rather 
than being represented in arrays. Adding compiler optimizations for hi-D 
vector operators would mean knowing the underlying implementation of the 
container, and that'd obviously be bad.

But I don't think vector optimizations should be constrained to 3D or 4D 
vectors. Generalize the optimizations on array types, and then any code 
that performs vector operations on those arrays automatically gets the 
performance boost, regardless of the dimensionality of their vectors.

--benji



More information about the Digitalmars-d mailing list