Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow selection of static or dynamic linking of simulation executable in OMEdit #7534

Closed
casella opened this issue Jun 9, 2021 · 23 comments
Closed
Assignees
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit
Milestone

Comments

@casella
Copy link
Contributor

casella commented Jun 9, 2021

Description

In 1.17.0, we introduced dynamic linking of simulation executables under Windows, to reduce the overall time spent from clicking the Simulate button to getting the simulation results. This time was substantially reduced, but some users are reporting DLL hell issue, see e.g. #7525

Although keeping dynamic linking as default makes sense for most users, we should ad an option in OMEdit to allow getting back to static linking, if one wants to have a standalone .exe file for some reason.

@adrpo
Copy link
Member

adrpo commented Jun 10, 2021

@casella we can do this via:

  1. a new parameter in buildModel|translateModel(..., linkType="static|dynamic")
  2. a command line config flag --linkType="static|dynamic"
    which one would be preferable?

The second one doesn't need to be set for each model.
The first one can have a default to "dynamic" and if you want "static" is an explicit user choice which does not remain for the next model. Myself I prefer this one.

@sjoelund
Copy link
Member

I think a command-line flag would be preferable. However, there is no static linking on Linux/MacOS, so it might be a bit weird that it does nothing...

@adeas31
Copy link
Member

adeas31 commented Jun 10, 2021

The second one has advantage in the case of #7525. Think of a user who always want to use static linking. For such user first option will be annoying to set for each model every time.

@adeas31
Copy link
Member

adeas31 commented Jun 10, 2021

I think a command-line flag would be preferable. However, there is no static linking on Linux/MacOS, so it might be a bit weird that it does nothing...

We only do it for Windows. I can also make it in OMEdit to only show controls when is running on Windows.

@sjoelund
Copy link
Member

sjoelund commented Jun 10, 2021

We only do it for Windows. I can also make it in OMEdit to only show controls when is running on Windows.

But if you want to hide the flag from omc --help, it would need to be an internal flag. But why would we hide such a flag from the documentation, etc?

Edit: Then again, we have the --target flag which does nothing on Linux either

@casella
Copy link
Contributor Author

casella commented Jun 10, 2021

I don't think it is a problem if some flags don't have any effect on some OSs. Maybe we should issue a warning if an option which is not available on the local OS is selected.

The command line flag has the advantage that it can be set in a vendor-specific annotation, similarly to other ones affecting compilation like "-O0".

@casella
Copy link
Contributor Author

casella commented Jun 22, 2021

As the comments in #7594 point out, there are some users (e.g. at EDF) that use the generated .exe outside OMEdit, possibly on a different computer. For portability, statically linked simulation executables are of course a lot better.

@felixmarsollier2 is still using 1.16.5 because of that, as with the case of ABB we should avoid at all cost having users stuck to old OMC versions because of this kind of issues. It would be really bad if he could not use 1.18.0, nor the forthcoming 1.19.0-dev nightly builds.

I would recommend to implement the command-line feature in 1.18.0. This is a special feature that is only useful in a small number of cases, so having to set it in each and every model is not a big deal - one would just set it as default in Tools|Options, and get that automatically in all models.

@adeas31, @adrpo, can we fit this in 1.18.0? This issue is actually a regression for people like @felix-marsollier2

@casella casella mentioned this issue Jun 22, 2021
23 tasks
adrpo added a commit to adrpo/OpenModelica that referenced this issue Jun 26, 2021
- add a new argument to Compile.bat linkType
- fix the code in omc when calling Compile.bat
- fix the code in OMEdit when calling Compile.bat
  new dialog needed, maybe a checkbox or dropdown
  with dynamic|static
@adrpo
Copy link
Member

adrpo commented Jun 26, 2021

Should be fixed with PR #7618, @adeas31 you can push to this PR if you want to make a new Qt dialog for this setting, or you can make a new PR. Your choice.

@casella
Copy link
Contributor Author

casella commented Jun 29, 2021

@felix-marsollier2, please try the new nightly build, you should now be able to get a statically linked .exe simulation file and use it anywhere.

@casella casella added this to the 1.18.0 milestone Jun 29, 2021
@felix-marsollier2
Copy link

Hi Everyone,

I tried with the version v1.18.0-dev-386-g13ce53237a, it seems that the flag do not generate error but the exe is still no longer portable. There are messages regarding missing DLL. Maybe I did something wrong during my process.

@adeas31
Copy link
Member

adeas31 commented Jul 5, 2021

Is it for some specific Modelica model? Which dll is missing?

@casella
Copy link
Contributor Author

casella commented Jul 5, 2021

Can you please post the missing DLL error in its entirety? Maybe something was forgotten in the static linking process.

@adrpo
Copy link
Member

adrpo commented Jul 5, 2021

I will check it again, maybe I missed something.

@felix-marsollier2
Copy link

Is it for some specific Modelica model?
I have tried with the model "TwoMasses" from Modelica.Thermal.HeatTransfer.Examples package (MSL3.2.3 but I think has no importance).

Before that, to select static linking, I went to Tools -> Options -> Simulation then I added in the Additional Translation Flags: --linkType=static
I restarted OMEdit to be sure that the flag is catched and stored. I ran the model that has generated the output files in the temporary folder. Then I copy pasted from the temporary folder either the folder or the exe itself to an other directory. I ran again the exe and the following errors were raised.

Which dll is missing?
Missing libsundials_kindsol.dll on my computer
Missing libsundials_idas.dll on my computer
Missing libsundials_cvode.dll on my computer
Missing libsundials_nvecserial.dll on my computer

What is strange is that I used the dassl solver where here, the error messages seem like refering to unused solvers

@felix-marsollier2
Copy link

Moreover when I run again the exe from the temporary folder, the same messages of missings dll appear.

@sjoelund
Copy link
Member

sjoelund commented Jul 6, 2021

What is strange is that I used the dassl solver where here, the error messages seem like refering to unused solvers

All solvers are linked to the simulation executable. You can select solver as a command-line argument.

@adeas31
Copy link
Member

adeas31 commented Jul 6, 2021

That is not how you use it from OMEdit.
Go to Tools->Options->Simulation and check Use static linking checkbox. Remove --linkType=static from Additional Translation Flags.

@felix-marsollier2
Copy link

That is not how you use it from OMEdit.
Go to Tools->Options->Simulation and check Use static linking checkbox. Remove --linkType=static from Additional Translation Flags.

That has worked well. Thanks again

@casella
Copy link
Contributor Author

casella commented Jul 6, 2021

@adeas31, for the record, why isn't --linkType=static enough to get rid of all DLL dependencies?

@casella
Copy link
Contributor Author

casella commented Jul 6, 2021

I just opened #7659 to improve the documentation of the flag. I also noticed a problem with the documentation formatting, so I opened #7661 about it.

@adeas31
Copy link
Member

adeas31 commented Jul 6, 2021

@adeas31, for the record, why isn't --linkType=static enough to get rid of all DLL dependencies?

It should be enough if OMEdit uses the compile process as omc does. OMEdit compiles the model by directly calling the compilation script and then passes the link type value based on the checkbox i.e., static or dynamic. So even if we set --linkType=static, it will be overwritten.

@casella
Copy link
Contributor Author

casella commented Jul 6, 2021

OK, so the --linkType flag would work fine if I set it with the API function setCommandLineOptions() in a .mos script?

@adrpo
Copy link
Member

adrpo commented Jul 6, 2021

Yes, if you then call simulate or buildModel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit
Projects
None yet
Development

No branches or pull requests

5 participants