[Bf-blender-cvs] [a922be9] master: Cycles: Repot CPU and CUDA capabilities to system info operator

Sergey Sharybin noreply at git.blender.org
Tue Jan 6 10:27:47 CET 2015


Commit: a922be9270496de95b8c8a4ec7923dd0cb50f184
Author: Sergey Sharybin
Date:   Tue Jan 6 14:13:21 2015 +0500
Branches: master
https://developer.blender.org/rBa922be9270496de95b8c8a4ec7923dd0cb50f184

Cycles: Repot CPU and CUDA capabilities to system info operator

For CPU it gives available instructions set (SSE, AVX and so).

For GPU CUDA it reports most of the attribute values returned by
cuDeviceGetAttribute(). Ideally we need to only use set of those
which are driver-specific (so we don't clutter system info with
values which we can get from GPU specifications and be sure they
stay the same because driver can't affect on them).

===================================================================

M	intern/cycles/blender/addon/engine.py
M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/device/device.cpp
M	intern/cycles/device/device.h
M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/device/device_intern.h
M	intern/cycles/device/device_opencl.cpp
M	release/scripts/modules/sys_info.py

===================================================================

diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 3563820..a0ad044 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -100,3 +100,7 @@ def with_osl():
 def with_network():
     import _cycles
     return _cycles.with_network
+
+def system_info():
+    import _cycles
+    return _cycles.system_info()
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 5a9895a8..37191bb 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -473,6 +473,12 @@ static PyObject *osl_compile_func(PyObject *self, PyObject *args)
 }
 #endif
 
+static PyObject *system_info_func(PyObject *self, PyObject *value)
+{
+	string system_info = Device::device_capabilities();
+	return PyUnicode_FromString(system_info.c_str());
+}
+
 static PyMethodDef methods[] = {
 	{"init", init_func, METH_VARARGS, ""},
 	{"create", create_func, METH_VARARGS, ""},
@@ -487,6 +493,7 @@ static PyMethodDef methods[] = {
 	{"osl_compile", osl_compile_func, METH_VARARGS, ""},
 #endif
 	{"available_devices", available_devices_func, METH_NOARGS, ""},
+	{"system_info", system_info_func, METH_NOARGS, ""},
 	{NULL, NULL, 0, NULL},
 };
 
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index e6e6bef..3a33b8f 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -265,5 +265,28 @@ vector<DeviceInfo>& Device::available_devices()
 	return devices;
 }
 
-CCL_NAMESPACE_END
+string Device::device_capabilities()
+{
+	string capabilities = "CPU device capabilities: ";
+	capabilities += device_cpu_capabilities() + "\n";
+#ifdef WITH_CUDA
+	if(device_cuda_init()) {
+		capabilities += "\nCUDA device capabilities:\n";
+		capabilities += device_cuda_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;
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 701080d..7c17f7f 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -148,6 +148,7 @@ public:
 	static string string_from_type(DeviceType type);
 	static vector<DeviceType>& available_types();
 	static vector<DeviceInfo>& available_devices();
+	static string device_capabilities();
 };
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index b72fa99..a993a58 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -419,5 +419,17 @@ void device_cpu_info(vector<DeviceInfo>& devices)
 	devices.insert(devices.begin(), info);
 }
 
-CCL_NAMESPACE_END
+string device_cpu_capabilities(void)
+{
+	string capabilities = "";
+	capabilities += system_cpu_support_sse2() ? "SSE2 " : "";
+	capabilities += system_cpu_support_sse3() ? "SSE3 " : "";
+	capabilities += system_cpu_support_sse41() ? "SSE41 " : "";
+	capabilities += system_cpu_support_avx() ? "AVX " : "";
+	capabilities += system_cpu_support_avx2() ? "AVX2" : "";
+	if(capabilities[capabilities.size() - 1] == ' ')
+		capabilities.resize(capabilities.size() - 1);
+	return capabilities;
+}
 
+CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index bda967c..7f2f141 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -29,6 +29,7 @@
 #include "util_map.h"
 #include "util_opengl.h"
 #include "util_path.h"
+#include "util_string.h"
 #include "util_system.h"
 #include "util_types.h"
 #include "util_time.h"
@@ -1119,5 +1120,135 @@ void device_cuda_info(vector<DeviceInfo>& devices)
 		devices.insert(devices.end(), display_devices.begin(), display_devices.end());
 }
 
