Thu, 19 Jul 2007 21:54:47 -0000

Related articles |
---|

Efficient Evaluation of Image Expressions hermann.rodrigues@gmail.com (Hermann) (2007-07-18) |

Re: Efficient Evaluation of Image Expressions torbenm@app-2.diku.dk (2007-07-19) |

Re: Efficient Evaluation of Image Expressions tmk@netvision.net.il (Michael Tiomkin) (2007-07-19) |

Re: Efficient Evaluation of Image Expressions Ibeam2000@gmail.com (Nick) (2007-07-22) |

Re: Efficient Evaluation of Image Expressions hermann.rodrigues@gmail.com (Hermann) (2007-07-23) |

Re: Efficient Evaluation of Image Expressions Ibeam2000@gmail.com (Nick) (2007-07-30) |

Re: Efficient Evaluation of Image Expressions Ibeam2000@gmail.com (Nick) (2007-08-01) |

From: | Michael Tiomkin <tmk@netvision.net.il> |

Newsgroups: | comp.compilers |

Date: | Thu, 19 Jul 2007 21:54:47 -0000 |

Organization: | Compilers Central |

References: | 07-07-066 |

Keywords: | optimize |

Posted-Date: | 19 Jul 2007 18:21:03 EDT |

On Jul 18, 11:40 pm, Hermann <hermann.rodrig...@gmail.com> wrote:

*> I have a language used perform map/image algebra calculations using*

*> expressions like the following: ...*

*> Simple expressions, like the one above, have good performance, but if*

*> the expression gets more complicated, the evaluation process becomes*

*> painfully slow. Any advice?*

Well, you can easily compile it to C/C++ - change 'abs' to 'fabs',

and 'if x then y else z' to '((x)?(y):(z))', and create a function

with the given parameters that returns the corresponding value. This

translation can be done in one pass on the tree, but you might need to

add the function header at a later stage if you do not know the number

of parameters in advance. Compile this function, link it to your

module or load it from a dynamic library (if you want to compile it as

a part of computation), and call it whenever you need evaluation.

If you do not know the number of parameters, and this number can be

very large, you might need a bit of inlined assembly to put the

corresponding values on the stack, or alternatively pass the

parameters as an array.

Michael

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.