SSE代码最多查找整数数组
我正在努力优化我的C ++代码以写入SSE指令。
我在我们所在的循环上工作。找到最大向量。
void findMax(vector<UInt64> & index)
auto size = index.size();
Uint64_t max_val = index[0];
for (size_t i = 1; i < size; ++i)
max_val = std::max(max_val, index[i]);
}
我正在尝试这种方式:
{
auto size = index.size();
const auto bytes_sse = sizeof(__m128i);
const __m128i * data = reinterpret_cast<const __m128i *>(&index);
__m128i max = reinterpret_cast<const __m128i *>(index[0]);
const auto loop_count_sse = (sizeof(index[0])*size)/bytes_sse;
for(size_t j=0;j<loop_count_sse;j++){
max = _mm_max_epi16(max, data+i);
data += bytes_sse;
}
但这是不起作用的,请帮助
I am working on optimizing my c++ code to write in to SSE instructions.
I am working on the loop where we are. finding the max of vector.
void findMax(vector<UInt64> & index)
auto size = index.size();
Uint64_t max_val = index[0];
for (size_t i = 1; i < size; ++i)
max_val = std::max(max_val, index[i]);
}
I am trying this way :
{
auto size = index.size();
const auto bytes_sse = sizeof(__m128i);
const __m128i * data = reinterpret_cast<const __m128i *>(&index);
__m128i max = reinterpret_cast<const __m128i *>(index[0]);
const auto loop_count_sse = (sizeof(index[0])*size)/bytes_sse;
for(size_t j=0;j<loop_count_sse;j++){
max = _mm_max_epi16(max, data+i);
data += bytes_sse;
}
but this is not working,Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论