ZeroMemory上证 [英] ZeroMemory in SSE

查看:157
本文介绍了ZeroMemory上证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要SSE(SSE2 prefered)简单ZeroMemory实施
有人可以帮助这一点。我serching直通SO和网,但没有找到直接答案。


解决方案

ZeroMemory() memset的()不够好?

免责声明:以下一些可能SSE3


  1. 通过循环填充任何未对齐的领先字节,直到该地址是16的倍数

  2. 来保存XMM章

  3. PXOR 来归零XMM章

  4. 而剩余长度> = 16,

    1. MOVDQA movntdq 做写


  5. 弹出来恢复XMM章。

  6. 填充任何未对齐的尾随字节。

movntdq 可能看起来会更快,因为它告诉处理器的数据未纳入缓存,但是这可能会导致性能损失后,如果该数据将要使用。如果你正在释放它之前擦洗内存它可能更合适(比如你可能会和 SecureZeroMemory做())。

I need simple ZeroMemory implementation with SSE (SSE2 prefered) Can someone help with that. I was serching thru SO and net but not found direct answer to that.

解决方案

Is ZeroMemory() or memset() not good enough?

Disclaimer: Some of the following may be SSE3.

  1. Fill any unaligned leading bytes by looping until the address is a multiple of 16
  2. push to save an xmm reg
  3. pxor to zero the xmm reg
  4. While the remaining length >= 16,

    1. movdqa or movntdq to do the write

  5. pop to restore the xmm reg.
  6. Fill any unaligned trailing bytes.

movntdq may appear to be faster because it tells the processor to not bring the data into your cache, but this can cause a performance penalty later if the data is going to be used. It may be more appropriate if you are scrubbing memory before freeing it (like you might do with SecureZeroMemory()).

这篇关于ZeroMemory上证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