运行时库的定义

C C++,本章讲述的运行时库例程的原型保存在一个名为 openacc.h 的头文件中。所有的库例程都是用“ C”连接的 extern 函数。这个文件中定义1
本章中所有例程的原型。
这些原型中使用的所有数据类型,包括一个描述加速器类型的枚举类型。
acc_async_noval acc_async_sync 的取值。
需要注意, OpenACC 规范并没有规定 acc_async_noval and acc_async_sync的值是什么,不同的编译器可能定义不同的值。 PGI 编译器将它们定义为宏。

ec3_1_1.c代码

 1 /* 文件名: ec3_1_1.c
 2 * 功能 : 输出查看acc_async_noval和and acc_async_sync的值
 3 */
 4 #include<stdio.h>
 5 #ifdef _OPENACC
 6 #include "openacc.h"
 7 #endif
 8 int main()
 9 {
10 #ifdef _OPENACC
11 printf("acc_async_noval = %d\n", acc_async_noval);
12 printf("acc_async_sync = %d\n", acc_async_sync);
13 #else
14 printf("OpenACC features are not supported or enabled.\n");
15 #endif
16 return 0;
17 }

编译信息:

C 和 C++中,表示设备类型值的数 据 类 型 是 acc_device_t ,Fortran 中 , 这 个 数 据 类 型 是integer(kind=acc_device_kind)。具体用什么值表示设备类型由编译器决定,C 和
C++中,这些值在头文件 openacc.h 中列出;Fortran 中,这些值在 Fortran 包含文件openacc_lib.h 和 Fortran 模块 openac 中列出。所有的编译器都支持四个值:acc_device_none, acc_device_default, acc_device_host acc_device_not_host. 若想了解其它的值,请查看编译器包含的相应文件,或者阅读编译器文档。 acc_device_default 不会是任何函数的返回值;用作输入参数时,它告诉运行时库使用编译器的默认设备类型。 acc_device_default 是缺省设备类型,由编译器自行决定。 PGI 编译器的缺省使用 nVidia 设备。 acc_device_default 不是一个确定的设备类型,因此不能做为函数的返回值。 nVidia 设备、 Xeon Phi 设备都可以做为函数的返回值。

PGI 编译器(版本 13.9)在 openacc.h 中将 acc_device_t 定义为枚举类型,能取 9个值

typedef enum{
acc_device_none = 0,
acc_device_default = 1,
acc_device_host = 2,
acc_device_not_host = 3,
acc_device_nvidia = 4,
acc_device_radeon = 5,
acc_device_xeonphi = 6,
acc_device_pgi_opencl = 7,
acc_device_nvidia_opencl = 8,
acc_device_opencl = 9
}acc_device_t;

PGI 编译器(版本 13.9)在 openacc_lib.h 中定义了 9 个整数常量

integer acc_device_none
parameter ( acc_device_none = 0 )
integer acc_device_default
parameter ( acc_device_default = 1 )
integer acc_device_host
parameter ( acc_device_host = 2 )
integer acc_device_not_host
parameter ( acc_device_not_host = 3 )
integer acc_device_nvidia
parameter ( acc_device_nvidia = 4 )
integer acc_device_radeon
parameter ( acc_device_radeon = 5 )
integer acc_device_xeonphi
parameter ( acc_device_xeonphi = 6 )
integer acc_device_opencl
parameter ( acc_device_opencl = 9 )

OpenACC 规范建议使用的设备名称还有 acc_device_nvidia、 acc_device_radeon、acc_device_xeonphi,分别对应英伟达 GPU、 AMD GPU 和因特尔至强融核(Xeon Phi)协
处理器。 虽然知道这些名字所对应的数值,也不要在程序代码中直接写定数值,以提高跨编译器的移植性。

转载于:https://www.cnblogs.com/liangliangdetianxia/p/4359857.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值