POV-Ray : Newsgroups : povray.advanced-users : function optimization question Server Time
30 Nov 2026 22:07:00 EST (-0500)
  function optimization question (Message 1 to 50 of 65)  
Goto Latest 50 Messages Next 15 Messages >>>
From:
Subject: function optimization question
Date: 15 Mar 2002 05:15:24
Message: <s4i39u0a519jemevbcmh1fuv2fb6e0du3a@4ax.com>
I wonder if this is optimized if functions evaluator:

select(
  x*Ey+y*Ex-R1*Ex,
  select(
    z+3*x.
    x*Ey+y*Ex-R1*Ex,
    123
  ),
 17
)

Note expression "x*Ey+y*Ex-R1*Ex" appear twice. How many times is it
calculated ?

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function optimization question
Date: 15 Mar 2002 06:31:30
Message: <3c91db92$1@news.povray.org>
> Note expression "x*Ey+y*Ex-R1*Ex" appear twice. How many times is it
> calculated ?

Twice. The function compiler cannot optimise common subexpressions and it is
unlikely this feature will be added to it in time for a 3.5 release because
it is very complex and would require another intermediate code
representation layer.  The (current) function compiler has no layer suitable
for general optimisations because it performs similfications and elimination
of constants in the expression tree.  That tree is then turned into function
VM instructions, which is nearly trivial because no complex language
constructs (which would benefit from such further optimisation as well) are
supported by the compiler.

    Thorsten


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 15 Mar 2002 13:49:14
Message: <5fg49ucdqt4o5ormk2g75rcckq30o1s4pl@4ax.com>
On Fri, 15 Mar 2002 12:33:16 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:
> > Note expression "x*Ey+y*Ex-R1*Ex" appear twice. How many times is it
> > calculated ?
>
> Twice. The function compiler cannot optimise common subexpressions and it is
> unlikely this feature will be added to it in time for a 3.5 release because
> it is very complex and would require another intermediate code
> representation layer. 

Then it is feature request for 4.5 since 4 will by much more complex task
around rewriting.

> The (current) function compiler has no layer suitable
> for general optimisations because it performs similfications and elimination
> of constants in the expression tree.  That tree is then turned into function
> VM instructions, which is nearly trivial because no complex language
> constructs (which would benefit from such further optimisation as well) are
> supported by the compiler.

As I remember text output of function parser - there were some kind of float
variables/registers/stack entries. I though that every such float has
dictionary feature (similiar to dictionary used gif coding) where every float
has preprocessed string (without whitespaces) with syntax used to build this
expression. So when new expression is calculated then it is verified with
dictionary and use reference to ready float. But my imagination was probably
far from implementation so forget it.

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function optimization question
Date: 15 Mar 2002 15:01:50
Message: <3c92532e$1@news.povray.org>
In article <5fg49ucdqt4o5ormk2g75rcckq30o1s4pl@4ax.com> , W„odzimierz ABX 
Skiba <abx### [at] babilonorg>  wrote:

> As I remember text output of function parser - there were some kind of float
> variables/registers/stack entries. I though that every such float has
> dictionary feature (similiar to dictionary used gif coding) where every float
> has preprocessed string (without whitespaces) with syntax used to build this
> expression. So when new expression is calculated then it is verified with
> dictionary and use reference to ready float. But my imagination was probably
> far from implementation so forget it.

Sadly, it isn't that simple.  The internal representation is a tree so finding
a subexpression would require to compare every possible subtree of the
function with every other possible subtree.  This task gets very complex
quickly.  That is why there is usually an intermediate representation more
suitable for this "kind of pattern matching" in advanced compilers.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Slime
Subject: Re: function optimization question
Date: 16 Mar 2002 03:20:15
Message: <3c93003f@news.povray.org>
> Twice. The function compiler cannot optimise common subexpressions and it
is
> unlikely this feature will be added to it in time for a 3.5 release
because
> it is very complex and would require another intermediate code
> representation layer.  The (current) function compiler has no layer
suitable
> for general optimisations because it performs similfications and
elimination
> of constants in the expression tree.  That tree is then turned into
function
> VM instructions, which is nearly trivial because no complex language
> constructs (which would benefit from such further optimisation as well)
are
> supported by the compiler.

