Skip to content
Maxim Yurkin edited this page May 22, 2024 · 4 revisions

This summarizes our experience of using MSYS2 on Windows. The main motivation (in comparison with MinGW) is that it has built-in package manager, allowing automatic handling of many dependences. It can be helpful for automatic builds in GitHub Actions (example). It is also convenient by being completely isolated from the rest of the Windows (by default), hence can be used in parallel to any other toolchains. But it has some drawbacks, so it is not yet the default development platform for Windows.

Compiling ADDA

First, install MSYS2 following the guidelines at https://www.msys2.org. They include installation of basic development toolchain

pacman -S --needed base-devel mingw-w64-x86_64-toolchain

and running special terminal "MSYS MinGW 64-bit" from Start menu (it will set the environment).

Second, position yourself into ADDA /src/ folder and run

pacman -S mingw-w64-x86_64-fftw
make seq
pacman -S mingw-w64-x86_64-msmpi
make mpi
pacman -S mingw-w64-x86_64-opencl-icd mingw-w64-x86_64-opencl-headers
make ocl OPTIONS=CLFFT_APPLE

Package installations need to be performed only once (each line is necessary for the specific ADDA version, but FFTW one is needed for all of them). Moreover, these installations require confirmations (just press Enter). The latter can be avoided by adding --noconfirm but that is not recommended, since pacman is not considered fully robust.

MS-MPI package can be omitted, but if used it replaces the separate installation of msmpisdk.msi. Still, any of these options require separate installation of runtime libraries (see instructions).

clFFT package is not yet available inside MSYS2, but can be installed the same as when using MinGW. The same applies to clBLAS. Thus, only the fallback Apple clFFT can be fully automated. GPU drivers supporting OpenCL are also required (see instructions).

The above receipt produces executables that can be run immediately from this terminal, with exception of MPI version, since mpiexec is not directly available (can probably be manually added to PATH variable internal to MSYS2). To run them in any other Windows terminal, one needs to provide a number of libraries from ...\msys64\mingw64\bin\ (...\msys64 is the installation path of MSYS2). Either add this path to the system PATH or copy the following files to the folder with ADDA binaries (suitable for distribution):

libfftw3-3.dll
libgcc_s_seh-1.dll
libgfortran-5.dll
libquadmath-0.dll
libwinpthread-1.dll
libOpenCL.dll
libstdc++-6.dll

The last one is required only for Apple clFFT.

If additionally ...\msys64\mingw64\bin\ is added to the system PATH, then compilation can also be performed from any terminal and, hence, makes the MSYS2 toolchain useable from any IDE.

Existing issues

  • Produced executables are slower (by about 10%) than MinGW ones - tested for version d7e6169 with adda -grid 128 -size 10. Specifically, 88s for MinGW, 95-97s using only MSYS2, 92s using MSYS2 binaries with MinGW DLLs (apart from libgfortran-5.dll that was still from MSYS2). So it is partly related to some MSYS2 libraries, that are, in turn, related to that of Cygwin. However, the MinGW+GCC toolchains were also different in these tests. This requires further study.
  • The choice of toolchains affects the list of DLLs that need to be distributed with ADDA binaries. Current MinGW compilation does not require any additional MinGW-specific DLLs (see win64/). It is not clear, whether the same can be accomplished with MSYS2. In particular, currently MSYS2 leads to dependence on libgfortran-5.dll and, through it, on libgcc_s_seh-1.dll, libquadmath-0.dll and libwinpthread-1.dll.
  • clFFT and clBLAS are not available as packages. It is not expected to be fixed soon, since MSYS2 packages are based on GCC (MinGW) toolchain (link), while clFFT and clBLAS have Windows makefiles only for Visual Studio (link).
  • Dependence on libOpenCL.dll seems to be redundant, since using OpenCL.dll (available with GPU drivers on Windows) should be sufficient. In particular, we tested renaming the system OpenCL.dll into libOpenCL.dll and placing it near the binary.
  • A known problem with MSYS2 terminal (mintty) - it buffers (hides) ADDA output till the end of simulation. Can be circumvented by -so_buf line.
  • While it is possible to compile ADDA obtained anyhow through Windows (e.g., direct download or git clone from MinGW), we have encountered problems with running tests in tests/2exec. They can be solved by doing everything (starting from git clone) in MSYS2.
Clone this wiki locally