Vector API factories
Paul Sandoz
paul.sandoz at oracle.com
Tue Jul 18 00:20:36 UTC 2017
> On 17 Jul 2017, at 16:55, Graves, Ian L <ian.l.graves at intel.com> wrote:
>
> Hi Paul,
>
> I love it!
>
> I think you're right that it makes a lot of sense to offload instantiation routines to species and make them semi-concrete by element type. This solves the issue of our element types being too unconstrained. This approach lets us fix the instantiatable-element-types by exposing allowed ones through this semi-concrete species. I think it also makes sense to refactor the vector construction methods to the Species class because instantiation is unique per-species and not per-vector. That's a good play.
>
Ok. With that and separating FP and bitwise i think we have a reasonable API story.
>
>
>> Also i am wondering about the horizontal reductions now returning a Vector.
>> I can see why you did this, we really don’t want the primitive boxes being
>> exposed and you can easily reuse the result in further calculations.
>>
>> This works well for the fixed sized small vectors but what if we have different
>> kinds of shape that signify a larger size?
>>
>> An alternative is to move those reductions into the semi-concrete species. If
>> there is a method to construct a new vector with an element at the first
>> position then i bet the JIT can optimize to avoid register shuffling.
>>
>
> Reductions are somewhat sensitive to species. I can see how some operations that are more amenable to floating point (div, etc) would be better served to be placed in a more precise location. Right now I think you're right that it makes sense to limit this placement to species and not Vector.
>
> Would species form the basis of a future templated feature-set of Vector that could be dropped in? Something that could come out of the enhanced generics work in Valhalla?
>
Yes, i think so. The lack of generics over primitives is steering me to keep Vector in the Vector world and species is the bridge to/from the Vector world.
Generics over values/primitives would be beneficial API-wise. Depending on the language features supported it may be possible to declare methods specific to the type parameter(s), so Vector<float> would have FP methods, where as Vector<int> would not (and vice versa for bitwise ops), thereby not requiring specific FP and bitwise interfaces.
Paul.
More information about the panama-dev
mailing list