使用SSE内部函数复制少量数据时出现问题
Issue copying small amount of data using SSE intrinsics
我在这里看到了类似的问题,并尝试使用类似的代码,但在某些地方出错了。。顺便说一下,这只是一个学习练习。这是代码:
struct alignas(16) Data
{
union
{
int field1;
int field2;
int field3;
int field4;
int field5;
int field6;
int field7;
int field8;
__m128 v[2];
};
};
void copy((__m128* __restrict b, const __m128* __restrict a)
{
*b++ = *a++;
*b++ = *a++;
}
int main(int, char**)
{
Data dst={0};
Data src={0};
src.field1=1;
src.field2=500;
src.field3=200;
src.field4=393;
src.field5=29383;
src.field6=3838;
src.field7=128484;
src.field8=111;
copy(dst.v,src.v);
std::cout<<" before copy dst.field1=" << dst.field1 <<" dst.field2=" << dst.field2 << std::endl;
return 0;
}
在复制之前,字段1和字段2都显示0,但复制之后都是111?我对c++还很陌生,所以它似乎是在复制结构体的最后32位而不是dst结构体的64位,但不确定为什么?
您的并集不正确,它有1个整数或__m128
数组。CCD_ 2、CCD_。除上次分配给field8
外,您的所有作业都将被覆盖。
你可以用这个代替:
struct alignas(16) Data
{
union
{
int fields[8];
__m128 v[2];
};
};
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++LinkedList问题.数据类型之间存在冲突?没有匹配的构造函数
- HDF5Cpp 扩展复合数据集超板问题
- C++:__aligned(__alignof__) 导致字符数组数据出现问题?
- 我对数据结构、双向链表有一些问题
- 使用蓝牙组件将数据从Android手机传输到串行设备时出现问题
- Java 客户端C++服务器数据发送/接收问题
- printf 数据类型说明符复杂问题
- 从文件导入数据时遇到问题.我有一个没完没了的循环
- 对于这个问题,是否有更好的数据结构和算法选择
- 使用SSE内部函数复制少量数据时出现问题
- 面临在 if 语句之外打印变量数据的问题 完成使用 Qt 编程
- 面对迭代矢量<矢量<string>>和打印数据的问题
- C++中从客户端到服务器的数据传输问题
- 将此类数据作为字符串进行比较时出现问题
- 线程清理器检测到数据争用,问题出在哪里?
- 如何解决在 clr 项目的特定文件中写入数据的问题?
- C++奇怪的问题.数据成员超出范围
- C 的多态性问题 - 数据覆盖
- 面试问题——数据结构