Compiled simulation error with Vensim DSS 8.0.9 x64

Use this forum to post Vensim related questions.
Post Reply
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

I have been unsuccessfully trying to configure Vensim DSS 8.0.9 x64 to simulate using the MS Visual Studio 2012 compiler.

Here is a screenshot of the error message that is produced:
error.png
error.png (149.86 KiB) Viewed 7054 times

I worry about "The specified configuration type is missing. The tools for the configuration might not be installed." What could that mean?
Also, it gives a hint that the command CL is either mistyped or unable to be found.

Contents of File 'MDLDP64.bat'

Code: Select all

@Echo Compiling Vensim model ...
@ECHO OFF

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"

if exist mdl.obj del mdl.obj 
if exist %3.dll del %3.dll
if .%2 == . goto noinclude

REM Create Debug DLL
REM echo Creating debug DLL
REM CL /GS /DEBUG /c /I "%2" /Zi /arch:SSE2 /Gd /Oy- /Od /D_DEBUG /MTd /DDBLPREC /DWIN32 /D_WIN32 mdl.c 

REM Create optimized DLL
echo Creating optimized DLL
CL /O2 /c /I "%2" /DDBLPREC /DWIN32 /DWIN64 /Dx64 /D_x64 /D_WIN32 /D_WIN64 mdl.c 

goto aftercomp

:noinclude
REM Create Debug DLL
CL /DEBUG /c /Zi /Od /D_DEBUG /MTd /DDBLPREC /DWIN32 /D_WIN32 mdl.c 
REM Create optimized DLL
CL /O2 /c  /DDBLPREC /DWIN32 mdl.c 

:aftercomp
if errorlevel 1 goto :error1
if not exist mdl.obj goto :error2

REM Add /DEBUG as an option to generatea a debug DLL.
LINK /DLL /OUT:%3.dll /def:%1sim.def mdl.obj /MACHINE:X64 

if errorlevel 1 goto :error3
if not exist %3.dll goto :error3

REM clean up .lib and .exp files - they are not needed 
del %3.lib
del %3.exp

goto :exit

:error1
echo Unable to compile - failed to set paths. Check the paths in mdldp.bat in vensim\comp
goto exit2

:error2
echo Unable to compile - missing mdl.obj.  You probably need to set paths in mdldp.bat in vensim\comp
goto exit2

:error3
echo Errors while linking %3.dll  - make sure compiled simulations were properly installed
goto :exit2

:exit2
pause
goto :exit3

:exit 
echo ----------
echo Compilation of %3 seems to have been successful.  
echo Close this window and continue.

:exit3
Line 4 from above, "call "C:\Program Files....." points to an existing file "vcvarsx86_amd64.bat". In Vensim, I configured the compiled simulation with

> Tools > Options > Advanced > Compiled simulation path > PATH/TO/MDLDP64.bat

and

> Tools > Options > Advanced > set the three ticks for "Compile"

Do you have any idea what could be wrong in this configuration? I appreciate any help or info on how to resolve it.
Administrator
Super Administrator
Posts: 4680
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by Administrator »

What happens if you open a command prompt and enter
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat

Then type
CL

If the compiler is set up correctly, CL should run and give you an error.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

This is the output I get in my cmd-window. Did I do it as you intended?
cmd_cl.PNG
cmd_cl.PNG (13.96 KiB) Viewed 7050 times
Administrator
Super Administrator
Posts: 4680
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by Administrator »

Yes, that's correct. And the output I expected.

Can you edit your mdldp64.bat and enter the word pause at the top and save. Then run the compilation process again, the batch file should pause immediately. I'm trying to work out if the correct mdldp64.bat is being called.

Code: Select all

pause
@Echo Compiling Vensim model ...
@ECHO OFF

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3868
Joined: Wed May 24, 2006 4:54 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by tomfid »

I'm guessing that VC 2012 is too old to support the x64 configuration flags that are used. The "configuration type missing" message seems to indicate that - I think it's a Microsoft message, not a Vensim message.

It might be possible to modify the installation to include whatever's missing, but it might be easier to install VC2019 (the community edition is free if you meet the license requirements).
Administrator
Super Administrator
Posts: 4680
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by Administrator »

VC 2012 should be ok Tom. Running the batch file and then CL shows it's set up for x64.

My guess is that the wrong batch file is being called to perform the compilation.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3868
Joined: Wed May 24, 2006 4:54 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by tomfid »

Another way to check that would be to change one of the echo lines to a unique message, like

echo Creating optimized DLL FROM MDLDP64.BAT

An independent test of the compiler would be to navigate the cmd window to the model folder where the generated mdl.c lives, then manually test:

> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
> CL /O2 /c /I "%2" /DDBLPREC /DWIN32 /DWIN64 /Dx64 /D_x64 /D_WIN32 /D_WIN64 mdl.c

If that works, then there's definitely something going wrong with the script.
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

Thanks for your help @tomfid and @Administrator.

I won't be in office until tomorrow to try out the tests you recommended. Once I return there, I will test it.
tomfid
Administrator
Posts: 3868
Joined: Wed May 24, 2006 4:54 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by tomfid »

Any luck?
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

Sorry for the delay, I didn't get to test it again until yesterday.

I could figure out that the compiled simulation wasn't working due to a wrong configuration. In the vensim settings, I configured a mdl.bat which pointed to the wrong location in the Visual Studio\bin directory.

I got it to work now, but some questions still remain unsolved: I tested the compiled simulation on two separate workstations. On one with Vensim 8.0.9 32-bit Double Precision and on the other with Vensim 7.3.5 32-bit Single Precision. The computing time of the simulation itself was about the same (in regard to different computing performance on each workstation).

On the first step after starting the simulation, which is generating the mdl.c and mdl.obj for the model (compiling model equations), rather big differences occured: for the Vensim 7.3.5 Single Precision version, it took only about 5 seconds to complete, while on the Vensim 8.0.9 Double Precision version, it took about 62 seconds.

Is this much of a difference normal and only depending if single or double precision is being used, or could it have another cause?
Administrator
Super Administrator
Posts: 4680
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by Administrator »

Must be either different compilers, or optimization settings for the compiler.

Are you using the same compiler on both machines?

And the line beginning "cl" in mdl.bat, what /O switches are on each?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3868
Joined: Wed May 24, 2006 4:54 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by tomfid »

The /O2 switch can make a big difference to compile time. In my limited experience the effect on run time is smaller, but still worth it if your run will be long.

It's also my impression that Viz Studio 2019 is a lot faster than 2015-2017. I haven't really tested side by side though.
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

Administrator wrote: Wed Feb 03, 2021 12:51 pm Must be either different compilers, or optimization settings for the compiler.

Are you using the same compiler on both machines?

And the line beginning "cl" in mdl.bat, what /O switches are on each?
Machine 1 is using Visual Studio 2010 with compile statement

Code: Select all

CL  /c /I "%2" /DWIN32 mdl.c
Machine 2 is using Visual Studio 2012 with compile statement

Code: Select all

CL  /O2 /c /I "%2"  /DDBLPREC /DWIN32 /arch:SSE2 mdl.c 
I didn't change this statement and left it as installed.
tomfid wrote: Wed Feb 03, 2021 4:02 pm The /O2 switch can make a big difference to compile time. In my limited experience the effect on run time is smaller, but still worth it if your run will be long.
To test the difference, I first removed the /O2 option and didn't see any visible notification for compiling model equations. Hence, the overall simulation process from start to end was a lot faster, but the simulation itself was about 50% slower. That was to be expected when removing the /O2, right?

When replacing /O2 with /O1 the compiling model equations task still took about 50 seconds, while the simulation itself was about the same speed as before (with /O2).
tomfid wrote: Wed Feb 03, 2021 4:02 pm It's also my impression that Viz Studio 2019 is a lot faster than 2015-2017. I haven't really tested side by side though.
I will try that out, thanks!

Also, I will post all the results I recorded once I am finished with the testing. I guess it will be interesting for other users as well.

Some time this year, we will probably run optimization/calibration tasks for many subscripted variables in quite big models, which will take weeks to complete. We are automating it with a dedicated C#-application which is utilizing the Vensim-DLL. Therefore, computing time is a big factor in the process.


Thanks a lot for your help!
tomfid
Administrator
Posts: 3868
Joined: Wed May 24, 2006 4:54 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by tomfid »

To test the difference, I first removed the /O2 option and didn't see any visible notification for compiling model equations. Hence, the overall simulation process from start to end was a lot faster, but the simulation itself was about 50% slower. That was to be expected when removing the /O2, right?
This is what I'd expect, though I would have guessed 10-20%, not 50%. There's quite a bit of variation due to model specifics though.
devM5
Junior Member
Posts: 18
Joined: Fri Jul 03, 2020 10:41 am
Vensim version: DSS

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by devM5 »

The difference may also come from me operating the stopwatch late in the evening, so it could be less :D

I will check it again.
Administrator
Super Administrator
Posts: 4680
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled simulation error with Vensim DSS 8.0.9 x64

Post by Administrator »

If you search the Web for Microsoft c++ compiler optimization settings, you might find one that works well for you. I've always used /O2 rather than /Os.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply