RE: [Dev-C++] Mixed Language Programming w/Dev-Cpp
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-10-30 20:28:06
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Wednesday, October 30, 2002 2:11 PM > To: Marc Heiligers > Cc: Ioannis Vranos; Dev-C++ Mailing List > Subject: RE: [Dev-C++] Mixed Language Programming w/Dev-Cpp > > > When you have declared > double a[10][10] > it is quite important to know in which order the individual values are > stored in memory, when trying to interface between two languages. > > If your C program does a[x][y] and your Fortran program has do do > a[z][y] to reach the same entry. No problem when you have all three > index variables available. It's a syntax matter. As far as i can guess Fortran implementation is not required to store them in that order. > However, when you take a pointer to a an entry inside the array, the > operation might be seen as a projection down to an array with fewer > dimensions. Obviously, if the entry order in memory has been > transposed, > the such a projection will fail misserably when switching > languages. The > sender thought it sent a row, but the receiver got a column. > > When people originally started to push for the C language, the above > problem gave rise to a related problem. When referencing large memory > structures, it is important to assure that the code uses locality of > reference and doesn't jump around everywhere in the data. Large linear > packages are always implemented so that they process entries > in the same > order that they are stored in memory. When converting such an > algorithm - > might be thousands uppon thousands of lines of code - it > isn't s easy to > just try and adjust for row/column switches. The result is that a C > translation of a Fortran algorithm might loose 10-30% or > maybe more of the > speed when the same Fortran algorithm was run. Why? > The mathematical world decided that C was a slower language > :-) Well, one of the reasons that Fortran is fast is because it is heavily optimised during those years and not because its syntax is close to the metal. Now this doesn't apply anymore. Check the following: http://csweb1.cs.tamu.edu/seminars/dlecture/abstracts/stroustrup.MPP-sli des.pdf where it has the graphh with the title "Uncompromising Performance". > Nowadays, > there are a lot of good algorithms originally written for C, > so this issue > shouldn't be a problem anymore. But still, there are some billion > Fortran lines of optimized and very advanced mathematics > algorithms out > there. Yes there are indeed. Btw, Fortran has the notion of pointers? Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |