Page 1 of 1

OpenCL no effect?

Posted: 2016-11-21T04:27:31-07:00
by Mr1Penguin
Hi! I compiled imagemagick on windows. Trying to process 800x450 image. I have suggestion imagemagick uses my cpu instead of gpu for making blur. Does it normal behavior?
only openmp:

Code: Select all

PS C:\Users\igors\Downloads\abc> Measure-Command {magick a.jpg -resize 800x800! -blur 20x20 -motion-blur 0x80-90 -motion
-blur 0x80+90 `( a.jpg `( -clone 0 -background black -shadow 60x25+0+0 `) -reverse -background none -layers merge +rep
age `) -gravity center -composite out.jpg}


Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 44
Milliseconds      : 950
Ticks             : 1049504577
TotalDays         : 0.00121470437152778
TotalHours        : 0.0291529049166667
TotalMinutes      : 1.749174295
TotalSeconds      : 104.9504577
TotalMilliseconds : 104950.4577
with opencl(second run with cache file):

Code: Select all

PS C:\Users\igors\Downloads\abc> Measure-Command {magick a.jpg -resize 800x800! -blur 20x20 -motion-blur 0x80-90 -motion
-blur 0x80+90 `( a.jpg `( -clone 0 -background black -shadow 60x25+0+0 `) -reverse -background none -layers merge +rep
age `) -gravity center -composite out.jpg}


Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 44
Milliseconds      : 668
Ticks             : 1046688393
TotalDays         : 0.00121144489930556
TotalHours        : 0.0290746775833333
TotalMinutes      : 1.744480655
TotalSeconds      : 104.6688393
TotalMilliseconds : 104668.8393

Code: Select all

type ImagemagickOpenCLDeviceProfile.xml
<devices>
  <device name="CPU" score="5.028"/>
  <device platform="Intel(R) OpenCL" vendor="Intel(R) Corporation" name="Intel(R) HD Graphics 520" version="20.19.15.4377" maxClockFrequency="1050" maxComputeUnits="24" score="0.7449"/>
  <device platform="Intel(R) OpenCL" vendor="Intel(R) Corporation" name="Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz" version="5.2.0.10094" maxClockFrequency="2500" maxComputeUnits="4" score="1.329"/>
  <device platform="NVIDIA CUDA" vendor="NVIDIA Corporation" name="GeForce GTX 950M" version="375.70" maxClockFrequency="1124" maxComputeUnits="5" score="1.024"/>
  <device platform="Experimental OpenCL 2.1 CPU Only Platform" vendor="Intel(R) Corporation" name="Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz" version="6.1.0.1600" maxClockFrequency="2500" maxComputeUnits="4" score="1.195"/>
</devices>

Code: Select all

magick -version
Version: ImageMagick 7.0.3-7 Q16 x64 2016-11-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 190024215
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

Re: OpenCL no effect?

Posted: 2016-11-21T04:42:11-07:00
by snibgo
I think OpenCL is used for "-blur" but not "-motion-blur".

Re: OpenCL no effect?

Posted: 2016-11-21T04:54:55-07:00
by Mr1Penguin
According this link opencl used in motion-blur too.
http://www.imagemagick.org/script/opencl.php

Re: OpenCL no effect?

Posted: 2016-11-21T05:03:21-07:00
by snibgo
Looking at effect.c and accelerate.c, I think that list isn't correct. But I might be wrong. A developer may comment.

I suggest you repeat your experiment with "-blur". Does OpenCL accelerate it?

Re: OpenCL no effect?

Posted: 2016-11-21T05:35:41-07:00
by Mr1Penguin

Code: Select all

PS C:\Users\igors\Downloads\abc> Measure-Command {magick art.jpg -resize 4096x4096! -blur 40x40 `( art.jpg `( -clone 0 -background black -shadow 60x25+0+0 `) -reverse -background none -layers merge +repage `) -gravity center -composite out.jpg}
opencl: 3113ms
openmp: 16263ms

Looks like opencl really don't used for motion-blur. Can it be removed in new version? I used the same line (convert 800x800 + motion-blur) on linux+IM6+nvidia450gts and it was really fast. But it was 6 months ago so i can't give any proofs for it(I hope I remember it correct).

Re: OpenCL no effect?

Posted: 2016-11-21T05:52:54-07:00
by Mr1Penguin
Hm. Found AccelerateMotionBlurImage function in accelerate.c/accelerate-private.h. And no one call it. Checked AccelerateBlurImage function and found call from effects.c. I'll try to call it from motion-blur function and give answer.
----added----
Looks like i can't do it right now and AccelerateMotionBlurImage is just echo of the past.

Re: OpenCL no effect?

Posted: 2016-11-22T15:29:58-07:00
by Mr1Penguin
I changed a code a little so it works for me now. But it requires image with alpha channel to work. I'll try to find workaround for that(maybe converting to png with alpha if image does not have it)
---Added---
And now it works with images without alpha