Implement requesting device by index

For now main goal is to be able to request specific Vega card.
In the longer term we can use this to select compute device
which is a non-display, or the one which is on specific PCI
slot or so.
This commit is contained in:
2018-08-10 10:21:04 +02:00
parent 26f5978aae
commit 0e1d2810fe
4 changed files with 77 additions and 18 deletions

View File

@@ -417,7 +417,7 @@ def modify_system_info(system_info):
def modify_device_info(device_info):
compute_device = bpy.context.scene.compute_device
device_type, device_name, compute_units = compute_device.split(":")
device_type, device_name, compute_units, device_index = compute_device.split(":")
if device_info["device_type"] == "OPENCL":
compute_devices = []
for device in device_info["compute_devices"]:
@@ -686,7 +686,7 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
if global_cancel:
global_result_dict = None
reset_global_state()
else:
elif global_result_dict:
global_result_stats = ""
for name_stat in global_result_dict["scenes"]:
stat = name_stat["stats"]
@@ -699,6 +699,8 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
else:
global_result_stats += "{}: {}" . format(name_stat['name'],
stat["result"])
else:
global_result_stats = ""
# TOGO(sergey): Use some more nice picture for the final slide.
global global_background_image_path
global_background_image_path = ""
@@ -730,7 +732,7 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
context.area.tag_redraw()
compute_device = context.scene.compute_device
device_type, device_name, compute_units = compute_device.split(":")
device_type, device_name, compute_units, device_index = compute_device.split(":")
self.tmpdir = tempfile.TemporaryDirectory(prefix="blender_benchmark_")
@@ -756,6 +758,7 @@ class BENCHMARK_OT_run_base(bpy.types.Operator):
# one of the mis to be enabled. Or when requesting GPU render without
# specifying GPU name.
ctx.device_single = True
ctx.device_index = device_index
# ctx.image_output_dir = "/tmp/"
self.benchmark_context = ctx
# Create thread for the actual benchmark.
@@ -910,15 +913,23 @@ def compute_device_list_get(self, context):
global global_cached_compute_devices
if global_cached_compute_devices:
return global_cached_compute_devices
compute_devices = [('CPU::', "CPU", "")]
compute_devices = [('CPU:::', "CPU", "")]
if not global_cached_system_info:
ctx = benchmark_context.Context()
ctx.blender = blender_executable_get()
ctx.configure_script = configure_script_get()
global_cached_system_info = system_info_get(ctx)
compute_units = query_opencl_compute_units()
device_indices = {}
for device in global_cached_system_info["devices"]:
raw_device_name = device["name"]
device_type = device["type"]
if raw_device_name in device_indices:
device_indices[raw_device_name] += 1
device_index = device_indices[raw_device_name]
else:
device_indices[raw_device_name] = 0
device_index = 0
if device_type == "CPU":
continue
elif device_type == "OPENCL":
@@ -930,11 +941,15 @@ def compute_device_list_get(self, context):
device_name += " " + compute_units[index][1]
device_compute_units = str(compute_units[index][1])
del compute_units[index]
device_id = "{}:{}:{}" . format(device_type, device["name"], device_compute_units)
device_id = "{}:{}:{}" . format(device_type,
device["name"],
device_compute_units)
compute_devices.append((device_id, device_name, ""))
elif device_type == "CUDA":
device_name = correct_device_name(device["name"])
device_id = "{}:{}:" . format(device_type, device["name"])
device_id = "{}:{}::{}" . format(device_type,
device["name"],
device_index)
compute_devices.append((device_id, device_name, ""))
global_cached_compute_devices = compute_devices
return compute_devices