Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

Commit 0322c0e

Browse files
authored
Merge pull request #244 from DeadSix27/test-processor
Apple Platform GPU Detection support
2 parents 0797c38 + efba772 commit 0322c0e

File tree

2 files changed

+76
-6
lines changed

2 files changed

+76
-6
lines changed

src/main.cpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,54 @@ static void dump_procs()
150150
case W2XCONV_PROC_OPENCL:
151151
{
152152
type = "OpenCL";
153+
switch (p->sub_type)
154+
{
155+
case W2XCONV_PROC_OPENCL_AMD_GPU:
156+
{
157+
type = "AMD-GPU";
158+
break;
159+
}
160+
case W2XCONV_PROC_OPENCL_NVIDIA_GPU:
161+
{
162+
type = "NVIDIA-GPU";
163+
break;
164+
}
165+
case W2XCONV_PROC_OPENCL_INTEL_GPU:
166+
{
167+
type = "INTEL-GPU";
168+
break;
169+
}
170+
case W2XCONV_PROC_OPENCL_UNKNOWN_GPU:
171+
{
172+
type = "UNKOWN-GPU";
173+
break;
174+
}
175+
case W2XCONV_PROC_OPENCL_AMD_CPU:
176+
{
177+
type = "AMD-CPU";
178+
break;
179+
}
180+
case W2XCONV_PROC_OPENCL_INTEL_CPU:
181+
{
182+
type = "INTEL-CPU";
183+
break;
184+
}
185+
case W2XCONV_PROC_OPENCL_UNKNOWN_CPU:
186+
{
187+
type = "UNKOWN-CPU";
188+
break;
189+
}
190+
case W2XCONV_PROC_OPENCL_DEVICE_UNKNOWN:
191+
{
192+
type = "UNKOWN";
193+
break;
194+
}
195+
default:
196+
{
197+
type = "OpenCV";
198+
break;
199+
}
200+
}
153201
break;
154202
}
155203
default:
@@ -159,7 +207,7 @@ static void dump_procs()
159207
}
160208
}
161209

162-
printf("%4d: %-45s(%-10s): num_core=%d\n", i, p->dev_name, type, p->num_core);
210+
printf("%4d: %-47s(%-10s): num_core=%d\n", i, p->dev_name, type, p->num_core);
163211
}
164212
}
165213

src/modelHandler_OpenCL.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ namespace w2xc
185185
clGetPlatformInfo(plts[i], CL_PLATFORM_NAME, 0, nullptr, &sz);
186186
std::vector<char> name(sz);
187187
clGetPlatformInfo(plts[i], CL_PLATFORM_NAME, sz, &name[0], &sz);
188+
189+
printf("Platform: %s\n",&name[0]);
188190

189191
bool is_amd = strstr(&name[0], "AMD") != NULL;
190192
bool is_apple = strstr(&name[0], "Apple") != NULL;
@@ -208,6 +210,12 @@ namespace w2xc
208210
cl_device_type dtype;
209211

210212
clGetDeviceInfo(dev, CL_DEVICE_TYPE, sizeof(dtype), &dtype, NULL);
213+
214+
size_t dev_name_len;
215+
clGetDeviceInfo(dev, CL_DEVICE_NAME, 0, nullptr, &dev_name_len);
216+
std::vector<char> dev_name(dev_name_len + 1);
217+
clGetDeviceInfo(dev, CL_DEVICE_NAME, dev_name_len, &dev_name[0], &dev_name_len);
218+
211219
int sub_type = 0;
212220

213221
if (is_amd)
@@ -222,6 +230,25 @@ namespace w2xc
222230
{
223231
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_INTEL;
224232
}
233+
else if (is_apple)
234+
{
235+
if(strstr(&dev_name[0], "AMD") != NULL || strstr(&dev_name[0], "Radeon") != NULL)
236+
{
237+
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_AMD;
238+
}
239+
else if(strstr(&dev_name[0], "NVIDIA") != NULL || strstr(&dev_name[0], "GeForce") != NULL)
240+
{
241+
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_NVIDIA;
242+
}
243+
else if(strstr(&dev_name[0], "Intel") != NULL)
244+
{
245+
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_INTEL;
246+
}
247+
else
248+
{
249+
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_UNKNOWN;
250+
}
251+
}
225252
else
226253
{
227254
sub_type = W2XCONV_PROC_OPENCL_PLATFORM_UNKNOWN;
@@ -241,11 +268,6 @@ namespace w2xc
241268
}
242269

243270
proc.sub_type = sub_type;
244-
245-
size_t dev_name_len;
246-
clGetDeviceInfo(dev, CL_DEVICE_NAME, 0, nullptr, &dev_name_len);
247-
std::vector<char> dev_name(dev_name_len + 1);
248-
clGetDeviceInfo(dev, CL_DEVICE_NAME, dev_name_len, &dev_name[0], &dev_name_len);
249271

250272
proc.dev_name = strdup(&dev_name[0]);
251273
proc.dev_id = cur_dev_id++;

0 commit comments

Comments
 (0)