Commit 2a0d58d4 authored by Christoph Gerum's avatar Christoph Gerum

Added opencl hello world example

parent 03073f66
File added
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv){
cl_uint platform_id_count = 0;
clGetPlatformIDs (0, 0, &platform_id_count);
printf("System has %d opencl Platforms\n", platform_id_count);
cl_platform_id *platform_ids = malloc(platform_id_count *
sizeof(cl_platform_id));
clGetPlatformIDs (platform_id_count, platform_ids, 0);
for(cl_uint i = 0; i < platform_id_count; i++){
char platform_name[256];
char platform_version[256];
size_t platform_name_size;
clGetPlatformInfo(platform_ids[i],
CL_PLATFORM_NAME,
256,
platform_name,
0);
clGetPlatformInfo(platform_ids[i],
CL_PLATFORM_VERSION,
256,
platform_version,
0);
printf("Platform[%d]: %s (Version: %s)\n", i, platform_name, platform_version);
cl_uint device_id_count = 0;
clGetDeviceIDs (platform_ids [i], CL_DEVICE_TYPE_ALL, 0, 0,
&device_id_count);
cl_device_id *device_ids = malloc(device_id_count
* sizeof(cl_device_id));
clGetDeviceIDs (platform_ids [i], CL_DEVICE_TYPE_ALL, device_id_count,
device_ids, 0);
for(int j = 0; j < device_id_count; j++){
char device_name[256];
clGetDeviceInfo( device_ids[j],
CL_DEVICE_NAME,
256,
device_name,
0);
printf(" Device[%d]: %s\n", j, device_name);
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment