Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin 2018-08-09 16:03:09 +02:00
commit b70f85f2aa
4 changed files with 47 additions and 18 deletions

@ -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);
} }
} }

@ -1136,6 +1136,21 @@ string OpenCLInfo::get_readable_device_name(cl_device_id device_id)
name = get_device_name(device_id); name = get_device_name(device_id);
} }
/* Special exception for AMD Vega, need to be able to tell
* Vega 56 from 64 apart.
*/
if (name == "Radeon RX Vega") {
cl_int max_compute_units = 0;
if (clGetDeviceInfo(device_id,
CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(max_compute_units),
&max_compute_units,
NULL) == CL_SUCCESS)
{
name += " " + to_string(max_compute_units);
}
}
/* Distinguish from our native CPU device. */ /* Distinguish from our native CPU device. */
if(get_device_type(device_id) & CL_DEVICE_TYPE_CPU) { if(get_device_type(device_id) & CL_DEVICE_TYPE_CPU) {
name += " (OpenCL)"; name += " (OpenCL)";

@ -168,6 +168,11 @@ string string_from_bool(bool var)
return "False"; return "False";
} }
string to_string(const char *str)
{
return string(str);
}
/* Wide char strings helpers for Windows. */ /* Wide char strings helpers for Windows. */
#ifdef _WIN32 #ifdef _WIN32

@ -29,6 +29,7 @@ using std::string;
using std::stringstream; using std::stringstream;
using std::ostringstream; using std::ostringstream;
using std::istringstream; using std::istringstream;
using std::to_string;
#ifdef __GNUC__ #ifdef __GNUC__
#define PRINTF_ATTRIBUTE __attribute__((format(printf, 1, 2))) #define PRINTF_ATTRIBUTE __attribute__((format(printf, 1, 2)))
@ -49,6 +50,7 @@ bool string_endswith(const string& s, const char *end);
string string_strip(const string& s); string string_strip(const string& s);
string string_remove_trademark(const string& s); string string_remove_trademark(const string& s);
string string_from_bool(const bool var); string string_from_bool(const bool var);
string to_string(const char *str);
/* Wide char strings are only used on Windows to deal with non-ascii /* Wide char strings are only used on Windows to deal with non-ascii
* characters in file names and such. No reason to use such strings * characters in file names and such. No reason to use such strings