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 56
|
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl.h>
#define MAX_PLATFORMS 32
#define MAX_DEVICES 32
int
main(void)
{
cl_int err;
cl_platform_id platforms[MAX_PLATFORMS];
cl_uint nplatforms;
cl_device_id devices[MAX_DEVICES];
cl_uint ndevices;
cl_uint i, j;
err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &nplatforms);
if (err != CL_SUCCESS)
return EXIT_FAILURE;
for (i = 0; i < nplatforms; i++)
{
err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
devices, &ndevices);
if (err != CL_SUCCESS)
return EXIT_FAILURE;
for (j = 0; j < ndevices; j++)
{
cl_long global_memsize, max_mem_alloc_size, min_max_mem_alloc_size;
err = clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_SIZE,
sizeof(global_memsize), &global_memsize, NULL);
if (err != CL_SUCCESS)
return EXIT_FAILURE;
err = clGetDeviceInfo(devices[j], CL_DEVICE_MAX_MEM_ALLOC_SIZE,
sizeof(max_mem_alloc_size), &max_mem_alloc_size,
NULL);
if (err != CL_SUCCESS)
return EXIT_FAILURE;
if (global_memsize == 0)
return EXIT_FAILURE;
min_max_mem_alloc_size = 128*1024*1024;
if (min_max_mem_alloc_size < global_memsize/4)
min_max_mem_alloc_size = global_memsize/4;
if (max_mem_alloc_size < min_max_mem_alloc_size)
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
|