klintan
April 20th, 2005, 08:25 AM
I'm writing a software that simulates forest growth, and it is very computing intense, e.g. for a number of trees it calculates mortality, growth, volume etc. using some quite complex formulas (typically the formulas have been created using regression analysis, and contain a number of variables that are multiplied with a number of constants).
The original version was written in Fortran 25 years ago, and I am currently re-writing it (and adding lots of new functionality) in c#. But obviously, the Fortran programs outperform my programs.
I have now come up with a number of options that would improve my performance. It has all to do with optimization of the most computing intense parts of the program, which could be done as follows:
1. Optimize the c# code, perhaps by moving all necessary variables to arrays instead of having them in objects and object collections
2. Move the critical parts to managed c++
3. Use one of the Fortran for .Net compilers available
4. Move the critical parts to a compiled dll, develop it in c++ (or Fortran), and call it via COM
Wouldn't 1-3 give the same result, don't all these methods produce IL, and the speed of the code just depends on how efficient my algorithms are?
4 could potentially be a lot faster, if I am able to move out large chunks of compuations. But, if the code in 1, 2, or 3 was efficient enough, maybe 4 wouldn't gain that much.
I read some thread where Java was compared to C in a large matrix operation, and Java was actually quite fast here.
Any comments or suggestions anyone?
The original version was written in Fortran 25 years ago, and I am currently re-writing it (and adding lots of new functionality) in c#. But obviously, the Fortran programs outperform my programs.
I have now come up with a number of options that would improve my performance. It has all to do with optimization of the most computing intense parts of the program, which could be done as follows:
1. Optimize the c# code, perhaps by moving all necessary variables to arrays instead of having them in objects and object collections
2. Move the critical parts to managed c++
3. Use one of the Fortran for .Net compilers available
4. Move the critical parts to a compiled dll, develop it in c++ (or Fortran), and call it via COM
Wouldn't 1-3 give the same result, don't all these methods produce IL, and the speed of the code just depends on how efficient my algorithms are?
4 could potentially be a lot faster, if I am able to move out large chunks of compuations. But, if the code in 1, 2, or 3 was efficient enough, maybe 4 wouldn't gain that much.
I read some thread where Java was compared to C in a large matrix operation, and Java was actually quite fast here.
Any comments or suggestions anyone?