Logo by Kaliyuga - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. November 27, 2022, 12:17:07 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2 3 ... 6   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: CUDA Y.A.M.Z  (Read 9178 times)
Description: Yet Another Mandelbrot Zoomer
0 Members and 1 Guest are viewing this topic.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« on: January 16, 2014, 06:04:51 PM »


CudaBrot Source code only.

Resurrecting an old favorite from my collection of antiques...

This program opens a window and just pans and zooms around the Mandelbrot set using the mouse or arrow keys, that's all it does, no fancy stuff (yet), it calculates every pixel every frame, no optimizing other than calculating the x,y values in one pass then feeding them into the mandelbrot routine for the second pass.

I kept it as simple as possible to make it easy to tinker with Qt, CUDA and Fractals, about 25k of code and the really interesting bits are only a couple of hundred lines.

For the novice, this is an easy bit of code to get your head around. It demonstrates how to use Qt's QGLWidget, Mouse and Keyboard Events, Timers, QtDesigner Forms ( : add some menus if you like : ) , how to set variables on the GPU for CUDA kernels from C++, how to setup and access buffers/textures for writing on the GPU and rendering by OpenGL and  how to compile CUDA code in your C++ project.

For the expert, it's a simple bit of code that can be used to test crunching routines on CUDA GPUs.
Two kernels, one fills an array with x,y datas the other one reads data, makes a calculation and stores the result in an RGBA pixel buffer.

Currently only double precision but some preliminary tests with double double and quad double are promising, this is intended as a test bed leading to arbitrary precision on the GPU for calculating fractals.

The default start coords are Tick-Tock from dinkydau, if you get this compiled just hit the "+" key on the keypad to zoom in, on a good GPU it only takes a couple of seconds to exhaust the limits of 64bit double precision at about 35-40 ms/frame. For a benchmark execute from the commandline with "benchmark" as the only option, you should see something like...
Code:
> Device 0: < GeForce GTX 760 >, Compute SM 3.0 detected
Benchmark:
        Max iterations:         1024
        Number of frames:       1000
        Avg msec per frame:     8.979000

An interesting experience seeing my crusty old routines crunching images in milliseconds what used to be minutes...

If you can write a doodler like this...

Code:
  uint   count = 0;
  double p = r;
  double q = i;
  double a;

  do  {
    if ( p * p + q * q > divergence ) break;

    a  =  p;
    p +=  q;
    p *= (a - q);
    q *= (a + a);
    p +=  r;
    q +=  i;
  }
  while (count++ < maxiter );

  return (count >= maxiter) ? 0 : ( count % maxcol + 2 );

...then you can test it on nVidia GPUs in this little proggie.

My goal is to learn how to implement some of the optimizations to be found here (on FractalForums) in high precision GPU code.

Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #1 on: January 16, 2014, 07:11:40 PM »

Could you write smth about CUDA installation ? This is still the first problem for me. TIA
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #2 on: January 16, 2014, 07:47:19 PM »

I'm using...

SuSE 12.3
kernel 3.7.10-1.24-desktop
x86_64 GNU/Linux

you?
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #3 on: January 16, 2014, 08:07:15 PM »

https://developer.nvidia.com/cuda-downloads has install packages and "getting started" guides for win & lin

for linux you install the rpm according to the RPM / DEB Installation Instructions

for windows check the Windows Getting Started Guide

you can also add these repositories via your linux package manager...
http://developer.download.nvidia.com/compute/cuda/repos/opensuse122/x86_64 ( 12.2 package works for 12.3 too)
http://download.nvidia.com/opensuse/12.3
« Last Edit: January 16, 2014, 08:19:27 PM by 3dickulus, Reason: repos » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #4 on: January 18, 2014, 02:06:43 PM »

Linux 3.11.0-15-generic  
x86_64
Ubuntu 13.10
NVIDIA-SMI 5.319.60   Driver Version: 319.60 
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9)


I have tried :

sudo bash cuda_5.5.22_linux_64.run

result :


Do you accept the previously read EULA? (accept/decline/quit):  accept
You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 319.37? ((y)es/(n)o/(q)uit): n
Install the CUDA 5.5 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-5.5 ]:
Install the CUDA 5.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/a/NVIDIA_CUDA-5.5_Samples ]:
   Unsupported compiler: 4.8.1
Missing recommended library: libXmu.so

Cannot find Toolkit in /usr/local/cuda-5.5

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installation Failed. Using unsupported Compiler.
Samples:  Cannot find Toolkit in /usr/local/cuda-5.5


Logfile is /tmp/cuda_install_10291.log

??
My gcc i to new ?

« Last Edit: January 18, 2014, 02:19:58 PM by Adam Majewski, Reason: new info » Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #5 on: January 18, 2014, 04:54:55 PM »

NVIDIA-SMI 5.319.60   Driver Version: 319.60  

You have the same driver I do, I am using GCC 4.7

Some have had success with Ubuntu, review this posting for instructions

http://askubuntu.com/questions/380609/anyone-has-successfully-installed-cuda-5-5-on-ubuntu-13-10-64-bit

hopefully this will work for you smiley

summary: The 319 driver works with the Ubuntu 12.10 deb package and GCC 4.7.2 or less
« Last Edit: January 18, 2014, 05:28:25 PM by 3dickulus, Reason: gcc » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #6 on: January 18, 2014, 06:31:47 PM »

after a little googling these are the simplest instructions I have found but I don't have Ubuntu so  I can't test...

