小编eye*_*ito的帖子

使用C/Intel程序集,测试128字节内存块是否包含全零的最快方法是什么?

继续我的第一个问题,我正在尝试优化通过VTune分析64位C程序找到的内存热点.

特别是,我想找到一种最快的方法来测试一个128字节的内存块是否包含全零.您可以假设内存块有任何所需的内存对齐方式; 我使用64字节对齐.

我正在使用配备Intel Ivy Bridge Core i7 3770处理器和32 GB内存的PC以及免费版的Microsoft vs2010 C编译器.

我的第一次尝试是:

const char* bytevecM;    // 4 GB block of memory, 64-byte aligned
size_t* psz;             // size_t is 64-bits
// ...
// "m7 & 0xffffff80" selects the 128 byte block to test for all zeros
psz = (size_t*)&bytevecM[(unsigned int)m7 & 0xffffff80];
if (psz[0]  == 0 && psz[1]  == 0
&&  psz[2]  == 0 && psz[3]  == 0
&&  psz[4]  == 0 && psz[5]  == 0
&&  psz[6]  == 0 …
Run Code Online (Sandbox Code Playgroud)

c optimization performance assembly intel-vtune

15
推荐指数
2
解决办法
2501
查看次数

标签 统计

assembly ×1

c ×1

intel-vtune ×1

optimization ×1

performance ×1