Jump to content
  • Advertisement
Sign in to follow this  
d000hg

Can SIMD do these things?

This topic is 4617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, some simple questions - I know SIMD basics but im not sure if these things are achieveable. Note I'm only interested in integers: 1)If I work with BYTEs, then I can work with 8 values at once with the 64bit MMX registers? 2)Can I 'scalarise' a SIMD data - ie can the last step of this be done in a single operation:
WORD data1[4],data2[4],data3[4];
data3 = MMX_mul(data1,data2);
int sum = data3[0]+data3[1]+data3[2]+data3[3];
3)C = min(A,B) is basically defined as:
if(A<B) C = A;
else C = B;
Is it possible to parallelise this - I think I've heard of MMX conditional/test operations?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by d000hg
1)If I work with BYTEs, then I can work with 8 values at once with the 64bit MMX registers?


Yes, see instructions such as PADDB.

Quote:

2)Can I 'scalarise' a SIMD data - ie can the last step of this be done in a single operation:
int sum = data3[0]+data3[1]+data3[2]+data3[3];



Not AFAIK.

Quote:
3)C = min(A,B) is basically defined as:
if(A<B) C = A;
else C = B;
Is it possible to parallelise this - I think I've heard of MMX conditional/test operations?


PCMPGTB is one example of an MMX comparision function - it sets the individual elements of the destination to 0 or 0xff depending on the result of the (greater-than) comparison. From this, you can easily compute a minimum.

Share this post


Link to post
Share on other sites
Is there an op which will set directly each element to be the min/max of the two arguments?

ie c = min(a,b)

Share this post


Link to post
Share on other sites
as for serialized sum of all components you may perhaps use the pavg,
which gives you the average of those components.
(pavgb for bytes of pavgw for words).

pavgw would be WORD avg = (data3[0]+2 + data3[1]+2 + data3[2]+2 + data3[3]+2) / 4;
The "+2" is for proper rounding.

Share this post


Link to post
Share on other sites
Not exactly. I've always been interested in a chance to use SIMD. The contest is one place I can do it, but I don't have my instruction-set reference.

I'm deliberately not asking anything specific to the contest, just "is there an op to do this"!

EDIT:
From those pages, PADDB can work on 64/128 bit operands in MMX/SSE2 respectively. How do I control which it uses on an SSE2-enabled system - just use the SSE registers instead of the MMn ones?

Share this post


Link to post
Share on other sites
When you use assembly you specify the register. The intrinsics are overloaded for the different types of data, so that's more or less the same.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You cann with instuction PCMPGTB, and with logical AND and OR make this wery quick, without connditonal jumps. instuctions PAND and POR.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!