From:http://installion.co.uk/ubuntu/saucy/multiverse/n/nvidia-cuda-toolkit/install.html
Quote
Check the multiverse repository is enabled.

Inspect /etc/apt/sources.list using your favourite editor with sudo which will ensure that you have the correct permissions.

~> sudo gedit /etc/apt/sources.list

Ensure that "multiverse" is included.

After any changes you should run this command to update your system.

~> sudo apt-get update

Install nvidia-cuda-toolkit

~> sudo apt-get install nvidia-cuda-toolkit

Which will install nvidia-cuda-toolkit and any other packages on which it depends.

You can always remove nvidia-cuda-toolkit again by following the instructions at this link... http://installion.co.uk/ubuntu/saucy/multiverse/n/nvidia-cuda-toolkit/uninstall.html

Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #7 on: January 18, 2014, 09:21:08 PM »

Thx. It works now :

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2012 NVIDIA Corporation
Built on Fri_Sep_21_17:28:58_PDT_2012
Cuda compilation tools, release 5.0, V0.2.1221
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #8 on: January 18, 2014, 09:31:55 PM »

Great smiley

just curious, which method worked?
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #9 on: January 18, 2014, 10:42:03 PM »

Great smiley

just curious, which method worked?


sudo apt-get install nvidia-cuda-toolkit

Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #10 on: January 22, 2014, 07:19:09 PM »

an interesting pair found in jul-man hybrid


* cudabrot1.jpg (30.61 KB, 532x428 - viewed 428 times.)
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #11 on: January 24, 2014, 05:37:37 PM »

accessing an array on gpu like
Code:
index=y*width+x;
n = array[index]

is slower than accessing like
Code:
index=y*width
n = array[index+x]

       I think it's because the compiler optimizes "index" as an incremented register (haven't checked assembler output)

found another small speedup by reducing the iterate function to 2 muls

Code:

    do
    {
        a  = p;
        p += q;
        p *= (a - q);
        q *= (a + a);
        p += r;
        q += i;
        if( ( p > 2.0 || p < -2.0 ) && ( q > 2.0 || q < -2.0 ) )
            return ( count );
    }
    while (count++ < maxiter );

    return 0;


from 8.9 ms/f to 7.6 ms/f  11.5% faster (in my dumb benchmark)

every bit helps smiley
« Last Edit: January 24, 2014, 05:51:38 PM by 3dickulus » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
JohnVV
Conqueror
*******
Posts: 123


having fun


« Reply #12 on: January 29, 2014, 10:39:40 PM »

Also one thing to keep in mind is a lot of distros are using the Nouveau driver BY DEFAULT
and replacing it with the Nvidia.run ( or the Akmod-nvidia on rpm based disrtos)
or fallowing the SuSE "" the repo way" or "the hard way" is not just a few mouse clicks


at least on the rpm systems i am used to
so people might want to reread the linux forums for your OS and MAKE 100% sure
that the nvidia driver is being used and NOT the nouveau  driver
Logged

Running OpenSUSE 42.1-64bit & ScientificLinux-6.7-64bit
I don't pitch Linux to my friends,I let Microsoft do it for me!"
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #13 on: January 29, 2014, 11:37:50 PM »

a good point, thanks for mentioning it  smiley

I've made the bold assumption that anyone browsing this board (and this thread) would have the inclination to install the drivers and dev stuff before looking for code to play with, but if not, I'm always willing to help get coders compiling.

it also might be worth mentioning that http://developer.download.nvidia.com/compute/cuda/repos/opensuse122/x86_64/cuda-repo-opensuse122-5.5-0.x86_64.rpm is not the dev package itself but installs a repo that contains all the right stuff for SuSE 12.2 and does work with 12.3, in fact it should work with any RH type rpm install system.



Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #14 on: January 30, 2014, 05:39:01 PM »

w00t!!!

I have managed to get GARPREC compiled and working as a linkable library, simple test results show it's good up to about 10,000 decimal places, wow, that's a lot of resources for one number...

Hacked it into CudaBrot and here's some results, the first render was way off, processing arrays in one fell swoop, it was only doing one iteration I think, a bit of hacking and voila, we have mandelbrot in a blink, oops, it's sideways, then tried a couple of zooms on tictoc, one at 1e-14 and another at 1e-91  but as you can see from the image there is a bug somewhere, not enough bits when calculating the Re/Im lookup array?


* test1.jpg (32.07 KB, 640x480 - viewed 371 times.)

* test2.jpg (18.69 KB, 640x480 - viewed 323 times.)

* test3.jpg (60.3 KB, 512x512 - viewed 342 times.)

* test4.jpg (73.29 KB, 640x480 - viewed 332 times.)
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Pages: [1] 2 3 ... 6   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
CUDA Programming with Ruby Programming ker2x 1 1633 Last post September 28, 2010, 09:55:46 PM
by ker2x
New CUDA developer Meet & Greet chacharles 9 3591 Last post May 19, 2011, 01:06:00 PM
by chacharles
CUDA Benoit Announcements & News RogerDahl 7 3299 Last post April 26, 2011, 09:39:00 PM
by RogerDahl
mandelbulb3D and CUDA Programming scavenger 12 6165 Last post May 08, 2013, 01:25:50 PM
by elphinstone
Anyone played with Arrayfire ? (CUDA/OpenCL/CPU) Programming « 1 2 » ker2x 18 7672 Last post February 16, 2016, 11:35:27 AM
by ker2x

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.188 seconds with 24 queries. (Pretty URLs adds 0.01s, 2q)