Cycles: Report more details about OpenCL devices

This commit is contained in:
fclem
2018-08-09 15:31:44 +02:00
committed by Sergey Sharybin
parent a241286859
commit 01feb5d6cc

View File

@@ -23,6 +23,7 @@
#include "util/util_foreach.h" #include "util/util_foreach.h"
#include "util/util_logging.h" #include "util/util_logging.h"
#include "util/util_set.h" #include "util/util_set.h"
#include "util/util_string.h"
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
@@ -166,11 +167,14 @@ string device_opencl_capabilities(void)
platform_ids.resize(num_platforms); platform_ids.resize(num_platforms);
opencl_assert(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL)); opencl_assert(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL));
#define APPEND_STRING_INFO(func, id, name, what) \ typedef char cl_string[1024];
#define APPEND_INFO(func, id, name, what, type) \
do { \ do { \
char data[1024] = "\0"; \ type data; \
memset(&data, 0, sizeof(data)); \
opencl_assert(func(id, what, sizeof(data), &data, NULL)); \ opencl_assert(func(id, what, sizeof(data), &data, NULL)); \
result += string_printf("%s: %s\n", name, data); \ result += string_printf("%s: %s\n", name, to_string(data).c_str()); \
} while(false) } while(false)
#define APPEND_STRING_EXTENSION_INFO(func, id, name, what) \ #define APPEND_STRING_EXTENSION_INFO(func, id, name, what) \
do { \ do { \
@@ -182,10 +186,10 @@ string device_opencl_capabilities(void)
} \ } \
} \ } \
} while(false) } while(false)
#define APPEND_PLATFORM_STRING_INFO(id, name, what) \ #define APPEND_PLATFORM_INFO(id, name, what, type) \
APPEND_STRING_INFO(clGetPlatformInfo, id, "\tPlatform " name, what) APPEND_INFO(clGetPlatformInfo, id, "\tPlatform " name, what, type)
#define APPEND_DEVICE_STRING_INFO(id, name, what) \ #define APPEND_DEVICE_INFO(id, name, what, type) \
APPEND_STRING_INFO(clGetDeviceInfo, id, "\t\t\tDevice " name, what) APPEND_INFO(clGetDeviceInfo, id, "\t\t\tDevice " name, what, type)
#define APPEND_DEVICE_STRING_EXTENSION_INFO(id, name, what) \ #define APPEND_DEVICE_STRING_EXTENSION_INFO(id, name, what) \
APPEND_STRING_EXTENSION_INFO(clGetDeviceInfo, id, "\t\t\tDevice " name, what) APPEND_STRING_EXTENSION_INFO(clGetDeviceInfo, id, "\t\t\tDevice " name, what)
@@ -195,11 +199,11 @@ string device_opencl_capabilities(void)
result += string_printf("Platform #%u\n", platform); result += string_printf("Platform #%u\n", platform);
APPEND_PLATFORM_STRING_INFO(platform_id, "Name", CL_PLATFORM_NAME); APPEND_PLATFORM_INFO(platform_id, "Name", CL_PLATFORM_NAME, cl_string);
APPEND_PLATFORM_STRING_INFO(platform_id, "Vendor", CL_PLATFORM_VENDOR); APPEND_PLATFORM_INFO(platform_id, "Vendor", CL_PLATFORM_VENDOR, cl_string);
APPEND_PLATFORM_STRING_INFO(platform_id, "Version", CL_PLATFORM_VERSION); APPEND_PLATFORM_INFO(platform_id, "Version", CL_PLATFORM_VERSION, cl_string);
APPEND_PLATFORM_STRING_INFO(platform_id, "Profile", CL_PLATFORM_PROFILE); APPEND_PLATFORM_INFO(platform_id, "Profile", CL_PLATFORM_PROFILE, cl_string);
APPEND_PLATFORM_STRING_INFO(platform_id, "Extensions", CL_PLATFORM_EXTENSIONS); APPEND_PLATFORM_INFO(platform_id, "Extensions", CL_PLATFORM_EXTENSIONS, cl_string);
cl_uint num_devices = 0; cl_uint num_devices = 0;
opencl_assert(clGetDeviceIDs(platform_ids[platform], opencl_assert(clGetDeviceIDs(platform_ids[platform],
@@ -220,13 +224,16 @@ string device_opencl_capabilities(void)
result += string_printf("\t\tDevice: #%u\n", device); result += string_printf("\t\tDevice: #%u\n", device);
APPEND_DEVICE_STRING_INFO(device_id, "Name", CL_DEVICE_NAME); APPEND_DEVICE_INFO(device_id, "Name", CL_DEVICE_NAME, cl_string);
APPEND_DEVICE_STRING_EXTENSION_INFO(device_id, "Board Name", CL_DEVICE_BOARD_NAME_AMD); APPEND_DEVICE_STRING_EXTENSION_INFO(device_id, "Board Name", CL_DEVICE_BOARD_NAME_AMD);
APPEND_DEVICE_STRING_INFO(device_id, "Vendor", CL_DEVICE_VENDOR); APPEND_DEVICE_INFO(device_id, "Vendor", CL_DEVICE_VENDOR, cl_string);
APPEND_DEVICE_STRING_INFO(device_id, "OpenCL C Version", CL_DEVICE_OPENCL_C_VERSION); APPEND_DEVICE_INFO(device_id, "OpenCL C Version", CL_DEVICE_OPENCL_C_VERSION, cl_string);
APPEND_DEVICE_STRING_INFO(device_id, "Profile", CL_DEVICE_PROFILE); APPEND_DEVICE_INFO(device_id, "Profile", CL_DEVICE_PROFILE, cl_string);
APPEND_DEVICE_STRING_INFO(device_id, "Version", CL_DEVICE_VERSION); APPEND_DEVICE_INFO(device_id, "Version", CL_DEVICE_VERSION, cl_string);
APPEND_DEVICE_STRING_INFO(device_id, "Extensions", CL_DEVICE_EXTENSIONS); APPEND_DEVICE_INFO(device_id, "Extensions", CL_DEVICE_EXTENSIONS, cl_string);
APPEND_DEVICE_INFO(device_id, "Max clock frequency (MHz)", CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint);
APPEND_DEVICE_INFO(device_id, "Max compute units", CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint);
APPEND_DEVICE_INFO(device_id, "Max work group size", CL_DEVICE_MAX_WORK_GROUP_SIZE, size_t);
} }
} }