Benchmark: Workaround to show proper Vega card

This commit is contained in:
2018-08-09 17:21:50 +02:00
parent 9325a0bb6a
commit 821f50cda1

View File

@@ -2,6 +2,7 @@ import datetime
import json import json
import os import os
import platform import platform
import subprocess
import sys import sys
import tempfile import tempfile
from threading import Thread, Lock from threading import Thread, Lock
@@ -836,6 +837,36 @@ class BENCHMARK_OT_restart(bpy.types.Operator):
################################################################################ ################################################################################
# Configuration. # Configuration.
def cl_query_executable_get():
benchmark_data_dir = blender_benchmark_data_dir_get()
system = platform.system()
if system == "Linux":
return os.path.join(benchmark_data_dir, "bin", "cl_query")
elif system == "Windows":
return os.path.join(benchmark_data_dir, "bin", "cl_query.exe")
elif system == "Darwin":
return os.path.join(benchmark_data_dir, "bin", "cl_query")
else:
raise Exception("Needs implementation")
def query_opencl_compute_units():
binary = cl_query_executable_get()
output = subprocess.check_output([binary])
lines = output.splitlines()
compute_units = []
for line in lines:
(name, max_compute_units) = line.rsplit(b':', 1)
compute_units.append((name.decode(), max_compute_units.decode()))
return compute_units
def find_first_device_index(compute_units, device_name):
if not compute_units:
return -1
for index, value in enumerate(compute_units):
if value[0] == device_name:
return index
return -1
def compute_device_list_get(self, context): def compute_device_list_get(self, context):
global global_cached_system_info global global_cached_system_info
global global_cached_compute_devices global global_cached_compute_devices
@@ -847,12 +878,18 @@ def compute_device_list_get(self, context):
ctx.blender = blender_executable_get() ctx.blender = blender_executable_get()
ctx.configure_script = configure_script_get() ctx.configure_script = configure_script_get()
global_cached_system_info = system_info_get(ctx) global_cached_system_info = system_info_get(ctx)
compute_units = query_opencl_compute_units()
for device in global_cached_system_info["devices"]: for device in global_cached_system_info["devices"]:
device_type = device["type"] device_type = device["type"]
if device_type == "CPU": if device_type == "CPU":
continue continue
elif device_type in ("OPENCL", "CUDA"): elif device_type in ("OPENCL", "CUDA"):
device_name = correct_device_name(device["name"]) device_name = correct_device_name(device["name"])
index = find_first_device_index(compute_units, device['name'])
if index != -1:
if device["name"] == "Radeon RX Vega":
device_name += " " + compute_units[index][1]
del compute_units[index]
device_id = "{}:{}" . format(device_type, device["name"]) device_id = "{}:{}" . format(device_type, device["name"])
compute_devices.append((device_id, device_name, "")) compute_devices.append((device_id, device_name, ""))
global_cached_compute_devices = compute_devices global_cached_compute_devices = compute_devices