检测预处理器-xarch选项? [英] Detect -xarch option in the preprocessor?

查看:126
本文介绍了检测预处理器-xarch选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Solaris 11上使用Sun Studio 12.4和12.5.我们有一个源文件,该文件提供CRC32的直接C/C ++实现,或者提供使用Intel内部函数的CRC32的优化版本.在运行时,函数指针填充了适当的实施方式.

I'm using Sun Studio 12.4 and 12.5 on Solaris 11. We have a source file that provides a straight C/C++ implementation of CRC32, or an optimized version of CRC32 using Intel intrinsics. At runtime, a function pointer is populated with the proper implementation.

测试与双Xeon的一个的x86服务器上,因为我们是基于编译器版本使代码可用路径是生产以下. SunCC 12.1添加了对SSE4的支持(如果我正确地解析了矩阵),因此我们尝试在__SUNPRO_CC >= 0x5100时启用它.

Testing on a x86 server with dual Xeon's is producing the following because we are making code paths available based on compiler versions. SunCC 12.1 added support for SSE4 (if I parsed the matrix properly), so we attempt to enable it when __SUNPRO_CC >= 0x5100.

"crc.cpp", line 311: ube: error: _mm_crc32_u8 intrinsic requires at least -xarch=sse4_2.

SunCC不会定义常规的GCC定义,例如__SSE4_1____SSE4_2__.此外,SunCC似乎没有像MS VC ++那样使内部函数可用,在MS VC ++中,编译器版本表示支持.

SunCC does not define customary GCC defines, like __SSE4_1__ and __SSE4_2__. In addition, SunCC does not appear to make intrinsics available like MS VC++, where a compiler version indicates the support.

SunCC出现,使基于选项的功能,但它不是我清楚如何检测它的预处理.另外,使用-xarch设置一些位,这些位会导致程序无法在下层处理器(类似于最小"平台)上执行.

SunCC appears to enable features based on -xarch options, but its not clear to me how to detect it in the preprocessor. In addition, using -xarch sets some bits that cause the program to fail execute on downlevel processors (something like a "minimum" platform).

我有两个问题.

  • 我怎样检测的预处理器选项?
  • 如何禁用-xarch位,以便程序可以在低级处理器上运行?
  • how do I detect the -xarch option in the preprocessor?
  • how do I disable the -xarch bits so the program can run on down level processors?

下面是从一个宏转储编译.通知没有什么表示可用的功能.

Below is from a macro dump compiling with -xarch=aes. Notice there is nothing to indicate features available.

$ /opt/solarisstudio12.4/bin/CC -native -m64 -xarch=aes -xdumpmacros -E /dev/null 2>&1 | /usr/gnu/bin/sort --ignore-case

#1 "/dev/null"
#define __alignof__ __alignof
#define __amd64 1
#define __amd64__ 1
#define __ARRAYNEW 1
#define __asm asm
#define __asm__ asm
#define __attribute __attribute__
#define __builtin_constant_p __oracle_builtin_constant_p
#define __builtin_fpclassify __oracle_builtin_fpclassify
#define __builtin_huge_val __oracle_builtin_huge_val
#define __builtin_huge_valf __oracle_builtin_huge_valf
#define __builtin_huge_vall __oracle_builtin_huge_vall
#define __builtin_infinity __oracle_builtin_infinity
#define __builtin_isfinite __oracle_builtin_isfinite
#define __builtin_isgreater __oracle_builtin_isgreater
#define __builtin_isgreaterequal __oracle_builtin_isgreaterequal
#define __builtin_isinf __oracle_builtin_isinf
#define __builtin_isless __oracle_builtin_isless
#define __builtin_islessequal __oracle_builtin_islessequal
#define __builtin_islessgreater __oracle_builtin_islessgreater
#define __builtin_isnan __oracle_builtin_isnan
#define __builtin_isnormal __oracle_builtin_isnormal
#define __builtin_isunordered __oracle_builtin_isunordered
#define __builtin_nan __oracle_builtin_nan
#define __builtin_signbit __oracle_builtin_signbit
#define __BUILTIN_VA_STRUCT 1
#define __cplusplus 199711L
#define __DATE__ "Jul 11 2016"
#define __FILE__ 
#define __has_attribute(x) __oracle_has_attribute(x)
#define __has_nothrow_assign(x) __oracle_has_nothrow_assign(x)
#define __has_nothrow_constructor(x) __oracle_has_nothrow_constructor(x)
#define __has_nothrow_copy(x) __oracle_has_nothrow_copy(x)
#define __has_trivial_assign(x) __oracle_has_trivial_assign(x)
#define __has_trivial_constructor(x) __oracle_has_trivial_constructor(x)
#define __has_trivial_copy(x) __oracle_has_trivial_copy(x)
#define __has_trivial_destructor(x) __oracle_has_trivial_destructor(x)
#define __has_virtual_destructor(x) __oracle_has_virtual_destructor(x)
#define __is_abstract(x) __oracle_is_abstract(x)
#define __is_base_of(x,y) __oracle_is_base_of(x,y)
#define __is_class(x) __oracle_is_class(x)
#define __is_empty(x) __oracle_is_empty(x)
#define __is_enum(x) __oracle_is_enum(x)
#define __is_final(x) __oracle_is_final(x)
#define __is_literal_type(x) __oracle_is_literal_type(x)
#define __is_pod(x) __oracle_is_pod(x)
#define __is_polymorphic(x) __oracle_is_polymorphic(x)
#define __is_standard_layout(x) __oracle_is_standard_layout(x)
#define __is_trivial(x) __oracle_is_trivial(x)
#define __is_union(x) __oracle_is_union(x)
#define __LINE__ 
#define __LP64__ 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __STDC__ 0
#define __sun 1
#define __SUN_PREFETCH 1
#define __SunOS 1
#define __SunOS_5_11 1
#define __SUNPRO_CC 0x5130
#define __SUNPRO_CC_COMPAT 5
#define __SVR4 1
#define __TIME__ "20:58:00"
#define __underlying_type(x) __oracle_underlying_type(x)
#define __unix 1
#define __volatile volatile
#define __volatile__ volatile
#define __x86_64 1
#define __x86_64__ 1
#define _BOOL 1
#define _LARGEFILE64_SOURCE 1
#define _LP64 1
#define _SIGNEDCHAR_ 1
#define _TEMPLATE_NO_EXTDEF 1
#define _WCHAR_T 
#define sun 1
#define unix 1

推荐答案

第二个问题:

我该如何禁用-xarch位,以便程序可以下级处理器上运行?

how do I disable the -xarch bits so the program can run on down level processors?

见章节的接头和库指南的7能力处理:

See Chapter 7 Capability Processing of the Linkers and Libraries Guide:

https://docs.oracle.com/cd/E53394_01/html/E54813/index.html

这展示了如何提供相同功能的多个实例 用功能位标记的.运行时链接器将 根据报告的功能确定使用哪个功能.

This shows you how to deliver multiple instances of the same function which are tagged with the capability bits. The runtime linker will resolve which function is used based on the reported capabilities.

如果你真的想自行管理功能位, 具体见节能力的指令第9章映射文件. 这说明如何删除从所生成的对象的能力.

If you really want to manage the capability bits yourself, see Chapter 9 Mapfiles in particular section CAPABILITY Directive. This shows how to remove capabilities from the generated object.

这篇关于检测预处理器-xarch选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