-CCL_NAMESPACE_END
+string device_cuda_capabilities(void)
+{
+	CUresult result = cuInit(0);
+	if(result != CUDA_SUCCESS) {
+		if(result != CUDA_ERROR_NO_DEVICE) {
+			return string("Error initializing CUDA: ") + cuewErrorString(result);
+		}
+		return "No CUDA device found";
+	}
+
+	int count;
+	result = cuDeviceGetCount(&count);
+	if(result != CUDA_SUCCESS) {
+		return string("Error getting devices: ") + cuewErrorString(result);
+	}
 
+	string capabilities = "";
+	for(int num = 0; num < count; num++) {
+		char name[256];
+		if(cuDeviceGetName(name, 256, num) != CUDA_SUCCESS) {
+			continue;
+		}
+		capabilities += string("\t") + name + "\n";
+		int value;
+#define GET_ATTR(attr) \
+		{ \
+			if(cuDeviceGetAttribute(&value, \
+			                        CU_DEVICE_ATTRIBUTE_##attr, \
+			                        num) == CUDA_SUCCESS) \
+			{ \
+				capabilities += string_printf("\t\tCU_DEVICE_ATTRIBUTE_" #attr "\t\t\t%d\n", \
+				                              value); \
+			} \
+		} (void)0
+		/* TODO(sergey): Strip all attributes which are not useful for us
+		 * or does not depend on the driver.
+		 */
+		GET_ATTR(MAX_THREADS_PER_BLOCK);
+		GET_ATTR(MAX_BLOCK_DIM_X);
+		GET_ATTR(MAX_BLOCK_DIM_Y);
+		GET_ATTR(MAX_BLOCK_DIM_Z);
+		GET_ATTR(MAX_GRID_DIM_X);
+		GET_ATTR(MAX_GRID_DIM_Y);
+		GET_ATTR(MAX_GRID_DIM_Z);
+		GET_ATTR(MAX_SHARED_MEMORY_PER_BLOCK);
+		GET_ATTR(SHARED_MEMORY_PER_BLOCK);
+		GET_ATTR(TOTAL_CONSTANT_MEMORY);
+		GET_ATTR(WARP_SIZE);
+		GET_ATTR(MAX_PITCH);
+		GET_ATTR(MAX_REGISTERS_PER_BLOCK);
+		GET_ATTR(REGISTERS_PER_BLOCK);
+		GET_ATTR(CLOCK_RATE);
+		GET_ATTR(TEXTURE_ALIGNMENT);
+		GET_ATTR(GPU_OVERLAP);
+		GET_ATTR(MULTIPROCESSOR_COUNT);
+		GET_ATTR(KERNEL_EXEC_TIMEOUT);
+		GET_ATTR(INTEGRATED);
+		GET_ATTR(CAN_MAP_HOST_MEMORY);
+		GET_ATTR(COMPUTE_MODE);
+		GET_ATTR(MAXIMUM_TEXTURE1D_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE3D_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE3D_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE3D_DEPTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_LAYERS);
+		GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES);
+		GET_ATTR(SURFACE_ALIGNMENT);
+		GET_ATTR(CONCURRENT_KERNELS);
+		GET_ATTR(ECC_ENABLED);
+		GET_ATTR(TCC_DRIVER);
+		GET_ATTR(MEMORY_CLOCK_RATE);
+		GET_ATTR(GLOBAL_MEMORY_BUS_WIDTH);
+		GET_ATTR(L2_CACHE_SIZE);
+		GET_ATTR(MAX_THREADS_PER_MULTIPROCESSOR);
+		GET_ATTR(ASYNC_ENGINE_COUNT);
+		GET_ATTR(UNIFIED_ADDRESSING);
+		GET_ATTR(MAXIMUM_TEXTURE1D_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE1D_LAYERED_LAYERS);
+		GET_ATTR(CAN_TEX2D_GATHER);
+		GET_ATTR(MAXIMUM_TEXTURE2D_GATHER_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_GATHER_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE);
+		GET_ATTR(MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE);
+		GET_ATTR(MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE);
+		GET_ATTR(TEXTURE_PITCH_ALIGNMENT);
+		GET_ATTR(MAXIMUM_TEXTURECUBEMAP_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS);
+		GET_ATTR(MAXIMUM_SURFACE1D_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACE2D_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACE2D_HEIGHT);
+		GET_ATTR(MAXIMUM_SURFACE3D_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACE3D_HEIGHT);
+		GET_ATTR(MAXIMUM_SURFACE3D_DEPTH);
+		GET_ATTR(MAXIMUM_SURFACE1D_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACE1D_LAYERED_LAYERS);
+		GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_HEIGHT);
+		GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_LAYERS);
+		GET_ATTR(MAXIMUM_SURFACECUBEMAP_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH);
+		GET_ATTR(MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS);
+		GET_ATTR(MAXIMUM_TEXTURE1D_LINEAR_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_HEIGHT);
+		GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_PITCH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH);
+		GET_ATTR(MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT);
+		GET_ATTR(COMPUTE_CAPABILITY_MAJOR);
+		GET_ATTR(COMPUTE_CAPABILITY_MINOR);
+		GET_ATTR(MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH);
+		GET_ATTR(STREAM_PRIORITIES_SUPPORTED);
+		GET_ATTR(GLOBAL_L1_CACHE_SUPPORTED);
+		GET_ATTR(LOCAL_L1_CACHE_SUPPORTED);
+		GET_ATTR(MAX_SHARED_MEMORY_PER_MULTIPROCESSOR);
+		GET_ATTR(MAX_REGISTERS_PER_MULTIPROCESSOR);
+		GET_ATTR(MANAGED_MEMORY);
+		GET_ATTR(MULTI_GPU_BOARD);
+		GET_ATTR(MULTI_GPU_BOARD_GROUP_ID);
+#undef GET_ATTR
+		capabilities += "\n";
+	}
+
+	return capabilities;
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index ae19355..47584ae 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -35,6 +35,10 @@ void device_cuda_info(vector<DeviceInfo>& devices);
 void device_network_info(vector<DeviceInfo>& devices);
 void device_multi_info(vector<DeviceInfo>& devices);
 
+string device_cpu_capabilities(void);
+string device_opencl_capabilities(void);
+string device_cuda_capabilities(void);
+
 CCL_NAMESPACE_END
 
 #endif /* __DEVICE_INTERN_H__ */
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 5062385..a5bf35a 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -1195,7 +1195,12 @@ void device_opencl_info(vector<DeviceInfo>& devices)
 	}
 }
 
+string device_opencl_capabilities(void)
+{
+	/* TODO(sergey): Not implemented yet. */
+	return "";
+}
+
 CCL_NAMESPACE_END
 
 #endif /* WITH_OPENCL */
-
diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index 7fd97c4..cecb2a7 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -187,6 +187,12 @@ def write_sysinfo(op):
             bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
             output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])
 
+    if bpy.app.build_options.cycles:
+        import cycles
+        output.write("\nCycles\n")
+        output.write(lilies)
+        output.write(cycles.engine.system_info())
+
     output.current_line_index = 0
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list