Skip to content
Maxim Yurkin edited this page Jul 3, 2024 · 25 revisions

Quick recipe

The following seems to be the simplest way to compile the current ADDA source (master branch) in sequential mode, without administrative rights (no software is installed into the system).

  • Download the latest release of w64devkit including Fortran. The corresponding file is named like w64devkit-fortran-###.zip. Extract it into C:.
  • Execute C:\w64devkit\w64devkit.exe. This will open Unix-like console, type the following into it (use right-click instead of Ctrl+V for pasting):
    cd $W64DEVKIT_HOME
    wget https://github.com/adda-team/adda/archive/refs/heads/master.zip
    unzip master.zip && rm master.zip
    wget https://fftw.org/pub/fftw/fftw-3.3.5-dll64.zip
    unzip fftw-3.3.5-dll64.zip -d fftw && rm fftw-3.3.5-dll64.zip
    cp fftw/libfftw3-3.dll fftw/libfftw3.dll
    cd adda-master/src
    make seq FFTW3_INC_PATH=$W64DEVKIT_HOME/fftw FFTW3_LIB_PATH=$W64DEVKIT_HOME/fftw
    mkdir ../win64 && cd ../win64
    cp ../src/seq/adda.exe .
    cp ../../fftw/libfftw3-3.dll .
    

Additional notes

  • The recipe creates a fully portable folder C:\w64devkit\adda-master\win64, containing ADDA binary and the required DLL. You may then move/copy this folder anywhere (even to other systems) and execute adda.exe by any means (similar to such folder in ADDA releases).
  • If internet connection is not available, you need to download the arguments of wget on a different computer and then copy them to the production one.
  • You can extract w64devkit to any other path. However, avoid your Downloads folder due to the extra scrutiny exercised for it by anti-virus software, as well as any folder names with spaces or non-ASCII characters.
  • Anti-virus software may raise alarm for some components of w64devkit. Try to continue, since ADDA does not need many of these components (e.g., the debugger).
  • If MPI and/or OpenCL libraries are installed, the corresponding ADDA modes can also be compiled. But those libraries generally require administrative rights, so we discuss them below.
  • The same can be applied to compile any released version of ADDA (here an example for v1.4.0), by adjusting the following three lines in the above. Note however, that previous ADDA versions may have issues with modern GCC versions (e.g., 1,2). Similarly, it can be adjusted to compile any fork/branch of ADDA.
    ...
    wget https://github.com/adda-team/adda/archive/refs/tags/v1.4.0.zip
    unzip v1.4.0.zip
    ...
    cd adda-v1.4.0/src
    ...
    
  • w64devkit is one of the possible tools, that package GCC together with MinGW-w64. For instance, WinLibs provides more flexibility with respect to the settings of GCC packages. However, w64devkit contains a shell and statically links all compiler-related DLLs.
  • The only limitation of w64devkit is that its built-in shell is ash from BusyBox, rather than a full Bash. This is fine for compiling ADDA (everything below) and for simple scripts in devtools/, as well as for shell tests in tests/equiv/. However, it does not work for tests/2exec/comp2exec due to a complex Bash syntax used there. The simplest solution for the latter is to use MSYS - the latest stable package. It is grossly outdated, but its Bash v.3.1.17 is sufficient for running the ADDA tests. Just extract the archive into C:\ (effectively, it will put everything in C:\msys\) and run C:\msys\msys.bat to start the shell.

Single-shell installation

This section is also based on w64devkit, but separates this toolkit from other external libraries (to be put into C:\local) and ADDA source. Thus, each component can be updated separately without the need to start from scratch. This is naturally required if you develop ADDA yourself or test its different versions/branches. The instructions aim at compiling all ADDA modes from w64devkit shell, however, you can easily remove the unnecessary parts. Other compilers are mentioned in the end of this page. Alternatively, we had a limited success with automatic package installation by MSYS2.

  • For MPI and OpenCL versions of ADDA, first install Microsoft MPI (including SDK) and GPU driver providing OpenCL.dll. This is the only step that necessarily requires administrative rights.
  • Download the latest release of w64devkit including Fortran. The corresponding file is named like w64devkit-fortran-###.zip. Extract it into C:.
  • Execute C:\w64devkit\w64devkit.exe and further work in this shell console. The following streamlines the installation of external libraries, superseeding the instructions for FFTW3, OpenCL, clFFT, or clBLAS.
  • Get external libraries. They are not expected to be further developed, so the last versions are hardwired into the script.
  mkdir -p c:/local && cd c:/local
  wget https://fftw.org/pub/fftw/fftw-3.3.5-dll64.zip
  unzip fftw-3.3.5-dll64.zip -d fftw-3.3.5 && rm fftw-3.3.5-dll64.zip
  wget https://github.com/clMathLibraries/clFFT/releases/download/v2.12.2/clFFT-2.12.2-Windows-x64.zip
  unzip clFFT-2.12.2-Windows-x64.zip && rm clFFT-2.12.2-Windows-x64.zip
  mv clFFT-2.12.2-Windows-x64 clFFT-2.12.2
  wget https://github.com/clMathLibraries/clBLAS/releases/download/v2.12/clBLAS-2.12.0-Windows-x64.zip
  unzip clBLAS-2.12.0-Windows-x64.zip -d temp && rm clBLAS-2.12.0-Windows-x64.zip
  mv temp/package clBLAS-2.12.0 && rm -R temp
  • Obtain OpenCL headers by either:
  wget https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/heads/main.zip
  unzip main.zip && rm main.zip
  mv OpenCL-Headers-main OpenCL-Headers

