Skip to content

Commit

Permalink
QE compile with mpif90 from OMPI
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jun 17, 2024
1 parent c9a2cdd commit 5a8c7ca
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
37 changes: 22 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
FROM build-base-image
FROM openmpi-builder-image AS openmpi-builder
FROM lapack-builder-image AS lapack-builder

# As build-machine image, it is not actually a runtime
# but I do the runtime multi-stage build to minimize the size
# and for testing the integrity of the openmpi/lapack... static build and move
FROM build-base-image AS qe-builder

WORKDIR /qe-build

# Compile Lapack
# TODO: this should be moved to build-machine base image
ARG LAPACK_VERSION="3.10.1"
# Copy build toolchains from the builder stage
COPY --from=openmpi-builder /opt/openmpi /opt/openmpi
COPY --from=lapack-builder /usr/local/lapack /usr/local/lapack

RUN wget -c -O lapack.tar.gz https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${LAPACK_VERSION}.tar.gz && \
mkdir -p lapack && \
tar xf lapack.tar.gz -C lapack --strip-components=1 && \
cd lapack && \
cp INSTALL/make.inc.gfortran make.inc && \
make lapacklib blaslib && \
mkdir -p /usr/local/lapack/lib && \
cp *.a /usr/local/lapack/lib
# Set up environment variables for OpenMPI
ENV PATH="/opt/openmpi/bin:$PATH"
ENV LD_LIBRARY_PATH="/opt/openmpi/lib:$LD_LIBRARY_PATH"

# Compile QE
# Compile QE (for test only)
ARG QE_VERSION

RUN wget -c -O qe.tar.gz https://gitlab.com/QEF/q-e/-/archive/qe-${QE_VERSION}/q-e-qe-${QE_VERSION}.tar.gz && \
mkdir -p qe && \
tar xf qe.tar.gz -C qe --strip-components=1 && \
cd qe && \
LAPACK_LIBS=/usr/local/lapack/lib/liblapack.a BLAS_LIBS=/usr/local/lapack/lib/librefblas.a ./configure -enable-static && \
make -j8 all && \
make -j8 pw && \
make install


# Move binaries to a small image to reduce the size
FROM runtime-base-image

COPY --from=0 /usr/local/bin/* /usr/local/bin/
COPY --from=qe-builder /usr/local/bin/* /usr/local/bin/

# Require OMPI to run
COPY --from=openmpi-builder /opt/openmpi /opt/openmpi

# Set up environment variables for OpenMPI
ENV PATH="/opt/openmpi/bin:$PATH"
ENV LD_LIBRARY_PATH="/opt/openmpi/lib:$LD_LIBRARY_PATH"
10 changes: 8 additions & 2 deletions build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"variable": {
"BUILD_BASE_IMAGE": {
"default": "docker.io/cnts4sci/base-mpich314:0.1.0"
"default": "ghcr.io/cnts4sci/bm:edge"
},
"RUNTIME_BASE_IMAGE": {
"default": "phusion/baseimage:focal-1.2.0"
"default": "docker.io/phusion/baseimage:focal-1.2.0"
},
"OPENMPI_BUILDER": {
"default": "ghcr.io/cnts4sci/bm-openmpi:edge"
},
"LAPACK_BUILDER": {
"default": "ghcr.io/cnts4sci/bm-lapack:edge"
},
"QE_VERSION": {
"default": "7.0"
Expand Down
19 changes: 14 additions & 5 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group "default" {
targets = ["mpich"]
targets = ["qe"]
}

variable "ORGANIZATION" {
Expand All @@ -12,6 +12,12 @@ variable "BULID_BASE_IMAGE" {
variable "RUNTIME_BASE_IMAGE" {
}

variable "OPENMPI_BUILDER" {
}

variable "LAPACK_BUILDER" {
}

variable "QE_VERSION" {
}

Expand All @@ -26,18 +32,21 @@ function "tags" {
]
}

target "mpich-meta" {
target "qe-meta" {
tags = tags("quantum-espresso")
}

target "mpich" {
inherits = ["mpich-meta"]
target "qe" {
inherits = ["qe-meta"]
context = "."
contexts = {
build-base-image = "docker-image://${BUILD_BASE_IMAGE}"
runtime-base-image = "docker-image://${RUNTIME_BASE_IMAGE}"
openmpi-builder-image = "docker-image://${OPENMPI_BUILDER}"
lapack-builder-image = "docker-image://${LAPACK_BUILDER}"
}
args = {
"QE_VERSION" = "${QE_VERSION}"
"QE_VERSION" = "${QE_VERSION}"
}
}

0 comments on commit 5a8c7ca

Please sign in to comment.