Hmm. I can see how this would be difficult to do automatically, but is there
any chance that 3.5 or a future version could support something where the
user is able to manually select parts of the function that will appear
later? For instance, if I said something like

function{
    f_noise3d(
        x/sqrt(x^2+y^2+z^2),
        y/sqrt(x^2+y^2+z^2),
        z/sqrt(x^2+y^2+z^2)
    )
}

then it has to evaluate that one peice three times. I can plainly see that
this will slow it down. So it would be cool if I could say something like

function{
    f_noise3d(
        x/(remember(1): sqrt(x^2+y^2+z^2)),
        y/(recall:1),
        z/(recall:1)
    )
}

Where the 1 indicates that the remembered item labeled "1" should be
recalled. The syntax I made up here is ugly, but is there any chance of this
functionality appearing in the future?

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 16 Mar 2002 09:20:33
Message: <3c9354b0@news.povray.org>
What you want is simple: Support for defining variables inside functions.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 16 Mar 2002 10:01:57
Message: <3c935e65@news.povray.org>
>   What you want is simple: Support for defining variables inside functions.

All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...

(I know, the language itself is already, but function themselfes are not, are they ?)


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 16 Mar 2002 10:19:01
Message: <3c936264@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...

  Imagine the mandelbrot pattern defined as a function... Or any other
fractal whatsoever.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 16 Mar 2002 10:57:49
Message: <3c936b7d$2@news.povray.org>
But it would be quite a high risk, to get a stack overflow ...

As I understood, functions are more deeper embedded in POVRay, than macros ...

so there probably would be a need for extra checkings, to make functions, not to block
the whole system ...

Imagine a function that looks up, because of a infinite-loop, that gets computet first
time at 50% of an Image ... (this image
rendered at 2pps) ...

how will you tell, that it's the function, dooing an infinite loop, and not "only the
image with a bit of
media/refraction/any-other-slow-feature" ?

I think it would be _very_ powerful, but it would lead to even more headaches than we
have already ...

I think you all know what I mean ... <looking into p.b-t> ....


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 16 Mar 2002 14:21:26
Message: <3c939b36@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
> But it would be quite a high risk, to get a stack overflow ...

  It would just give a "max recursion depth limit reached" error. Nothing
fancy.
  Of course this limit should be something usable, eg. at least hundreds or
better some thousands.
  Naturally if some type of iterative loop is implemented, then recursion
will not be needed.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 16 Mar 2002 14:32:21
Message: <3c939dc5$1@news.povray.org>
>   Naturally if some type of iterative loop is implemented, then recursion
> will not be needed.

And you can't tell if these loops will terminate, if it's turing complete ...
so one could lock up the render, without knowing it ....

probably one have to include something like a "maxiteration" for loops (if they were
available) .. so to cancel an infinite loop
after, maybe, 10000 times going over a specified "label" .... (just an idea) ...


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: function optimization question
Date: 16 Mar 2002 15:21:55
Message: <MPG.16fdc81e3ce92ec49896ea@news.povray.org>
In article <3c939dc5$1@news.povray.org>, jan### [at] lzernet says...

> And you can't tell if these loops will terminate, if it's turing complete ...
> so one could lock up the render, without knowing it ....

Whats the problem? A sufficienty complicated object (preferrably with a 
glas material and filled with scattering media...) can do practically the 
same.

Lutz-Peter


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 16 Mar 2002 16:10:46
Message: <3c93b4d6$1@news.povray.org>
Yeah ... but it WILL terminate ...

and even if recursion-depth will be 2^32 .... it WILL terminate ...

you can't tell this for every function if the "machine" is turing-complete

... or better the other way around:

If  a function terminates, then: fine...
but if it is running, there's no algorithmic way, to determine if this function will
ever terminate or not ...
Your only chance is to wait and see ...

of course, there are trivial ones, but for every function you find, that is possible
to tell, there are infinite other functions,
where you can't tell ...


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 16 Mar 2002 16:11:03
Message: <3c93b4e7@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
> And you can't tell if these loops will terminate, if it's turing complete ...
> so one could lock up the render, without knowing it ....

  So can a #while. So what?
  That's not the problem here.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 16 Mar 2002 16:57:45
Message: <3c93bfd9$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote:
> Jan Walzer <jan### [at] lzernet> wrote:
> > And you can't tell if these loops will terminate, if it's turing complete ...
> > so one could lock up the render, without knowing it ....
>
>   So can a #while. So what?
>   That's not the problem here.

but it happens at parse-stage ... there's no image rendered yet, and you can debug it
by using the debug-stream ...

functions can get evaluated at rendertime ...
you can't debug them by writing some intermediate-values to some stream ...

you see my prob ?


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: function optimization question
Date: 16 Mar 2002 17:30:54
Message: <MPG.16fde65b9dbc8c219896eb@news.povray.org>
In article <3c93b4d6$1@news.povray.org>, jan### [at] lzernet says...

> and even if recursion-depth will be 2^32 .... it WILL terminate ...

But that's only relevant in theory because you won't wait that long 
anyway.

Lutz-Peter


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 16 Mar 2002 20:46:08
Message: <3c93f560@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
> but it happens at parse-stage ... there's no image rendered yet, and you can debug
it by using the debug-stream ...

  You can do the same thing with functions.

> functions can get evaluated at rendertime ...
> you can't debug them by writing some intermediate-values to some stream ...

  Yes, you can.

> you see my prob ?

  No.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: function optimization question
Date: 16 Mar 2002 20:49:30
Message: <chrishuff-5A16DA.20492316032002@netplex.aussie.org>
In article <3c93bfd9$1@news.povray.org>, "Jan Walzer" <jan### [at] lzernet> 
wrote:

> but it happens at parse-stage ... there's no image rendered yet, and you can 
> debug it by using the debug-stream ...
> 
> functions can get evaluated at rendertime ...
> you can't debug them by writing some intermediate-values to some stream ...

Why not? Just make an equivalent to #debug that operates at function 
evaluation time, whether while parsing or rendering.

If you set an arbitrary limit, it will either be too low and get in 
people's way (like the recursion limit for macros), or be too high and 
not be useful. Why bother?

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Slime
Subject: Re: function optimization question
Date: 16 Mar 2002 22:22:17
Message: <3c940be9$1@news.povray.org>
>   What you want is simple: Support for defining variables inside
functions.

Hmm, I suppose you're right. Is that difficult? I'd think you'd only need
some sort of array attached to the function internally, holding all the
values and their respective variable names.

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

From: Peter Popov
Subject: Re: function optimization question
Date: 17 Mar 2002 01:49:19
Message: <2re89uo42pdv7nstepkrs12id6b055ukoj@4ax.com>
On Sat, 16 Mar 2002 20:49:23 -0600, Christopher James Huff
<chr### [at] maccom> wrote:

>If you set an arbitrary limit, it will either be too low and get in 
>people's way (like the recursion limit for macros), or be too high and 
>not be useful. Why bother?

Only if you make it built-in. If you can change it in the scene or in
the ini file, there will not be such a problem.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 17 Mar 2002 04:55:42
Message: <3c94681e@news.povray.org>
"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag news:3c93f560@news.povray.org...
> Jan Walzer <jan### [at] lzernet> wrote:
> > but it happens at parse-stage ... there's no image rendered yet, and you can debug
it by using the debug-stream ...
>
>   You can do the same thing with functions.
No ... I can't

