1 |
caltinay |
4955 |
#include <cuda_runtime_api.h> |
2 |
|
|
#include <stdio.h> |
3 |
|
|
#include <stdlib.h> |
4 |
|
|
|
5 |
|
|
void usage(const char *name) |
6 |
|
|
{ |
7 |
|
|
printf("usage: %s [device_id]\n", name); |
8 |
|
|
} |
9 |
|
|
|
10 |
|
|
int main(int argc, char **argv) |
11 |
|
|
{ |
12 |
|
|
int num_devices = 0; |
13 |
|
|
int device_id = 0; |
14 |
|
|
if(argc == 2) |
15 |
|
|
{ |
16 |
|
|
device_id = atoi(argv[1]); |
17 |
|
|
} |
18 |
|
|
else if(argc > 2) |
19 |
|
|
{ |
20 |
|
|
usage(argv[0]); |
21 |
|
|
exit(-1); |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
cudaGetDeviceCount(&num_devices); |
25 |
|
|
if(num_devices > device_id) |
26 |
|
|
{ |
27 |
|
|
cudaDeviceProp properties; |
28 |
|
|
cudaGetDeviceProperties(&properties, device_id); |
29 |
|
|
printf("--gpu-architecture=sm_%d%d", properties.major, properties.minor); |
30 |
|
|
return 0; |
31 |
|
|
} // end if |
32 |
|
|
else |
33 |
|
|
{ |
34 |
|
|
printf("No available device with id %d\n", device_id); |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
return -1; |
38 |
|
|
} |
39 |
|
|
|