ViennaCL - The Vienna Computing Library: viennacl/ocl/device_utils.hpp Source File

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
45 enum vendor_id
46 {
47 beignet_id = 358,
48 intel_id = 32902,
49 nvidia_id = 4318,
50 amd_id = 4098,
51 unknown_id = 0
52 };
53
54 //Architecture Family
55 enum device_architecture_family
56 {
57 //NVidia
58 tesla = 0,
59 fermi,
60 kepler,
61 maxwell,
62
63 //AMD
64 evergreen,
65 northern_islands,
66 southern_islands,
67 volcanic_islands,
68
69 unknown
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
140 VIENNACL_DEVICE_MAP("Cedar",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
147 VIENNACL_DEVICE_MAP("Caicos",northern_islands);
148 VIENNACL_DEVICE_MAP("Turks",northern_islands);
149 VIENNACL_DEVICE_MAP("Barts",northern_islands);
150 VIENNACL_DEVICE_MAP("Cayman",northern_islands);
151 VIENNACL_DEVICE_MAP("Antilles",northern_islands);
152
153 //SouthernIslands
154 VIENNACL_DEVICE_MAP("Cape",southern_islands);
155 VIENNACL_DEVICE_MAP("Bonaire",southern_islands);
156 VIENNACL_DEVICE_MAP("Pitcairn",southern_islands);
157 VIENNACL_DEVICE_MAP("Curacao",southern_islands);
158 VIENNACL_DEVICE_MAP("Tahiti",southern_islands);
159 VIENNACL_DEVICE_MAP("Malta",southern_islands);
160 VIENNACL_DEVICE_MAP("Trinidad",southern_islands);
161 VIENNACL_DEVICE_MAP("Tobago",southern_islands);
162 VIENNACL_DEVICE_MAP("Oland",southern_islands);
163
164 //VolcanicIslands
165 VIENNACL_DEVICE_MAP("Hawaii",volcanic_islands);
166 VIENNACL_DEVICE_MAP("Vesuvius",volcanic_islands);
167 VIENNACL_DEVICE_MAP("Tonga",volcanic_islands);
168 VIENNACL_DEVICE_MAP("Antigua",volcanic_islands);
169 VIENNACL_DEVICE_MAP("Grenada",volcanic_islands);
170 VIENNACL_DEVICE_MAP("Fiji",volcanic_islands);
171
172 //APUs (map to closest hardware architecture)
173 VIENNACL_DEVICE_MAP("Scrapper",northern_islands);
174 VIENNACL_DEVICE_MAP("Devastator",northern_islands);
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
viennacl::ocl::fermi
Definition: device_utils.hpp:59
VIENNACL_DEVICE_MAP
#define VIENNACL_DEVICE_MAP(device, arch)
viennacl::ocl::nvidia_id
Definition: device_utils.hpp:49
viennacl::ocl::northern_islands
Definition: device_utils.hpp:65
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::ocl::unknown_id
Definition: device_utils.hpp:51
viennacl::ocl::volcanic_islands
Definition: device_utils.hpp:67
viennacl::ocl::kepler
Definition: device_utils.hpp:60
viennacl::ocl::southern_islands
Definition: device_utils.hpp:66
viennacl::ocl::beignet_id
Definition: device_utils.hpp:47
viennacl::ocl::tesla
Definition: device_utils.hpp:58
viennacl::ocl::amd_id
Definition: device_utils.hpp:50
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::ocl::get_architecture_family
device_architecture_family get_architecture_family(cl_uint vendor_id, std::string const &name)
Definition: device_utils.hpp:72
viennacl::ocl::vendor_id
vendor_id
Definition: device_utils.hpp:45
viennacl::ocl::intel_id
Definition: device_utils.hpp:48
viennacl::ocl::maxwell
Definition: device_utils.hpp:61
viennacl::ocl::evergreen
Definition: device_utils.hpp:64
viennacl::ocl::device_architecture_family
device_architecture_family
Definition: device_utils.hpp:55
viennacl::ocl::unknown
Definition: device_utils.hpp:69