> > functions can get evaluated at rendertime ...
> > you can't debug them by writing some intermediate-values to some stream ...
>
>   Yes, you can.
Can I ? ... How ?
> > you see my prob ?
>
>   No.

You mean, I should better read the doc ? There is a way ?


Post a reply to this message

From: Christopher James Huff
Subject: Re: function optimization question
Date: 17 Mar 2002 11:00:36
Message: <chrishuff-2E48C6.11003017032002@netplex.aussie.org>
In article <3c94681e@news.povray.org>, "Jan Walzer" <jan### [at] lzernet> 
wrote:

> You mean, I should better read the doc ? There is a way ?

Are you just trying to be annoying?
Your argument: if flow control structures are added, it would be 
possible to end up with endlessly iterating structures with no way to 
output debug values.
There is currently no way to do it, but there currently aren't flow 
control structures either. There is no reason a debug command couldn't 
be added to functions, making your argument invalid.

I really don't think it is a problem anyway...you can make infinite 
loops now, or do other things that take extremely long times to render.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 17 Mar 2002 16:27:07
Message: <3c950a2b@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
>>   Yes, you can.
> Can I ? ... How ?

#debug concat(str(MyFunction(1,2,3),0,-1), "\n")

  It doesn't matter if 'MyFunction' is a macro or a function. If it hangs,
it will hang at parse time.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 17 Mar 2002 16:28:29
Message: <3c950a7c@news.povray.org>
Peter Popov <pet### [at] vipbg> wrote:
>>If you set an arbitrary limit, it will either be too low and get in 
>>people's way (like the recursion limit for macros), or be too high and 
>>not be useful. Why bother?

> Only if you make it built-in. If you can change it in the scene or in
> the ini file, there will not be such a problem.

  So let's put a limit to the number of times a #while can execute. Right?

  I really don't see the problem here. If someone wants to make an infinite
loop, then let them make one. It's not your headache.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 17 Mar 2002 16:41:49
Message: <3c950d9d$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote:
> Jan Walzer <jan### [at] lzernet> wrote:
> >>   Yes, you can.
> > Can I ? ... How ?
>
> #debug concat(str(MyFunction(1,2,3),0,-1), "\n")
>
>   It doesn't matter if 'MyFunction' is a macro or a function. If it hangs,
> it will hang at parse time.

not for every case/function ...

What I meant, is that you can hardly compute/debug any values a function can
give while tracing (imagine, you have it as a imagemap)...

I think Christopher is right, when he means taht we shouldn't dispute about
issues, that are currently no problems at all ...

so propably I can say a EOT here ?

let me just say, that I think it would be great idea, to have recursive
funtions with definable variables, yes ... but leave this issue until 3.5 is
out ... OK ?


Post a reply to this message

From: Peter Popov
Subject: Re: function optimization question
Date: 17 Mar 2002 17:30:21
Message: <ft5a9uohspmhdva28oajq30ttitpgld9eb@4ax.com>
On 17 Mar 2002 16:28:29 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  I really don't see the problem here. If someone wants to make an infinite
>loop, then let them make one. It's not your headache.

Infinite loops have their uses. We're talking infinite recursion here,
and on less memory-protected systems a stack fault can cost more than
an interrupted render.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:49:53
Message: <4o9b9uk060bfb0orvu43ltcf2v6rsaamhp@4ax.com>
On Mon, 11 Mar 2002 03:17:07 -0500, "Slime" <noo### [at] hotmailcom> wrote:
>
> function{
>    f_noise3d(
>        x/(remember(1): sqrt(x^2+y^2+z^2)),
>        y/(recall:1),
>        z/(recall:1)
>    )
> }
>
> Where the 1 indicates that the remembered item labeled "1" should be
> recalled. The syntax I made up here is ugly, but is there any chance of this
> functionality appearing in the future?

