/[escript]/trunk/cusplibrary/build/print_sm_version.cpp
ViewVC logotype

Annotation of /trunk/cusplibrary/build/print_sm_version.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (hide annotations)
Mon Sep 15 01:25:23 2014 UTC (6 years, 4 months ago) by caltinay
File size: 694 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

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    

  ViewVC Help
Powered by ViewVC 1.1.26