-
Notifications
You must be signed in to change notification settings - Fork 0
/
platforms.c
55 lines (40 loc) · 1.45 KB
/
platforms.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
int i, j;
char* info;
size_t infoSize;
cl_uint platformCount;
cl_platform_id *platforms;
const char* attributeNames[5] = { "Name", "Vendor",
"Version", "Profile", "Extensions" };
const cl_platform_info attributeTypes[5] = { CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,
CL_PLATFORM_VERSION, CL_PLATFORM_PROFILE, CL_PLATFORM_EXTENSIONS };
const int attributeCount = sizeof(attributeNames) / sizeof(char*);
// get platform count
clGetPlatformIDs(5, NULL, &platformCount);
// get all platforms
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
clGetPlatformIDs(platformCount, platforms, NULL);
// for each platform print all attributes
for (i = 0; i < platformCount; i++) {
printf("\n %d. Platform \n", i+1);
for (j = 0; j < attributeCount; j++) {
// get platform attribute value size
clGetPlatformInfo(platforms[i], attributeTypes[j], 0, NULL, &infoSize);
info = (char*) malloc(infoSize);
// get platform attribute value
clGetPlatformInfo(platforms[i], attributeTypes[j], infoSize, info, NULL);
printf(" %d.%d %-11s: %s\n", i+1, j+1, attributeNames[j], info);
free(info);
}
printf("\n");
}
free(platforms);
return 0;
}