使用Intel编译器(7)其它(1)多目标处理器程序的编写指南
来源:互联网 发布:水果软件中文版 编辑:程序博客网 时间:2024/05/20 17:25
http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/index.htm
说明:本系列文章为个人笔记,如有不正确之处,请参考官方相关文档,如果错误发现,我会尽量更新修改。另外,以下内容不保证对于所有版本的编译器都正确,编译器的实现也可能有一些变化之处,具体参考官方文档。
更多说明请参考http://blog.csdn.net/gengshenghong/article/details/7034748中补充说明部分。
Summary:多目标处理器程序的编写指南。
(1) 介绍:
前面在分析编译器优化选项的时候已经知道,大部分优化选项是可以用于主流的处理器的,少数选项是专门为Intel处理器上使用的。有一个问题是:如果希望代码在不同处理器上都能得到最大化的优化,我们的一个考虑是,对于每一种处理器,编写适合于其上面的代码,那么如何实现这一功能,让程序能运行时自动检测CPU类型,执行最优化的代码?这就是编译器的manual processor dispatch feature特性。
(2) manual processor dispatch feature
通过给函数使用cpu_specific和cpu_dispatch关键字指定处理器类型,从而可以为同一个函数实现不同处理器的版本,编译器生成的代码会在运行时检查CPU类型,执行对应的代码。需要说明的是,这里可指定的CPU类型包括IA32和Intel64架构的Inte处理器,当然,编译器会生成一个普通版本的函数,能运行于其它类型的所有通用处理器。
使用语法:
__declspec(cpu_dispatch(cpuid, cpuid,...)):提供一个目标处理器类型的列表,和一个空的函数体。
the __declspec(cpu_specific(cpuid)):用于修饰对应的每一个处理器类型版本的函数。
cpuid是预定义的一些处理器类型,其值主要如下(关于其对应表示的处理器型号参考手册说明):
core_2nd_gen_avx
core_aes_pclmulqdq
core_i7_sse4_2
core_2_duo_sse4_1
core_2_duo_ssse3
atom
pentium_4_sse3
pentium_4
pentium_m
pentium_iii
generic
说明:在处理器类型找不到匹配的函数的实现版本时,就会选择执行generic版本。如果要在所有处理器上都能运行,就一定要提供generic版本,否则可能导致某些处理器无法运行。
下面是官方文档上一个使用的例子:
#include <stdio.h>__declspec(cpu_dispatch(core_2nd_gen_avx, core_i7_sse4_2, core_2_duo_ssse3, generic ))void dispatch_func() {};__declspec(cpu_specific(core_2nd_gen_avx))void dispatch_func() {printf("\nCode for 2nd generation Intel Core processors with support for AVX goes here\n");}__declspec(cpu_specific(core_i7_sse4_2))void dispatch_func() {printf("\nCode for Intel Core processors with support for SSE4.2 goes here\n");}__declspec(cpu_specific(core_2_duo_ssse3))void dispatch_func() {printf("\nCode for Intel Core 2 Duo processors with support for SSSE3 goes here\n");}__declspec(cpu_specific(generic))void dispatch_func() {printf("\nCode for non-Intel processors and generic Intel processors goes here\n");}int main() {dispatch_func();printf("Return from dispatch_func\n");return 0;}
- 使用Intel编译器(7)其它(1)多目标处理器程序的编写指南
- 使用Intel编译器(5)PGO(8)编译器其它工具
- Fedora14 i386下 使用Intel编译器 安装WRF指南
- 使用intel编译器的指令窗口 intel fortran compiler
- intel处理器的简史
- 使用Intel编译器(0)基础(1)内联
- 使用Intel编译器SSA
- Intel 1Gb/10Gb网卡在多核处理器中使用的加速技术
- 使用Intel编译器(3)HLO(1)高级别优化的选项和使用
- Intel XScale处理器的历史
- 使用Intel编译器(4)IPO(1)IPO了解和使用
- 使用Intel编译器(5)PGO(1)PGO了解和使用
- 使用Intel编译器(1)并行化(3)自动并行化相关的选项和总结
- 使用Intel编译器获得一致的浮点数值计算结果
- f2py的语法(备查)-使用Intel Visual Fortran Compiler编译器
- Intel处理器手册系统编程指南第2章(1)
- Intel处理器的结构--多核编程学习笔记1
- 使用Intel编译器(6)SSA(1)SSA介绍
- Glossary
- MyEclipse 6.0更改代码提示快捷键,同样Mylipse快捷键的更改都如此。
- wpf 处理耗时的工作利用 BrackgroundWorder
- 一致性哈希算法(consistent hashing)
- Esx4.0开机报错(vsd-mount失败)
- 使用Intel编译器(7)其它(1)多目标处理器程序的编写指南
- Android中 如何判断现在所处的界面是否为home主桌面
- oracle: OCA-047-题解与实验(12)--Create table的常见写法
- How to write device driver
- ehcache的使用(2)-- 集群
- Practical Java(重点版)之异常处理
- 2011-12-29
- 一个计算机专业学生几年的Java编程经验汇总
- JQuery常用语法!