格式
C 或 C++:
int acc_get_num_devices( acc_device_t );
描述
例程 acc_get_num_devices 返回主机上指定类型的加速器设备数量。输入参数说明对哪种类型的设备计数。
1 /* 文件名: getnumdevices.c
2 * 功能 : 测试函数acc_get_num_devices(.)
3 */
4 #include<stdio.h>
5 #include "openacc.h"
6 int main()
7 {
8 int num = -8888;
9 num = acc_get_num_devices(acc_device_none);
10 printf("device_non = %d
", num);
11 num = acc_get_num_devices(acc_device_default);
12 printf("device_deault = %d
", num);
13 num = acc_get_num_devices(acc_device_host);
14 printf("device_host = %d
", num);
15 num = acc_get_num_devices(acc_device_not_host);
16 printf("device_not_host = %d
", num);
17 num = acc_get_num_devices(acc_device_nvidia);
18 printf("device_nvidia = %d
", num);
19 return 0;
20 }
编译信息:
acc_device_non 含义猜测为“不是任何类型设备”,不用作输入参数来指定任何有意义的设备类型,但可以用作 acc_device_t 类型变量的初始值。 acc_device_default 设备数量为 0,说明 acc_device_default 不是一个具体的设备类型,用作本函数的输入参数没有实用意义;acc_device_host 设 备 指 CPU , 虽 然 是 两 路 服 务 器 , 但 acc_device_host 仍 然 为 0.acc_device_not_host 是 CPU 之外的所有加速器设备,包括 OpenACC 规范支持的所有设备。acc_device_nvidia 指英伟达 GPU,2