未解析的外部符号__mm256_setr_epi64x [英] unresolved external symbol __mm256_setr_epi64x
问题描述
我用g ++编写和调试了一些AVX代码,现在我想让它与MSVC一起工作,但是我一直得到
错误LNK2019:在函数private:union __m256i __thiscall avx_matrix :: avx_bit_mask(unsigned int)const(?avx_bit_mask @ avx_matrix @@ ABE?AT__m256i @@ I @ Z)中引用的未解析的外部符号__mm256_setr_epi64x b $ b
引用的代码片段是
.. 。
#include< immintrin.h>
...
/ *除第pos位置之外的所有零(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);
}
...
- 启用
/ arch:AVX
,但它没有任何区别。 - 我的机器肯定支持AVX -
- 此外, http://msdn.microsoft.com/en-us/library/hh977022.aspx 列出可用内联函数中的
_mm256_setr_epi64x
。
任何帮助将非常感激。
看起来这可能是一个已知错误 - 某些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);
}
这可能会更有效率。 / p>
I have written and debugged some AVX code with g++ and now I'm trying to get it to work with MSVC, but I keep getting
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)
The referenced piece of code is
...
#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);
}
...
- I have enabled
/arch:AVX
, but it doesn't make any difference. - My machine definitely supports AVX - it is the same one I used for the original Linux project.
- Also, http://msdn.microsoft.com/en-us/library/hh977022.aspx lists
_mm256_setr_epi64x
among the available intrinsics.
Any help would be much appreciated.
It looks this might actually be a known bug - certain AVX intrinsics are apparently not available in 32-bit mode. Try building for 64 bit and/or upgrading to Visual Studio 2013 Update 2, where this has supposedly now been fixed.
Alternatively, if you just have the one instance above where you are using this intrinsic, then you could change your function to:
__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);
}
or perhaps even:
__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);
}
which might be a little more efficient.
这篇关于未解析的外部符号__mm256_setr_epi64x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!