-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile_llvm
More file actions
81 lines (66 loc) · 2.82 KB
/
Copy pathDockerfile_llvm
File metadata and controls
81 lines (66 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Use gmao/llvm-flang as base image
FROM gmao/llvm-flang
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
# Install necessary packages
RUN apt-get update && apt-get install -y \
wget \
bzip2 \
ca-certificates \
curl \
git \
nano \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set up working directory
WORKDIR /app
# Install Anaconda
RUN wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh -O /tmp/anaconda.sh \
&& bash /tmp/anaconda.sh -b -p /opt/anaconda \
&& rm /tmp/anaconda.sh
# Add Anaconda to PATH
ENV PATH="/opt/anaconda/bin:${PATH}"
# Initialize conda for bash shell
RUN echo ". /opt/anaconda/etc/profile.d/conda.sh" >> ~/.bash_profile
RUN echo ". /opt/anaconda/etc/profile.d/conda.sh" >> ~/.bashrc
# Copy environment.yaml file
COPY environment.yaml .
# Create conda environment from the yaml file
# this installs fpm and intel compiler
RUN conda env create -f environment.yaml
RUN echo "conda activate band" >> ~/.bash_profile
RUN echo "conda activate band" >> ~/.bashrc
# Source - https://stackoverflow.com/a/39777387
# Posted by Ahmad Abdelghany, modified by community. See post 'Timeline' for change history
# Retrieved 2025-11-09, License - CC BY-SA 4.0
# this command, together with putting conda activation in .bash_profile, means we have
# enabled the conda environment for every command
SHELL ["/bin/bash", "--login", "-c"]
# Copy the fortran code over
# first we build the expected directory structure
# and then we copy files
RUN mkdir /app/src
RUN mkdir /app/test
COPY src /app/src/
COPY test /app/test
COPY fpm.toml /app/
# also copy over the python functions for testing
RUN mkdir /app/python
COPY python /app/python/
# Link the LLVM OpenMP runtime into everything fpm builds here (including
# interactive fpm invocations inside the container). The flang-compiled
# shared library references __kmpc_* symbols, and without -fopenmp at link
# time the Python ctypes load of libband_distribution.so fails.
ENV FPM_LDFLAGS="-fopenmp"
# Now compile the fortran code.
# The compiler is invoked as `flang`: the flang-new name was dropped in
# LLVM 20. -fdo-concurrent-to-openmp=host parallelizes the do concurrent
# loops via the OpenMP runtime; without it they compile to serial loops.
# LD_LIBRARY_PATH is cleared for the compile: the Intel packages in the
# conda env put their own (stripped) libLLVM on the path at activation,
# which breaks the system flang with a symbol lookup error.
RUN LD_LIBRARY_PATH="" fpm test --compiler flang --profile release --flag "-O3 -fopenmp -fdo-concurrent-to-openmp=host" \
&& LD_LIBRARY_PATH="" fpm install --prefix=. --compiler flang --profile release --flag "-O3 -fopenmp -fdo-concurrent-to-openmp=host"
# Needed to find the appropriate .so files from within python
ENV LD_LIBRARY_PATH=/app/lib:$LD_LIBRARY_PATH