Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-06-05 15:13:59 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-06-05 15:17:30 +0300
commit28f798f86ef965b22743bcefb94e8b9f9162c10a (patch)
tree21008f26b94af975c244915517c9519279dc2211 /intern/cycles/device
parentd5bca524d55d929a9e725a51b373de4804e1fe2e (diff)
Cycles: Initial support for OpenCL capabilities reports
For now it's just generic information, still need to expose memory, workgorup sizes and so on.
Diffstat (limited to 'intern/cycles/device')
-rw-r--r--intern/cycles/device/device.cpp3
-rw-r--r--intern/cycles/device/device_cuda.cpp2
-rw-r--r--intern/cycles/device/device_opencl.cpp73
3 files changed, 72 insertions, 6 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 0a4802c2c90..5cad8e1b49c 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -327,13 +327,10 @@ string Device::device_capabilities()
#endif
#ifdef WITH_OPENCL
- /* TODO(sergey): Needs proper usable implementation. */
- /*
if(device_opencl_init()) {
capabilities += "\nOpenCL device capabilities:\n";
capabilities += device_opencl_capabilities();
}
- */
#endif
return capabilities;
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 80a2dda22c4..eb861d79a8c 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1163,7 +1163,7 @@ string device_cuda_capabilities(void)
if(result != CUDA_ERROR_NO_DEVICE) {
return string("Error initializing CUDA: ") + cuewErrorString(result);
}
- return "No CUDA device found";
+ return "No CUDA device found\n";
}
int count;
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 87d4ee91919..6cda617e43a 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -3437,8 +3437,77 @@ void device_opencl_info(vector<DeviceInfo>& devices)
string device_opencl_capabilities(void)
{
- /* TODO(sergey): Not implemented yet. */
- return "";
+ string result = "";
+ string error_msg = ""; /* Only used by opencl_assert(), but in the future
+ * it could also be nicely reported to the console.
+ */
+ cl_uint num_platforms = 0;
+ opencl_assert(clGetPlatformIDs(0, NULL, &num_platforms));
+ if(num_platforms == 0) {
+ return "No OpenCL platforms found\n";
+ }
+ result += string_printf("Number of platforms: %d\n", num_platforms);
+
+ vector<cl_platform_id> platform_ids;
+ platform_ids.resize(num_platforms);
+ opencl_assert(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL));
+
+#define APPEND_STRING_INFO(func, id, name, what) \
+ do { \
+ char data[1024] = "\0"; \
+ opencl_assert(func(id, what, sizeof(data), &data, NULL)); \
+ result += string_printf("%s: %s\n", name, data); \
+ } while(false)
+#define APPEND_PLATFORM_STRING_INFO(id, name, what) \
+ APPEND_STRING_INFO(clGetPlatformInfo, id, "\tPlatform " name, what)
+#define APPEND_DEVICE_STRING_INFO(id, name, what) \
+ APPEND_STRING_INFO(clGetDeviceInfo, id, "\t\t\tDevice " name, what)
+
+ vector<cl_device_id> device_ids;
+ for (cl_uint platform = 0; platform < num_platforms; ++platform) {
+ cl_platform_id platform_id = platform_ids[platform];
+
+ result += string_printf("Platform #%d\n", platform);
+
+ APPEND_PLATFORM_STRING_INFO(platform_id, "Name", CL_PLATFORM_NAME);
+ APPEND_PLATFORM_STRING_INFO(platform_id, "Vendor", CL_PLATFORM_VENDOR);
+ APPEND_PLATFORM_STRING_INFO(platform_id, "Version", CL_PLATFORM_VERSION);
+ APPEND_PLATFORM_STRING_INFO(platform_id, "Profile", CL_PLATFORM_PROFILE);
+ APPEND_PLATFORM_STRING_INFO(platform_id, "Extensions", CL_PLATFORM_EXTENSIONS);
+
+ cl_uint num_devices = 0;
+ opencl_assert(clGetDeviceIDs(platform_ids[platform],
+ CL_DEVICE_TYPE_ALL,
+ 0,
+ NULL,
+ &num_devices));
+ result += string_printf("\tNumber of devices: %d\n", num_devices);
+
+ device_ids.resize(num_devices);
+ opencl_assert(clGetDeviceIDs(platform_ids[platform],
+ CL_DEVICE_TYPE_ALL,
+ num_devices,
+ &device_ids[0],
+ NULL));
+ for (cl_uint device = 0; device < num_devices; ++device) {
+ cl_device_id device_id = device_ids[device];
+
+ result += string_printf("\t\tDevice: #%d\n", device);
+
+ APPEND_DEVICE_STRING_INFO(device_id, "Name", CL_DEVICE_NAME);
+ APPEND_DEVICE_STRING_INFO(device_id, "Vendor", CL_DEVICE_VENDOR);
+ APPEND_DEVICE_STRING_INFO(device_id, "OpenCL C Version", CL_DEVICE_OPENCL_C_VERSION);
+ APPEND_DEVICE_STRING_INFO(device_id, "Profile", CL_DEVICE_PROFILE);
+ APPEND_DEVICE_STRING_INFO(device_id, "Version", CL_DEVICE_VERSION);
+ APPEND_DEVICE_STRING_INFO(device_id, "Extensions", CL_DEVICE_EXTENSIONS);
+ }
+ }
+
+#undef APPEND_STRING_INFO
+#undef APPEND_PLATFORM_STRING_INFO
+#undef APPEND_DEVICE_STRING_INFO
+
+ return result;
}
CCL_NAMESPACE_END