Question


I need to add/mul/sub two __m128 (float) variables using Accelerate framework. But, I can't find function to do that. All Accelerate framework functions takes int__vector__ type instead float__vector__ type. I find function for dividing 'vdivf', but I need to add/mul/sub too.

Can anyone tell me, how to add/mul/sub two __m128 (float) variables using Accelerate framework? Something like this: _mm_add_ps, _mm_sub_ps, _mm_mul_ps but using Accelerate framework API.

Était-ce utile?

La solution

You don't need an API for basic arithmetic:

__m128 x, y;
__m128 z = x + y;
__m128 w = x - y;
__m128 t = x * y;

An API would be totally unnecessary for these operations, so Accelerate doesn't have one.

That said, if you have existing code which uses the SSE intrinsics (_mm_add_ps, etc), and you're really trying to make "minimum code changes", why are you changing anything at all? The SSE intrinsics work just fine on OS X as well.

Autres conseils

The problem is that Accelerate is a higher level API than using SSE2 intrinsics. SSE intrinsics map to single instructions which operate on one vector at a time. Accelerate provides a higher level API of functions which operate at a much larger granularity, typically with arrays of a reasonable size. To port your existing code you should just stick with SSE intrinsics, and if you really do need PowerPC support then you'll need to #idef the SSE code and write an equivalent AltiVec implementation for the ppc build. I doubt this will be worth the effort however - Apple stopped selling PowerPC Macs around 7 years ago, so the market for PowerPC apps must be very small by now.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top