summaryrefslogtreecommitdiff
path: root/silx/opencl
diff options
context:
space:
mode:
Diffstat (limited to 'silx/opencl')
-rw-r--r--silx/opencl/codec/byte_offset.py4
-rw-r--r--silx/opencl/codec/test/test_byte_offset.py6
-rw-r--r--silx/opencl/convolution.py8
-rw-r--r--silx/opencl/test/test_convolution.py9
-rw-r--r--silx/opencl/test/test_linalg.py2
5 files changed, 23 insertions, 6 deletions
diff --git a/silx/opencl/codec/byte_offset.py b/silx/opencl/codec/byte_offset.py
index eaf37ee..9a52427 100644
--- a/silx/opencl/codec/byte_offset.py
+++ b/silx/opencl/codec/byte_offset.py
@@ -4,7 +4,7 @@
# Project: Sift implementation in Python + OpenCL
# https://github.com/silx-kit/silx
#
-# Copyright (C) 2013-2018 European Synchrotron Radiation Facility, Grenoble, France
+# Copyright (C) 2013-2020 European Synchrotron Radiation Facility, Grenoble, France
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
@@ -436,4 +436,4 @@ class ByteOffset(OpenclProcessing):
:rtype: bytes
"""
compressed_array = self.encode(data)
- return compressed_array.get().tostring()
+ return compressed_array.get().tobytes()
diff --git a/silx/opencl/codec/test/test_byte_offset.py b/silx/opencl/codec/test/test_byte_offset.py
index 9ce1cfc..e523b0f 100644
--- a/silx/opencl/codec/test/test_byte_offset.py
+++ b/silx/opencl/codec/test/test_byte_offset.py
@@ -4,7 +4,7 @@
# Project: Byte-offset decompression in OpenCL
# https://github.com/silx-kit/silx
#
-# Copyright (C) 2013-2018 European Synchrotron Radiation Facility,
+# Copyright (C) 2013-2020 European Synchrotron Radiation Facility,
# Grenoble, France
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
@@ -170,7 +170,7 @@ class TestByteOffset(unittest.TestCase):
compressed_array = bo.encode(ref)
t1 = time.time()
- compressed_stream = compressed_array.get().tostring()
+ compressed_stream = compressed_array.get().tobytes()
self.assertEqual(raw, compressed_stream)
logger.debug("Global execution time: OpenCL: %.3fms.",
@@ -203,7 +203,7 @@ class TestByteOffset(unittest.TestCase):
# Get data from out array, read it from bo object queue
out_bo_queue = out.with_queue(bo.queue)
- compressed_stream = out_bo_queue.get().tostring()[:compressed_size]
+ compressed_stream = out_bo_queue.get().tobytes()[:compressed_size]
self.assertEqual(raw, compressed_stream)
def test_encode_to_bytes(self):
diff --git a/silx/opencl/convolution.py b/silx/opencl/convolution.py
index b8dd8f6..138b985 100644
--- a/silx/opencl/convolution.py
+++ b/silx/opencl/convolution.py
@@ -94,6 +94,14 @@ class Convolution(OpenclProcessing):
self.is_cpu = (self.device.type == "CPU")
self.use_textures = not(self.extra_options["dont_use_textures"])
self.use_textures *= not(self.is_cpu)
+ # Nvidia Fermi GPUs (compute capability 2.X) do not support opencl read_imagef
+ try:
+ cc = self.ctx.devices[0].compute_capability_major_nv
+ self.use_textures *= (cc >= 3)
+ except cl.LogicError: # probably not a Nvidia GPU
+ pass
+ except AttributeError: # probably not a Nvidia GPU
+ pass
def _get_dimensions(self, shape, kernel):
self.shape = shape
diff --git a/silx/opencl/test/test_convolution.py b/silx/opencl/test/test_convolution.py
index c213808..27cb8a9 100644
--- a/silx/opencl/test/test_convolution.py
+++ b/silx/opencl/test/test_convolution.py
@@ -113,9 +113,18 @@ class TestConvolution(unittest.TestCase):
)
def instantiate_convol(self, shape, kernel, axes=None):
+ def is_fermi_device(dev):
+ try:
+ res = (dev.compute_capability_major_nv < 3)
+ except cl.LogicError:
+ res = False
+ except AttributeError:
+ res = False
+ return res
if (self.mode == "constant") and (
not(self.param["use_textures"])
or (self.ctx.devices[0].type == cl._cl.device_type.CPU)
+ or (is_fermi_device(self.ctx.devices[0]))
):
self.skipTest("mode=constant not implemented without textures")
C = Convolution(
diff --git a/silx/opencl/test/test_linalg.py b/silx/opencl/test/test_linalg.py
index b72fa20..0b6c730 100644
--- a/silx/opencl/test/test_linalg.py
+++ b/silx/opencl/test/test_linalg.py
@@ -66,7 +66,7 @@ def gradient(img):
gradient = np.zeros(shape, dtype=img.dtype)
slice_all = [0, slice(None, -1),]
for d in range(img.ndim):
- gradient[slice_all] = np.diff(img, axis=d)
+ gradient[tuple(slice_all)] = np.diff(img, axis=d)
slice_all[0] = d + 1
slice_all.insert(1, slice(None))
return gradient