Preamble
Suppose you have written a file named logfunc.cpp
containing an implementation of your mathematical objective function and a main.cpp
file containing call(s) to the ParaMonte routines of your choice to sample the objective function.
The corresponding required logfunc.hpp
and paramonte.hpp
header files can be also downloaded from here and here.
At this point, you need to have already made up your mind about which approach you want to take to compile and link your code to the ParaMonte library,
- you have already built the ParaMonte library from scratch on your system, or,
- you intend to use the prebuilt ParaMonte libraries.
If you have not made up your mind yet, we recommend using the prebuilt ParaMonte binaries. Although the entire ParaMonte library build process is fully automated, it can take much longer than simply downloading the prebuilt ParaMonte libraries from the project’s repository.
Preamble: The compiler choice
To build and link your application, we recommend installing the following compilers on your system,
- On Windows OS
-
We recommend installing and using the Intel Parallel Studio
2019.1.1
or newer, although older versions may also work. -
Alternatively, you can also install and use a recent release of the Microsoft Visual C/C++ compiler (MSVC) 2019 or newer on your system. The
community
release of this compiler is free to the public and sufficient for many applications.Tip: The MSVC compiler, as part of the Microsoft Visual Studio, is a prerequisite for the successful installation of the Intel Parallel Studio on Windows. Therefore, if you have already successfully installed the Intel compilers on your Windows system, you should also be able to use the MSVC C/C++ compiler.
-
- On Linux OS
- We recommend installing and using the Intel Parallel Studio ≥
2019.1.1
or newer, although older versions may also work. - Alternatively, you can also install a recent release of the GNU Compiler Collection
gcc/g++/gfortran
(preferably version10.1.0
or newer) instead of the Intel compiler suite. If you intend to build parallel applications, you will have to also have a compatible MPI library installed on your system, preferably the MPICH MPI library3.2
or newer.
- We recommend installing and using the Intel Parallel Studio ≥
- On macOS
The situation is slightly complicated on MacOS. Apparently, Apple and Intel corporations have an intense internal rivalry and competition with each other, so much that Apple did not want to help Intel make their MPI library available on macOS. As a result, the Intel Parallel Studio cannot be used to build parallel MPI applications on macOS. Therefore,- If you intend to build and use serial ParaMonte applications, then we still recommend installing and using the Intel Compiler Suite ≥ 2019.1.1 or newer on your system.
- If you intend to build and use parallel ParaMonte applications, then the best option would be to download and install a recent version of the GNU Compiler Collection (preferably, the same version with which the ParaMonte was built:
10.1.0
) as well as the Open-MPI library4.0.5
.Tip: See the instructions on the installation page on how to seamlessly install the above compilers and libraries in less than one minute on your Mac.
Preamble: Setting up the environment
In brief, the process of building your C++ application involves the following steps,
- Either,
- Download the ParaMonte prebuilt library of your choice from the release page of the ParaMonte repository on GitHub. If you are not sure which one is suitable for your usage, see,
- the pre-installation notes and,
- the installation instructions for Windows, or,
- the installation instructions for macOS, or,
- the installation instructions for Linux.
Tip: On Windows, unzipping the compressed file is easy as clicking on the file to open it via the Windows explorer. On Linux or macOS, you can untar the compress file via the following command in a Bash terminal,tar xvzf libparamonte_cpp_linux_x64_intel_release_shared_heap.tar.gz
where you will have to replacelibparamonte_cpp_linux_x64_intel_release_shared_heap
with the name of the compressed library file that you have downloaded. - or build the ParaMonte library for the configuration of your choice.
Tip: When building the ParaMonte library or downloading the prebuilt ParaMonte libraries, always choose therelease
mode as your library build-type among the available three default choices (release
,testing
,debug
). Therelease
build-type results in the highest-performing ParaMonte library build and the fastest runtime simulations. If needed, use thetesting
build-type solely for quick application builds for testing purposes and thedebug
build-type solely for debugging your simulations at runtime. - Download the ParaMonte prebuilt library of your choice from the release page of the ParaMonte repository on GitHub. If you are not sure which one is suitable for your usage, see,
- Navigate to the directory containing your uncompressed ParaMonte library files and paste (that is, overwrite the existing three
paramonte.in
,logfunc.cpp
, andmain.cpp
files with) your files and codes. - Open a command-line interface and navigate to the directory containing your uncompressed ParaMonte library files.
- On Windows
-
If you choose to use the Intel C++ compiler to build your application, then we strongly recommend you to use the Intel Parallel Studio’s customized command-line interface that is automatically installed on your system. You can access it from the Windows startup menu as illustrated in the figure below.
Open a 64-bit instance of the Intel Parallel Studio’s command-line interface. This command-line prompt comes with all the relevant compiler and linker environmental variables predefined in your session so that you won’t need to manually modify the contents of your environmentalPATH
variable. -
If you choose to use the MSVC C++ compiler
cl
, then we strongly recommend you to use the Microsoft Visual Studio’s customized command-line interface that is automatically installed on your system along with the compiler. It is normally named x64 Native Tools Command Prompt for VS 2XXX, where2XXX
is the version of the MSVC you have installed on your system. You can access it from the Windows startup menu as illustrated in the figure below, where the Microsoft Visual Studio 2019 is located (as well as an older existing installation of the Visual Studio 2017).
Open an instance of the x64 Native Tools Command Prompt which is automatically installed on your system along with the MSVC compiler. This command-line comes with all the relevant compiler and linker environmental variables predefined in your session so that you won’t need to manually modify the contents of the environmentalPATH
variable.Important: It is imperative that you open an x64-compatible version of the MSVC command prompt, just as shown in the above. The ParaMonte library binaries are exclusively built forx64
(x86_64
) type of architecture and therefore any compilation and linking via non-x64 tools will fail.
-
- On Linux / macOS, use a Bash terminal.
- On Windows
Building the executable: The quick automated approach
- On Windows
- To build your application via the Intel C++ compiler, type the following on the Intel Parallel Studio command-line interface that you opened in the previous section,
build.bat
- To build your application via the Microsoft C++ compiler, type the following on the Microsoft Visual Studio command-line interface that you opened in the previous section,
build.bat msvc
The above Batch script will both build and run the application executable. See this page on how to set the number of processors for parallel simulations.
- To build your application via the Intel C++ compiler, type the following on the Intel Parallel Studio command-line interface that you opened in the previous section,
- On Linux / macOS
Type the following on the Bash terminal that you opened in the previous section,chmod +x build.sh ./build.sh
Tip: There are several options that can be specified at the time of calling thebuild.sh
script, including the option to set the default number of MPI- or Coarray- parallel tasks. To get help on the options, try,./build.sh -h
or,./build.sh --help
Tip: By default, the build-script automatically chooses the compiler for building your application based on the name of the prebuilt ParaMonte library that you have chosen to use. You can override this default option by providing the compiler name and the compile/linker flags via the two command-line options-c
and-f
to the build-script. For example,-
to compile and link a serial C++ application via the GNU C++ compiler against a Linux-version or a macOS-version of an Intel-prebuilt serial shared ParaMonte library in
release
mode, you can specify the following options for the build-script on the command-line,./build.sh -c g++ -f "-O3"
-
to compile and link an MPI-parallel C++ application via the Intel MPI-wrapper for the GNU C++ compiler against a Linux-version of an Intel-prebuilt serial shared ParaMonte library in
release
mode, you can specify the following options for the build-script on the command-line,./build.sh -c mpicxx -f "-O3"
-c
compiler option, it is imperative to specify the-f
compiler-flags option along with it. Failure to do so will cause the script to switch to the default inferred flags from the name of the compiler used in the filename of the ParaMonte library that is being used. The inconsistent compiler flags will then cause the application-build to abort.The build-script generates the executable along with a Bash script
run.sh
in the same directory, which can be called on the command-line to run the executable. See this page on how to set the number of processors for parallel simulations and run the executable. -
to compile and link a serial C++ application via the GNU C++ compiler against a Linux-version or a macOS-version of an Intel-prebuilt serial shared ParaMonte library in
If your simulation-build and run have been successful, you can skip the following detailed sections on the build process via different specific compilers on different platforms and glance through the tips and information provided in the examples on this website to post-process the ParaMonte simulation results and output files.
Building the executable: Do-it-yourself
There are currently more than 210 possible configurations with which you can build the ParaMonte library. Covering the compilation and linking procedure for all of these different scenarios here is impossible. To simplify, we will only consider compiling and linking your C++ application via the ParaMonte library build in release
mode for only shared (dynamic) linking. Before continuing to build your application manually, make sure you follow the guidelines outlined in the Preamble section in the above.
Building the executable on Windows via the Intel C++ compiler
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:set "COMPILER_LINKER_FLAGS=/O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /Ob2 /Qinline-dllimport"
- for
testing
:set "COMPILER_LINKER_FLAGS=/Od"
- for
debug
:set "COMPILER_LINKER_FLAGS=/debug:full /Zi /Od /Wall /traceback /Qcheck-pointers:rw /Qcheck-pointers-undimensioned /Qdiag-error-limit:10 /Qtrapuv"
Building the executable on Windows via the Intel C++ compiler for serial applications
-
We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_cpp_windows_x64_intel_release_shared_heap.dll libparamonte_cpp_windows_x64_intel_release_shared_heap.exp libparamonte_cpp_windows_x64_intel_release_shared_heap.lib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. -
Now, we are going to use the Intel C++ compiler to compile and link your code,
set "COMPILER_LINKER_FLAGS=/O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /Ob2 /Qinline-dllimport"
icl %COMPILER_LINKER_FLAGS% logfunc.cpp main.cpp libparamonte_cpp_windows_x64_intel_release_shared_heap.lib /link /out:main.exe
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.4.245 Build 20190417 Copyright (C) 1985-2019 Intel Corporation. All rights reserved. logfunc.cpp main.cpp Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:main.exe C:\Users\SHAHMO~1\AppData\Local\Temp\ipo_4826420.obj libparamonte_cpp_windows_x64_intel_release_shared_heap.lib
-
The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Windows via the Intel C++ compiler for parallel applications
-
For simplicity, we will only consider the MPI-parallelism here. We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.dll libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.exp libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. -
Now, we are going to use the Intel C++ MPI compiler wrapper to compile and link your code,
set "COMPILER_LINKER_FLAGS=/O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /Ob2 /Qinline-dllimport"
mpiicc %COMPILER_LINKER_FLAGS% logfunc.c main.c libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib /link /out:main.exe
mpicc.bat for the Intel(R) MPI Library 2019 Update 4 for Windows* Copyright 2007-2019 Intel Corporation. Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.4.245 Build 20190417 Copyright (C) 1985-2019 Intel Corporation. All rights reserved. logfunc.cpp main.cpp Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:main.exe "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib\release" "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib" impi.lib impicxx.lib C:\Users\SHAHMO~1\AppData\Local\Temp\ipo_4049220.obj libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib
-
The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Windows via the Microsoft Visual C++ compiler
Open an instance of the x64 Native Tools Command Prompt which is automatically installed on your system along with the MSVC compiler. As discussed in the preamble, this command-line comes with all the relevant compiler and linker environmental variables predefined in your session so that you won’t need to manually modify the contents of the environmental PATH
variable.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:set "COMPILER_LINKER_FLAGS=/O2"
- for
testing
:set "COMPILER_LINKER_FLAGS=/Od"
- for
debug
:set "COMPILER_LINKER_FLAGS=/Od /Z7"
Building the executable on Windows via the Microsoft Visual C++ compiler for serial applications
-
We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_cpp_windows_x64_msvc_release_shared_heap.dll libparamonte_cpp_windows_x64_msvc_release_shared_heap.exp libparamonte_cpp_windows_x64_msvc_release_shared_heap.lib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. - Now, we are going to use the MSVC C++ compiler
cl
to compile and link your code,set "COMPILER_LINKER_FLAGS=/O2"
cl %COMPILER_LINKER_FLAGS% logfunc.c main.c libparamonte_cpp_windows_x64_intel_release_shared_heap.lib /link /out:main.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.22.27905 for x64 Copyright (C) Microsoft Corporation. All rights reserved. logfunc.cpp main.cpp Generating Code... Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. /out:logfunc.exe /out:main.exe logfunc.obj main.obj libparamonte_cpp_windows_x64_intel_release_shared_heap.lib
- The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Windows via the Microsoft Visual C++ compiler for parallel applications
-
For simplicity, we will only consider the MPI-parallelism here. We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.dll libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.exp libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. - Now, we are going to use the Intel
mpicc
ormpicl
C++ MPI compiler wrappers along with the Microsoft C++ compilercl.exe
(specified by the flag-cc=cl
) to compile and link your code,set "COMPILER_LINKER_FLAGS=/O2"
mpicc -cc=cl %COMPILER_LINKER_FLAGS% logfunc.c main.c libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib /link /out:main.exe
mpicc.bat for the Intel(R) MPI Library 2019 Update 4 for Windows* Copyright 2007-2019 Intel Corporation. Microsoft (R) C/C++ Optimizing Compiler Version 19.22.27905 for x64 Copyright (C) Microsoft Corporation. All rights reserved. logfunc.cpp main.cpp Generating Code... Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. /out:logfunc.exe "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib\release" "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib" -out:main.exe impi.lib impicxx.lib logfunc.obj main.obj libparamonte_cpp_windows_x64_intel_release_shared_heap_impi.lib
Tip: While building your parallel application, if you encounter linking errors similar toLINK : fatal error LNK1181: cannot open input file 'impi.lib'
then see this troubleshooting page for a possible resolution. - The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on macOS via the Intel C++ compiler
Open a Bash terminal that recognizes your local installation of the Intel compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-no-multibyte-chars -O3"
- for
testing
:export COMPILER_LINKER_FLAGS="-no-multibyte-chars -O0"
- for
debug
:export COMPILER_LINKER_FLAGS="-no-multibyte-chars -O0 -debug full"
To understand the reason for adding the compiler flag -no-multibyte-chars
on macOS, see this troubleshooting page
Building the executable on macOS via the Intel C++ compiler for serial applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel C++ compiler, in general, you should be able to use the Intel C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_darwin_x64_intel_release_shared_heap.dylib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
-
Now, we are going to use the Intel C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-no-multibyte-chars -O3"
icpc $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_darwin_x64_intel_release_shared_heap.dylib -o main.exe
- The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on macOS via the GNU C++ compiler
Open a Bash terminal that recognizes your local installation of the GNU compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-O3"
- for
testing
:export COMPILER_LINKER_FLAGS="-O0"
- for
debug
:export COMPILER_LINKER_FLAGS="-O0 -g"
Building the executable on macOS via the GNU C++ compiler for serial applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU C++ compiler, in general, you should be able to use the GNU C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_darwin_x64_gnu_release_shared_heap.dylib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
-
Now, we are going to use the GNU C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
g++ $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_darwin_x64_gnu_release_shared_heap.dylib -o main.exe
- The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on macOS via the GNU C++ compiler for MPI-parallel applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU C++ compiler, in general, you should be able to use the GNU C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_darwin_x64_gnu_release_shared_heap_mpich.dylib logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Note: If you are using theOpenMPI
library in place of theMPICH
MPI library, simply replace the keywordmpich
withopenmpi
anywhere it appears on this page. -
Now, we are going to use the Open-MPI compiler wrapper for the GNU C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
mpicxx $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_darwin_x64_gnu_release_shared_heap_mpich.dylib -o main.exe
- The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Linux via the Intel C++ compiler
Open a Bash terminal that recognizes your local installation of the Intel compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-O3"
- for
testing
:export COMPILER_LINKER_FLAGS="-O0"
- for
debug
:export COMPILER_LINKER_FLAGS="-O0 -debug full"
Building the executable on Linux via the Intel C++ compiler for serial applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel C++ compiler, in general, you should be able to use the Intel C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_linux_x64_intel_release_shared_heap.so logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
-
Now, we are going to use the Intel C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
icpc $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_linux_x64_intel_release_shared_heap.so -o main.exe
- The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Linux via the Intel C++ compiler for MPI-parallel applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel C++ compiler, in general, you should be able to use the Intel C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_linux_x64_intel_release_shared_heap_impi.so logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
-
Now, we are going to use the Intel MPI compiler wrapper for the Intel C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
mpiicpc $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_linux_x64_intel_release_shared_heap_impi.so -o main.exe
- The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Linux via the GNU C++ compiler
Open a Bash terminal that recognizes your local installation of the GNU compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-O3"
- for
testing
:export COMPILER_LINKER_FLAGS="-O0"
- for
debug
:export COMPILER_LINKER_FLAGS="-O0 -g"
Building the executable on Linux via the GNU C++ compiler for serial applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU C++ compiler, in general, you should be able to use the GNU C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_linux_x64_gnu_release_shared_heap.so logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
-
Now, we are going to use the GNU C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
g++ $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_linux_x64_gnu_release_shared_heap.so -o main.exe
- The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.cpp
.
Building the executable on Linux via the GNU C++ compiler for MPI-parallel applications
- We will consider building the C++ application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU C++ compiler, in general, you should be able to use the GNU C++ compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU C++ compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your C++ example codes to this folder (This will overwrite the existing
logfunc.cpp
andmain.cpp
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_cpp_linux_x64_gnu_release_shared_heap_mpich.so logfunc.cpp logfunc.hpp main.cpp paramonte.hpp paramonte.in README.md
Note: If you are using theOpenMPI
library in place of theMPICH
MPI library, simply replace the keywordmpich
withopenmpi
anywhere it appears on this page. -
Now, we are going to use the MPICH MPI compiler wrapper for the GNU C++ compiler to compile and link your code,
export COMPILER_LINKER_FLAGS="-O3"
mpicxx $COMPILER_LINKER_FLAGS logfunc.cpp main.cpp libparamonte_cpp_linux_x64_gnu_release_shared_heap_mpich.so -o main.exe
- The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.cpp
.