다음 코드는 컴파일되지 않습니다. 오류 메시지는 다음과 같습니다제한 (암페어) 함수의 기본 매개 변수
오류 1 :
error C3930: 'foo' : no overloaded function has restriction specifiers that are compatible with the ambient context ''
오류 2 :
error C2660: 'f1' : function does not take 0 arguments
오류 3 :
IntelliSense: amp-restricted function "int foo() restrict(amp)" (declared at line 5) must be called from an amp-restricted function
프로그램 :
#include <amp.h>
#include <iostream>
using namespace std;
int foo() restrict(amp) { return 5; }
int f1(int x = foo()) restrict(amp) {
return x;
}
int main()
{
using namespace concurrency;
int a[10] = {0};
array_view<int> av(10, a);
parallel_for_each(av.extent, [=](index<1> i) restrict(amp) {
av[i] = f1();
});
for(unsigned i=0; i<10; ++i) {
cout << av[i] << "\n";
}
return 0;
}
이상하게도, foo()
에있는 restrict(amp)
을 제거하고 람다에있는 f1()
의 전화 번호를 예를 들어 5
으로 바꾸면 프로그램이 잘 컴파일됩니다. 그렇다면 앰프 함수의 기본 인수에서 함수 호출에 대한 규칙은 무엇입니까?
GCC와 MSVC 모두에서 기괴한 메시지가 나타납니다. 그것은'MyStruct'의 배열을 가지고 있고, 요소의 수는 하나씩 꺼져 있습니다 : MyStruct s_val [3] = {MyStruct (...), MyStruct (...)}; 어떤 컴파일러도 카운트가 꺼져 있다고 말하지 않았습니다. – jww