- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello everyone,
I have this problem, hope that you can help me out:
There is a subroutine in Fortran code that has been given to me. This Fortran code is acually a simulation model of a physical process, so there is a criteria of simulation speed. I compiled the Fortran code into a DLL file.
Then the DLL subroutine is called from a Fortran program by using Windows API functions LoadLibrary and GetprocessAdress, it gives a the speed ratio of 770 which means that it takes 1 second to simulate the physical process in 770 seconds real time
Next, i do the same thing but this time in C++, and this gives me a speed ratio of 380 which is 2 times slower than the calling from Fortran program
i have tried to get through the problem by setting the Runtime library option when compiling C++ program to "Multithreaded DLL" which was set to the DLL but it did not resolve the problem
Anyone has any idea of what has happened with the call from C++?
Thanks for your help,
Link kopiert
- « Vorherige
-
- 1
- 2
- Nächste »
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
i have made a dll without anny input argument (something like "void DLL(void)"), then i simply call the function from both C/C++ and Fortran (there is no loops this time) the program C/C++ is always much slower than Fortran program
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Show all code. Show all compiler options.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
For Fortran projects you can see the compile options in effect by right clicking on the project in the Visual Studio solution explorer and selecting Properties, then Fortran > Command line.
You don't show the code for the DLL.
Those two console window screenshots appear to have different working directories. Are you loading exactly the same DLL? How do you ensure that?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
The fact that the factor between the two cases is very close to two is suspicious. Is the CPU_TIME result printe by the program consistent with the elapsed time measured by your wrist watch?
The source code for the DLL is incomplete - you've only provided one subroutine. That means readers of the forum can't compile your code and investigate things - they have to "head compile" what you've provided and hope that things that are called are inocuous. Speaking for myself - my head compiler is notoriously buggy at the best of times. If you don't want to post the full source, then chop it down yourself to a compilable and linkable subset that still exhibits the problem (as a debugging/diagnostic strategy you should be doing this anyway). Otherwise we're all guessing.
What options are you using for the C program?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
yes, it is correct compared to wrist watch
IanH wrote:
The fact that the factor between the two cases is very close to two is suspicious. Is the CPU_TIME result printe by the program consistent with the elapsed time measured by your wrist watch?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
i did copying from folder to folder to assure comparability, but its was not good. Now, i copy 2 .exe file to the same folder and it gives same results. im sorry for that,
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
here are calling programs from dev-c++ and Visual Fortran, i dont understand why there is a slight difference in the result(comparison.JPG)
LanH, I can't find away to show all compiler option for you, is there a particular part you want to see?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
steve, you can see the fortran code in .f90 and the C++ one in .cpp, .h files. bmchenrry, i used dev-c++ and intel fortran, the results are identical with both fortran and C++
Thx
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
linker option for DLL and calling program

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite
- « Vorherige
-
- 1
- 2
- Nächste »