Scripts for building G+Smo Docker images
| License | MPL 2.0 |
| OS support | Linux, Windows, macOS |
| Docker pulls | |
| Repository | mmoelle1/gismo |
| Status | completed |
| Developer | Matthias Möller |
| Maintainer | M.Moller@tudelft.nl |
| Last checked | 21-01-2022 |
Table of content
The run_build_docker.sh script provides an easy mechanism to create
customized Docker images. We assume that you have installed Docker as
described at Docker.com and can
execute it with your user privileges. To build a customized Docker
image run
./run_build_docker.sh os-compiler-cxx-buildtype[-cpu][-coeff_type][-index_type][-option0][-option1][...][:arch][/branch]| Mandatory configuration | |
|---|---|
os |
Name of the operating system including specific version number. Supported values are: ubuntu16.04, ubuntu18.04, and ubuntu20.04. |
compiler |
Name of the compiler including a specific version number. Supported values are: clang3.5 to clang11 and gcc4.7 to gcc11. Note that not all compiler versions are available on all operating systems. Newer compiler versions typically require also newer operating systems. |
cxx |
C++ standard. Supported values are: cxx11, cxx14, cxx17, cxx20, and cxx23. |
buildtype |
Build type. Supported values are: debug, release, debinfo, and minsize. |
| Optional configuration | |
|---|---|
cpu |
Name of the cpu architecture. Supported values are auto, none, generic, core, merom, penryn, nehalem, westmere, sandybridge, ivybridge, haswell, broadwell, skylake, skylake-xeon, kabylake, cannonlake, cacadelake, cooperlake, icelake, icelake-xeon, tigerlake, alderlake, sapphirerapids, bonnell, silvermont, goldmont, goldmont-plus, tremont, knl, knm, atom, k8, k8-sse3, barcelona, istanbul, magny-cours, bulldozer, interlagos, piledriver, steamroller, excavator, amd14h, amd16h, zen, zen2, and zen3. If not given then generic is used as default. |
coeff_type |
Global coefficient type. Supported values are: float, double, longdouble, mpfr::mpreal, mpq_class, posit_2_0, posit_3_0, posit_3_1, posit_4_0, posit_4_1, posit_8_0, posit_8_1, posit_16_1, posit_32_2, posit_64_3, posit_128_4, and posit_256_5. If not given then double is used as default. |
index_type |
Global index type. Supported values are: int, int32_t, int64_t, long, and longlong. If not given then int is used as default. |
Disclaimer: Not all optional features are supported on all architectures and/or OS versions. Please report errors to the maintainer.
| Optional features | |
|---|---|
adiff/noadiff |
Enable/disable building G+Smo with AutoDiff support. Default is disabled. |
examples/noexamples |
Enable/disable building G+Smo examples. Default is enabled. |
lib/nolib |
Enable/disable building G+Smo as library. Default is enabled. |
mpi/nompi |
Enable/disable building G+Smo with MPI support. Default is disabled. Not that Trilinos requires MPI to be enabled and will overwrite this setting. |
omp/noomp |
Enable/disable building G+Smo with OpenMP support. Default is disabled for Clang compiler and enabled for all other compilers. |
pardiso/nopardiso |
Enable/disable building G+Smo with Pardiso support. Default is disabled. |
pastix/nopastix |
Enable/disable building G+Smo with Pastix support. Default is disabled. |
pch/nopch |
Enable/disable building G+Smo with support for pre-compiled headers. Default is disabled. |
psolid/nopsolid |
Enable/disable building G+Smo with PSOLID support. Default is disabled. |
smesh/nosmesh |
Enable/disable building G+Smo with Surface Mesh support. Default is disabled. |
spectra/nospectra |
Enable/disable building G+Smo with Spectra support. Default is disabled. |
superlu/nosuperlu |
Enable/disable building G+Smo with SuperLU support. Default is disabled. |
taucs/notaucs |
Enable/disable building G+Smo with Taucs support. Default is disabled. |
umfpack/noumfpack |
Enable/disable building G+Smo with UMFPACK support. Default is disabled. |
unittests/nounittests |
Enable/disable building G+Smo unittests. Default is disabled. |
| Optional G+Smo extensions | |
|---|---|
codipack/nocodipack |
Enable/disable gsCoDiPack extension. Default is disabled. |
compflow/nocompflow |
Enable/disable gsCompFlow extension (private repository!). Default is disabled. |
elasticity/noelasticity |
Enable/disable gsElasticity extension. Default is disabled. |
exastencils/noexastencils |
Enable/disable gsExastencils extension (private repository!). Default is disabled. |
gmp/nogmp |
Enable/disable gsGmp extension. Default is disabled. This G+Smo extension is enabled automatically if coeff_type is set to mpfr::mpreal or mpq_class. |
ipopt/noipopt |
Enable/disable gsIpOpt extension. Default is disabled. |
klshell/noklshell |
Enable/disable gsKLShell extension. Default is disabled. |
mpfr/nompfr |
Enable/disable gsMpfr extension. Default is disabled. This G+Smo extension is enabled automatically if coeff_type is set to mpfr::mpreal. |
motor/nomotor |
Enable/disable motor extension (private repository!). Default is disabled. |
opencascade/noopencascade |
Enable/disable gsOpenCascade extension. Default is disabled. |
opennurbs/noopennurbs |
Enable/disable gsOpennurbs extension. Default is disabled. |
trilinos/notrilinos |
Enable/disable gsTrilinos extension. Default is disabled. |
structuralanalysis/nostructuralanalysis |
Enable/disable gsStructuralAnalysis extension. Default is disabled. |
universal/nouniversal |
Enable/disable gsUniversal extension. Default is disabled. This G+Smo extension is enabled automatically if coeff_type is set to any of the supported posit_x_y . |
unsupported/nounsupported |
Enable/disable unsupported extension. Default is disabled. |
Disclaimer: Not all G+Smo extensions are supported on all architectures and/or OS versions. Please report errors to the maintainer. Private repositories are not accessible without a password.
The following Docker images are built automatically for commits to the G+Smo stable branch. Unspecified options are set to their default values:
ubuntu20.04-gcc11-cxx11-release(GCC 11.x, C++11, Release mode with OpenMP)ubuntu20.04-clang11-cxx11-release(Clang 11.x, C++11, Release mode with OpenMP)
The directory structure of the G+Smo library is as follows:
$HOME/gismo: G+Smo main directory$HOME/gismo/build/bin: pre-compiled executables of example and tutorial applications$HOME/gismo/examples: source code of example and tutorial applications$HOME/gismo/filedata: parameterisations and other configuration files$HOME/gismo/src: source code of the G+Smo library
For a full description of the source code directory structure see the G+Smo Wiki.
To install Docker for your platform (Windows, macOS, Linux, cloud platforms, etc.) follow the instructions at docker.com.
Once you have Docker installed, you can run one of the above images by executing the following command:
docker run --rm -ti mmoelle1/gismo:ubuntu20.04-gcc11-cxx11-release
You will be logged in under username gismo with standard password gismo. The --rm flag to the docker run command ensures that the container is removed upon termination. The directory $HOME/gismo/build/bin is added to the PATH variable so that example and tutorial applications can be run directly, e.g.:
docker run --rm -ti mmoelle1/gismo:ubuntu20.04-gcc11-cxx11-release geometry_example
If you want to access data that is stored in a directory on your host computer from within your Docker container you need to mount (-v) the directory on your host computer when starting the Docker container. Assume that you want to make your current working directory on your host computer ($(pwd)) accessible under /home/gismo/shared in the docker container you need start the docker image as follows:
docker run --rm -ti -v $(pwd):/home/gismo/shared mmoelle1/gismo:ubuntu20.04-gcc11-cxx11-release
It is also possible to mount a directory on your host computer to a directory of the Docker container and make it the working (-w) so that files generated inside the Docker container are accessible on your host computer:
docker run --rm -ti -w/home/gismo/shared -v $(pwd):/home/gismo/shared mmoelle1/gismo:ubuntu20.04-gcc11-cxx11-release
A good starting point for learning the G+Smo library is to walk through the example and tutorial applications.
Open the file hooks/build and add a code block of the form
# gsKLShell extension
shopt -s extglob;
case "$IMAGE_NAME" in
?(*\-)noklshell?(\-*))
if [[ ${GISMO_OPTIONAL} =~ "gsKLShell" ]]; then
GISMO_OPTIONAL="${GISMO_OPTIONAL//gsKLShell/}"
fi
;;
?(*\-)klshell?(\-*))
if [[ ${GISMO_OPTIONAL} ]]; then
GISMO_OPTIONAL="${GISMO_OPTIONAL};gsKLShell"
else
GISMO_OPTIONAL="gsKLShell"
fi
;;
esac
shopt -u extglob;That's it for most extensions.
If your extension requires certain options to be set make sure you add the above code snippet before the handling of these options, e.g., the gsTrilinos extension requires GISMO_WITH_MPI=ON and is therefore handled before.
# gsTrilinos extension (must be before checking for MPI support)
shopt -s extglob;
case "$IMAGE_NAME" in
?(*\-)notrilinos?(\-*))
if [[ ${GISMO_OPTIONAL} =~ "gsTrilinos" ]]; then
GISMO_OPTIONAL="${GISMO_OPTIONAL//gsTrilinos/}"
fi
;;
?(*\-)trilinos?(\-*))
if [[ ${GISMO_OPTIONAL} ]]; then
GISMO_OPTIONAL="${GISMO_OPTIONAL};gsTrilinos"
else
GISMO_OPTIONAL="gsTrilinos"
fi
GISMO_WITH_MPI=ON
;;
esac
shopt -u extglob;
[...]
# MPI support
shopt -s extglob;
case "$IMAGE_NAME" in
?(*\-)nompi?(\-*))
GISMO_WITH_MPI=OFF
;;
?(*\-)mpi?(\-*))
GISMO_WITH_MPI=ON
;;
*)
if [ -z "$GISMO_WITH_MPI" ]; then
GISMO_WITH_MPI=OFF
fi
;;
esac
shopt -u extglob;If your extension requires additional software packages (e.g., a Fortran compiler or additional libraries and header files) to be installed in the Docker image open the file ubuntu20.04/Dockerfile and add a code block of the form
# Install prerequisites for gsOpenCascade extension
RUN if [ ${GISMO_OPTIONAL} =~ "gsOpenCascade" ] ; then \
apt-get update -q && \
apt-get install --no-install-recommends -yq \
libgl-dev \
libxi-dev \
libxmu-dev \
mesa-common-dev \
tk-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
fiRepeat the above step for all Dockerfiles.
Disclaimer: Different OSes might have different naming conventions for libraries and/or header files and even use different commands for installing software packages. Consult your OS documentation for further details.
The first step in adding a G+Smo option is similar to adding a G+Smo extension (see above). Open the file hooks/build and add a code block of the form
# MPI support
shopt -s extglob;
case "$IMAGE_NAME" in
?(*\-)nompi?(\-*))
GISMO_WITH_MPI=OFF
;;
?(*\-)mpi?(\-*))
GISMO_WITH_MPI=ON
;;
*)
if [ -z "$GISMO_WITH_MPI" ]; then
GISMO_WITH_MPI=OFF
fi
;;
esac
shopt -u extglob;Next, open the file ubuntu20.04/Dockerfile and add a code block of the form
# GISMO_WITH_MPI : {ON,OFF}
ARG GISMO_WITH_MPI=OFFAdditionally, add this flag to the cmake command at the bottom of the file
# Configure and build G+Smo library
RUN cd gismo && \
mkdir build && \
cd build && \
CC=$CC \
CXX=$CXX \
FC=$FC \
cmake .. \
[...]
-DGISMO_WITH_MPI=$GISMO_WITH_MPI \
[...]
make
Repeat the above step for all Dockerfiles.
Adding a new Docker image 'newimage' (replace with the desired name) requires some more work.
First, open the file run_build_docker.sh and add a code block of the form
?(*:)?(*\-)newimage?(\-*))
(DOCKER_REPO="mmoelle1/gismo"
DOCKERFILE="${BASE_DIR}/newimage/Dockerfile"
source ${BASE_DIR}/newimage/hooks/build)
;;Next, create the directory newimage and create a Dockerfile. We suggest to copy an existing Dockerfile, e.g., from ubuntu20.04 and update it to your needs.
Next, create a new directory newimage/hooks and create a link named build to the file hooks/build.
Finally, create a file _compiler_settings in the directory newimage/hooks with the following content (adapted to your needs):
#!/bin/bash
# hooks/_compiler_settings
# Compiler setting
shopt -s extglob;
case "$IMAGE_NAME" in
# Clang
?(*\-)clang6.0?(\-*))
CC=clang-6.0
CXX=clang++-6.0
;;
[...]
# GCC
?(*\-)gcc7?(\-*))
CC=gcc-7
CXX=g++-7
FC=gfortran-7
;;
[...]
*)
echo "[***] Unsupported compiler"
exit 1
;;
esac
shopt -u extglob;
echo "[---] CC: ${CC}"
echo "[---] CXX: ${CXX}"
echo "[---] FC: ${FC}"In summary, you should have created the following directory structure and files
newimage
|
+-- Dockerfile
|
+-- hooks
|
+-- _compiler_settings
|
+-- build -> ../../hooks/build