It can appear tomorrow :-) if you just write:

 function{
    #local Function_With_One_Sqrt=function(x,y,z,sqrtxyz){
      f_noise3d(
          x/sqrtxyz,
          y/sqrtxyz,
          z/sqrtxyz
      )
    };
    Function_With_One_Sqrt(x,y,z,sqrt(x^2+y^2+z^2))
 }

The difference between your simple example and my case is very important.
While your subexpresssion is used three times in every function call, my
subexpression was used with apropriate condition in select(). I can't
precalculate it as subfunction with additional parameter becouse statisticaly
it is used only in 30% calls for example. Of course I can separate content of
select as sub function but it can slow down evaluation a lot when
subexpression is builded with hundreds of selects.

ABX


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:56:50
Message: <vgab9uk6h9gik1v2lr4qdata0advargi60@4ax.com>
On Sat, 16 Mar 2002 16:02:52 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...

Personally I think that internally functions are ready for recursions :-)
I've got message "Possible infinite recursive function call." some time.
I've also got message like "Reached maximum number of
recursion in functions". In both cases messages were produced as a result of
bug as I reported in povray.beta-test but the fact they are builded in POV-Ray
lead me to conclusion that recursion is a part of design :-)

ABX


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:59:03
Message: <90bb9uou3kmgj2ld4rm2k0pbpg8rdnmdlk@4ax.com>
On 16 Mar 2002 14:21:26 -0500, Warp <war### [at] tagpovrayorg> wrote:
> It would just give a "max recursion depth limit reached" error.

I've got such a message in 3.5 as I reported.

ABX
--
disc{z,-z 5#macro O()asc(substr("-+((1*(,1,/.-,*/(,&.323/'1"e,1))*.1-4#declare
e=e-1;#end#local e=26;pigment{#local g=function(_){ceil(_)-_}function#local//X
k=function{pattern{object{sphere_sweep{linear_spline 13#while(e>0)<O(),O()//AB
>.01#end}}}}{k(g(atan2(x,y)),g(ln((y+x)^2+1e-5)),0)}}finish{ambient 1}}//POV35


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 10:30:40
Message: <slrna9emd1.ei2.ron.parker@fwi.com>
On Mon, 18 Mar 2002 09:56:12 +0100, Włodzimierz ABX Skiba wrote:
> On Sat, 16 Mar 2002 16:02:52 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
>> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...
> 
> Personally I think that internally functions are ready for recursions :-)
> I've got message "Possible infinite recursive function call." some time.
> I've also got message like "Reached maximum number of
> recursion in functions". In both cases messages were produced as a result of
> bug as I reported in povray.beta-test but the fact they are builded in POV-Ray
> lead me to conclusion that recursion is a part of design :-)

Loops, too.  They're just not part of the syntax.  The 3.5 beta has some
debugging features built in, though, so you can actually use them.  For 
example, here's a simple iterative factorial function:

#declare Fact=function(x) {"fact.out","fact.func" };

#debug concat(str(Fact(0),3,3), "\n")
#debug concat(str(Fact(1),3,3), "\n")
#debug concat(str(Fact(2),3,3), "\n")
#debug concat(str(Fact(3),3,3), "\n")
#debug concat(str(Fact(4),3,3), "\n")

and here are the contents of the file "fact.func":

grow    2
load    SP(0),r2
loadi   1,r0
cmpi    0,r2
ble     8
mul     r2,r0
subi    1, r2
jmp     3
rts

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 10:36:07
Message: <7ime9ukggvcv8thtubar3a94hadk998qn1@4ax.com>
On 19 Mar 2002 10:30:40 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> Loops, too.

Sounds great.

> They're just not part of the syntax.

Is this a bonus pack for patch writers or it will be boundled with Profesional
Edition ? ;-)

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 10:41:16
Message: <slrna9en0s.eie.ron.parker@fwi.com>
On Tue, 19 Mar 2002 16:35:29 +0100, Włodzimierz ABX Skiba wrote:
> On 19 Mar 2002 10:30:40 -0500, Ron Parker <ron### [at] povrayorg> wrote:
>> Loops, too.
> 
> Sounds great.
> 
>> They're just not part of the syntax.
> 
> Is this a bonus pack for patch writers or it will be boundled with Profesional
> Edition ? ;-)

What, assembly-language-like bytecode isn't good enough for you?  Kids these
days...

I think at the moment that it's a bonus pack for patch writers.  I don't know
what the Team's plans are WRT the debugging features, but you can probably
place large bets on the syntax not changing before 3.5.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From: Christoph Hormann
Subject: Re: function optimization question
Date: 19 Mar 2002 11:04:02
Message: <3C976170.93CD802F@gmx.de>
Ron Parker wrote:
> 
> [...]
> > Is this a bonus pack for patch writers or it will be boundled with Profesional
> > Edition ? ;-)
> 
> What, assembly-language-like bytecode isn't good enough for you?  Kids these
> days...
> 

