Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #ifdef __APPLE__
- #include <OpenCL/opencl.h>
- #else
- #include <CL/cl.h>
- #endif
- //using namespace std;
- int main() {
- printf("hi\n");
- cl_int errcode;
- cl_uint num_platforms;
- errcode = clGetPlatformIDs(0, NULL, &num_platforms);
- //return 0;
- printf("Platforms count: %d\n", num_platforms);
- cl_platform_id *platforms;
- platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * num_platforms);
- //platforms = new cl_platform_id[num_platforms];
- errcode = clGetPlatformIDs(num_platforms, platforms, NULL);
- for (int i = 0; i < num_platforms; ++i) {
- size_t ret_size;
- errcode = clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 0, NULL, &ret_size);
- //char* plat_name = (char*)malloc(ret_size);
- char* plat_name = new char[ret_size];
- errcode = clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, ret_size, plat_name, NULL);
- printf("%d. %s\n", platforms[i], plat_name);
- //delete[] plat_name;
- free(plat_name);
- }
- for (int i = 0; i < num_platforms; ++i) {
- cl_uint num_devices;
- errcode = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices);
- cl_device_id *devices = (cl_device_id*) malloc(sizeof(cl_device_id) * num_devices);
- errcode = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, num_devices, devices, NULL);
- printf("::%d\n", errcode);
- //printf("devices %u\n", num_devices);
- //continue;
- char *driver_version;
- size_t valueSize;
- for (int j = 0; j < num_devices; ++j) {
- errcode = clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &valueSize);
- printf("::%d\n", errcode);
- printf("ok %u\n", valueSize);
- //valueSize = 50;
- driver_version = (char*) malloc(valueSize);
- errcode = clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, valueSize, driver_version, NULL);
- printf("::%d\n", errcode);
- printf("%d. %s\n", devices[j], driver_version);
- free(driver_version);
- }
- free(devices);
- }
- free(platforms);
- //delete[] platforms;
- /*char *driver_version;
- size_t valueSize;
- //printf("ok\n");
- for (int i = 0; i < num_platforms; ++i) {
- //clGetDeviceInfo(0, CL_DRIVER_VERSION, sizeof(char*), &driver_version, NULL);
- clGetDeviceInfo(platforms[i], CL_DRIVER_VERSION, 0, NULL, &valueSize);
- printf("ok %u\n", valueSize);
- //valueSize = 50;
- driver_version = (char*) malloc(valueSize);
- clGetDeviceInfo(0, CL_DRIVER_VERSION, valueSize, driver_version, NULL);
- printf("%d. %s\n", platforms[i], driver_version);
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement