#include <stdio.h>
#include <stdlib.h>
//#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#include "opencl.h"
//#include "CL/cl.h"
int main() {
cl_uint TotalPlatforms;
clGetPlatformIDs(5, NULL, &TotalPlatforms);
cl_platform_id* platforms;
platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * TotalPlatforms);
clGetPlatformIDs(TotalPlatforms, platforms, NULL);
char* infobuf = NULL;
size_t bufSize;
const cl_platform_info platformInfoTypes[5] = { CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,
CL_PLATFORM_VERSION, CL_PLATFORM_PROFILE, CL_PLATFORM_EXTENSIONS };
const char* platformInfoNames[5] = { "Name", "Vendor", "Version", "Profile", "Extensions" };
const int attributeCount = sizeof(platformInfoNames) / sizeof(char*);
for (int i = 0; i < TotalPlatforms; i++) {
for (int j = 0; j < attributeCount; j++) {
clGetPlatformInfo(platforms[i], platformInfoTypes[j], 0, NULL, &bufSize);
infobuf = (char*)malloc(bufSize);
clGetPlatformInfo(platforms[i], platformInfoTypes[j], bufSize, infobuf, NULL);
printf("Platform %s: %s\n", platformInfoNames[j], infobuf);
free(infobuf);
}
printf("\n");
}
free(platforms);
char ch = getchar();
return 0;
}
/*
run:
Platform Name: NVIDIA CUDA
Platform Vendor: NVIDIA Corporation
Platform Version: OpenCL 3.0 CUDA 11.6.127
Platform Profile: FULL_PROFILE
Platform Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics
cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64
cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing
cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll
cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts
cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics
cl_khr_device_uuid cl_khr_pci_bus_info cl_khr_external_semaphore
cl_khr_external_memory cl_khr_external_semaphore_win32 cl_khr_external_memory_win32
*/