首页 > 其他 > 详细

getnumdevices.c && setgetdevicetype例程

时间:2015-03-23 15:55:55      阅读:247      评论:0      收藏:0      [点我收藏+]

getnumdevices.c代码

 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\n", num);
11 num = acc_get_num_devices(acc_device_default);
12 printf("device_deault = %d\n", num);
13 num = acc_get_num_devices(acc_device_host);
14 printf("device_host = %d\n", num);
15 num = acc_get_num_devices(acc_device_not_host);
16 printf("device_not_host = %d\n", num);
17 num = acc_get_num_devices(acc_device_nvidia);
18 printf("device_nvidia = %d\n", num);
19 return 0;
20 }

 

setgetdevicetype.c代码

 1 /* 文件名: setgetdevicetype.c
 2 * 功能 : 测试两个函数acc_set_device_type(.)和acc_get_device_type(.).
 3 */
 4 #include<stdio.h>
 5 #include"openacc.h"
 6 int main()
 7 {
 8 acc_device_t devt = acc_device_none;
 9 devt = acc_get_device_type();
10 printf(" no device set, type = %d\n", devt);
11 acc_set_device_type(acc_device_default);
12 devt = acc_get_device_type();
13 printf(" device_default set, type = %d\n", devt);
14 acc_set_device_type(acc_device_nvidia);
15 devt = acc_get_device_type();
16 printf(" device_nvidia set, type = %d\n", devt);
17 acc_set_device_type(acc_device_host);
18 devt = acc_get_device_type();
19 printf(" device_host set, type = %d\n", devt);
20 acc_set_device_type(acc_device_not_host);
21 devt = acc_get_device_type();
22 printf("device_not_host set, type = %d\n", devt);
23 acc_set_device_type(acc_device_xeonphi);
24 devt = acc_get_device_type();
25 printf(" device_xeonphi set, type = %d\n", devt);
26 return 0;
27 }

编译信息:

技术分享

getnumdevices.c && setgetdevicetype例程

原文:http://www.cnblogs.com/liangliangdetianxia/p/4359931.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!