Basic programming language :: thinBasic Community
September 10, 2010, 10:21:01 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: RobotDuel - Game for 2 players: http://community.thinbasic.com/index.php?topic=305.0
 
  Home Help thinGaming Search Calendar Gallery Articles Donations Tags Media Center Login Register   *

thinBasic 1.8.0.0 is out !  :: See this post ( last update: 2010.03.07 ! )  :: Latest beta version: thinBasic beta 1.8.6.0 ( last update: 2010.08.02 ! )
Main menu
Members
Total Members: 526
Latest: jnash67
Stats
Total Posts: 26734
Total Topics: 3548
Online Today: 31
Online Ever: 121
(August 16, 2009, 07:08:32 am)
Users Online
Users: 1
Guests: 10
Total: 11
2 Spiders, 10 Guests, 1 User
Charles Pegge
Yahoo spider, MSN spider
Subject Statistics
Topic: OpenCL: "Hello World" adapted from Apple code Replies: 17 posts
Read 864 times 0 Members and 1 Guest are viewing this topic.
Pages: 1 2
  Add bookmark  |  Print  
Author Topic: OpenCL: "Hello World" adapted from Apple code  (Read 864 times)
0 Members and 1 Guest are viewing this topic.
Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« on: February 07, 2010, 07:06:05 pm »

Hi,

after brief pause here comes next journey to the realm of OpenCL.
This time it is adaptation of Apple "OpenCL Hello World" code.

The current situation with drivers on OpenCL is quite terrifying, even this official example didn't run here, and I had to do few tweaks to make it work. For this reason I am very curious about your experience with the code.

Lesson learned - avoid at any cost situation, where your application should rely on technique described in specification as "implementation defined".

Another funny thing which occurs with this example is that it has some precision problems, for 3 digits after dot ok, but the rest is usually slightly imprecise. Maybe it is caused by fact thinBASIC used EXT precision during calculations.


Have fun,
Petr

P.S. Should be the Apple notice kept in this modified version? I do not understand clearly what they are saying there.
Attached files
* OpenCL_HelloWorld.zip (16.44 KB - downloaded 14 times.)
« Last Edit: February 10, 2010, 10:17:48 am by Petr Schreiber » Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
Charles Pegge
Sr. Member
****

Karma: 34
Online

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #1 on: February 07, 2010, 11:21:55 pm »

Hi Petr,

I get correct 1009/1024 computed 1009/1024
Logged

kent sarikaya
Hero Member
*****

Karma: 26
Offline

Gender: Male
Posts: 3235


OS:
Windows XP Windows XP
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #2 on: February 08, 2010, 05:53:14 am »

Petr, did you join the Apple world as Mike Hartlef and my Nephew have?
Logged

Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« Reply #3 on: February 08, 2010, 07:54:23 am »

Charles,

thank you, I get the same result 1009/1024.
When you look at the numbers they are not that much off topic, but still...

Hehe Kent, no no, here you can still hear about people with iPhone from legends rather than seeing somebody actually have it Smile
I just desperately seek for working OpenCL code, but so far any code I pick, I always have to amend it.
Did it ran on your nvidia? It did for me under 196.21, but not sure about older drivers.


Petr

Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
kent sarikaya
Hero Member
*****

Karma: 26
Offline

Gender: Male
Posts: 3235


OS:
Windows XP Windows XP
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #4 on: February 08, 2010, 10:07:13 pm »

I get an error since I don't have the opencl.dll. I am doing my coding on my old gateway notebook, and that alas has an ATI Radeon Mobility.
I need to read up on all these new opengl thingy's... opencl, opengl es to see what is what and if I need to download any of them.
Logged

Charles Pegge
Sr. Member
****

Karma: 34
Online

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #5 on: February 08, 2010, 10:34:22 pm »


OpenCL is not quite the paragon of elegance we might hope for - far too many parameters to deal with. I suppose they are trying to cover all the options that might occur but it makes it hard for early adopters.
Logged

Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« Reply #6 on: February 08, 2010, 11:12:16 pm »

Hi Kent,

GeForce 8xxx/9xxx/2xx+ is required, or Radeon HD 4xxx/5xxx series, both with the latest drivers.

It is slightly confusing technology at the time, mostly due to little fragile implementations currently, but I found it quite exciting to explore and it is indeed very fast once you understand the basic rules.

It seems with ATi you can use both CPU and GPU as devices, with Nvidia it seems only GPUs are supported, as there is no Nvidia CPU Smile

I am curious if Intel will enter this area... I hope it won't end as their promised OpenGL 3.x support.


Petr
Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
kent sarikaya
Hero Member
*****

Karma: 26
Offline

Gender: Male
Posts: 3235


OS:
Windows XP Windows XP
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #7 on: February 09, 2010, 07:15:21 am »