;-)

Anyway it would be great if there was some kind of documentation for such
hidden features.  Not neccessarily in the user docs, but maybe included in
the source code package.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 18 Mar. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 11:09:28
Message: <2foe9u0noelccpuqc58519jv8h45lk153b@4ax.com>
On 19 Mar 2002 10:41:16 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> What, assembly-language-like bytecode isn't good enough for you?  Kids these
> days...

My asked for my daughter. She likes building functions in macros and render in
one pass ;-)

> I think at the moment that it's a bonus pack for patch writers.  I don't know
> what the Team's plans are WRT the debugging features

http://news.povray.org/3c2caae6@news.povray.org

> but you can probably
> place large bets on the syntax not changing before 3.5.

it's dream of many people I think

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:11:22
Message: <slrna9eopc.ejm.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:04:00 +0100, Christoph Hormann wrote:
> 
> 
> Ron Parker wrote:
>> 
>> [...]
>> > Is this a bonus pack for patch writers or it will be boundled with Profesional
>> > Edition ? ;-)
>> 
>> What, assembly-language-like bytecode isn't good enough for you?  Kids these
>> days...
>> 
> 
> ;-)
> 
> Anyway it would be great if there was some kind of documentation for such
> hidden features.  Not neccessarily in the user docs, but maybe included in
> the source code package.

There is no source code package yet, right?  And when there is, there will
be the same documentation I used to find this feature.

That documentation looks something like this:

    else if(Token.Token_Id == STRING_LITERAL_TOKEN)
        {
                FNCode_SetFlag(2, Token.Token_String);
                Get_Token();
                if(Token.Token_Id == COMMA_TOKEN)
                {
                        Get_Token();
                        if(Token.Token_Id != STRING_LITERAL_TOKEN)
                                Expectation_Error("valid function expression");
                        FNCode_SetFlag(1, Token.Token_String);
                }
                else
                {
                        Unget_Token();
                        expression = FNSyntax_ParseExpression();
                }
        }

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:20:52
Message: <slrna9epb4.ejm.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:08:50 +0100, Włodzimierz ABX Skiba wrote:
> On 19 Mar 2002 10:41:16 -0500, Ron Parker <ron### [at] povrayorg> wrote:
>> What, assembly-language-like bytecode isn't good enough for you?  Kids these
>> days...
> 
> My asked for my daughter. She likes building functions in macros and render in
> one pass ;-)
> 
>> I think at the moment that it's a bonus pack for patch writers.  I don't know
>> what the Team's plans are WRT the debugging features
> 
> http://news.povray.org/3c2caae6@news.povray.org

Well, there ya go then.  Straight from the horse's mouth.  Of course, since
it's just turned off with a compile-time switch, enterprising patch writers
will be able to turn it back on easily.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end 
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 11:21:51
Message: <0ape9uormom5m6kg6v7hn5ld9nm2o92mmk@4ax.com>
On 19 Mar 2002 11:11:22 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> That documentation looks something like this:

