https://bugs.kde.org/show_bug.cgi?id=423632

--- Comment #4 from Thomas Coquelin <toto...@yahoo.fr> ---
I found this small python script to test opencv :

#################################################"
"""
cpu_gpu.py
An OpenCL-OpenCV-Python CPU vs GPU comparison
"""
import cv2
import timeit

# A simple image pipeline that runs on both Mat and Umat
def img_cal(img, mode):
    if mode=='UMat':
        img = cv2.UMat(img)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img = cv2.GaussianBlur(img, (7, 7), 1.5)
    img = cv2.Canny(img, 0, 50)
    if type(img) == 'cv2.UMat':
        img = cv2.UMat.get(img)
    return img

# Timing function
def run(processor, function, n_threads, N):
    cv2.setNumThreads(n_threads)
    t = timeit.timeit(function, globals=globals(), number=N)/N*1000
    print('%s avg. with %d threads: %0.2f ms' % (processor, n, t))
    return t

img = cv2.imread('abricotier.tif')
img_UMat = cv2.UMat(img)
N = 200
threads = [1,  16]

processor = {'GPU': "img_cal(img_UMat,mode='UMat')",
             'CPU': "img_cal(img,mode='Mat')"}
results = {}
for n in threads:
    for pro in processor.keys():
        results[pro,n] = run(processor=pro,
                             function= processor[pro],
                             n_threads=n, N=N)

print('\nGPU speed increase over 1 CPU thread [%%]: %0.2f' % \
      (results[('CPU', 1)]/results[('GPU', 1)]*100))
print('CPU speed increase on 16 threads versus 1 thread [%%]: %0.2f' % \
      (results[('CPU', 1)]/results[('CPU', 16)]*100))
##############################################################""

The script works properly :
#############################
$ python3.7 opencv_test.py 
LoadLib(libhsa-amd-aqlprofile64.so) failed: libhsa-amd-aqlprofile64.so: cannot
open shared object file: No such file or directory
GPU avg. with 1 threads: 19.34 ms
CPU avg. with 1 threads: 338.04 ms
GPU avg. with 16 threads: 16.43 ms
CPU avg. with 16 threads: 74.33 ms

GPU speed increase over 1 CPU thread [%]: 1747.75
CPU speed increase on 16 threads versus 1 thread [%]: 454.77
#########################################

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to