Skip to content

Commit

Permalink
Interflop (#13)
Browse files Browse the repository at this point in the history
* Update dependencies requirements
    - Move GCC 6.0 -> 7.0 since gcc-6.0 produces
      a segfault during the compilation
    - Add dependencies for glibc 2.28 since
      the <threads.h> is missing in glibc 2.27
      See https://www.gnu.org/software/gnulib/manual/html_node/threads_002eh.html

* Set llvm-16 as the latest version supported
    - llvm-17 and >= required to rewrite the
      LLVM passes using the new pass manager.
    - Fix Python packages installation with
    >= python3.11

* Remove prng and Verrou dependencies from fma for license compatibility reasons.
  - Now interflop_fma uses builtin fma implementation

* Update logger:
    - Add a new function to log debug messages
    - Add VFC_BACKENDS_LOGGER_LEVEL environment
    variable to control the verbosity of the logger

* Update the tests:
    - Add skipable tests, marked with # SKIP
      test_cython and FORTRAN tests
    - Add time profiling to the tests,
      enabled with PROFILE_TIME env variable
    - Clean tests
    - Add test for FMA instrumentation
    * Mark test_static as XFAIL:
       Mark this test as expected to fail (exit 88) static mode fails with
       - libinterflop_ieee.so due to libquadmath not being handled correctly, it
         fails with glibc 2.31 and works with glibc 2.35 and above
       - libinterflop_mca.so (any backends using RNG)  due to issues with the TLS and static libraries
         (see https://www.akkadia.org/drepper/tls.pdf sec 3.1)

* Fix issues with vprec backend:
    - Now implement round-to-nearest, ties-to-even
      TODO: fix corner case when both closest
      values are equidistant.
    - Pass `test.sh full` in test_vprec_backend
    - Now uses C implementation test against MPFR
      instead of relying on Bigfloat Python package
    - Add `retest.sh` to retest failed tests
      ex: ./retest.sh log.error
   * Fix bug in interflop_vprec_function_instrumentation.c
      - pointer to float values could be read while
        being null. Add a check to avoid this.
      - Unify Ftypes with the ones in interflop.h
      - Code refactoring

* Update documentation
  • Loading branch information
yohanchatelain authored Apr 26, 2024
1 parent 4880559 commit eaceafc
Show file tree
Hide file tree
Showing 125 changed files with 2,645 additions and 77,140 deletions.
88 changes: 84 additions & 4 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,88 @@ on:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
release:
types: [ published ]

env:
TEST_TAG: verificarlo/verificarlo:test
LATEST_TAG: verificarlo/verificarlo:latest

jobs:
docker-flang:
runs-on: ubuntu-22.04
env:
TEST_TAG: verificarlo/verificarlo:test
LATEST_TAG: ${{ github.repository }}:latest
RELEASE_TAG: ${{ github.repository }}:${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: Test
run: |
docker run --rm ${{ env.TEST_TAG }} /bin/bash -c "make -C /build/verificarlo installcheck"
- name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.LATEST_TAG }}
${{ env.RELEASE_TAG }}
docker:
runs-on: ubuntu-20.04
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu:20.04
llvm: 7
gcc: 7
- os: ubuntu:20.04
llvm: 8
gcc: 7
- os: ubuntu:20.04
llvm: 9
gcc: 7
- os: ubuntu:20.04
llvm: 10
gcc: 7
- os: ubuntu:22.04
llvm: 11
gcc: 9
- os: ubuntu:22.04
llvm: 12
gcc: 9
- os: ubuntu:22.04
llvm: 13
gcc: 9
- os: ubuntu:22.04
llvm: 14
gcc: 9
- os: ubuntu:22.04
llvm: 15
gcc: 9
- os: ubuntu:24.04
llvm: 16
gcc: 9
file: Dockerfile_ubuntu-24.04
runs-on: ubuntu-22.04
env:
TEST_TAG: verificarlo/verificarlo:test-llvm-${{ matrix.llvm }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,6 +99,12 @@ jobs:
context: .
load: true
tags: ${{ env.TEST_TAG }}
file: ${{ matrix.file || 'Dockerfile' }}
build-args: |
UBUNTU_VERSION=${{ matrix.os }}
LLVM_VERSION=${{ matrix.llvm }}
GCC_VERSION=${{ matrix.gcc }}
WITH_FLANG=
- name: Test
run: |
docker run --rm ${{ env.TEST_TAG }} /bin/bash -c "make -C /build/verificarlo installcheck"
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# This image includes support for Fortran and uses llvm-7 and gcc-7
#

FROM ubuntu:20.04
ARG UBUNTU_VERSION=ubuntu:20.04
FROM ${UBUNTU_VERSION}
LABEL maintainer="verificarlo contributors <[email protected]>"

ARG PYTHON_VERSION=3.8
ARG LLVM_VERSION=7
ARG GCC_VERSION=7
ARG WITH_FLANG=flang
ARG GCC_PATH=/usr/lib/gcc/x86_64-linux-gnu/${GCC_VERSION}
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
ENV PATH /usr/local/bin:$PATH
Expand All @@ -20,8 +22,9 @@ RUN apt-get -y install --no-install-recommends \
bash ca-certificates make git libmpfr-dev \
autogen dh-autoreconf autoconf automake autotools-dev libedit-dev libtool libz-dev binutils \
clang-${LLVM_VERSION} llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev \
libomp5-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev \
gcc-${GCC_VERSION} g++-${GCC_VERSION} \
gfortran-${GCC_VERSION} libgfortran-${GCC_VERSION}-dev flang \
gfortran-${GCC_VERSION} libgfortran-${GCC_VERSION}-dev ${WITH_FLANG} \
python3 python3-pip python3-dev cython3 parallel && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -30,7 +33,7 @@ WORKDIR /build/
ENV LIBRARY_PATH ${GCC_PATH}:$LIBRARY_PATH

# Install other Python dependencies (not available with apt-get) via pip
RUN ln -s /usr/bin/x86_64-linux-gnu-gcc-7 /usr/bin/x86_64-linux-gnu-gcc
RUN ln -s /usr/bin/x86_64-linux-gnu-gcc-${GCC_VERSION} /usr/bin/x86_64-linux-gnu-gcc

# Download and configure verificarlo from git master
ENV AR=gcc-ar-${GCC_VERSION}
Expand All @@ -40,12 +43,16 @@ ENV CXX=g++-${GCC_VERSION}
COPY . /build/verificarlo/
WORKDIR /build/verificarlo

RUN ./install-interflop.sh && \

RUN if [ "$WITH_FLANG" = "flang" ]; then \
export FLANG_OPTION="--with-flang"; \
else \
export FLANG_OPTION="--without-flang"; \
fi && \
./autogen.sh && \
./configure \
--with-llvm=$(llvm-config-${LLVM_VERSION} --prefix) \
--with-flang CC=gcc-${GCC_VERSION} CXX=g++-${GCC_VERSION} \
|| cat config.log
$FLANG_OPTION || { cat config.log; exit 1; }

# Build verificarlo
RUN make && make install
Expand Down
62 changes: 62 additions & 0 deletions Dockerfile_ubuntu-24.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Dockerfile for Verificarlo (github.com/verificarlo/verificarlo)
# This image includes support for Fortran and uses llvm-7 and gcc-7
#

ARG UBUNTU_VERSION=ubuntu:24.04
FROM ${UBUNTU_VERSION}
LABEL maintainer="verificarlo contributors <[email protected]>"

ARG PYTHON_VERSION=3.12
ARG LLVM_VERSION=14
ARG GCC_VERSION=9
ARG WITH_FLANG=flang
ARG GCC_PATH=/usr/lib/gcc/x86_64-linux-gnu/${GCC_VERSION}
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
ENV PATH /usr/local/bin:$PATH
ENV PYTHONPATH /usr/local/lib/python${PYTHON_VERSION}/site-packages/:${PYTHONPATH}

# Retrieve dependencies
RUN apt-get -y update && apt-get -y --no-install-recommends install tzdata
RUN apt-get -y install --no-install-recommends \
bash ca-certificates make git libmpfr-dev \
autogen dh-autoreconf autoconf automake autotools-dev libedit-dev libtool libz-dev binutils \
libstdc++-14-dev libomp-${LLVM_VERSION}-dev libclang-rt-${LLVM_VERSION}-dev \
clang-${LLVM_VERSION} llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev \
gcc-${GCC_VERSION} g++-${GCC_VERSION} \
gfortran-${GCC_VERSION} libgfortran-${GCC_VERSION}-dev ${WITH_FLANG} \
python3 python3-pip python3-dev cython3 parallel && \
rm -rf /var/lib/apt/lists/*

WORKDIR /build/

ENV LIBRARY_PATH ${GCC_PATH}:$LIBRARY_PATH

# Install other Python dependencies (not available with apt-get) via pip
RUN ln -s /usr/bin/x86_64-linux-gnu-gcc-${GCC_VERSION} /usr/bin/x86_64-linux-gnu-gcc

# Download and configure verificarlo from git master
ENV AR=gcc-ar-${GCC_VERSION}
ENV RANLIB=gcc-ranlib-${GCC_VERSION}
ENV CC=gcc-${GCC_VERSION}
ENV CXX=g++-${GCC_VERSION}
COPY . /build/verificarlo/
WORKDIR /build/verificarlo


RUN if [ "$WITH_FLANG" = "flang" ]; then \
export FLANG_OPTION="--with-flang"; \
else \
export FLANG_OPTION="--without-flang"; \
fi && \
./autogen.sh && \
./configure \
--with-llvm=$(llvm-config-${LLVM_VERSION} --prefix) \
$FLANG_OPTION || { cat config.log; exit 1; }

# Build verificarlo
RUN make && make install

# Setup working directory
VOLUME /workdir
WORKDIR /workdir
15 changes: 13 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
ACLOCAL_AMFLAGS=-I m4

all: interflop-stdlib-install $(SUBDIRS)

interflop-stdlib-install:
make -C src/interflop-stdlib
make -C src/interflop-stdlib install

SUBDIRS=src/

dist_bin_SCRIPTS=verificarlo verificarlo-c verificarlo-f verificarlo-c++
Expand Down Expand Up @@ -26,7 +33,7 @@ check:
@echo "Tests should be run after install with make installcheck"

install-exec-hook:
$(PYTHON) -m pip install . && \
$(PYTHON) -m pip install $(PYTHON_INSTALL_FLAGS) . && \
echo "Run 'source $(setenvdir)/set-env' to set environment variables"

installcheck:
Expand All @@ -44,7 +51,11 @@ installcheck:
fi

# clean-local is a clean dependency of autotool clean target
clean-local: cleantests
clean-local: cleanstdlib cleantests

cleanstdlib:
# Clean interflop-stdlib directory
cd src/interflop-stdlib && make clean && cd ../..

cleantests:
# Clean tests directory
Expand Down
34 changes: 29 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ GCC_VERSION=`$CC --version | head -n1 | awk '{print $NF;}'`
AC_MSG_CHECKING([for gcc version])
AC_DEFINE_UNQUOTED([GCC_VERSION],[$GCC_VERSION],[The gcc version])
AC_MSG_RESULT([$GCC_VERSION])
AX_COMPARE_VERSION([$GCC_VERSION],[ge],['6.0.0'],[],[AC_MSG_ERROR([At least GCC version 6 is required])])
AX_COMPARE_VERSION([$GCC_VERSION],[ge],['7.0.0'],[],[AC_MSG_ERROR([At least GCC version 7 is required])])
AC_DEFINE_UNQUOTED([GCC_PATH], ["$CC"], [GCC path (for compiling)])
AC_SUBST(GCC_PATH, $CC)
AX_LLVM([4.0],[15.0.6],[all])
AX_LLVM([4.0],[16.0.6],[all])
AC_SUBST(LLVM_CPPFLAGS, $LLVM_CPPFLAGS)
AC_SUBST(LLVM_LDFLAGS, $LLVM_LDFLAGS)
AC_SUBST(LLVM_VERSION_MAJOR, $LLVM_VERSION_MAJOR)

GLIBC_VERSION=`ldd --version | head -n1 | awk '{print $NF;}'`
AC_MSG_CHECKING([for glibc version])
AC_DEFINE_UNQUOTED([GLIBC_VERSION],[$GLIBC_VERSION],[The glibc version])
AC_MSG_RESULT([$GLIBC_VERSION])
AX_COMPARE_VERSION([$GLIBC_VERSION],[ge],['2.28.0'],[],[AC_MSG_ERROR([At least glibc version 2.28 is required])])

AC_PATH_PROG([CLANG], [clang], "", $LLVM_BINDIR/ $PATH)
if test -z "$CLANG"; then
AC_PATH_PROGS([CLANG], [clang-"$LLVM_VERSION_MAJOR"."$LLVM_VERSION_MINOR" clang], "")
Expand Down Expand Up @@ -174,8 +180,8 @@ AC_FUNC_REALLOC

AC_CHECK_FUNCS([atexit dup2 floor getenv gettimeofday getpagesize getpid memset mkdir pow sqrt strcasecmp strchr strdup strerror strrchr strstr strtol strtoull tzset utime])

# Check for Python 3
AM_PATH_PYTHON([3])
# Check for Python 3.8
AM_PATH_PYTHON([3.8])

if test -n "$PYTHON" && test -x "$PYTHON" ; then
AC_MSG_CHECKING([for python])
Expand All @@ -190,7 +196,25 @@ else
AC_MSG_ERROR([could not find python 2.7 or higher])])
fi


# Get Python version
PYTHON_VERSION=`$PYTHON --version 2>&1 | awk '{print $2;}'`
AC_MSG_CHECKING([for python version])
AC_DEFINE_UNQUOTED([PYTHON_VERSION],[$PYTHON_VERSION],[The python version])
AC_MSG_RESULT([$PYTHON_VERSION])

# Compare Python version with 3.11
AX_COMPARE_VERSION([$PYTHON_VERSION],[ge],['3.11.0'],
# Since Python 3.11, the --break-system-packages flag is required to install packages
# in the user site directory. This is to avoid conflicts with system packages like apt.
# https://peps.python.org/pep-0668/
[PYTHON_INSTALL_FLAGS="--break-system-packages"], # If Python version >= 3.11
[PYTHON_INSTALL_FLAGS=""] # If Python version < 3.11
)

AC_DEFINE_UNQUOTED([PYTHON_INSTALL_FLAGS], ["$PYTHON_INSTALL_FLAGS"], [Python install flags])
AC_SUBST(PYTHON_INSTALL_FLAGS, $PYTHON_INSTALL_FLAGS)

AC_CONFIG_SUBDIRS([src/interflop-stdlib])

AX_WARNINGS()
AX_LTO()
Expand Down
Loading

0 comments on commit eaceafc

Please sign in to comment.