CERN Accelerating science

You are here

Beta-testing Molflow on Windows, Linux and Mac

2018-10-09 16_14_20-PowerPoint Slide Show  -  Presentation1.png

In the last months, apart from introducing small updates in the "main fork", Molflow has been significantly rewritten under the hood. Although the original code was written mostly in a platform-independent way, several features were calling Windows-specific features:

  • Molflow was doing calculations through subprocesses. These were separate programs (instances of molflowSub.exe), and the communication with the interface was done via non-persistent memory-mapped files. Memory-mapped files are "virtual" files that exist only in the memory and are destroyed when the process ends. There is no portable way to create such memory-mapped files.
  • The file open/save dialogs were displayed using Windows functions
  • Opening/saving Zip and Geo7Z files used ZipUtils, a Windows-only library and 7-zip, a Windows-only binary file
  • Using the clipboard was Windows-specific
  • Many 3rd party libraries (PugiXML, libPNG, Clipper, GNU Scientific Library, etc.) were included in 64-bit Windows static libraries.

Porting to Linux and Mac became possible mainly because as of late 2018, the new C++17 standard is finally reliably supported by both Visual Studio and the GCC compiler (Mac and Linux). This new version of the C++ language allows standard functions to handle tasks such as multithreading, filesystem operations and automatic types. For a developer, it means that you can, for example, get the folder path of a file using a standard function, without having to worry whether folders are separated by a / or \ character on the current operating system. In short, you write a high-level code, and the compiler will take care of the rest.

The porting process went through the following steps:

  • Migrating from SDL 1.2 to SDL2 framework (rewriting mouse wheel, text input, graphics window handling). Using SDL2's built-in clipboard handling, I could get rid of Windows-specific copy/paste
  • Changing the multi-process parallelism to multitreading: from now all data (geometry, settings) exists only once in memory, and is guarded against concurrent writing by mutexes. No more molflowSub.exe are present, instead one executable is spawning multiple threads.
  • All libraries were compiled from source for the different distributions, so they can be linked under Linux and Mac
  • Mac-specific modifications were done (inverting mouse wheel, replacing Ctrl with the Command button)
  • Replacing the Zip library with a cross-platform one, and rewriting the app updater to use only C++ filesystem commands
  • Replacing file dialogs with a cross-platform library

Now, while most of the code has changed substantially, the user should not notice any change at all. Since the geometry exists only once in memory, the ram usage is somewhat lower, and the multithreading model is between 5-10% slower compared to the multi-process version (2.6.x). Yet, I believe that by developing a cross-platform, open-source code using modern C++ features, Molflow is future-proofed a bit more.

You can download the beta versions here, and read the instructions for Linux and for Mac. They'll go out of beta as soon as I can make proper testing on Linux and Mac environments. Then I'll "push" the new version through the auto-updater.

Meanwhile, I welcome any reports of bugs and glitches in the forum.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer