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 ", 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 }
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 ", devt); 11 acc_set_device_type(acc_device_default); 12 devt = acc_get_device_type(); 13 printf(" device_default set, type = %d ", devt); 14 acc_set_device_type(acc_device_nvidia); 15 devt = acc_get_device_type(); 16 printf(" device_nvidia set, type = %d ", devt); 17 acc_set_device_type(acc_device_host); 18 devt = acc_get_device_type(); 19 printf(" device_host set, type = %d ", devt); 20 acc_set_device_type(acc_device_not_host); 21 devt = acc_get_device_type(); 22 printf("device_not_host set, type = %d ", devt); 23 acc_set_device_type(acc_device_xeonphi); 24 devt = acc_get_device_type(); 25 printf(" device_xeonphi set, type = %d ", devt); 26 return 0; 27 }
编译信息: