gcc7 또는 clang이있는 Intel의 AVX 확장에서 256 비트 벡터 데이터 유형 (__m256d)을 컴파일 할 때 오류가 발생합니다. 128 비트 벡터를 컴파일하고 사용할 수 있습니다 (-mavx 플래그 없음). 그러나 avx 벡터를 시도하자마자 일부 어셈블러 명령 정의를 찾을 수 없거나 (GCC7) 링커 오류 (clang)가 있습니다. 포트를 사용하여 모든 컴파일러 또는 패키지를 설치합니다.-mavx 플래그가있는 GCC7 링커 오류
프로그램 : gcc7와
#include <iostream>
#include <emmintrin.h>
#include <immintrin.h>
#include <pmmintrin.h>
#include <xmmintrin.h>
struct cpx256 {
union {
struct {
double r1, i1, r2, i2;
};
__m256d v;
};
cpx256(double r1_in, double i1_in, double r2_in, double i2_in) :
r1(r1_in), i1(i1_in), r2(r2_in), i2(i2_in){}
};
std::ostream & operator<< (std::ostream & os, cpx256 cmplx) {
os << cmplx.r1;
(cmplx.i1 > 0) ? (os << "+" << cmplx.i1 << "j") : (os << cmplx.i1 << "j");
os << " | ";
os << cmplx.r2;
(cmplx.i2 > 0) ? (os << "+" << cmplx.i2 << "j") : (os << cmplx.i2 << "j");
return os;
}
int main(){
cpx256 b = cpx256(1,2, 3, 4);
std::cout << b << std::endl;
return 0;
}
:
clang -std=c++11 -Wall -Wextra -mtune=native -ffast-math -fverbose-asm -mavx avx.cpp
Undefined symbols for architecture x86_64:
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in avx-dfd779.o
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::ios_base::getloc() const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in avx-dfd779.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(double)", referenced from:
operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, cpx256) in avx-dfd779.o
"std::__1::cout", referenced from:
_main in avx-dfd779.o
"std::__1::ctype<char>::id", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::locale::~locale()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::__1::ios_base::clear(unsigned int)", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"std::terminate()", referenced from:
___clang_call_terminate in avx-dfd779.o
"operator new(unsigned long)", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in avx-dfd779.o
"___cxa_begin_catch", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
___clang_call_terminate in avx-dfd779.o
"___cxa_end_catch", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
"___gxx_personality_v0", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in avx-dfd779.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in avx-dfd779.o
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in avx-dfd779.o
Dwarf Exception Unwind Info (__eh_frame) in avx-dfd779.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
연타 :
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-4.0/bin
그 소리와
g++ -std=c++11 -Wall -Wextra -mtune=native -ffast-math -fverbose-asm -mavx avx.cpp
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:57:no such instruction: `vmovsd %xmm0, -16(%rbp)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:58:no such instruction: `vmovsd %xmm1, -24(%rbp)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:59:no such instruction: `vmovsd %xmm2, -32(%rbp)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:60:no such instruction: `vmovsd %xmm3, -40(%rbp)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:63:no such instruction: `vmovsd -16(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:64:no such instruction: `vmovsd %xmm0, (%rax)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:66:no such instruction: `vmovsd -24(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:67:no such instruction: `vmovsd %xmm0, 8(%rax)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:69:no such instruction: `vmovsd -32(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:70:no such instruction: `vmovsd %xmm0, 16(%rax)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:72:no such instruction: `vmovsd -40(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:73:no such instruction: `vmovsd %xmm0, 24(%rax)'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:99:no such instruction: `vmovd %rdx, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:103:no such instruction: `vmovsd 24(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:104:no such instruction: `vxorpd %xmm1, %xmm1,%xmm1'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:105:no such instruction: `vcomisd %xmm1, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:113:no such instruction: `vmovd %rax, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:123:no such instruction: `vmovd %rdx, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:138:no such instruction: `vmovd %rdx, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:142:no such instruction: `vmovsd 40(%rbp), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:143:no such instruction: `vxorpd %xmm1, %xmm1,%xmm1'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:144:no such instruction: `vcomisd %xmm1, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:152:no such instruction: `vmovd %rax, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:162:no such instruction: `vmovd %rdx, %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:190:no such instruction: `vmovsd lC4(%rip), %xmm2'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:191:no such instruction: `vmovsd lC5(%rip), %xmm1'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:192:no such instruction: `vmovsd lC6(%rip), %xmm0'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:195:no such instruction: `vmovapd %xmm2, %xmm3'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:196:no such instruction: `vmovapd %xmm1, %xmm2'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:197:no such instruction: `vmovapd %xmm0, %xmm1'
/var/folders/06/hdqdxlh14czcvkk4t55894y80000gn/T//ccXFPOnA.s:198:no such instruction: `vmovd %rdx, %xmm0'
나는 링커 오류
GCC7 :
g++ (MacPorts gcc7 7-20170622_0) 7.1.1 20170622
내 노트북 CPU : 2.8 GHz의 인텔 코어 i7 (AVX를 지원해야한다), 맥 OS 시에라 10.12.5 나는 또한 포트 내 링커를 업데이트
(ld64 - 최신 274.2)를 설치하고 mp-clang-4.0을 설치하고 활성화했습니다. 어떤 아이디어?
코드는 Xcode와 함께 제공되는 일반 Apple 버전의 clang을 사용하여 문제없이 컴파일 및 링크됩니다. 자제력있는 컴파일러 설치가 고장난 것 같습니다. –
사용중인 어셈블러 버전을 확인하십시오. 'vmovd % rdx, % xmm0'이 어셈블되지 않으면 설정이 정말로 망가져 버립니다. –
clang 버전 8.1.0을 사용하는 것으로 보입니다. 하지만 대부분 GNU 컴파일러 컬렉션을 사용합니다. 다른 버전이 필요한 모든 버전을 확인하는 방법을 모르겠습니다. 'LLVM-GCC -v 애플 LLVM 버전 8.1.0 (그 소리-802.0.42) 대상 : x86_64에-사과 darwin16.6.0 스레드 모델 : POSIX InstalledDir : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin' –