Jump to content

+= In Vops ?


SvenP

Recommended Posts

Yes, use a a For (loop) VOP. Create a Constant VOP and name its variable as total_opac. Wire it into the For loop VOP. Inside the the For loop VOP, Add your computation to the total_opac input and wire the result into the output vop. Outside the For loop VOP, you can then take the result from the total_opac output.

Link to comment
Share on other sites

Yes, use a a For (loop) VOP. Create a Constant VOP and name its variable as total_opac. Wire it into the For loop VOP. Inside the the For loop VOP, Add your computation to the total_opac input and wire the result into the output vop. Outside the For loop VOP, you can then take the result from the total_opac output.

23721[/snapback]

So edward, the Constant VOP is like to declare a variable?

Is strange that you can change the value of a constant, or not?

Link to comment
Share on other sites

I suppose but that's how the code is generated. The value coming out of the Constant VOP is certainly a constant. What you do with the constant afterwards is a different story. In the VOP network, you're not really outputting the constant but a particular output from the For loop VOP.

Link to comment
Share on other sites

I suppose but that's how the code is generated. The value coming out of the Constant VOP is certainly a constant. What you do with the constant afterwards is a different story. In the VOP network, you're not really outputting the constant but a particular output from the For loop VOP.

23738[/snapback]

I used to use the Parameter VOP to create variables for the For and IF VOP.

Link to comment
Share on other sites

So edward, the Constant VOP is like to declare a variable?

Is strange that you can change the value of a constant, or not?

23732[/snapback]

Isn't it more like that every outpt of a VOP node can be seen as a new variable? So feeding a constant into an addition VOP doesn't change the constant, but creates a new variable with the summed value. Even newer compilers (C/C++) introduce new variable names when optimizing code (and perhaps so does the vex compiler, too?). This is called SSA (single static assignment) and is for example implemented in gcc4. This optimization step removes all reassignments of a variable with assignments to new variables. So a variable never changes its value. An example will clarify my vague explanations above:

You may have a piece of code like the following:

int a=b+c;
doSomething(a);
a += d;
doSomeOtherThing(a);

It is equivalent with the following code:

int a=b+c;
doSomething(a);
int e = a+d;
doSomeOtherThing(e);

In the second version a variable never changes it's value and can therefore be seen as a "constant".

A compiler might even generate the second version as an intermediate step before generating assembly code.

I hope this wasn't too technical and confusing ;-)

Link to comment
Share on other sites

Isn't it more like that every outpt of a VOP node can be seen as a new variable? So feeding a constant into an addition VOP doesn't change the constant, but creates a new variable with the summed value. Even newer compilers (C/C++) introduce new variable names when optimizing code (and perhaps so does the vex compiler, too?). This is called SSA (single static assignment) and is for example implemented in gcc4. This optimization step removes all reassignments of a variable with assignments to new variables. So a variable never changes its value. An example will clarify my vague explanations above:

....

In the second version a variable never changes it's value and can therefore be seen as a "constant".

A compiler might even generate the second version as an intermediate step before generating assembly code.

I hope this wasn't too technical and confusing ;-)

23777[/snapback]

Thanks Frank for clearing it.

So for optimization pourposes the code generator treats all the variables like constant, creating new variables for every operation result.

Why is better to use a new variable than using an existing variables and reasigning it, in both cases you assing a value to something.?

Link to comment
Share on other sites

Well, I don't really know much about this and even less how the vex compiler handles it.

For a deeper explanation of SSA you can take a look at the explanation on the wikipedia page: http://en.wikipedia.org/wiki/Static_single_assignment_form

There they have a nice example, why this might be usefull.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...