and it's very similiar to 6.1.6.6 chapter :-)

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:26:13
Message: <slrna9epl7.ejm.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:21:13 +0100, Włodzimierz ABX Skiba wrote:
> On 19 Mar 2002 11:11:22 -0500, Ron Parker <ron### [at] povrayorg> wrote:
>> That documentation looks something like this:
> 
> and it's very similiar to 6.1.6.6 chapter :-)

I'm obviously missing something... there is no 6.1.6.6???

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 11:29:28
Message: <pnpe9uk2an43j2rvp72b6b8qrominjqgpd@4ax.com>
On 19 Mar 2002 11:26:13 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> > > That documentation looks something like this:
> > 
> > and it's very similiar to 6.1.6.6 chapter :-)
>
> I'm obviously missing something... there is no 6.1.6.6???

It was supposed to be a joke since there is also no "else if(Token.Token_Id ==
STRING_LITERAL_TOKEN)" in my installation of documentation ;-)

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:32:46
Message: <slrna9eq1g.eln.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:28:46 +0100, Włodzimierz ABX Skiba wrote:
> On 19 Mar 2002 11:26:13 -0500, Ron Parker <ron### [at] povrayorg> wrote:
>> > > That documentation looks something like this:
>> > 
>> > and it's very similiar to 6.1.6.6 chapter :-)
>>
>> I'm obviously missing something... there is no 6.1.6.6???
> 
> It was supposed to be a joke since there is also no "else if(Token.Token_Id ==
> STRING_LITERAL_TOKEN)" in my installation of documentation ;-)

That's because you don't have the source code package, and all the 
documentation it customarily comes with.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Christoph Hormann
Subject: Re: function optimization question
Date: 19 Mar 2002 11:39:43
Message: <3C9769CB.293D5093@gmx.de>
Ron Parker wrote:
> 
> There is no source code package yet, right?  And when there is, there will
> be the same documentation I used to find this feature.
> 
> That documentation looks something like this:
> 
>     else if(Token.Token_Id == STRING_LITERAL_TOKEN)
> [...]

This of course was not what i meant, i meant a description of how to write
those assembly instructions.  A list of available commands and some
documented samples would help a lot.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 18 Mar. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:41:12
Message: <slrna9eqha.emg.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:39:39 +0100, Christoph Hormann wrote:
> 
> 
> Ron Parker wrote:
>> 
>> There is no source code package yet, right?  And when there is, there will
>> be the same documentation I used to find this feature.
>> 
>> That documentation looks something like this:
>> 
>>     else if(Token.Token_Id == STRING_LITERAL_TOKEN)
>> [...]
> 
> This of course was not what i meant, i meant a description of how to write
> those assembly instructions.  A list of available commands and some
> documented samples would help a lot.

Oh.  Well, you're in luck there.  There is a significant amount of 
documentation for the bytecode in the appropriate source file.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Christoph Hormann
Subject: Re: function optimization question
Date: 19 Mar 2002 11:46:58
Message: <3C976B7F.FB30FD25@gmx.de>
Ron Parker wrote:
> 
> Oh.  Well, you're in luck there.  There is a significant amount of
> documentation for the bytecode in the appropriate source file.
> 

Great.

I'm eagerly waiting to see it...


Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 18 Mar. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 19 Mar 2002 14:35:50
Message: <3c979316@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
> What, assembly-language-like bytecode isn't good enough for you?

  That's luxury!
  The only valid input for functions should be opcodes written in hexadecimal!

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 30 Mar 2002 05:09:45
Message: <3ca58ee9@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote:
> > What, assembly-language-like bytecode isn't good enough for you?
>   That's luxury!
>   The only valid input for functions should be opcodes written in hexadecimal!

I'm wondering, what kind of instruction word this ASM-interpreter uses ...

are they more CISC- or more RISC- like ? ...

BTW: What 'bout self-modifying code ? ... that would be nice ... back to oldschool


