ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2016, 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 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 
46 {
47  beignet_id = 358,
48  intel_id = 32902,
49  nvidia_id = 4318,
50  amd_id = 4098,
52 };
53 
54 //Architecture Family
56 {
57  //NVidia
58  tesla = 0,
62 
63  //AMD
68 
70 };
71 
72 inline device_architecture_family get_architecture_family(cl_uint vendor_id, std::string const & name)
73 {
74  /*-NVidia-*/
75  if (vendor_id==nvidia_id)
76  {
77  //GeForce
78  vcl_size_t found=0;
79  if ((found= name.find("GeForce",0)) != std::string::npos)
80  {
81  if ((found = name.find_first_of("123456789", found)) != std::string::npos)
82  {
83  switch (name[found])
84  {
85  case '2' : return tesla;
86  case '3' : return tesla;
87 
88  case '4' : return fermi;
89  case '5' : return fermi;
90 
91  case '6' : return kepler;
92  case '7' : if (name[found+1] == '5')
93  return maxwell; // GeForce 750 (Ti) are Maxwell-based on desktop GPUs.
94  return kepler;
95 
96  case '8' : if (name[found+3] == '0') // Geforce 8600 and friends
97  return tesla;
98  return kepler; // high-end mobile GPUs tend to be Kepler, low-end GPUs are Maxwell. What a mess. Better be conservative here and pick Kepler.
99 
100  case '9' : if (name[found+3] == '0') // Geforce 9600 and friends
101  return tesla;
102  return maxwell; // GeForce 980, etc.
103 
104  default: return unknown;
105  }
106  }
107  else
108  return unknown;
109  }
110 
111  //Tesla
112  else if ((found = name.find("Tesla",0)) != std::string::npos)
113  {
114  if ((found = name.find_first_of("CMK", found)) != std::string::npos)
115  {
116  switch (name[found])
117  {
118  case 'C' : return fermi;
119  case 'M' : return fermi;
120  case 'K' : return kepler;
121 
122  default : return unknown;
123  }
124  }
125  else
126  return unknown;
127  }
128 
129  else
130  return unknown;
131  }
132 
133  /*-AMD-*/
134  else if (vendor_id==amd_id)
135  {
136 
137 #define VIENNACL_DEVICE_MAP(device,arch)if (name.find(device,0)!=std::string::npos) return arch;
138 
139  //Evergreen
141  VIENNACL_DEVICE_MAP("Redwood",evergreen);
142  VIENNACL_DEVICE_MAP("Juniper",evergreen);
143  VIENNACL_DEVICE_MAP("Cypress",evergreen);
144  VIENNACL_DEVICE_MAP("Hemlock",evergreen);
145 
146  //NorthernIslands
152 
153  //SouthernIslands
163 
164  //VolcanicIslands
171 
172  //APUs (map to closest hardware architecture)
175 
176 #undef VIENNACL_DEVICE_MAP
177 
178  return unknown;
179 
180  }
181 
182  /*-Other-*/
183  else
184  return unknown;
185 
186 }
187 
188 }
189 } //namespace viennacl
190 
191 #endif
#define VIENNACL_DEVICE_MAP(device, arch)
This file provides the forward declarations for the main types used within ViennaCL.
std::size_t vcl_size_t
Definition: forwards.h:75
device_architecture_family get_architecture_family(cl_uint vendor_id, std::string const &name)