flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > So, I tried to make a vectorized mandelbrot

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Fractals are not really suitable to vectorize, but I thought I'd give it a try. Seems that there is something fishy about my result Smile

Image

_________________
This is a block of text that can be added to posts you make.
Post 16 Oct 2011, 03:36
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
what math algo were you using?
Post 16 Oct 2011, 04:39
View user's profile Send private message Reply with quote
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin
Very Happy
I like Vertex fractals.


Description: Windows OpenGL IFF
Download
Filename: iffgl.rar
Filesize: 3.84 KB
Downloaded: 398 Time(s)


_________________
CLI
HLT
Post 16 Oct 2011, 04:44
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
typedef wrote:
what math algo were you using?


Z=Z^2^6+Z0

Z0=position

Haven't figured out why the borders are all fuzzy.

_________________
This is a block of text that can be added to posts you make.
Post 16 Oct 2011, 14:06
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Wonder if it's some kind of precision artifacts. Seems like I'm losing 3/4 of the horizontal resolution at moderate iteration counts.

Image

Here is an exe if you would like to play with it. Mouse X position controls the iteration count.
http://files.sys5.se/fractal.exe

_________________
This is a block of text that can be added to posts you make.
Post 17 Oct 2011, 03:46
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Damn,,,,I have epilepsy and I kinda got a seizure... *choking*
Post 17 Oct 2011, 04:36
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
@mindcooler: You're probably just writing the pixels in wrong order. Just do a SHUFPD xmm0,xmm0,00011011b before MOVDQA [mem],xmm0.
There are many examples of vectorized fractals so don't say that its not suitable. You just need to be careful Wink
Post 17 Oct 2011, 07:07
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Madis731 wrote:
@mindcooler: You're probably just writing the pixels in wrong order. Just do a SHUFPD xmm0,xmm0,00011011b before MOVDQA [mem],xmm0.
There are many examples of vectorized fractals so don't say that its not suitable. You just need to be careful Wink


I tried flipping the pixels, but it only got fuzzier Smile

_________________
This is a block of text that can be added to posts you make.
Post 17 Oct 2011, 15:06
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Then I guess the bug is elsewhere, but I think you also know what the next logical suggestion will be. The source?
Post 17 Oct 2011, 15:17
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler

_________________
This is a block of text that can be added to posts you make.
Post 17 Oct 2011, 15:35
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
According to this: http://www.mathworks.com/moler/exm/chapters/mandelbrot.pdf (p.6 figure 13.4) you might have a problem with precision.

Have you heard about subpixel rendering or double resolution antialiasing, supersampling etc.?
http://en.wikipedia.org/wiki/Spatial_anti-aliasing
I think this is what's making this picture look awful.

I made this little change in code and the blocks grew in size, but there were less holes:
Code:
                shufps  xmm5,xmm5,0 ;Make 4 neighboring pixels the same.
                movups  dqword [edi],xmm5
    
Post 17 Oct 2011, 15:50
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Weird thing is, the problem seems to be in just the x direction, as if the pixels are not continuous. I get full resolution in the y direction. I've checked the generated coordinates in a quad, and they line up perfectly.

You shouldn't need to resort to antialiasing to get down to pixel-sized chunks. There is probably some subtle problem with the vectorization in the iteration loop. I think if I were to make it scalar the problem would go away.

_________________
This is a block of text that can be added to posts you make.
Post 17 Oct 2011, 16:34
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Found it!
Code:
 .xloop:
                movaps  xmm0,dqword [deltas]
                movss   xmm1,[.r]
                shufps  xmm1,xmm1,$00
        addps   xmm1,xmm0 ;You need this HERE!
                movaps  xmm6,xmm1
                movss   xmm2,[.i]
                shufps  xmm2,xmm2,$00
                ;addps   xmm1,xmm0 ;...but NOT here!
                movaps  xmm7,xmm2
    
Post 17 Oct 2011, 16:58
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
I tried optimizing a bit (11-14% on Core 2):
Code:
 .xloop:
                movaps  xmm0,dqword [deltas]
                movss   xmm1,[.r]
                shufps  xmm1,xmm1,$00
                addps   xmm1,xmm0
                movaps  xmm6,xmm1
                movss   xmm2,[.i]
                shufps  xmm2,xmm2,$00
                movaps  xmm7,xmm2

                ;mov     ebx,MAXITER
                mov     ebx,[maxiter]
                movss   xmm4,[.r]
 .iteration:
                movaps  xmm3,xmm1 ;freeing xmm4 allows us to use it for [.r]
                mulps   xmm1,xmm1 ;try to use full pipeline
                mulps   xmm3,xmm2
                mulps   xmm2,xmm2
                addps   xmm3,xmm3
                subps   xmm1,xmm2
                movaps  xmm2,xmm3
                addps   xmm1,xmm6
                addps   xmm2,xmm7
                movaps  xmm5,xmm1
                addps   xmm5,xmm2

                dec     ebx
                jne     .iteration

                cmpltps xmm5,dqword [bailout]
                movups  dqword [edi],xmm5

                addss   xmm4,[.delta4]
                movss   [.r],xmm4

                add     edi,16
                dec     edx
                jne     .xloop

                movss   xmm4,[.i]
                addss   xmm4,[.delta]
                movss   [.i],xmm4
    
Post 18 Oct 2011, 16:37
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Madis731 wrote:
Found it!
Code:
 .xloop:
                movaps  xmm0,dqword [deltas]
                movss   xmm1,[.r]
                shufps  xmm1,xmm1,$00
        addps   xmm1,xmm0 ;You need this HERE!
                movaps  xmm6,xmm1
                movss   xmm2,[.i]
                shufps  xmm2,xmm2,$00
                ;addps   xmm1,xmm0 ;...but NOT here!
                movaps  xmm7,xmm2
    


Oh wow, that is amazing! I remember moving that line to the bottom of what I thought was the r calculation, obviously I moved it too far! Smile

_________________
This is a block of text that can be added to posts you make.
Post 18 Oct 2011, 21:31
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Madis731 wrote:
I tried optimizing a bit (11-14% on Core 2):


Nice, keeping it in the same place instead of moving it all over.

As I'm new to SSE, I don't know much about pipelining, what should I keep in mind while doing SSE work?

Now that it works properly I'm going to try to split it up into worker threads. I'm new to that too, so another adventure awaits Smile

_________________
This is a block of text that can be added to posts you make.
Post 18 Oct 2011, 21:42
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
http://agner.org/optimize/ - 2. optimizing_assembly.pdf
Post 19 Oct 2011, 08:52
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Yes, I suppose I have to get acquainted with mr Agner someday Smile
Post 19 Oct 2011, 21:47
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
mindcooler wrote:
Fractals are not really suitable to vectorize, but I thought I'd give it a try. Seems that there is something fishy about my result Smile
Might be caused by a bug, but it looks nice Smile

_________________
Image - carpe noctem
Post 20 Oct 2011, 18:14
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
refering to OP: can you zoom in such fractal? it might be an interestng animation
Post 20 Oct 2011, 19:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.