Post a reply to this message

From: Warp
Subject: Re: function optimization question
Date: 30 Mar 2002 08:36:19
Message: <3ca5bf52@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
> I'm wondering, what kind of instruction word this ASM-interpreter uses ...

> are they more CISC- or more RISC- like ? ...

  That depends on how you define CISC and RISC.
  I don't think there are really many instructions, so one could say that
it's a "reduced instruction set". However, one typical feature of CISC is
that each instruction takes the same amount of memory and 1 clock cycle to
execute, which I don't think is the case.

> BTW: What 'bout self-modifying code ? ... that would be nice ... back to oldschool

  I doubt that you have any possibility of writing to memory.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: function optimization question
Date: 30 Mar 2002 08:58:37
Message: <chrishuff-1E06E2.08592530032002@netplex.aussie.org>
In article <3ca5bf52@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> > BTW: What 'bout self-modifying code ? ... that would be nice ... back to 
> > oldschool
> 
>   I doubt that you have any possibility of writing to memory.

Depends on what you mean by self modifying...POV-Script could probably 
output a function ASM file and then load it as a function.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 31 Mar 2002 06:47:43
Message: <3ca6f75f$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag news:3ca5bf52@news.povray.org...
> Jan Walzer <jan### [at] lzernet> wrote:
> > I'm wondering, what kind of instruction word this ASM-interpreter uses ...
>
> > are they more CISC- or more RISC- like ? ...
>
>   That depends on how you define CISC and RISC.
>   I don't think there are really many instructions, so one could say that
> it's a "reduced instruction set". However, one typical feature of CISC is
> that each instruction takes the same amount of memory and 1 clock cycle to
> execute, which I don't think is the case.

That is RISC ... the reduced instructionset normally has every opcode same
length (4Bytes on a 32Bit-architecture (look_at MIPS))... This is the criteria
I wanted to ask. OTOH CISC has different length opcodes, that are interpreted by
an microcode, where normally different runtimes for different ops can be seen ...
... of course, the time, needed for execution of an operation is not necessary the
same for all instructions of a RISC machine, too ...

I see now, that my question was not exactly formulated ...
I better should have asked: will the ASM-code more base on Load-Store-arch (which
is "quite" common for RISC) or will it be more like Work-Direct-In-Mem-arch (which
is more common for CISC) ...

> > > BTW: What 'bout self-modifying code ? ... that would be nice ... back to
> > > oldschool
> >   I doubt that you have any possibility of writing to memory.
[CJH]> Depends on what you mean by self modifying...POV-Script could probably
[CJH]> output a function ASM file and then load it as a function.

No ... this is not what I meant ... I mean, that the prog, can modify itself
in memory, to speedup execution ...
... or to make unreadable code ...


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function optimization question
Date: 31 Mar 2002 10:24:09
Message: <3ca72a19@news.povray.org>
In article <3ca5bf52@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   That depends on how you define CISC and RISC.
>   I don't think there are really many instructions, so one could say that
> it's a "reduced instruction set". However, one typical feature of CISC is
> that each instruction takes the same amount of memory and 1 clock cycle to
> execute, which I don't think is the case.

It shows some typical RISC characteristics:  Each instruction takes the same
amount of memory (usually 4 bytes or whatever two shorts in a struct will need
depending on the compiler/platform used) and it is designed as load/store
architecture.  As for execution time, basic instructions offer somewhere
around 1/10 to 1/20 of the target architecture speed.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Jan Walzer
Subject: Re: function optimization question
Date: 31 Mar 2002 10:31:07
Message: <3ca72bbb$1@news.povray.org>
ahh ... thx Thorsten ... that's what I wanted to know ...

... YES! ... /me want's this feature, accessible from Userspace (ie. not by patches)
and with _FULL DOCUMENTATION_ ... *g*


Post a reply to this message

Goto Latest 50 Messages Next 15 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.