ViennaCL - The Vienna Computing Library  1.5.2
device_utils.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_OCL_DEVICE_UTILS_HPP_
2 #define VIENNACL_OCL_DEVICE_UTILS_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2014, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #define VIENNACL_OCL_MAX_DEVICE_NUM 8
26 
27 #ifdef __APPLE__
28 #include <OpenCL/cl.h>
29 #else
30 #include <CL/cl.h>
31 #endif
32 
33 
34 #include <stddef.h>
35 #include <map>
36 #include <string>
37 
38 #include "viennacl/forwards.h"
39 
40 namespace viennacl
41 {
42  namespace ocl
43  {
44 
45  static const cl_uint intel_id = 32902;
46  static const cl_uint nvidia_id = 4318;
47  static const cl_uint amd_id = 4098;
48  static const cl_uint unknown_id = 0;
49 
50  //Architecture Family
52  //NVidia
56 
57  //AMD
61 
63  };
64 
65  static device_architecture_family get_device_architecture(cl_uint vendor_id, std::string const & name){
66 
67  /*-NVidia-*/
68  if(vendor_id==nvidia_id){
69  //GeForce
70  vcl_size_t found=0;
71  if((found= name.find("GeForce",0)) != std::string::npos){
72  if((found = name.find_first_of("123456789", found)) != std::string::npos){
73  switch (name[found]) {
74  case '2' : return Tesla;
75  case '3' : return Tesla;
76 
77  case '4' : return Fermi;
78  case '5' : return Fermi;
79 
80  case '6' : return Kepler;
81  case '7' : return Kepler;
82 
83  default: return UNKNOWN;
84  }
85  }
86  else
87  return UNKNOWN;
88  }
89 
90  //Tesla
91  else if((found = name.find("Tesla",0)) != std::string::npos){
92  if((found = name.find("CMK", found)) != std::string::npos){
93  switch(name[found]){
94  case 'C' : return Fermi;
95  case 'M' : return Fermi;
96 
97  case 'K' : return Kepler;
98 
99  default : return UNKNOWN;
100  }
101  }
102  else
103  return UNKNOWN;
104  }
105 
106  else
107  return UNKNOWN;
108  }
109 
110  /*-AMD-*/
111  else if(vendor_id==amd_id){
112 
113 #define VIENNACL_DEVICE_MAP(device,arch)if(name.find(device,0)!=std::string::npos) return arch;
114 
115  //Evergreen
117  VIENNACL_DEVICE_MAP("Redwood",Evergreen);
118  VIENNACL_DEVICE_MAP("Juniper",Evergreen);
119  VIENNACL_DEVICE_MAP("Cypress",Evergreen);
120  VIENNACL_DEVICE_MAP("Hemlock",Evergreen);
121 
122  //NorthernIslands
128 
129  //SouthernIslands
135 
136 #undef VIENNACL_DEVICE_MAP
137 
138  return UNKNOWN;
139 
140  }
141 
142  /*-Other-*/
143  else{
144  return UNKNOWN;
145  }
146 
147  }
148 
149 
150  }
151 } //namespace viennacl
152 
153 #endif
154 
std::size_t vcl_size_t
Definition: forwards.h:58
Definition: device_utils.hpp:54
Definition: device_utils.hpp:55
#define VIENNACL_DEVICE_MAP(device, arch)
Definition: device_utils.hpp:62
This file provides the forward declarations for the main types used within ViennaCL.
Definition: device_utils.hpp:53
device_architecture_family
Definition: device_utils.hpp:51
Definition: device_utils.hpp:58
Definition: device_utils.hpp:60
Definition: device_utils.hpp:59