Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sQuid

Fast Zero Checking

This topic is 5658 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

Hi there, Does anyone know a fast method for checking if an array of floats are all equal to zero? Is there an assembly instruction for checking contiguous memory? tia

Share this post


Link to post
Share on other sites
Advertisement
Yes.

xor eax, eax
mov ecx, cnt
mov edi, buf
repz scasd
jnz not_all_0


A loop will likely be faster, though, on >= 586 CPUs.
Compare dwords, not floats (requires fcom, fnstsw, lahf => sloow), and unroll the loop. If the array is really big, think about checking qwords at a time; also, prefetch.

Share this post


Link to post
Share on other sites

  • 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!