Skip to content

Commit

Permalink
#926: opencl fixes:
Browse files Browse the repository at this point in the history
* fixup platform and device selection scoring
* add debug logging: show env used and values we match against
* honour prefered device name and platform with cuda

git-svn-id: https://xpra.org/svn/Xpra/trunk@10084 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 28, 2015
1 parent 15d95e1 commit 5f22826
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/xpra/codecs/csc_opencl/colorspace_converter.py
Expand Up @@ -103,7 +103,9 @@ def select_device():
log_platforms_info()
#try to choose a platform and device using *our* heuristics / env options:
options = {}
log("select_device() environment preferred DEVICE_NAME=%s, DEVICE_TYPE=%s, DEVICE_PLATFORM=%s", PREFERRED_DEVICE_NAME, PREFERRED_DEVICE_TYPE, PREFERRED_DEVICE_PLATFORM)
for platform in opencl_platforms:
log("evaluating platform=%s", platform.name)
if platform.name.startswith("AMD") and not AMD_WARNING_SHOWN:
log.warn("Warning: the AMD OpenCL is loaded, it is known to interfere with signal delivery!")
log.warn(" please consider disabling OpenCL or removing the AMD icd")
Expand All @@ -116,23 +118,26 @@ def select_device():
log("ignoring unsupported platform/device: %s / %s", platform.name, d.name)
continue
dtype = device_type(d)
log("evaluating device type=%s, name=%s", dtype, d.name)
if is_cuda:
score = 0
elif dtype==PREFERRED_DEVICE_TYPE:
score = 40
else:
score = 10

if not is_cuda:
if len(PREFERRED_DEVICE_NAME)>0 and d.name.find(PREFERRED_DEVICE_NAME)>=0:
score += 50
if len(PREFERRED_DEVICE_PLATFORM)>0 or str(platform.name).find(PREFERRED_DEVICE_PLATFORM)>=0:
score += 50
if len(PREFERRED_DEVICE_NAME)>0 and d.name.find(PREFERRED_DEVICE_NAME)>=0:
score += 50
if len(PREFERRED_DEVICE_PLATFORM)>0 and str(platform.name).find(PREFERRED_DEVICE_PLATFORM)>=0:
score += 50

#Intel SDK does not work (well?) on AMD CPUs
#and CUDA has problems doing YUV to RGB..
if (platform.name.startswith("Intel") and d.name.startswith("AMD")) or is_cuda:
score = max(0, score - 20)
if platform.name.startswith("Intel"):
if d.name.find("AMD")>=0 or is_cuda:
score = max(0, score - 20)
elif d.name.find("Intel")>=0:
score += 10

options.setdefault(score, []).append((d, platform))
log("best device/platform options: %s", options)
Expand Down Expand Up @@ -166,7 +171,7 @@ def select_device():
log.warn("OpenCL Error: failed to find a working platform and device combination... trying with pyopencl's 'create_some_context'")
context = pyopencl.create_some_context(interactive=False)
devices = context.get_info(pyopencl.context_info.DEVICES)
log.info("chosen context has %s device(s):", len(devices))
log.info("chosen context has %s devices:", len(devices))
for d in devices:
log_device_info(d)
assert len(devices)==1, "we only handle a single device at a time, sorry!"
Expand Down

0 comments on commit 5f22826

Please sign in to comment.