1 /*
2     This file is part of darktable,
3     Copyright (C) 2012-2020 darktable developers.
4 
5     darktable is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9 
10     darktable is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with darktable.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 
21 #include <strings.h>
22 
23 #ifndef __APPLE__
24 // strings and compute model versions vim-macro converted from http://developer.nvidia.com/cuda/cuda-gpus
25 // 2012/09/18.
26 // we're not really interested in updates, this is merely used to detect which gpus don't support sm_20
27 // (and we hope newer gpus will all do that)
28 static const char *nvidia_gpus[] = {
29   // clang-format off
30 
31   "Tesla C2075", "2.0",
32   "Tesla C2050/C2070", "2.0",
33   "Tesla C1060", "1.3",
34   "Tesla C870", "1.0",
35   "Tesla D870", "1.0",
36   "Tesla K20", "3.5",
37   "Tesla K10", "3.0",
38   "Tesla M2050/M2070/M2075/M2090", "2.0",
39   "Tesla S1070", "1.3",
40   "Tesla M1060", "1.3",
41   "Tesla S870", "1.0",
42   "Quadro K5000", "3.0",
43   "Quadro 6000", "2.0",
44   "Quadro 5000", "2.0",
45   "Quadro 4000", "2.0",
46   "Quadro 4000 for Mac", "2.0",
47   "Quadro 2000", "2.1",
48   "Quadro 2000D", "2.1",
49   "Quadro 600", "2.1",
50   "Quadro FX 5800", "1.3",
51   "Quadro FX 5600", "1.0",
52   "Quadro FX 4800", "1.3",
53   "Quadro FX 4800 for Mac", "1.3",
54   "Quadro FX 4700 X2", "1.1",
55   "Quadro FX 4600", "1.0",
56   "Quadro FX 3800", "1.3",
57   "Quadro FX 3700", "1.1",
58   "Quadro FX 1800", "1.1",
59   "Quadro FX 1700", "1.1",
60   "Quadro FX 580", "1.1",
61   "Quadro FX 570", "1.1",
62   "Quadro FX 470", "1.1",
63   "Quadro FX 380", "1.1",
64   "Quadro FX 380 Low Profile", "1.2",
65   "Quadro FX 370", "1.1",
66   "Quadro FX 370 Low Profile", "1.1",
67   "Quadro CX", "1.3",
68   "Quadro NVS 450", "1.1",
69   "Quadro NVS 420", "1.1",
70   "Quadro NVS 300", "1.2",
71   "Quadro NVS 295", "1.1",
72   "Quadro Plex 7000", "2.0",
73   "Quadro Plex 2200 D2", "1.3",
74   "Quadro Plex 2100 D4", "1.1",
75   "Quadro Plex 2100 S4", "1.0",
76   "Quadro K500M", "3.0",
77   "Quadro 5010M", "2.0",
78   "Quadro 5000M", "2.0",
79   "Quadro 4000M", "2.1",
80   "Quadro 3000M", "2.1",
81   "Quadro 2000M", "2.1",
82   "Quadro 1000M", "2.1",
83   "Quadro FX 3800M", "1.1",
84   "Quadro FX 3700M", "1.1",
85   "Quadro FX 3600M", "1.1",
86   "Quadro FX 2800M", "1.1",
87   "Quadro FX 2700M", "1.1",
88   "Quadro FX 1800M", "1.2",
89   "Quadro FX 1700M", "1.1",
90   "Quadro FX 1600M", "1.1",
91   "Quadro FX 880M", "1.2",
92   "Quadro FX 770M", "1.1",
93   "Quadro FX 570M", "1.1",
94   "Quadro FX 380M", "1.2",
95   "Quadro FX 370M", "1.1",
96   "Quadro FX 360M", "1.1",
97   "Quadro NVS 320M", "1.1",
98   "Quadro NVS 160M", "1.1",
99   "Quadro NVS 150M", "1.1",
100   "Quadro NVS 140M", "1.1",
101   "Quadro NVS 135M", "1.1",
102   "Quadro NVS 130M", "1.1",
103   "Quadro NVS 450", "1.1",
104   "Quadro NVS 420", "1.1",
105   "NVIDIA NVS 300", "1.2",
106   "Quadro NVS 295", "1.1",
107   "NVS 4200M", "2.1",
108   "NVS 5100M", "1.2",
109   "NVS 3100M", "1.2",
110   "NVS 2100M", "1.2",
111   "NVS 300", "1.2",
112   "GeForce GTX 690", "3.0",
113   "GeForce GTX 680", "3.0",
114   "GeForce GTX 670", "3.0",
115   "GeForce GTX 660 Ti", "3.0",
116   "GeForce GTX 660", "3.0",
117   "GeForce GTX 650", "3.0",
118   "GeForce GTX 560 Ti", "2.1",
119   "GeForce GTX 550 Ti", "2.1",
120   "GeForce GTX 460", "2.1",
121   "GeForce GTS 450", "2.1",
122   "GeForce GTX 590", "2.0",
123   "GeForce GTX 580", "2.0",
124   "GeForce GTX 570", "2.0",
125   "GeForce GTX 480", "2.0",
126   "GeForce GTX 470", "2.0",
127   "GeForce GTX 465", "2.0",
128   "GeForce GTX 295", "1.3",
129   "GeForce GTX 285", "1.3",
130   "GeForce GTX 285 for Mac", "1.3",
131   "GeForce GTX 280", "1.3",
132   "GeForce GTX 275", "1.3",
133   "GeForce GTX 260", "1.3",
134   "GeForce GT 640", "2.1",
135   "GeForce GT 630", "2.1",
136   "GeForce GT 620", "2.1",
137   "GeForce GT 610", "2.1",
138   "GeForce GT 520", "2.1",
139   "GeForce GT 440", "2.1",
140   "GeForce GT 430", "2.1",
141   "GeForce GT 420", "1.0",
142   "GeForce GT 240", "1.2",
143   "GeForce GTS 240", "1.2",
144   "GeForce GT 220", "1.2",
145   "GeForce 210", "1.2",
146   "GeForce GTS 250", "1.1",
147   "GeForce GTS 150", "1.1",
148   "GeForce GT 130", "1.1",
149   "GeForce GT 120", "1.1",
150   "GeForce G100", "1.1",
151   "GeForce 9800 GX2", "1.1",
152   "GeForce 9800 GTX+", "1.1",
153   "GeForce 9800 GTX", "1.1",
154   "GeForce 9600 GSO", "1.1",
155   "GeForce 9500 GT", "1.1",
156   "GeForce 9400 GT", "1.1",
157   "GeForce 8800 GTS", "1.1",
158   "GeForce 8800 GTS 512", "1.1",
159   "GeForce 8800 GT", "1.1",
160   "GeForce 8800 GS", "1.1",
161   "GeForce 8600 GTS", "1.1",
162   "GeForce 8600 GT", "1.1",
163   "GeForce 8500 GT", "1.1",
164   "GeForce 8400 GS", "1.1",
165   "GeForce 9400 mGPU", "1.1",
166   "GeForce 9300 mGPU", "1.1",
167   "GeForce 8300 mGPU", "1.1",
168   "GeForce 8200 mGPU", "1.1",
169   "GeForce 8100 mGPU", "1.1",
170   "GeForce 8800 Ultra", "1.0",
171   "GeForce 8800 GTX", "1.0",
172   "GeForce GT 340", "1.0",
173   "GeForce GT 330", "1.0",
174   "GeForce GT 320", "1.0",
175   "GeForce 315", "1.0",
176   "GeForce 310", "1.0",
177   "GeForce 9800 GT", "1.0",
178   "GeForce 9600 GT", "1.0",
179   "GeForce 9400GT", "1.0",
180   "GeForce GTX 680M", "3.0",
181   "GeForce GTX 675M", "2.1",
182   "GeForce GTX 670M", "2.1",
183   "GeForce GTX 660M", "3.0",
184   "GeForce GT 650M", "3.0",
185   "GeForce GT 640M", "3.0",
186   "GeForce GT 640M LE", "3.0",
187   "GeForce GT 635M", "2.1",
188   "GeForce GT 630M", "2.1",
189   "GeForce GT 620M", "2.1",
190   "GeForce 610M", "2.1",
191   "GeForce GTX 580M", "2.1",
192   "GeForce GTX 570M", "2.1",
193   "GeForce GTX 560M", "2.1",
194   "GeForce GT 555M", "2.1",
195   "GeForce GT 550M", "2.1",
196   "GeForce GT 540M", "2.1",
197   "GeForce GT 525M", "2.1",
198   "GeForce GT 520MX", "2.1",
199   "GeForce GT 520M", "2.1",
200   "GeForce GTX 485M", "2.1",
201   "GeForce GTX 470M", "2.1",
202   "GeForce GTX 460M", "2.1",
203   "GeForce GT 445M", "2.1",
204   "GeForce GT 435M", "2.1",
205   "GeForce GT 420M", "2.1",
206   "GeForce GT 415M", "2.1",
207   "GeForce GTX 480M", "2.0",
208   "GeForce GTS 360M", "1.2",
209   "GeForce GTS 350M", "1.2",
210   "GeForce GT 335M", "1.2",
211   "GeForce GT 330M", "1.2",
212   "GeForce GT 320M", "1.2",
213   "GeForce GT 325M", "1.2",
214   "GeForce GT 240M", "1.2",
215   "GeForce G210M", "1.2",
216   "GeForce 310M", "1.2",
217   "GeForce 305M", "1.2",
218   "GeForce GTX 285M", "1.1",
219   "GeForce GTX 280M", "1.1",
220   "GeForce GTX 260M", "1.1",
221   "GeForce 9800M GTX", "1.1",
222   "GeForce 8800M GTX", "1.1",
223   "GeForce GTS 260M", "1.1",
224   "GeForce GTS 250M", "1.1",
225   "GeForce 9800M GT", "1.1",
226   "GeForce 9600M GT", "1.1",
227   "GeForce 8800M GTS", "1.1",
228   "GeForce 9800M GTS", "1.1",
229   "GeForce GT 230M", "1.1",
230   "GeForce 9700M GT", "1.1",
231   "GeForce 9650M GS", "1.1",
232   "GeForce 9700M GT", "1.1",
233   "GeForce 9650M GS", "1.1",
234   "GeForce 9600M GT", "1.1",
235   "GeForce 9600M GS", "1.1",
236   "GeForce 9500M GS", "1.1",
237   "GeForce 8700M GT", "1.1",
238   "GeForce 8600M GT", "1.1",
239   "GeForce 8600M GS", "1.1",
240   "GeForce 9500M G", "1.1",
241   "GeForce 9300M G", "1.1",
242   "GeForce 8400M GS", "1.1",
243   "GeForce G210M", "1.1",
244   "GeForce G110M", "1.1",
245   "GeForce 9300M GS", "1.1",
246   "GeForce 9200M GS", "1.1",
247   "GeForce 9100M G", "1.1",
248   "GeForce 8400M GT", "1.1",
249   "GeForce G105M", "1.1",
250   "GeForce G102M", "1.1",
251   "GeForce G 103M", "1.1",
252   "ION", "1.0",
253   NULL, NULL
254 
255   // clang-format on
256 };
257 #endif
258 
dt_nvidia_gpu_supports_sm_20(const char * model)259 int dt_nvidia_gpu_supports_sm_20(const char *model)
260 {
261 #ifdef __APPLE__
262   // on Mac OSX the OpenCL driver does not seem to support inline asm - even with recent NVIDIA GPUs
263   return 0;
264 #else
265   int i = 0;
266   while(nvidia_gpus[2 * i] != NULL)
267   {
268     if(!strcasecmp(model, nvidia_gpus[2 * i]))
269     {
270       if(nvidia_gpus[2 * i + 1][0] >= '2') return 1;
271       return 0;
272     }
273     i++;
274   }
275   // if we don't know the device, it's probably too new and all good.
276   return 1;
277 #endif
278 }
279 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
280 // vim: shiftwidth=2 expandtab tabstop=2 cindent
281 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
282