vector Cross/Dot using core.simd?

Sean Cavanaugh WorksOnMyMachine at gmail.com
Sat Aug 11 18:32:36 PDT 2012


On 8/11/2012 8:23 PM, F i L wrote:
> I'm trying to write a Cross and Dot function using core.simd.float4 and DMD
>
> Does anyone know anything about SIMD operations that may be able to help
> me translate these functions into a D equivalent? I would very much
> appreciate your help.


Some reference:

C++ simd intrinsic for dot product (requires SSE 4.1, very modern)
_mm_dp_ps

C++ simd instrinsic for horizontal add (requires SSE3, also reasonably 
modern)
_mm_hadd_ps

If you are on SSE2 (which is the base spec for x64) and also the minimum 
CPU target we use at work for commercial game development, you are stuck 
doing shuffles and adds for dot product, which effectively process these 
operations as scalar).

Ideally one of the sides of the dot product is an array and you can 
vectorize the dot product itself (1 vector vs 4 others, or 4 v 4).  This 
is common when setting up shapes like view frustum culling (point tested 
against 6-8 extruded planes in an array)




More information about the Digitalmars-d-learn mailing list