or, if you have Git installed (then you can later update them by git pull):

  git clone https://github.com/KhronosGroup/OpenCL-Headers.git
  • Consolidate headers and libraries. This cotradicts the Unix philosophy, which suggests specifying include and linking paths to each of the external libraries separately, but is more convenient, while copying of OpenCL.dll is necessary anyway. Hard links are used to save disk space, they can be replaced by symlinks (-s instead of -l) if the shell is executed with administrative rights. In this case, OpenCL.dll can also be copied through a symlink.
  mkdir -p bin include lib
  cp -lR fftw-3.3.5/*.h clFFT-2.12.2/include/*.h clBLAS-2.12.0/include/*.h OpenCL-Headers/CL -t include
  cp -l fftw-3.3.5/libfftw3-3.dll clFFT-2.12.2/bin/clFFT.dll clBLAS-2.12.0/bin/clBLAS.dll -t bin
  cp -l clFFT-2.12.2/bin/clFFT.dll clBLAS-2.12.0/bin/clBLAS.dll -t lib
  cp -l fftw-3.3.5/libfftw3-3.dll lib/libfftw3.dll
  cp c:/Windows/System32/OpenCL.dll -t lib
  • Set compilation environment specifically for this shell. By default, w64devkit uses your Windows profile folder as home; placing .profile there will avoid modification of w64devkit.ini (the last line), but may potentially interfere with other shells used on the same computer.
  echo 'export PATH="c:/local/bin;$PATH"' >> .profile
  echo 'export CPATH="c:/local/include;$CPATH"' >> .profile  
  echo 'export LIBRARY_PATH="c:/local/lib;$LIBRARY_PATH"' >> .profile 
  echo 'home = c:/local' >> $W64DEVKIT_HOME/w64devkit.ini
  • Close the window and open again C:\w64devkit\w64devkit.exe. Now you can navigate to the path, where ADDA source is located (potentially under Git versioning), compile (make all) and run it (from this shell).
  • Other version of w64devkit (corresponding to different version of GCC) can be later installed instead of or in parallel to the existing one (in a different folder). The only extra setting is the specification of the home folder in w64devkit.ini (the last code line above).

Advanced options

The following aims to make both compilation and execution of ADDA binaries possible from any console, shell, or script (in contrast to that only inside w64devkit console).

To run the compiled ADDA binaries from anywhere, you need either to move all DLLs from C:\local\bin into the same folder (as in the Quick recipe above) or add this path to the PATH environmental varialbe. This can be done by:

  • press Open Run (WindowsKey + R)
  • type there rundll32 sysdm.cpl,EditEnvironmentVariables and Enter.
  • Select Path in the upper list (User variables) and press Change....
  • Press Create and type in C:\local\bin.
  • Press OK in this and the parent window. You may also add this path to system-wide Path (bottom list in the Window of environmental variables), if you have administrative rights. However, for that you need to press Cltr + Shift + Enter instead of Enter in the second step above.

To be able to compile ADDA from anywhere:

  • Add C:\w64devkit\bin to the PATH.
  • Locate the library folder of your GCC installation, someting like C:\w64devkit\lib\gcc\x86_64-w64-mingw32\14.1.0
  • Go into this folder and look for file specs. If it does not exist, execute
    gcc -dumpspecs > specs
    
  • Modify specs file:
    • Add -Ic:/local/include to end of definitions for cpp and cc1plus, changing them to, e.g.,

      *cpp:
      %{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} ... -Ic:/local/include
      ...
      *cc1plus:
      -Ic:/local/include
      
      
    • Add -Lc:/local/lib to end of definition for link_libgcc, changing it to, e.g.,

      *link_libgcc:
      %D -Lc:/local/lib
      
  • If you have several versions of w64devkit installed, the above should be repeated for each of them. The specific version used for compilation is determined by the folder, which appears first on the PATH environmental variable. Therefore, make sure that the correct version of gcc is found when executing gcc -dumpspecs > specs in the above script.

After this set-up the compilation should work from any console. Specifically, apart from the w64devkit console and aforementioned MSYS, we have tested Windows cmd and PowerShell, as well as built-in console of Far Manager (v3.0 x64). There is, however, an issue with Git Bash (installed with Git for Windows) - it breaks compilation in OpenCL mode, probably due to some inconsistent handling of line endings when sed ... is applied to oclkernels.cl in ocl/Makefile. The workaround for the latter is to use OCL_READ_SOURCE_RUNTIME compilation option.

Notes on 32-bit Windows

Since version 1.4 we do not provide 32-bit executables, since some of the external libraries, such as clFFT and clBLAS, are not immediately available in this format. Moreover, we believe that it is overall a bad idea to run ADDA on such systems due to limited available RAM. However, there are no principal internal limitations in ADDA. Therefore, if you really want to compile ADDA for 32 bit Windows, that is possible. We give brief notes on that in the following:

  • Follow the above guidelines for 64-bit Windows, but select the GCC package for Win32 (i686).
  • All external libraries should be for 32-bit Windows. If you can't find some libraries either compile them yourself or avoid them by compilation options.
  • If you compile 32-bit executable in 64-bit Windows and use system DLLs for linking (e.g. OpenCL.dll), use the ones from C:\Windows\SysWOW64 instead of C:\Windows\System32.

Other compilers

Using a different compiler should be easy if it uses the same MinGW-w64 framework and the corresponding system libraries, although we do not have experience with that.

By contrast, using compilers based on Visual Studio implementation of system libraries leads to many problems with respect to existing Makefile. A popular compiler of this type is the Intel compiler (for Windows), both Classic and new oneAPI versions. We provide a workaround batch script for that (src/iw_compile.bat), which provides the simplest ADDA compilation (corresponding to make seq). Look inside this script for details on its usage, including the installation of Intel compilers and Visual Studio environment. It is also possible to fully employ the capabilities of Visual Studio (for code exploration and debugging) at the cost of manual project setup, as described here.

Clone this wiki locally