我已经使用g++编写和调试了一些AVX代码,现在我正在尝试让它与MSVC一起工作,但是我一直收到以下错误:
“error 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”
所引用的代码片段为:
“error 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”
所引用的代码片段为:
...
#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);
}
...
- 我已启用
/arch:AVX
,但是没有任何区别。 - 我的机器确实支持 AVX - 它与我用于原始 Linux 项目的机器相同。
- 另外,http://msdn.microsoft.com/en-us/library/hh977022.aspx 列出了可用 Intrinsic 函数之一是
_mm256_setr_epi64x
。
非常感谢您的帮助。
__AVX__
和__AVX2__
。它只支持2003年的OpenMP。当我将我的分形代码转换为使用FMA时,MSVC比不使用FMA要慢得多。而在GCC中,它则更快。 - Z boson_mm256_loadu_si256
的解决方案显然比我的好。我没有仔细考虑过这个问题。当然,我永远不会在主循环中使用我的解决方案。我专注于内部函数。如果这个问题问如何高效地设置单个位给定索引,那么它会更好。 - Z boson