I think all of these guys in the cutting edge see the big paradigm shift coming. Multi-Core everywhere and on all sorts of devices. The tegra 2 is a dual core with incredible battery life.  Look at the left side bar from this link, it gives you an idea where we are and will be computing instead of the desktop.
http://www.nvidia.com/object/tegra_250.html

I can see why OpenCL is here now, just not sure which direction to go right now... just sort of sitting back and watching on a daily basis at the big changes coming this year.
Logged

Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« Reply #8 on: February 09, 2010, 09:37:04 am »

Hi Kent,

yes, very nice device. But once you touch the GPGPU with tens or even hundreds of little dedicated compute devices ... 2 cores is not enough Laughing

I updated the code.
Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
kent sarikaya
Hero Member
*****

Karma: 26
Offline

Gender: Male
Posts: 3235


OS:
Windows XP Windows XP
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #9 on: February 09, 2010, 09:57:07 pm »

What I am saying Petr is that this is the trend. The dual core tegra 2, is 2 arm processors and a gpu able to run unreal engine 3. Next year we might see the Tegra 4, quad core.. and so on. People are liking not being tethered to their desks and the new input that the processors are now able to process, multi-touch and tilt and acceleration sensors make using the devices very easy and intuitive.

I am seeing it with my family members who stumbled with the mouse and never really did anything with their computers besides surf the web and check email. They never used their webcams, they couldn't put their photos into attachments etc. But now with these new devices they are able to do all of the above and are actually enjoying and thrilled by it.

Anyways I am glad you took on OpenCL as I think it will be very very useful soon everywhere.
Logged

Charles Pegge
Sr. Member
****

Karma: 34
Online

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #10 on: February 10, 2010, 07:50:13 am »

Hi Petr,

Your 15 incorrect results are almost certainly caused by the SINGLE precision multiply in the GPU.

A 32 bit float has 1 sign bit 8 exponent bits and that leaves 23 bits for the significand
but this may be further affected by the GPU rounding behaviour.

Info on floating point formats:

http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Charles

PS: I have your program working inside Oxygen with your OpenCL headers and very few alterations Smile
Will post soon.

« Last Edit: February 10, 2010, 07:55:41 am by Charles Pegge » Logged

Charles Pegge
Sr. Member
****

Karma: 34
Online

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #11 on: February 10, 2010, 09:31:01 am »

Hi Petr,

I am now getting 100% correct results by assigning data()^2 and results() to SINGLE variables then comparing them.
So I exonerate the GPU from any rounding anomalies. Smile

Oxygen Code:
Code
 
   ' Validate our results
 
   correct = 0
   single r,d
    '
   For i = 1 To count
       r=results(i)
       d=dat(i) * dat(i)
       If r=d Then
         correct += 1        
       Else
         'PrintL Round(results(i), 6), Format$(Round(dat(i) * data(i), 6))
         if len(s)<1000 then s+=d tab r crlf
       End If        
   Next
 
 
Logged

Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« Reply #12 on: February 10, 2010, 10:20:05 am »

Hi Charles,

very interesting, thanks for the info occasion
I tried to mod the thinBASIC code to the approach you proposed, but I still get mismatch.
Could you check the code from the first post if I ported it correctly?

I am looking forward to Oxygen version!


Petr
Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
Charles Pegge
Sr. Member
****

Karma: 34
Online

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #13 on: February 10, 2010, 12:46:03 pm »


Hi Petr,

I confirm there is still a precision matching problem in thinBasic and I get the same result as before.

I've just posted the Oxygen OpenCL_HelloWorld with the latest Oxygen which now supports
BYVAL 0
BYREF ANY
Also fixed a few other problems relating to BYVAL quads.

Support for EXT variables requires further work but I have redefined EXT as DOUBLE in the main source code, without altering your header files in any way.


So you will need both Oxygen and OpenCL zips.

http://community.thinbasic.com/index.php?topic=2517
Logged

Petr Schreiber
Global Moderator
Hero Member
*****

Karma: 77
Offline

Posts: 5088


TBGL developer

OS:
Windows XP Windows XP
Browser:
Firefox 3.6 Firefox 3.6


WWW
« Reply #14 on: February 10, 2010, 05:17:52 pm »

Thanks Charles!

worked perfectly. Only problem is that in case error occurs (try to change kernel name to some nonsense), it GPFs in Oxygen. But maybe it is caused by fact the Oxygen version does not stop on an error, which will be easy to fix.


Petr
Logged

psch.thinbasic.com / forum
Information about ThinBASIC 3D programming and download of free TBGL tools.

WinXP Home SP3 - Sempron 3400+ @ 1.8GHz - 1Gb RAM @ 533 - NVIDIA GeForce 9500GT 512MB / NVIDIA GeForce 6200 TC
Tags: opencl hello world 
Pages: 1 2
  Add bookmark  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!


Google visited last this page August 30, 2010, 11:10:39 am