c++ - 未解析的外部符号 __mm256_setr_epi64x

标签 c++ visual-studio-2012 intrinsics avx msvc12

我已经用 g++ 编写和调试了一些 AVX 代码,现在我正试图让它与 MSVC 一起工作,但我不断得到

error LNK2019: unresolved external symbol __mm256_setr_epi64x referenced in function "private: union __m256i __thiscall avx_matrix::avx_bit_mask(unsigned int)const " (?avx_bit_mask@avx_matrix@@ABE?AT__m256i@@I@Z)

引用的代码是

...

#include <immintrin.h>

...

    /* All zeros except for pos-th position (0..255) */
    __m256i avx_matrix::avx_bit_mask(const std::size_t pos) const
    {
        int64_t a = (pos >= 0 && pos < 64) ? 1LL << (pos - 0) : 0;
        int64_t b = (pos >= 64 && pos < 128) ? 1LL << (pos - 64) : 0;
        int64_t c = (pos >= 128 && pos < 192) ? 1LL << (pos - 128) : 0;
        int64_t d = (pos >= 192 && pos < 256) ? 1LL << (pos - 256) : 0;
        return _mm256_setr_epi64x(a, b, c, d);
    }
...

如有任何帮助,我们将不胜感激。

最佳答案

看起来这可能实际上是一个 known bug - 某些 AVX 内在函数显然在 32 位模式下不可用。尝试针对 64 位构建和/或升级到 Visual Studio 2013 Update 2,据推测,该问题现已得到修复。

或者,如果您只有上面的一个实例,您正在使用这个内在函数,那么您可以将您的函数更改为:

__m256i avx_matrix::avx_bit_mask(const std::size_t pos) const
{
    int64_t a[4] = { (pos >=   0 && pos <  64) ? 1LL << (pos -   0) : 0,
                     (pos >=  64 && pos < 128) ? 1LL << (pos -  64) : 0,
                     (pos >= 128 && pos < 192) ? 1LL << (pos - 128) : 0,
                     (pos >= 192 && pos < 256) ? 1LL << (pos - 256) : 0 };
    return _mm256_loadu_si256((__m256i *)a);
}

或者甚至:

__m256i avx_matrix::avx_bit_mask(const std::size_t pos) const
{
    int64_t a[4] = { 0 };
    a[pos >> 6] = 1LL << (pos & 63ULL);
    return _mm256_loadu_si256((__m256i *)a);
}

哪个可能更有效率。

关于c++ - 未解析的外部符号 __mm256_setr_epi64x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27258261/

相关文章:

c++ - 多尺度检测循环在 OpenCV 的 HOG 检测中是如何工作的?

c++ - gcc4.9.2的std::vector的libstdc++实现继承自_Vector_base(非虚拟析构函数)。为什么这样可以?

c# - vs2012中删除自动编码项的快捷方式?

visual-studio - MsBuild 找不到发布配置文件

c++ - 使用(float&)int可以进行类型修剪,(float const&)int可以像(float)int那样转换吗?

c++ - Google Mock 中的双重免费

c++ - 我的 g++ 使用 vector<weak_ptr> erase() 方法生成奇怪的警告

entity-framework - 无法使用 TFS 从数据库更新 EF 模型

c - 如何使用 SSE Intrinsics 将值存储在非连续的内存位置?

c - SSE 字节和半字交换