Skip to content

Commit

Permalink
"macro" to try to butcher the english language a bit less!
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@10085 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 28, 2015
1 parent 5f22826 commit e50e265
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/xpra/codecs/csc_opencl/colorspace_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pyopencl #@UnresolvedImport
from pyopencl import mem_flags #@UnresolvedImport

from xpra.util import updict
from xpra.util import updict, engs
from xpra.os_util import memoryview_to_bytes

PREFERRED_DEVICE_TYPE = os.environ.get("XPRA_OPENCL_DEVICE_TYPE", "GPU")
Expand Down Expand Up @@ -63,13 +63,13 @@ def log_device_info(device):
log("max_work_item_sizes=%s", device.max_work_item_sizes)

def log_platforms_info():
log("found %s OpenCL platforms:", len(opencl_platforms))
log("found %s OpenCL platform%s:", len(opencl_platforms), engs(opencl_platforms))
for platform in opencl_platforms:
devices = platform.get_devices()
p = "*"
if not is_supported(platform.name):
p = "-"
log("%s %s - %s devices:", p, platform_info(platform), len(devices))
log("%s %s - %s device%s:", p, platform_info(platform), len(devices), engs(devices))
for d in devices:
p = "-"
if d.available and d.compiler_available and d.get_info(pyopencl.device_info.IMAGE_SUPPORT) and is_supported(platform.name):
Expand Down Expand Up @@ -140,7 +140,7 @@ def select_device():
score += 10

