From cadbf0d8cfa78b36f40853eb4296c4cd85281d48 Mon Sep 17 00:00:00 2001 From: yohanchatelain Date: Wed, 15 May 2024 13:43:06 -0400 Subject: [PATCH] Pre-release v2.0.0 - Update numpy version from 1.22.0 to 1.22.4 - Update sklearn version from 1.0.2 to 1.3.2 - Refactore docker images - Add test for scikit-learn --- .../Dockerfile.ubuntu-20.04-0-lapack-libmath | 70 +++++++++---------- .../Dockerfile.ubuntu-20.04-1-python | 49 +++++++------ .../Dockerfile.ubuntu-20.04-2-numpy | 49 +++++++------ .../Dockerfile.ubuntu-20.04-2-numpy-only | 49 +++++++------ .../Dockerfile.ubuntu-20.04-3-scipy | 62 ++++++++-------- .../Dockerfile.ubuntu-20.04-3-scipy-only | 56 ++++++++------- .../Dockerfile.ubuntu-20.04-4-sklearn | 38 +++++----- docker/resources/libmath/mpfr/Makefile | 4 -- .../libmath/mpfr/src/wrapping_script.c | 3 +- docker/resources/libmath/quad/Makefile | 4 -- .../libmath/quad/src/wrapping_script.c | 4 +- docker/resources/libmath/set-fuzzy-libmath.py | 41 +++++------ docker/resources/libmath/standard/Makefile | 4 -- .../libmath/standard/src/wrapping_script.c | 16 ++--- docker/resources/scipy-sanity-check.py | 9 +-- 15 files changed, 226 insertions(+), 232 deletions(-) diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-0-lapack-libmath b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-0-lapack-libmath index 48d2810..626b053 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-0-lapack-libmath +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-0-lapack-libmath @@ -1,5 +1,6 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/verificarlo:${VERIFICARLO_VERSION} +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/verificarlo:${VERIFICARLO_VERSION} # Setup build dependencies RUN apt-get update -qqq &&\ @@ -14,9 +15,7 @@ RUN apt-get update -qqq &&\ # Copy verificarlo's exclusion file for Python 3 COPY docker/resources/python-vfc-exclude.txt /tmp/python-vfc-exclude.txt -COPY docker/resources/verificarlo.patch /tmp/verificarlo.patch COPY docker/resources/libmath/set-fuzzy-libmath.py /usr/local/bin/set-fuzzy-libmath -RUN patch $(which verificarlo) /tmp/verificarlo.patch # Setting compilers and linkers to use verificarlo ENV CC "verificarlo-c" @@ -24,49 +23,48 @@ ENV CXX "verificarlo-c++" ENV FC "verificarlo-f" ENV LDSHARED "verificarlo-c" -# Load backend IEEE -RUN mkdir -p /opt/ && touch /opt/vfc-backends.txt +# Setting verificarlo's backend file ENV VFC_BACKENDS_FROM_FILE=/opt/vfc-backends.txt -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE -# Create instrumented shared mathematical library +# Copy libmath source code COPY docker/resources/libmath/ /opt/mca-libmath/ -RUN cd /opt/mca-libmath/ &&\ - make CONSERVATIVE=True &&\ - make test +# Load backend IEEE and +# create instrumented shared mathematical library +RUN mkdir -p /opt/ && \ + echo "libinterflop_ieee.so" > /opt/vfc-backends.txt && \ + cd /opt/mca-libmath/ && \ + make && \ + make test # Build BLAS and LAPACK from the following URL's instructions: # http://ab-initio.mit.edu/wiki/index.php/Template:Installing_BLAS_and_LAPACK -RUN cd /opt/build/ &&\ - wget http://www.netlib.org/lapack/lapack-3.9.0.tgz &&\ - gunzip lapack-3.9.0.tgz &&\ - tar xf lapack-3.9.0.tar &&\ - cd /opt/build/lapack-3.9.0/ &&\ - cp make.inc.example make.inc &&\ - sed -i 's/= gcc/= verificarlo-c/g' make.inc &&\ - sed -i 's/= gfortran/= verificarlo-f/g' make.inc &&\ - sed -i 's/TIMER = INT_ETIME/#TIMER = INT_ETIME/g' make.inc &&\ - sed -i 's/# TIMER = NONE/TIMER = NONE/g' make.inc &&\ - mkdir build &&\ - cd /opt/build/lapack-3.9.0/build &&\ - cmake FC=verificarlo-f -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=verificarlo-c -DCMAKE_Fortran_COMPILER=verificarlo-f \ - -DCBLAS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="--conservative" -DCMAKE_Fortran_FLAGS="--conservative" .. &&\ - make -j $(nproc) &&\ - make install - -# Remove temporary files -RUN rm -rf /opt/build/* +RUN cd /opt/build/ && \ + wget http://www.netlib.org/lapack/lapack-3.9.0.tgz && \ + gunzip lapack-3.9.0.tgz && \ + tar xf lapack-3.9.0.tar && \ + cd /opt/build/lapack-3.9.0/ && \ + cp make.inc.example make.inc && \ + sed -i 's/= gcc/= verificarlo-c/g' make.inc && \ + sed -i 's/= gfortran/= verificarlo-f/g' make.inc && \ + sed -i 's/TIMER = INT_ETIME/#TIMER = INT_ETIME/g' make.inc && \ + sed -i 's/# TIMER = NONE/TIMER = NONE/g' make.inc && \ + mkdir build && \ + cd /opt/build/lapack-3.9.0/build && \ + cmake FC=verificarlo-f -DCMAKE_BUILD_TYPE=RELEASE \ + -DCMAKE_C_COMPILER=verificarlo-c -DCMAKE_Fortran_COMPILER=verificarlo-f \ + -DCBLAS=ON -DBUILD_SHARED_LIBS=ON .. && \ + make -j $(nproc) && \ + make install && \ + rm -rf /opt/build/* -# Restore default behavior for verificarlo's CC -ENV CC "verificarlo-c" +# Preload the instrumented shared library ENV VFC_BACKENDS_LOGGER="False" ENV VFC_BACKENDS_SILENT_LOAD="True" -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE - -# Preloading the instrumented shared library ARG FUZZY_LIBMATH_VERSION=standard -RUN set-fuzzy-libmath --version=${FUZZY_LIBMATH_VERSION} + +RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE && \ + set-fuzzy-libmath --version=${FUZZY_LIBMATH_VERSION} # Set bash shell as entrypoint ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-1-python b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-1-python index d708bb1..91bcb64 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-1-python +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-1-python @@ -1,31 +1,30 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-lapack -# Use IEEE mode for compiling with verificarlo -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE - -# Remove any existing python packages -RUN apt -y -qqq remove python3 +ARG PYTHON_VERSION=3.8.5 -## Build Python 3.8.5 from source and the associated pip -RUN cd /opt/build/ && \ - wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz && \ - tar xvf Python-3.8.5.tgz && \ - cd Python-3.8.5 && \ - LDFLAGS="--conservative --exclude-file=/tmp/python-vfc-exclude.txt" \ - CFLAGS="--conservative --exclude-file=/tmp/python-vfc-exclude.txt" \ +# Use IEEE mode for compiling with verificarlo +RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + # Remove any existing python packages + apt -y -qqq remove python3 && \ + # Build Python from source and the associated pip + cd /opt/build/ && \ + wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \ + tar xvf Python-${PYTHON_VERSION}.tgz && \ + cd Python-${PYTHON_VERSION} && \ + LDFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt" \ + CFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt" \ LDSHARED='verificarlo-c -shared' \ - ./configure --with-ensurepip=install &&\ - make -j $(nproc) &&\ - make install &&\ - wget https://bootstrap.pypa.io/get-pip.py &&\ - python3 get-pip.py - -# Remove temporary files -RUN rm -rf /opt/build/* - -# Restore default MCA mode -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE + ./configure --with-ensurepip=install && \ + make -j $(nproc) && \ + make install && \ + wget https://bootstrap.pypa.io/get-pip.py && \ + python3 get-pip.py && \ + # Remove temporary files + rm -rf /opt/build/* && \ + # Restore default MCA mode + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE # Set entrypoint ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy index 4f293cd..168c9d2 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy @@ -1,34 +1,33 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5 +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5 -# Use IEEE mode for compiling with verificarlo -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE +ARG NUMPY_VERSION=1.22.4 # Copy verificarlo's exclusion file for Python 3 COPY docker/resources/numpy-vfc-exclude.txt /tmp/numpy-vfc-exclude.txt COPY docker/resources/numpy-sanity-check.py /tmp/numpy-sanity-check.py -# Build numpy from sources and link with the local BLAS and LAPACK -RUN python3 -m pip install cython - -RUN cd /opt/build/ &&\ - wget https://github.com/numpy/numpy/releases/download/v1.22.0/numpy-1.22.0.tar.gz &&\ - tar xvf numpy-1.22.0.tar.gz &&\ - cd numpy-1.22.0 &&\ +# Use IEEE mode for compiling with verificarlo +RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + # Build numpy from sources and link with the local BLAS and LAPACK + python3 -m pip install cython==0.29.30 && \ + cd /opt/build/ &&\ + wget https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}/numpy-${NUMPY_VERSION}.tar.gz &&\ + tar xvf numpy-${NUMPY_VERSION}.tar.gz &&\ + cd numpy-${NUMPY_VERSION} &&\ CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" LDSHARED='verificarlo-c -shared' \ - CFLAGS="--conservative --exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ - LDFLAGS="--conservative --exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ - python3 setup.py build -j $(nproc) --disable-optimization install - - -# Smoked test for vectorization. -# We should run the full numpy test suit in next versions -RUN python3 /tmp/numpy-sanity-check.py - -# Remove temporary files -RUN rm -rf /opt/build/* - -# Restore default MCA mode -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE + CFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + FCFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + CXXFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + LDFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + python3 setup.py build -j $(nproc) --disable-optimization install && \ + # Smoked test for vectorization. + # We should run the full numpy test suit in next versions + cd && python3 /tmp/numpy-sanity-check.py && \ + # Remove temporary files + rm -rf /opt/build/* && \ + # Restore default MCA mode + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy-only b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy-only index eee8334..db84249 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy-only +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-2-numpy-only @@ -1,34 +1,33 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-lapack -# Use IEEE mode for compiling with verificarlo -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE +ARG NUMPY_VERSION=1.22.4 # Copy verificarlo's exclusion file for Python 3 COPY docker/resources/numpy-vfc-exclude.txt /tmp/numpy-vfc-exclude.txt COPY docker/resources/numpy-sanity-check.py /tmp/numpy-sanity-check.py -# Build numpy from sources and link with the local BLAS and LAPACK -RUN python3 -m pip install --upgrade pip && python3 -m pip install --ignore-installed cython==0.29.24 - -RUN cd /opt/build/ &&\ - wget https://github.com/numpy/numpy/releases/download/v1.22.0/numpy-1.22.0.tar.gz &&\ - tar xvf numpy-1.22.0.tar.gz &&\ - cd numpy-1.22.0 &&\ +# Use IEEE mode for compiling with verificarlo +RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + # Build numpy from sources and link with the local BLAS and LAPACK + python3 -m pip install cython==0.29.30 && \ + cd /opt/build/ &&\ + wget https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}/numpy-${NUMPY_VERSION}.tar.gz &&\ + tar xvf numpy-${NUMPY_VERSION}.tar.gz &&\ + cd numpy-${NUMPY_VERSION} &&\ CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" LDSHARED='verificarlo-c -shared' \ - CFLAGS="--conservative --exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ - LDFLAGS="--conservative --exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ - python3 setup.py build -j $(nproc) --disable-optimization install - - -# Smoked test for vectorization. -# We should run the full numpy test suit in next versions -RUN python3 /tmp/numpy-sanity-check.py - -# Remove temporary files -RUN rm -rf /opt/build/* - -# Restore default MCA mode -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE + CFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + FCFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + CXXFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + LDFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \ + python3 setup.py build -j $(nproc) --disable-optimization install && \ + # Smoked test for vectorization. + # We should run the full numpy test suit in next versions + cd && python3 /tmp/numpy-sanity-check.py && \ + # Remove temporary files + rm -rf /opt/build/* && \ + # Restore default MCA mode + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy index 6b0309c..d90b9ed 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy @@ -1,40 +1,40 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy -# Load backend IEEE -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE +ARG SCIPY_VERSION=1.7.3 # Copy sanity check for SciPy -COPY docker/resources/numpy-sanity-check.py /tmp/scipy-sanity-check.py - -# Install SciPy dependencies -RUN pip3 install joblib pythran pybind11 -# Replace gfortran with verificarlo-f -RUN cp /usr/local/bin/verificarlo-f /usr/bin/gfortran - -# Remove debug flag which makes flag crash -RUN sed -i "302s/.*/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options/" $(which verificarlo) - -RUN cd /opt/build/ &&\ - wget https://github.com/scipy/scipy/releases/download/v1.7.3/scipy-1.7.3.tar.gz &&\ - tar xvf scipy-1.7.3.tar.gz &&\ - cd scipy-1.7.3 &&\ - CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" LDSHARED='verificarlo-c -shared' \ - CFLAGS="--conservative -Wunused-command-line-argument" \ - LDFLAGS="--conservative -Wunused-command-line-argument" \ - python3 setup.py build --disable-optimization -j $(nproc) install +COPY docker/resources/scipy-sanity-check.py /tmp/ -# Restore original verificarlo -RUN sed -i "302s/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options//" $(which verificarlo) - -# Sanity check -RUN python3 /tmp/scipy-sanity-check.py - -# Remove temporary files -RUN rm -rf /opt/build/* +# Load backend IEEE +RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + # Install SciPy dependencies + pip3 install joblib pythran pybind11 && \ + # Replace gfortran with verificarlo-f + cp /usr/local/bin/verificarlo-f /usr/bin/gfortran && \ + # Remove debug flag which makes compilation crash + sed -i "397s/.*/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options/" $(which verificarlo) && \ + cd /opt/build/ &&\ + wget https://github.com/scipy/scipy/releases/download/v${SCIPY_VERSION}/scipy-${SCIPY_VERSION}.tar.gz &&\ + tar xvf scipy-${SCIPY_VERSION}.tar.gz &&\ + cd scipy-${SCIPY_VERSION} &&\ + CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" \ + LDSHARED='verificarlo-c -shared' \ + CFLAGS="-Wunused-command-line-argument" \ + CXXFLAGS="-Wunused-command-line-argument" \ + FCFLAGS="-Wunused-command-line-argument" \ + LDFLAGS="-Wunused-command-line-argument" \ + python3 setup.py build --disable-optimization -j $(nproc) install && \ + # Restore original verificarlo + sed -i "397s/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options//" $(which verificarlo) && \ + # Set default MCA mode + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE && \ + # Sanity check + cd && python3 /tmp/scipy-sanity-check.py && \ + rm -rf /opt/build/* # Restore default behavior for verificarlo's CC ENV CC "verificarlo-c" -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy-only b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy-only index 6a9c563..635aa6a 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy-only +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-3-scipy-only @@ -1,34 +1,40 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-numpy +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-numpy -# Load backend IEEE -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE +ARG SCIPY_VERSION=1.7.3 # Copy sanity check for SciPy -COPY docker/resources/numpy-sanity-check.py /tmp/scipy-sanity-check.py - -# Install SciPy dependencies -RUN pip3 install joblib pythran pybind11 -# Replace gfortran with verificarlo-f -RUN cp /usr/local/bin/verificarlo-f /usr/bin/gfortran - -RUN cd /opt/build/ &&\ - wget https://github.com/scipy/scipy/releases/download/v1.7.3/scipy-1.7.3.tar.gz &&\ - tar xvf scipy-1.7.3.tar.gz &&\ - cd scipy-1.7.3 &&\ - CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" LDSHARED='verificarlo-c -shared' \ - CFLAGS="--conservative -Wunused-command-line-argument" \ - LDFLAGS="--conservative -Wunused-command-line-argument" \ - python3 setup.py build --disable-optimization -j $(nproc) install +COPY docker/resources/scipy-sanity-check.py /tmp/ -# Sanity check -RUN python3 /tmp/scipy-sanity-check.py - -# Remove temporary files -RUN rm -rf /opt/build/* +# Load backend IEEE +RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + # Install SciPy dependencies + pip3 install joblib pythran pybind11 && \ + # Replace gfortran with verificarlo-f + cp /usr/local/bin/verificarlo-f /usr/bin/gfortran && \ + # Remove debug flag which makes compilation crash + sed -i "397s/.*/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options/" $(which verificarlo) && \ + cd /opt/build/ &&\ + wget https://github.com/scipy/scipy/releases/download/v${SCIPY_VERSION}/scipy-${SCIPY_VERSION}.tar.gz &&\ + tar xvf scipy-${SCIPY_VERSION}.tar.gz &&\ + cd scipy-${SCIPY_VERSION} &&\ + CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" \ + LDSHARED='verificarlo-c -shared' \ + CFLAGS="-Wunused-command-line-argument" \ + CXXFLAGS="-Wunused-command-line-argument" \ + FCFLAGS="-Wunused-command-line-argument" \ + LDFLAGS="-Wunused-command-line-argument" \ + python3 setup.py build --disable-optimization -j $(nproc) install && \ + # Restore original verificarlo + sed -i "397s/ llvm_options = llvm_options.replace(\"'-g'\",'') if \"'-g'\" in llvm_options else llvm_options//" $(which verificarlo) && \ + # Set default MCA mode + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE && \ + # Sanity check + cd && python3 /tmp/scipy-sanity-check.py && \ + rm -rf /opt/build/* # Restore default behavior for verificarlo's CC ENV CC "verificarlo-c" -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE ENTRYPOINT [ "/bin/bash"] diff --git a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-4-sklearn b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-4-sklearn index 9c2de8f..65349c8 100644 --- a/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-4-sklearn +++ b/docker/base/ubuntu-20.04/Dockerfile.ubuntu-20.04-4-sklearn @@ -1,24 +1,28 @@ -ARG VERIFICARLO_VERSION=v0.9.1 -FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy-scipy +ARG ORG=verificarlo +ARG VERIFICARLO_VERSION=v2.0.0 +FROM ${ORG}/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy-scipy -# Load backend IEEE -RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE +ARG SKLEARN_VERSION=1.3.2 + +COPY docker/resources/sklearn-sanity-check.py /tmp/ -RUN cd /opt/build &&\ - wget https://github.com/scikit-learn/scikit-learn/archive/refs/tags/1.0.2.tar.gz &&\ - tar xvf 1.0.2.tar.gz &&\ - cd scikit-learn-1.0.2 &&\ +# Load backend IEEE +RUN pip install cython>=3.0.0 -U && \ + echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE && \ + cd /opt/build && \ + wget https://github.com/scikit-learn/scikit-learn/archive/refs/tags/${SKLEARN_VERSION}.tar.gz &&\ + tar xvf ${SKLEARN_VERSION}.tar.gz &&\ + cd scikit-learn-${SKLEARN_VERSION} &&\ CC="verificarlo-c" FC="verificarlo-f" CXX="verificarlo-c++" \ - CFLAGS="--conservative -Wunused-command-line-argument" \ - LDFLAGS="--conservative -Wunused-command-line-argument" \ + CFLAGS="-Wunused-command-line-argument" \ + FCFLAGS="-Wunused-command-line-argument" \ + LDFLAGS="-Wunused-command-line-argument" \ LDSHARED="verificarlo-c -shared" \ - python3 -m pip install --verbose . - -# Remove temporary files -RUN rm -rf /opt/build/* + python3 -m pip install --verbose . && \ + # Remove temporary files + echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE && \ + cd && python3 /tmp/sklearn-sanity-check.py && \ + rm -rf /opt/build/* -# Restore default behavior for verificarlo's CC -ENV CC "verificarlo-c" -RUN echo "libinterflop_mca_int.so -m rr" > $VFC_BACKENDS_FROM_FILE ENTRYPOINT [ "/bin/bash"] diff --git a/docker/resources/libmath/mpfr/Makefile b/docker/resources/libmath/mpfr/Makefile index 1e42af4..92aae33 100755 --- a/docker/resources/libmath/mpfr/Makefile +++ b/docker/resources/libmath/mpfr/Makefile @@ -14,10 +14,6 @@ SRCS = src/wrapping_script.c # source files OBJS = $(SRCS:.c=.o) ROOT = $(PWD) -ifdef CONSERVATIVE -CFLAGS += --conservative -endif - .PHONY: tracer $(TARGET_LIB): $(OBJS) diff --git a/docker/resources/libmath/mpfr/src/wrapping_script.c b/docker/resources/libmath/mpfr/src/wrapping_script.c index bc63b52..72b76fc 100755 --- a/docker/resources/libmath/mpfr/src/wrapping_script.c +++ b/docker/resources/libmath/mpfr/src/wrapping_script.c @@ -1,8 +1,9 @@ #define _GNU_SOURCE #include -#include #include +#include "interflop/interflop.h" + __float128 mpfr_get_float128(mpfr_t op, mpfr_rnd_t rnd); #define QUAD_PREC 113 diff --git a/docker/resources/libmath/quad/Makefile b/docker/resources/libmath/quad/Makefile index 62aa158..0112978 100755 --- a/docker/resources/libmath/quad/Makefile +++ b/docker/resources/libmath/quad/Makefile @@ -15,10 +15,6 @@ SRCS = src/wrapping_script.c # source files OBJS = $(SRCS:.c=.o) ROOT = $(PWD) -ifdef CONSERVATIVE -CFLAGS += --conservative -endif - .PHONY: tracer $(TARGET_LIB): $(OBJS) diff --git a/docker/resources/libmath/quad/src/wrapping_script.c b/docker/resources/libmath/quad/src/wrapping_script.c index b628554..9d4d6ba 100755 --- a/docker/resources/libmath/quad/src/wrapping_script.c +++ b/docker/resources/libmath/quad/src/wrapping_script.c @@ -1,10 +1,12 @@ #define _GNU_SOURCE + #include -#include #include #include #include +#include "interflop/interflop.h" + #define GET_PRECISION(TYPE) _Generic(TYPE, float : 24, double : 53) #define DEFINE_1_WRAPPER(WRAPPER, INTERNAL, TYPE) \ diff --git a/docker/resources/libmath/set-fuzzy-libmath.py b/docker/resources/libmath/set-fuzzy-libmath.py index 9fc2d8e..a47445c 100755 --- a/docker/resources/libmath/set-fuzzy-libmath.py +++ b/docker/resources/libmath/set-fuzzy-libmath.py @@ -1,44 +1,40 @@ #!/usr/bin/env python3 +# TODO rewrite this script in bash to avoid the python3 dependency + import argparse import os import textwrap -ld_preload_file = '/etc/ld.so.preload' -fuzzy_libmath_root = '/opt/mca-libmath' +ld_preload_file = "/etc/ld.so.preload" +fuzzy_libmath_root = "/opt/mca-libmath" -versions = [ - 'no-fuzzy', - 'fast', - 'standard', - 'quad', - 'mpfr' -] +versions = ["no-fuzzy", "fast", "standard", "quad", "mpfr"] -libmath_so = 'libmath.so' +libmath_so = "libmath.so" def switch_version(version): try: - with open(ld_preload_file, encoding='utf-8') as fi: + with open(ld_preload_file, encoding="utf-8") as fi: current_so = fi.readline().strip().split() except FileNotFoundError: current_so = [] new_so = [so for so in current_so if not so.startswith(fuzzy_libmath_root)] - if version != 'no-fuzzy': + if version != "no-fuzzy": new_version = os.path.join(fuzzy_libmath_root, version, libmath_so) new_so.append(new_version) to_write = " ".join(new_so) - with open(ld_preload_file, "w", encoding='utf-8') as fo: + with open(ld_preload_file, "w", encoding="utf-8") as fo: fo.write(to_write) def parse_args(): - help_msg = '''\ + help_msg = """\ Fuzzy libmath version to use: - no-fuzzy: Disable fuzzy libmath - fast: Use the standard libmath available on the system. @@ -50,13 +46,14 @@ def parse_args(): Slower than the standard version but more accurate. - mpfr: Use the mpfr library for intermediate results. Slowest version but gives the correct rounding. - ''' - - parser = argparse.ArgumentParser('set-fuzzy-libmath', - formatter_class=argparse.RawTextHelpFormatter, - epilog=textwrap.dedent(help_msg)) - parser.add_argument('--version', required=True, choices=versions, - action='store') + """ + + parser = argparse.ArgumentParser( + "set-fuzzy-libmath", + formatter_class=argparse.RawTextHelpFormatter, + epilog=textwrap.dedent(help_msg), + ) + parser.add_argument("--version", required=True, choices=versions, action="store") args = parser.parse_args() return args @@ -66,5 +63,5 @@ def main(): switch_version(args.version) -if '__main__' == __name__: +if "__main__" == __name__: main() diff --git a/docker/resources/libmath/standard/Makefile b/docker/resources/libmath/standard/Makefile index a06f3bd..bcba745 100755 --- a/docker/resources/libmath/standard/Makefile +++ b/docker/resources/libmath/standard/Makefile @@ -14,10 +14,6 @@ SRCS = src/wrapping_script.c # source files OBJS = $(SRCS:.c=.o) ROOT = $(PWD) -ifdef CONSERVATIVE -CFLAGS += --conservative -endif - .PHONY: tracer $(TARGET_LIB): $(OBJS) diff --git a/docker/resources/libmath/standard/src/wrapping_script.c b/docker/resources/libmath/standard/src/wrapping_script.c index f039599..b18490f 100755 --- a/docker/resources/libmath/standard/src/wrapping_script.c +++ b/docker/resources/libmath/standard/src/wrapping_script.c @@ -1,8 +1,8 @@ #define _GNU_SOURCE #include -#include #include -//#include + +#include "interflop/interflop.h" #define xstr(s) str(s) #define str(s) #s @@ -89,12 +89,12 @@ static void (*real_sincosf)(float dbl, float *sin, float *cos); #define ZERO(TYPE) _Generic(TYPE, float : 0.0f, double : 0.0) #define GET_FTYPE(TYPE) _Generic(TYPE, float : FFLOAT, double : FDOUBLE) -#define DEFINE_1_WRAPPER(NAME, TYPE) \ - TYPE NAME(TYPE x) { \ - real_##NAME = dlsym(RTLD_NEXT, #NAME); \ - TYPE res = real_##NAME(x); \ - interflop_call(INTERFLOP_INEXACT_ID, GET_FTYPE(x), &res, -1); \ - return res; \ +#define DEFINE_1_WRAPPER(NAME, TYPE) \ + TYPE NAME(TYPE x) { \ + real_##NAME = dlsym(RTLD_NEXT, #NAME); \ + TYPE res = real_##NAME(x); \ + interflop_call(INTERFLOP_INEXACT_ID, GET_FTYPE(x), &res, -1); \ + return res; \ } #define DEFINE_1i_1_WRAPPER(NAME, TYPE) \ diff --git a/docker/resources/scipy-sanity-check.py b/docker/resources/scipy-sanity-check.py index 40e453b..a5e91e7 100644 --- a/docker/resources/scipy-sanity-check.py +++ b/docker/resources/scipy-sanity-check.py @@ -1,11 +1,12 @@ import scipy import scipy.linalg +import numpy as np -def test_det(): - ret = set([scipy.linalg.det([[1, 2], [3, 4]]) for _ in range(100)]) - assert len(ret) != 1 +def test_inv(): + ret = np.unique(([scipy.linalg.inv([[1, 2], [3, 4]]) for _ in range(100)])) + assert ret.size != 4 if "__main__" == __name__: - test_det() + test_inv()