Page 1 of 1

Magick++ can't use GPU even after enabling OpenCL

Posted: 2018-07-01T20:12:32-07:00
by milad
I wanted to use GPU in Magick++ functions of my project. I've built ImageMagick using this tutorial (OpenCL enabled). The convert.exe file after the built says that OpenCL is enabled. I've included the necessary headers and libs (CORE_RL_Magick++_.lib, CORE_RL_MagickCore_.lib, CORE_RL_MagickWand_.lib). I've also set a IMAGEMAGICK_OPENCL_CACHE_DIR system variable with a path (to store the necessary file). I'm using Windows and Visual Studio. My GPU supports OpenCL.
This is my code:

Code: Select all

...
#include <Magick++.h>
#include <MagickCore/MagickCore.h>
#include <MagickWand/MagickWand.h>
#include <MagickCore\accelerate-private.h>
...

using namespace Magick;

int main(int argc, char *argv[])
{
    EnableOpenCL();
    InitializeMagick(NULL);
    EnableOpenCL(); // Executed this after InitializeMagick too to be sure. Maybe it's needed to be executed after InitializeMagick().

    Image img;
    img.read("F:/tmp/test/22/7.png");

    // These two functions should use GPU. But they don't. :
    img.gaussianBlur(15, 3);
    img.edge();
}
The code gives no errors but as you can see my code has functions that ImageMagick can use GPU in them. But it does not. It only uses CPU. Also, ImageMagick generates no files in the path set by IMAGEMAGICK_OPENCL_CACHE_DIR.
What part of it is wrong?

This is the output of convert -version:

Code: Select all

C:\Users\User1>convert -version
Version: ImageMagick 7.0.8-4 Q16 x64 2018-06-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 190024210
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Note: In the documentation there are some code that uses the InitImageMagickOpenCL() function. I've tried to use it but couldn't find it. It's like my Magick++ doesn't even have this function.