1. Repeat efficiency
- Posted by xerox_irs at lvcm.com Feb 18, 2003
- 472 views
This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C2D749.80F63A00 charset="iso-8859-1" I'm making a large z-buffer for a 3d program is dos. "zbuffer=3Drepeat(repeat(0,1024),768)" --works fast but when I "zbuffer[y][x]=3Dsomething"--it slows down really bad, probably because = it allocates a new double every time i do that I've tried "zbuffer=3Drepeat(repeat(0,1024),768)+0.0" --takes a minute but makes "zbuffer[y][x]=3Dsomething" alot faster like multiple times faster but the problem is that zbuffer must clear every frame. so something like this still wouldn't work constant clear_buffer=3Drepeat(repeat(0,1024),768)+0.0 while 1 do zbuffer=3Dclear_buffer --it would only be fast once !!!!! = then make the "zbuffer[y][x]=3Dsomething" slow aagain --do 3d stuff here end while can you make the allocating cache bigger to whre if I allocate 8 megs = then free then it will not need to call the allocateing process for = every "zbuffer[y][x]=3Dsomething", it would just take up the a part = 8meg. So euphoria would not give the 8meg back so quitly after allocateing it = so i could use it quickly. How should I make the zbuffer ???????? the only possibility is just to inverse the points every time, which = would slow it down alot zbuffer=3Drepeat(repeat(0,1024),768)+0.0 while 1 do zbuffer=3D-zbuffer --do 3d stuff here zbuffer=3D-zbuffer --do inverse 3d stuff here end while P.S. I want to keep it all in euphoria, and not use any asm so it can be = as readable and portable as possible. ------=_NextPart_000_0012_01C2D749.80F63A00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I'm making a large z-buffer for a 3d = program is=20 dos.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>"zbuffer=3Drepeat(repeat(0,1024),768)" = --works fast=20 but when I</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>"zbuffer[y][x]=3Dsomething"--it slows = down really=20 bad, probably because it allocates a new double every time i do=20 that</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I've tried</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <DIV><FONT face=3DArial = size=3D2>"zbuffer=3Drepeat(repeat(0,1024),768)+0.0" --takes a=20 minute but makes</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>"zbuffer[y][x]=3Dsomething" alot faster = like multiple=20 times faster</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>but the problem is that zbuffer must = clear every=20 frame.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>so something like this still wouldn't=20 work</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>constant=20 clear_buffer=3Drepeat(repeat(0,1024),768)+0.0</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>while 1 do</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =20 zbuffer=3Dclear_buffer --it = would only=20 be fast once !!!!! then make the "zbuffer[y][x]=3Dsomething" slow=20 aagain</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> --do 3d=20 stuff here</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end while</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>can you make the allocating cache = bigger to whre if=20 I allocate 8 megs then free then it will not need to call the = allocateing=20 process for every "zbuffer[y][x]=3Dsomething", it would just take up the = a part=20 8meg.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>So euphoria would not give the 8meg = back so quitly=20 after allocateing it so i could use it quickly.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>How should I make the zbuffer = ????????</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>the only possibility is just to inverse = the points=20 every time, which would slow it down alot</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial = size=3D2>zbuffer=3Drepeat(repeat(0,1024),768)+0.0</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>while 1 do</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =20 zbuffer=3D-zbuffer</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> --do 3d=20 stuff here</FONT></DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial size=3D2> =20 zbuffer=3D-zbuffer</FONT></DIV> <DIV><FONT face=3DArial = size=3D2> --do=20 inverse 3d stuff here</FONT></DIV>end while</FONT></DIV> <DIV> </DIV></FONT></DIV> <DIV><FONT face=3DArial size=3D2>P.S. I want to keep it all in euphoria, = and not use=20 any asm so it can be as readable and portable as possible.</FONT></DIV> ------=_NextPart_000_0012_01C2D749.80F63A00--
2. Re: Repeat efficiency
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 18, 2003
- 461 views
On Tue, 18 Feb 2003 12:30:21 -0800, <xerox_irs at lvcm.com> wrote: > > I'm making a large z-buffer for a 3d program is dos. > > "zbuffer=repeat(repeat(0,1024),768)" --works fast but when I > > "zbuffer[y][x]=something"--it slows down really bad, probably because it > allocates a new double every time i do that > > I've tried > > "zbuffer=repeat(repeat(0,1024),768)+0.0" --takes a minute but makes > > "zbuffer[y][x]=something" alot faster like multiple times faster > > but the problem is that zbuffer must clear every frame. > > so something like this still wouldn't work > > constant clear_buffer=repeat(repeat(0,1024),768)+0.0 > > while 1 do > zbuffer=clear_buffer --it would only be fast once !!!!! then make > the "zbuffer[y][x]=something" slow aagain > --do 3d stuff here > end while > > can you make the allocating cache bigger to whre if I allocate 8 megs > then free then it will not need to call the allocateing process for every > "zbuffer[y][x]=something", it would just take up the a part 8meg. > So euphoria would not give the 8meg back so quitly after allocateing it > so i could use it quickly. > > How should I make the zbuffer ???????? > > the only possibility is just to inverse the points every time, which > would slow it down alot > > zbuffer=repeat(repeat(0,1024),768)+0.0 > > while 1 do > zbuffer=-zbuffer > --do 3d stuff here > zbuffer=-zbuffer > --do inverse 3d stuff here > end while > > P.S. I want to keep it all in euphoria, and not use any asm so it can be > as readable and portable as possible. The following code takes 0.11 seconds on my Windows 2000 , Intel P3, 550MHz ----- sequence clearb sequence zbuffer atom e e = time() clearb = repeat(repeat(0.0, 1024), 768) zbuffer = clearb for i = 1 to 768 do for j = 1 to 1024 do zbuffer[i][j] = 2.34 -- any value end for end for zbuffer = clearb ? time() - e -- cheers, Derek Parnell
3. Re: Repeat efficiency
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 18, 2003
- 479 views
On Tue, 18 Feb 2003 12:30:21 -0800, xerox_irs at lvcm.com wrote: >"zbuffer=3Drepeat(repeat(0,1024),768)+0.0" --takes a minute but makes =46irst, take a good, long, hard look at not using fractions. If there is any way to do this stuff in integers only (eg instead of working things out in inches with an accuracy of 1/1000th of an inch, just work everything out in 1/1000th's of inches), then everything will be fifty times faster as well. Secondly, especially for something of obviously fixed size like this, seriously consider allocating a block of memory and knocking up a few simple routines to peek and poke it. Not strictly euphoria, but once "black-boxed" you won't care. eg (warning completely untested!): zbuffer=3Dallocate(1024*768*4) type x_coord(integer x) if x<1 or x>1024 then return 0 end if return 1 end type type y_coord(integer y) if y<1 or y>768 then return 0 end if return 1 end procedure procedure setz(x_coord x, y_coord y, integer value) poke4(zbuffer+(x-1)*1024+y-1,value) end procedure function getz(x_coord x, y_coord y) return peek4s(zbuffer+(x-1)*1024+y-1) end function You can quickly validate this sort of code by checking that setz/getz(1,1) stores/gets first four bytes of zbuffer and that setz/getz(1024,768) the last 4 (ie 1024*768*4-4) (declare/pass x and y as normal integers, the types above are for local safety checks only and can be turned off (for speed) by specifying without type_check once it all works). HTH Pete
4. Re: Repeat efficiency
- Posted by xerox_irs at lvcm.com Feb 18, 2003
- 446 views
Hre's my test of it, maybe i should just use integers, and no floats. Integer in this test is about 1000 times faster!!!!!!!!!!. But its just becuase each and every one of the floats has to be allocated seperatly!!!!!. Thats 9.0 MBs for 1024x768*(32bit-pointer+64bit double float). The allocate routine is called every time. Is there any way to change that? --the code starts include machine.e tick_rate(1000) sequence clearb sequence zbuffer atom e e = time() clearb = repeat(repeat(0.0, 1024), 768) zbuffer = clearb for i = 1 to 768 do for j = 1 to 1024 do zbuffer[i][j] = 1+1 -- computing a value runtime makes it store differently end for end for zbuffer = clearb ? time() - e e = time() clearb = repeat(repeat(0.0, 1024), 768) zbuffer = clearb for i = 1 to 768 do for j = 1 to 1024 do zbuffer[i][j] = 1.1+1.1 -- computing a float makes it allocate room for it everytime!, would be faster with large cache --of pre-allocated memory!!!!! end for end for zbuffer = clearb ? time() - e --results 0.1289803592 seconds 108.2445168 seconds ----- Original Message ----- From: Derek Parnell <ddparnell at bigpond.com> To: EUforum <EUforum at topica.com> Sent: Tuesday, February 18, 2003 3:11 PM Subject: Re: Repeat efficiency > > On Tue, 18 Feb 2003 12:30:21 -0800, <xerox_irs at lvcm.com> wrote: > > > > > I'm making a large z-buffer for a 3d program is dos. > > > > "zbuffer=repeat(repeat(0,1024),768)" --works fast but when I > > > > "zbuffer[y][x]=something"--it slows down really bad, probably because it > > allocates a new double every time i do that > > > > I've tried > > > > "zbuffer=repeat(repeat(0,1024),768)+0.0" --takes a minute but makes > > > > "zbuffer[y][x]=something" alot faster like multiple times faster > > > > but the problem is that zbuffer must clear every frame. > > > > so something like this still wouldn't work > > > > constant clear_buffer=repeat(repeat(0,1024),768)+0.0 > > > > while 1 do > > zbuffer=clear_buffer --it would only be fast once !!!!! then make > > the "zbuffer[y][x]=something" slow aagain > > --do 3d stuff here > > end while > > > > can you make the allocating cache bigger to whre if I allocate 8 megs > > then free then it will not need to call the allocateing process for every > > "zbuffer[y][x]=something", it would just take up the a part 8meg. > > So euphoria would not give the 8meg back so quitly after allocateing it > > so i could use it quickly. > > > > How should I make the zbuffer ???????? > > > > the only possibility is just to inverse the points every time, which > > would slow it down alot > > > > zbuffer=repeat(repeat(0,1024),768)+0.0 > > > > while 1 do > > zbuffer=-zbuffer > > --do 3d stuff here > > zbuffer=-zbuffer > > --do inverse 3d stuff here > > end while > > > > P.S. I want to keep it all in euphoria, and not use any asm so it can be > > as readable and portable as possible. > > The following code takes 0.11 seconds on my Windows 2000 , Intel P3, 550MHz > ----- > sequence clearb > sequence zbuffer > atom e > e = time() clearb = repeat(repeat(0.0, 1024), 768) > zbuffer = clearb > for i = 1 to 768 do > for j = 1 to 1024 do > zbuffer[i][j] = 2.34 -- any value > end for > end for > zbuffer = clearb > ? time() - e > > -- > > > cheers, > Derek Parnell > > > > TOPICA - Start your own email discussion group. FREE! >
5. Re: Repeat efficiency
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 19, 2003
- 511 views
On Tue, 18 Feb 2003 15:50:58 -0800, <xerox_irs at lvcm.com> wrote: > > Hre's my test of it, maybe i should just use integers, and no floats. > Integer in this test is about 1000 times faster!!!!!!!!!!. > But its just becuase each and every one of the floats has to be allocated > seperatly!!!!!. Thats 9.0 MBs for 1024x768*(32bit-pointer+64bit double > float). The allocate routine is called every time. Is there any way to > change that? > [snip] Here is code that does it three different ways. The fastest is to use a sequence as an integer vector. -------- include machine.e tick_rate(1000) sequence clearb sequence zbuffer sequence cclearb sequence zzbuffer atom e atom z,p,m e = time() clearb = repeat(repeat(0, 1024), 768) zbuffer = clearb for k = 1 to 10 do for i = 1 to 768 do for j = 1 to 1024 do zbuffer[i][j] = floor(1500/134) end for end for end for zbuffer = clearb printf(1, "Integer Matrix %f\n", time() - e) e = time() cclearb = repeat(0, 1024* 768) zzbuffer = cclearb for k = 1 to 10 do for i = 1 to 768 * 1024 do zzbuffer[i] = floor(1500/134) end for end for zzbuffer = cclearb printf(1, "Integer Vector %f\n", time() - e) e = time() m = 4 * 768 * 1024 z = allocate(m) mem_set(z, m, 0) for k = 1 to 10 do p = z for i = 1 to 768 * 1024 do poke4(p,floor(1500/134)) p+=4 end for end for mem_set(z, m, 0) printf(1, "RAM Vector %f\n", time() - e) -- cheers, Derek Parnell
6. Re: Repeat efficiency
- Posted by xerox_irs at lvcm.com Feb 19, 2003
- 472 views
Thank you very much with your help, i think ill go with the integer matrix. ----- Original Message ----- From: Derek Parnell <ddparnell at bigpond.com> Subject: Re: Repeat efficiency > > On Tue, 18 Feb 2003 15:50:58 -0800, <xerox_irs at lvcm.com> wrote: > > > > > Hre's my test of it, maybe i should just use integers, and no floats. > > Integer in this test is about 1000 times faster!!!!!!!!!!. > > But its just becuase each and every one of the floats has to be allocated > > seperatly!!!!!. Thats 9.0 MBs for 1024x768*(32bit-pointer+64bit double > > float). The allocate routine is called every time. Is there any way to > > change that? > > > [snip] > > Here is code that does it three different ways. The fastest is to use a > sequence as an integer vector. > -------- > include machine.e > tick_rate(1000) > sequence clearb > sequence zbuffer > sequence cclearb > sequence zzbuffer > atom e > atom z,p,m > > e = time() clearb = repeat(repeat(0, 1024), 768) > > zbuffer = clearb > for k = 1 to 10 do > > for i = 1 to 768 do > for j = 1 to 1024 do > zbuffer[i][j] = floor(1500/134) > end for > end for end for > zbuffer = clearb > > printf(1, "Integer Matrix %f\n", time() - e) > > e = time() cclearb = repeat(0, 1024* 768) > > zzbuffer = cclearb > for k = 1 to 10 do > > for i = 1 to 768 * 1024 do > zzbuffer[i] = floor(1500/134) > end for end for > zzbuffer = cclearb > > printf(1, "Integer Vector %f\n", time() - e) > > e = time() m = 4 * 768 * 1024 > z = allocate(m) > mem_set(z, m, 0) > for k = 1 to 10 do > > p = z > for i = 1 to 768 * 1024 do > poke4(p,floor(1500/134)) > p+=4 > end for > end for > > mem_set(z, m, 0) > > printf(1, "RAM Vector %f\n", time() - e) > > > -- > > cheers, > Derek Parnell > > > > TOPICA - Start your own email discussion group. FREE! >
7. Re: Repeat efficiency
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 20, 2003
- 458 views
You're correct. Not very intuitive for me. I had in mind that I was setting a block of memory to a value so I thought in terms of a block (Addr : Length) then the value. It should have been... size = 4 * 768 * 1024 addr = allocate(size) mem_set(addr, 0, size) ---------------- cheers, Derek Parnell ----- Original Message ----- From: "Andy Serpa" <ac at onehorseshy.com> To: "EUforum" <EUforum at topica.com> Sent: Thursday, February 20, 2003 1:57 AM Subject: RE: Repeat efficiency > > > > > e = time() m = 4 * 768 * 1024 > > > z = allocate(m) > > > mem_set(z, m, 0) > > The 2nd & 3rd terms of mem_set look inverted here. > > > > TOPICA - Start your own email discussion group. FREE! >
8. Re: Repeat efficiency
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 20, 2003
- 485 views
On Thu, 20 Feb 2003 15:50:04 +0000, Andy Serpa <ac at onehorseshy.com> wrote: >I think it was intuitive of you -- I think the required order of terms=20 >is counter-inituitive. The only reason I noticed is because I always=20 >screw that one up. Just seems more natural the other way... set(z,y,x)... Right or wrong, bit late to change it anyway?: Starting at z set to y the next x bytes vs: Starting at z set x bytes to y... Just to be damn awkward, what makes sense for me is: set_mem(x,z,y) aka set x bytes from address z on to y. Am I kidding? you figure it out... ... This is precisely the kind of thing that should not suddenly cease to work, but in java-speak "deprecated" and something better invented. However, of course, the documentation is pretty exact and really, for such a rarely used function, why mess? Pete
9. Re: Repeat efficiency
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 20, 2003
- 463 views
On Thu, 20 Feb 2003 22:47:25 +0000, Pete Lomax <petelomax at blueyonder.co.uk> wrote: > > On Thu, 20 Feb 2003 15:50:04 +0000, Andy Serpa <ac at onehorseshy.com> > wrote: > >> I think it was intuitive of you -- I think the required order of terms >> is counter-inituitive. The only reason I noticed is because I always >> screw that one up. Just seems more natural the other way... > > set(z,y,x)... > > Right or wrong, bit late to change it anyway?: > > Starting at z set to y the next x bytes > vs: > Starting at z set x bytes to y... > > Just to be damn awkward, what makes sense for me is: > > set_mem(x,z,y) > > aka set x bytes from address z on to y. > > Am I kidding? you figure it out> > ... > > > ... > > > This is precisely the kind of thing that should not suddenly cease to > work, but in java-speak "deprecated" and something better invented. > > However, of course, the documentation is pretty exact and really, for > such a rarely used function, why mess? > Though I do like the ability in Visual Basic to have named parameters, to do this sort of thing... mem_set Addr:=z, Size:=m, Value:=0 that way the coder can place the parameters in any order that makes sense for them. -- cheers, Derek Parnell