由于某种原因 cilk_spawn 不适用于 x86 内在函数。每次尝试将两者组合到同一函数的主体中时,都会出现错误。(请注意 cilk_for 工作正常)。如果我删除所有 SIMD 指令,它会编译并运行良好。
#include <stdio.h>
#include <x86intrin.h>
#include <math.h>
#include <cilk/cilk.h>
int main()
{
int w = cilk_spawn sqrt(10);
__m128i x = _mm_set_epi64x(1, 1);
x = _mm_add_epi64(x, x);
cilk_sync;
printf("%d\n", w);
return 0;
}
这是 gcc 输出:
gcc-4.9 -std=c99 -march=native -fcilkplus -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/include/xmmintrin.h:1258:0,
from /usr/lib/gcc/x86_64-linux-gnu/4.9/include/x86intrin.h:31,
from ../main.c:2:
../main.c: In function ‘main’:
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/emmintrin.h:581:1: error: inlining failed in call to always_inline ‘_mm_set_epi64x’: function not inlinable
_mm_set_epi64x (long long __q1, long long __q0)
^
../main.c:9:10: error: called from here
__m128i x = _mm_set_epi64x(1, 1);
^
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/include/xmmintrin.h:1258:0,
from /usr/lib/gcc/x86_64-linux-gnu/4.9/include/x86intrin.h:31,
from ../main.c:2:
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/emmintrin.h:1025:1: error: inlining failed in call to always_inline ‘_mm_add_epi64’: function not inlinable
_mm_add_epi64 (__m128i __A, __m128i __B)
^
subdir.mk:18: recipe for target 'main.o' failed
../main.c:10:4: error: called from here
x = _mm_add_epi64(x, x);
^
make: *** [main.o] Error 1
我刚刚注意到这是 GCC 4.9 但错误消息与 GCC 5 相同。