Require pybind 2.6 from environment for gmxapi Python package extension module.
[alexxy/gromacs.git] / admin / containers / scripted_gmx_docker_builds.py
index 3ed8cb7020cfa03a4b0d47ace8f1e1a0883fe6cb..4492c4593665ff002c0016b29f737fa36f75f17f 100755 (executable)
@@ -53,6 +53,7 @@ Authors:
     * Eric Irrgang <ericirrgang@gmail.com>
     * Joe Jordan <e.jjordan12@gmail.com>
     * Mark Abraham <mark.j.abraham@gmail.com>
+    * Gaurav Garg <gaugarg@nvidia.com>
 
 Usage::
 
@@ -116,7 +117,9 @@ _rocm_extra_packages = [
         'libelf1',
         'rocm-opencl',
         'rocm-dev',
-        'clinfo'
+        'clinfo',
+        'rocfft',
+        'hipfft',
 ]
                      
 
@@ -206,6 +209,27 @@ def base_image_tag(args) -> str:
             raise RuntimeError('Logic error: no Linux distribution selected.')
     return base_image_tag
 
+# Convert the linux distribution variables into something that hpccm
+# understands.
+def hpccm_distro_name(args) -> str:
+    if args.centos is not None:
+        name_mapping = { '7': 'centos7',
+                         '8': 'centos8' }
+        if args.centos in name_mapping:
+            hpccm_name = name_mapping[args.centos]
+        else:
+            raise RuntimeError('Logic error: unsupported CentOS distribution selected.')
+    elif args.ubuntu is not None:
+        name_mapping = { '20.04': 'ubuntu20',
+                         '18.04': 'ubuntu18',
+                         '16.04': 'ubuntu16' }
+        if args.ubuntu in name_mapping:
+            hpccm_name = name_mapping[args.ubuntu]
+        else:
+            raise RuntimeError('Logic error: unsupported Ubuntu distribution selected.')
+    else:
+        raise RuntimeError('Logic error: no Linux distribution selected.')
+    return hpccm_name
 
 def get_llvm_packages(args) -> typing.Iterable[str]:
     # If we use the package version of LLVM, we need to install extra packages for it.
@@ -245,7 +269,10 @@ def get_compiler(args, compiler_build_stage: hpccm.Stage = None) -> bb_base:
                 raise RuntimeError('No TSAN compiler build stage!')
         # Build the default compiler if we don't need special support
         else:
-            compiler = hpccm.building_blocks.llvm(extra_repository=True, version=args.llvm)
+            # Currently the focal apt repositories do not contain
+            # llvm higher than 11, so we work around that. This will
+            # need further work when we start supporting ubuntu 22.04
+            compiler = hpccm.building_blocks.llvm(version=args.llvm, upstream=True if int(args.llvm) > 11 else False)
 
     elif args.oneapi is not None:
         if compiler_build_stage is not None:
@@ -325,6 +352,19 @@ def get_clfft(args):
     else:
         return None
 
+def get_heffte(args):
+    if (args.heffte is not None):
+        return hpccm.building_blocks.generic_cmake(
+            cmake_opts=['-D CMAKE_BUILD_TYPE=Release',
+                                    '-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda',
+                                    '-D Heffte_ENABLE_CUDA=ON',
+                                    '-D Heffte_ENABLE_FFTW=OFF',
+                                    '-D BUILD_SHARED_LIBS=ON'],
+            repository='https://bitbucket.org/icl/heffte.git',
+            prefix='/usr/local', recursive=True, commit=args.heffte, directory='heffte')
+    else:
+        return None
+
 def get_hipsycl(args):
     if args.hipsycl is None:
         return None
@@ -334,8 +374,7 @@ def get_hipsycl(args):
     if args.rocm is None:
         raise RuntimeError('hipSYCL requires the rocm packages')
 
-    cmake_opts = [f'-DLLVM_DIR=/usr/lib/llvm-{args.llvm}/cmake',
-                  f'-DCLANG_EXECUTABLE_PATH=/usr/bin/clang++-{args.llvm}',
+    cmake_opts = [f'-DLLVM_DIR=/opt/rocm/llvm/lib/cmake/llvm',
                   '-DCMAKE_PREFIX_PATH=/opt/rocm/lib/cmake',
                   '-DWITH_ROCM_BACKEND=ON']
     if args.cuda is not None:
@@ -470,6 +509,7 @@ def prepare_venv(version: StrictVersion) -> typing.Sequence[str]:
     # WARNING: Please keep this list synchronized with python_packaging/requirements-test.txt
     # TODO: Get requirements.txt from an input argument.
     commands.append(f"""{venv_path}/bin/python -m pip install --upgrade \
+            'breathe' \
             'cmake>=3.16.3' \
             'flake8>=3.7.7' \
             'gcovr>=4.2' \
@@ -480,7 +520,6 @@ def prepare_venv(version: StrictVersion) -> typing.Sequence[str]:
             'Pygments>=2.2.0' \
             'pytest>=3.9' \
             'setuptools>=42' \
-            'scikit-build>=0.10' \
             'Sphinx>=1.6.3' \
             'sphinxcontrib-plantuml>=0.14'""")
 
@@ -633,6 +672,11 @@ def build_stages(args) -> typing.Iterable[hpccm.Stage]:
     building_blocks['base_packages'] = hpccm.building_blocks.packages(
         ospackages=_common_packages)
 
+    # Normally in hpccm the first call to baseimage sets the context
+    # for other packages, e.g. for which apt respository to
+    # use. We want to set that early on.
+    hpccm.config.set_linux_distro(hpccm_distro_name(args))
+
     # These are the most expensive and most reusable layers, so we put them first.
     building_blocks['compiler'] = get_compiler(args, compiler_build_stage=stages.get('compiler_build'))
     building_blocks['gdrcopy'] = get_gdrcopy(args, building_blocks['compiler'])
@@ -680,6 +724,8 @@ def build_stages(args) -> typing.Iterable[hpccm.Stage]:
 
     building_blocks['clfft'] = get_clfft(args)
 
+    building_blocks['heffte'] = get_heffte(args)
+
     building_blocks['hipSYCL'] = get_hipsycl(args)
 
     building_blocks['intel-compute-runtime'] = get_intel_compute_runtime(args)