View Full Version : OpenCL: Image Processing Test [Updated Sep 04 2011]
Petr Schreiber
12-02-2010, 16:47
I prepaired the first application with visual output in OpenCL, as I consider it more interesting than just watch numbers.
It is basic image processing tester, you can freely edit the OpenCL program source, and the application will always expose all methods implemented.
Unlike previous demos, this time the CL source is designed like DLL, composed of multiple procedures.
Before using them, on application startup, the library will be compiled, and then you can directly execute the various kernels (methods of image processing).
As usually, please let me know how did it work for you.
On my PC with the sample image I get the result right after clicking the Process button, instantly. And this is in case where I use single "thread" for each pixel, which is the worst scenario.
Important note: The code requires the OpenCL headers (http://www.thinbasic.com/community/showthread.php?10159-OpenCL-Headers-Updated-Sep-04-2011).
Petr
Charles Pegge
12-02-2010, 23:35
Hi Petr,
This worked fine on my Nvidia GT100 system. It is good to see a range of OpenCL functions in action. My mental grasp of this parallel execution stuff is quite slow to develop. It is like learning to program all over again. New synapses need time to grow :)
Charles
Petr Schreiber
12-02-2010, 23:42
Thanks Charles,
that is what I like most about the OpenCL, it is completely different programming from what I did till now. Very refreshing to think differently.
Just the learning is currently like walking through a bush of roses, because you often realize tutorials on the net do not work the way they should.
Petr
Petr you are going to make me break my recent rule, after my last Windows install, to not put anything other than games on my gaming computer. Will get back to you later after I do the deed tonight:)
Petr it ran great. I really like the 2line stripe. Now I don't need to look for a scanline plugin for photoshop. I like to use that effect for video transmissions from space, that is cool!
Petr Schreiber
13-02-2010, 11:01
Thanks Kent for the test!
Petr, I saw in the code opening up jpg. So I tried it and the first one it opened up fine, well it was upside down when it opened. The second one caused a crash. Do you have jpg importing started. or was it just pure luck that it worked on that one?
Petr Schreiber
13-02-2010, 11:24
Hi Kent,
I know, the TImage library sadly seems to be very unreliable, even for BMPs. This is why in the code I used Canvas methods in case of BMP file. We are investigating the issue.
Hi Petr,
All of your OpenCL programs work for me except for the image processing application. Here are the messages in the cmd screen when I try to run the program:
OpenCL initialized...
GPU Library is being compiled...
Description: Failed to build program!:
:86: error: no matching overload found for arguments of type 'double'
float fR = convert_float(pixelIn[n].z) * sin(n/10.0);
^~~
:87: error: no matching overload found for arguments of type 'double'
float fG = convert_float(pixelIn[n].y) * sin((n+1)/10.0);
^~~
:88: error: no matching overload found for arguments of type 'double'
float fB = convert_float(pixelIn[n].x) * sin((n+2)/10.0);
^~~
:104: error: no matching overload found for arguments of type 'double'
float fR = convert_float(pixelIn[n].z) * sin((n+pixelIn[n].z)/20.0);
^~~
:105: error: no matching overload found for arguments of type 'double'
float fG = convert_float(pixelIn[n].y) * cos((n+1+pixelIn[n].y)/20.0);
^~~
:106: error: no matching overload found for arguments of type 'double'
float fB = convert_float(pixelIn[n].x) * sin((n+2+pixelIn[n].x)/20.0);
^~~
OpenCL code: [!] Unknown error: 1
Press any key to quit...
The dialog box opens after this, but no image is present. I'm using the intact folder containing the bmp file, headers, and tbasic script file.
My computer is a Quad-Core Sager 9262 laptop with 2 NVidia 9800M GTX video cards (1 gb each, 14 compute units and 112 cores each). I am using the 190.89 Beta driver, which works well with CUDA and the OpenCL programs from NVidia. I am running ThinBasic 1.7.10.2 Beta.
Cheers,
Stan
Petr Schreiber
23-02-2010, 10:28
Hi Stan,
your PC is power monster!
The reason of problems could be that OpenCL has been introduced in NVIDIA drivers very recently. I experienced quite a few oddities with 190.89 myself too, and almost with each driver release after this, I had to mod the code little bit.
This is the price for working with latest, borning technology.
Do you think it would be possible for you to install ForceWare 196.21? I use them with 9500GT (lot weaker than yours, but the same family) without problem.
Thank you,
Petr
Hi Petr,
Yes... I saved a LONG time to buy the computer and it certainly is a power monster!
I will install the Forceware 196.21 drivers as soon as I can... although I probably won't be able to install them until the weekend.
Thanks for the reply... one of the reasons I am switching to ThinBasic is due to how quickly you, Eros, Michael, and others respond to my "newbie" questions. I am very impressed!
Thanks!
Stan
Hi Stan,
your PC is power monster!
The reason of problems could be that OpenCL has been introduced in NVIDIA drivers very recently. I experienced quite a few oddities with 190.89 myself too, and almost with each driver release after this, I had to mod the code little bit.
This is the price for working with latest, borning technology.
Do you think it would be possible for you to install ForceWare 196.21? I use them with 9500GT (lot weaker than yours, but the same family) without problem.
Thank you,
Petr
ErosOlmi
23-02-2010, 16:10
Thanks for the reply... one of the reasons I am switching to ThinBasic is due to how quickly you, Eros, Michael, and others respond to my "newbie" questions. I am very impressed!
That's our way to show passion in programming ;)
As I often say: sometimes we are able, sometimes not. But we will try.
Hi Eros,
I DO sense the passion here... and that is another reason to switch to ThinBasic!
Cheers,
Stan
Thanks for the reply... one of the reasons I am switching to ThinBasic is due to how quickly you, Eros, Michael, and others respond to my "newbie" questions. I am very impressed!
That's our way to show passion in programming ;)
As I often say: sometimes we are able, sometimes not. But we will try.
Hi Petr,
Success! I updated my 9800M GTX drivers to 195.xx (whatever the latest mobile drivers are) and your OpenCL image processing program worked perfectly!
Nice work!
Stan
Hi Stan,
your PC is power monster!
The reason of problems could be that OpenCL has been introduced in NVIDIA drivers very recently. I experienced quite a few oddities with 190.89 myself too, and almost with each driver release after this, I had to mod the code little bit.
This is the price for working with latest, borning technology.
Do you think it would be possible for you to install ForceWare 196.21? I use them with 9500GT (lot weaker than yours, but the same family) without problem.
Thank you,
Petr
Petr Schreiber
25-02-2010, 17:13
Thanks a lot for letting me know!
That is good news :)
Petr