options.setdefault(score, []).append((d, platform))
log("best device/platform options: %s", options)
log("best device/platform option%s: %s", engs(options), options)
for score in reversed(sorted(options.keys())):
for d, p in options.get(score):
try:
Expand Down Expand Up @@ -171,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 devices:", len(devices))
log.info("chosen context has %s device%s:", len(devices), engs(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
3 changes: 2 additions & 1 deletion src/xpra/codecs/cuda_common/cuda_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pycuda import tools
from pycuda.compiler import compile

from xpra.util import engs

CUDA_DEVICE_ID = int(os.environ.get("XPRA_CUDA_DEVICE", "-1"))
CUDA_DEVICE_NAME = os.environ.get("XPRA_CUDA_DEVICE_NAME", "")
Expand Down Expand Up @@ -111,7 +112,7 @@ def init_all_devices():
#we print the list info "header" from inside the loop
#so that the log output is bunched up together
log.info("CUDA %s / PyCUDA %s, found %s device%s:",
".".join([str(x) for x in driver.get_version()]), pycuda.VERSION_TEXT, ngpus, ["","s"][int(ngpus!=1)])
".".join([str(x) for x in driver.get_version()]), pycuda.VERSION_TEXT, ngpus, engs(ngpus))
DEVICES.append(i)
log.info(" + %s (memory: %s%% free, compute: %s.%s)", device_info(device), 100*free/total, SMmajor, SMminor)
finally:
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/codecs/nvenc4/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from pycuda import driver
from pycuda.driver import memcpy_htod
from pycuda.compiler import compile

from xpra.util import AtomicInteger, updict
from xpra.util import AtomicInteger, updict, engs
from xpra.os_util import _memoryview
from xpra.codecs.cuda_common.cuda_context import init_all_devices, get_devices, select_device, \
get_cuda_info, get_pycuda_info, device_info, reset_state, \
Expand Down Expand Up @@ -2091,7 +2091,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetEncodePresetCount(self.context, encode_GUID, &presetCount)
raiseNVENC(r, "getting preset count for %s" % guidstr(encode_GUID))
log("found %s preset%s:", presetCount, ["","s"][int(presetCount!=1)])
log("found %s preset%s:", presetCount, engs(presetCount))
assert presetCount<2**8
preset_GUIDs = <GUID*> malloc(sizeof(GUID) * presetCount)
assert preset_GUIDs!=NULL, "could not allocate memory for %s preset GUIDs!" % (presetCount)
Expand Down Expand Up @@ -2178,7 +2178,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetInputFormatCount(self.context, encode_GUID, &inputFmtCount)
raiseNVENC(r, "getting input format count")
log("%s input format type%s:", inputFmtCount, ["","s"][int(inputFmtCount!=1)])
log("%s input format type%s:", inputFmtCount, engs(inputFmtCount))
assert inputFmtCount>0 and inputFmtCount<2**8
inputFmts = <NV_ENC_BUFFER_FORMAT*> malloc(sizeof(int) * inputFmtCount)
assert inputFmts!=NULL, "could not allocate memory for %s input formats!" % (inputFmtCount)
Expand Down Expand Up @@ -2228,7 +2228,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetEncodeGUIDCount(self.context, &GUIDCount)
raiseNVENC(r, "getting encoder count")
log("found %i encoder%s:", GUIDCount, ["","s"][int(GUIDCount!=1)])
log("found %i encoder%s:", GUIDCount, engs(GUIDCount))
assert GUIDCount<2**8
encode_GUIDs = <GUID*> malloc(sizeof(GUID) * GUIDCount)
assert encode_GUIDs!=NULL, "could not allocate memory for %s encode GUIDs!" % (GUIDCount)
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/codecs/nvenc5/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from pycuda import driver
from pycuda.driver import memcpy_htod
from pycuda.compiler import compile

from xpra.util import AtomicInteger, updict
from xpra.util import AtomicInteger, updict, engs
from xpra.os_util import _memoryview
from xpra.codecs.cuda_common.cuda_context import init_all_devices, get_devices, select_device, \
get_cuda_info, get_pycuda_info, device_info, reset_state, \
Expand Down Expand Up @@ -2126,7 +2126,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetEncodePresetCount(self.context, encode_GUID, &presetCount)
raiseNVENC(r, "getting preset count for %s" % guidstr(encode_GUID))
log("found %s preset%s:", presetCount, ["","s"][int(presetCount!=1)])
log("found %s preset%s:", presetCount, engs(presetCount))
assert presetCount<2**8
preset_GUIDs = <GUID*> malloc(sizeof(GUID) * presetCount)
assert preset_GUIDs!=NULL, "could not allocate memory for %s preset GUIDs!" % (presetCount)
Expand Down Expand Up @@ -2213,7 +2213,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetInputFormatCount(self.context, encode_GUID, &inputFmtCount)
raiseNVENC(r, "getting input format count")
log("%s input format type%s:", inputFmtCount, ["","s"][int(inputFmtCount!=1)])
log("%s input format type%s:", inputFmtCount, engs(inputFmtCount))
assert inputFmtCount>0 and inputFmtCount<2**8
inputFmts = <NV_ENC_BUFFER_FORMAT*> malloc(sizeof(int) * inputFmtCount)
assert inputFmts!=NULL, "could not allocate memory for %s input formats!" % (inputFmtCount)
Expand Down Expand Up @@ -2263,7 +2263,7 @@ cdef class Encoder:
with nogil:
r = self.functionList.nvEncGetEncodeGUIDCount(self.context, &GUIDCount)
raiseNVENC(r, "getting encoder count")
log("found %i encoder%s:", GUIDCount, ["","s"][int(GUIDCount!=1)])
log("found %i encoder%s:", GUIDCount, engs(GUIDCount))
assert GUIDCount<2**8
encode_GUIDs = <GUID*> malloc(sizeof(GUID) * GUIDCount)
assert encode_GUIDs!=NULL, "could not allocate memory for %s encode GUIDs!" % (GUIDCount)
Expand Down
6 changes: 6 additions & 0 deletions src/xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,9 @@ def nonl(x):

def xor(s1,s2):
return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))

def engs(v):
try:
return ["","s"][int(len(v)!=1)]
except:
return ""

0 comments on commit e50e265

Please sign in to comment.