- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have converted an existing Fortran program, which does many iterations of calculations, to C and found that the Fortran runs about 4 times slower than the C version. The results of the two programs match exactly. I expected the Fortran version to be faster than the C version so I must be doing something wrong. The Fortran version is strictly Fortran 77 code compiled with the Intel compiler and the C version is compiled with the Microsoft C compiler and bothwerecreated in Visual Studio 2005. I did the timing tests by running the "release" versions of both programs, not the "debug" versions, outside the IDE from a BAT file. Any ideas? During the Fortran compilation I get messages like "Loop was vectorized", "Permuted loop was vectorized" and "partial loop was vectorized". For example, I get the message twice for the following piece of code which is not nested in any other loops (these are all single dimension COMMON integer arrays and MAXART is a COMMON integer):
[cpp] DO 5 I = 1, MAXART ARTCL(I) = 0 ARTRK(I) = 0 ARTPR(I) = 0 ARTCLS(I) = 0 NUMSIG(I) = 0 IF (I .LE. 10) YNSAT(I) = .FALSE. 5 CONTINUEDo these messagesadversely affect the speed? The Fortran timing was calculated by calling CPU_TIME at the beginning and end of execution.
[/cpp]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That you got those messages suggests to me that you have nested loops going through an array in the "wrong order" for Fortran, causing memory accesses to skip around. C stores arrays in "row-major order", where the rightmost subscript varies the fastest, but Fortran uses "column major order" where the leftmost subscript varies the fastest. If you directly translated the code and didn't reverse the order of the subscripts, you'll hurt performance. Evidently, the compiler tried to help you in some places, but perhaps was not able to do it everywhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
That you got those messages suggests to me that you have nested loops going through an array in the "wrong order" for Fortran, causing memory accesses to skip around. C stores arrays in "row-major order", where the rightmost subscript varies the fastest, but Fortran uses "column major order" where the leftmost subscript varies the fastest. If you directly translated the code and didn't reverse the order of the subscripts, you'll hurt performance. Evidently, the compiler tried to help you in some places, but perhaps was not able to do it everywhere.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page