矢量类库:解决使用 vec4d 时的问题
这是一段导致我出现问题/错误的简化代码(Vec4d 来自 Agner Fog 库 VCL)
#define AVX256_ALIGNED_MALLOC(type,size) (type *)_aligned_malloc(size * sizeof(type),32)
#define AVX256_FREE(ptr) _aligned_free(ptr)
int N = 1024;
std::vector<double> A(N);
double* Aaligned = AVX256_ALIGNED_MALLOC(double, N);
memcpy(Aaligned, &A[0], N * sizeof(double));
int N4=N>>2;
for(size_t i = 4; i <N4-4; ++i)
{
//....
... = ((Vec4d*)(Aaligned - 1))[i] + ((Vec4d*)(Aaligned))[i] + ((Vec4d*)(Aaligned + 1))[i];
}
AVX256_FREE(Aaligned);
如果我清楚我可以使用,
((Vec4d*)(Aaligned))[i]
您能否确认我不能使用
((Vec4d*)(Aaligned-1))[i]
或 ((Vec4d*)(Aaligned+1))[i] 有什么提示吗? 非常感谢。 吕克
here a piece of simplified code that causes me a problem/error (Vec4d is coming from the Agner Fog library VCL)
#define AVX256_ALIGNED_MALLOC(type,size) (type *)_aligned_malloc(size * sizeof(type),32)
#define AVX256_FREE(ptr) _aligned_free(ptr)
int N = 1024;
std::vector<double> A(N);
double* Aaligned = AVX256_ALIGNED_MALLOC(double, N);
memcpy(Aaligned, &A[0], N * sizeof(double));
int N4=N>>2;
for(size_t i = 4; i <N4-4; ++i)
{
//....
... = ((Vec4d*)(Aaligned - 1))[i] + ((Vec4d*)(Aaligned))[i] + ((Vec4d*)(Aaligned + 1))[i];
}
AVX256_FREE(Aaligned);
If it is clear to me that I'am allowed to use
((Vec4d*)(Aaligned))[i]
Can you confirm that I cannot use
((Vec4d*)(Aaligned-1))[i]
or
((Vec4d*)(Aaligned+1))[i]
Any hints ?
Many thanks.
Luc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论