IBM XL/C在预处理器中是否支持Altivec?
问题描述:
我想确定何时激活一些Altivec代码路径。当我检查-qaltivec
生效时的预处理器宏时,我看不到相应的预处理器宏(请参见下文)。IBM XL/C在预处理器中是否支持Altivec?
我们担心或恐惧的是需要-qaltivec
和-DALTIVEC=1
或类似的。用户几乎从不阅读手册,因此会为该平台生成无尽的问题和错误报告。如果RTFM能够发挥作用,那么在过去的50年左右就会发生。
当-qaltivec
有效时,XL/C信号Altivec是否有效?如果不是,还有其他方法可以推断出来吗?
在此先感谢。
下面是从GCC111这是一个Power7机器。我不确定为什么编译器声称不支持Altivec。
$ xlC -qshowmacros -qaltivec -E adhoc.cpp.proto | sort | egrep -iv 'sync'
1506-1162 (W) The altivec option is not supported for the target architecture and is ignored.
"adhoc.cpp.proto", line 2.10: 1506-296 (S) #include file <iosfwd> not found.
"adhoc.cpp.proto", line 3.10: 1506-296 (S) #include file <string> not found.
#define _AIX 1
#define _AIX32 1
#define _AIX41 1
#define _AIX43 1
#define _AIX50 1
#define _AIX51 1
#define _AIX52 1
#define _AIX53 1
#define _AIX61 1
#define _AIX71 1
#define _ARCH_COM 1
#define _ARCH_PPC 1
#define _BIG_ENDIAN 1
#define _CHAR_UNSIGNED 1
#define _IBMR2 1
#define _ILP32 1
#define _LONG_LONG 1
#define _POWER 1
#define __ALIGN 1
#define __BASE_FILE__ "adhoc.cpp.proto"
#define __BIG_ENDIAN__ 1
#define __BOOL__ 1
#define __C99_BOOL 1
#define __C99_COMPLEX 1
#define __C99_COMPOUND_LITERAL 1
#define __C99_CPLUSCMT 1
#define __C99_DESIGNATED_INITIALIZER 1
#define __C99_DUP_TYPE_QUALIFIER 1
#define __C99_EMPTY_MACRO_ARGUMENTS 1
#define __C99_FLEXIBLE_ARRAY_MEMBER 1
#define __C99_HEX_FLOAT_CONST 1
#define __C99_INLINE 1
#define __C99_LLONG 1
#define __C99_MACRO_WITH_VA_ARGS 1
#define __C99_MAX_LINE_NUMBER 1
#define __C99_MIXED_DECL_AND_CODE 1
#define __C99_MIXED_STRING_CONCAT 1
#define __C99_NON_CONST_AGGR_INITIALIZER 1
#define __C99_NON_LVALUE_ARRAY_SUB 1
#define __C99_PRAGMA_OPERATOR 1
#define __C99_RESTRICT 1
#define __C99_STATIC_ARRAY_SIZE 1
#define __C99_STD_PRAGMAS 1
#define __C99_TGMATH 1
#define __C99_UCN 1
#define __C99_VAR_LEN_ARRAY 1
#define __C99__FUNC__ 1
#define __CHAR_UNSIGNED__ 1
#define __DIGRAPHS__ 1
#define __FENCE 1
#define __FUNCTION__ __FUNCTION__
#define __GCC_PROTO_OVERRIDES_KNR_DEF 1
#define __HHW_BIG_ENDIAN__ 1
#define __HHW_RS6000__ 1
#define __HOS_AIX__ 1
#define __IBMC_NORETURN 1
#define __IBMC_STATIC_ASSERT 1
#define __IBMC__ 1210
#define __IBM_ALIGNOF__ 1
#define __IBM_ATTRIBUTES 1
#define __IBM_COMPUTED_GOTO 1
#define __IBM_DOLLAR_IN_ID 1
#define __IBM_EXTENSION_KEYWORD 1
#define __IBM_GCC_ASM 1
#define __IBM_GCC__INLINE__ 1
#define __IBM_GENERALIZED_LVALUE 1
#define __IBM_INCLUDE_NEXT 1
#define __IBM_LABEL_VALUE 1
#define __IBM_LOCAL_LABEL 1
#define __IBM_MACRO_WITH_VA_ARGS 1
#define __IBM_NESTED_FUNCTION 1
#define __IBM_PP_PREDICATE 1
#define __IBM_PP_WARNING 1
#define __IBM_REGISTER_VARS 1
#define __IBM__IMAG__ 1
#define __IBM__REAL__ 1
#define __IBM__TYPEOF__ 1
#define __ILP32__ 1
#define __LONGDOUBLE64 1
#define __MATH__ 1
#define __PPC 1
#define __PPC__ 1
#define __SIZE_TYPE__ unsigned int
#define __STDC_HOSTED__ 1
#define __STDC_VERSION__ 199901L
#define __STDC__ 1
#define __STR__ 1
#define __THW_BIG_ENDIAN__ 1
#define __THW_PPC__ 1
#define __THW_RS6000__ 1
#define __TOS_AIX__ 1
#define __XLC121__ 1
#define __XLC13__ 1
#define __XLC_BUILTIN_VAARG__ 1
#define __alignof __alignof__
#define __const const
#define __const__ const
#define __powerpc 1
#define __powerpc__ 1
#define __signed signed
#define __signed__ signed
#define __typeof __typeof__
#define __unix 1
#define __unix__ 1
#define __volatile volatile
#define __volatile__ volatile
#define __xlC__ 0x0c01
#define __xlC_ver__ 0x00000000
#define __xlc__ "12.1.0.0"
答
通常的宏大多数编译器(GCC 等)自动定义为__VEC__
(或至少是这种符号我通常使用在跨平台的代码,以测试的AltiVec)。当使用-maltivec
或-qaltivec
时,用于xlc的IBM claims that __ALTIVEC__
is also defined(参见“预定义的宏”)。
谢谢@保罗。我在[IBM手册](https://www-01.ibm.com/support/docview.wss?uid=swg27024811)中看到了'__VEC__',但它不存在,如上所示。我真的不明白XL C/C++声称'-qaltivec'是一个不受支持的选项。这对我来说毫无意义。但是为了公平地编译器,当我包含''并尝试使用'__vector'时,编译未知类型的错误。所以编译器真的很困惑。 –
jww
Altivec仅在具有矢量单位的CPU上受支持。 AIX上XLC的默认CPU架构是pwr4,它是操作系统所需的最低CPU。由于pwr4没有矢量单位,XLC发布了您看到的错误。要解决这个问题,请添加-qarch = pwr7或-qarch = auto。 –