Skip to content

Commit

Permalink
New release v0.5.0 (#37)
Browse files Browse the repository at this point in the history
* New release v0.5.0
    - Use verificarlo:v0.5.0 instead of v0.4.1
    - Fix issue #34 on vectorized instructions with numpy
    - Add CHANGELOG
    - Add verificarlo_version as parameter in Dockerfile files
* Add conservative mode in libmath
  • Loading branch information
yohanchatelain authored Jun 23, 2021
1 parent 4484855 commit 06c8059
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 105 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/build-fuzzy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build Fuzzy Environments

on:
Expand All @@ -17,32 +18,32 @@ jobs:
include:
- NAME: Lapack + Libmath
DOCKER_FROM: ""
DOCKER_TO: fuzzy_v0.4.1-lapack
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack
DOCKER_TO: fuzzy_v0.5.0-lapack
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-0-lapack-libmath

- NAME: Python
DOCKER_FROM: fuzzy_v0.4.1-lapack
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5
DOCKER_FROM: fuzzy_v0.5.0-lapack
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-1-python

- NAME: Numpy
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-2-numpy

- NAME: Scipy
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy-scipy
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-3-scipy

- NAME: Scikit-Learn
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-4-sklearn

name: ${{ matrix.NAME }}
Expand Down Expand Up @@ -94,7 +95,8 @@ jobs:
fi
docker build ./ -t ${{ matrix.DOCKER_IMAGE }} \
-f ${{ matrix.DOCKER_FILE }}
-f ${{ matrix.DOCKER_FILE }} \
--build-arg VERIFICARLO_VERSION=v0.5.0
docker save ${{ matrix.DOCKER_IMAGE }} -o /tmp/${{ matrix.DOCKER_TO }}.tar
Expand All @@ -115,9 +117,9 @@ jobs:
runs-on: ubuntu-20.04
env:
RUN_IF_CHANGED: docker
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_IMAGE: verificarlo/fuzzy
DOCKER_FROM_TAG: v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
DOCKER_FROM_TAG: v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn

steps:
- name: Checkout repository
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# [v0.5.0] 2021/06/18

## Changed
* Changed verificarlo version to compile fuzzy images [v0.4.1 -> v0.5.0]

## Deprecated
* Version v0.4.1 should not be used anymore because it contains a bug
on vectorized instructions.

# [v0.4.1] 2021/06/18

## Added
* Add build script to wrap an existing docker image with the fuzzy-libmath
* Add dockerfile for base3 + sklearn:0.23.2 (base 4)
* Add dockerfile for base2 + scipy:1.5.4 (base 3)
* Add dockerfile for base1 + numpy:1.19.1 (base 2)
* Add dockerfile for base0 + python:3.8.5 (base 1)
* Add dockerfile for fuzzy lapack:3.9.0 + libmath (base 0)
* Add fuzzy libmath project from https://github.com/big-data-lab-team/MCA-libmath

# [v0] 2021/05/12

This release is merely being issued such that the project can begin indexing on Zenodo, and a DOI can be referenced for this project.
21 changes: 10 additions & 11 deletions docker/base/Dockerfile.ubuntu20.04-0-lapack-libmath
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM verificarlo/verificarlo:v0.4.1
ARG VERIFICARLO_VERSION=v0.5.0
FROM verificarlo/verificarlo:${VERIFICARLO_VERSION}

RUN cat /proc/cpuinfo | grep flags | uniq
RUN cat /proc/cpuinfo | grep "model name" | uniq

# Setup build dependencies
RUN apt-get update -qqq &&\
Expand All @@ -12,13 +16,8 @@ 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 and apply verificarlo patch for adding VFC_BACKENDS_FROM_FILE option
# Could be removed when verificarlo-v0.4.2 will be available
COPY docker/resources/verificarlo.patch /tmp/verificarlo.patch
COPY docker/resources/vfcwrapper.patch /tmp/vfcwrapper.patch
RUN patch $(which verificarlo) /tmp/verificarlo.patch
RUN patch /usr/local/include/vfcwrapper.c /tmp/vfcwrapper.patch

# Setting compilers and linkers to use verificarlo
ENV CC "verificarlo-c"
Expand All @@ -33,7 +32,7 @@ RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
# Create instrumented shared mathematical library
COPY docker/resources/libmath/ /opt/mca-libmath/
RUN cd /opt/mca-libmath/ &&\
make &&\
make CONSERVATIVE=True &&\
make test


Expand All @@ -52,20 +51,20 @@ RUN cd /opt/build/ &&\
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 .. &&\
-DCBLAS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="--conservative" -DCMAKE_Fortran_FLAGS="--conservative" .. &&\
make &&\
make install

# Remove temporary files
RUN rm -rf /opt/build/*

# Preloading the instrumented shared library
ENV LD_PRELOAD="/opt/mca-libmath/libmath.so:/usr/local/lib/libblas.so:/usr/local/lib/libcblas.so"

# Restore default behavior for verificarlo's CC
ENV CC "verificarlo-c"
ENV VFC_BACKENDS_SILENT_LOAD="True"
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE

# Preloading the instrumented shared library
ENV LD_PRELOAD="/opt/mca-libmath/libmath.so:/usr/local/lib/libblas.so:/usr/local/lib/libcblas.so"

# Set bash shell as entrypoint
ENTRYPOINT [ "/bin/bash"]
16 changes: 14 additions & 2 deletions docker/base/Dockerfile.ubuntu20.04-1-python
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM verificarlo/fuzzy:v0.4.1-lapack
ARG VERIFICARLO_VERSION=v0.5.0
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack

RUN cat /proc/cpuinfo | grep flags | uniq
RUN cat /proc/cpuinfo | grep "model name" | uniq


# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
# and causes bug
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
ENV LD_PRELOAD=""

# Use IEEE mode for compiling with verificarlo
RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
Expand All @@ -11,7 +21,7 @@ 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 && \
CFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt" ./configure --enable-optimizations --with-ensurepip=install &&\
CFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt --conservative" ./configure --enable-optimizations --with-ensurepip=install &&\
make -j &&\
make install &&\
wget https://bootstrap.pypa.io/get-pip.py &&\
Expand All @@ -23,5 +33,7 @@ RUN rm -rf /opt/build/*
# Restore default MCA mode
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE

ENV LD_PRELOAD=${LD_PRELOAD_OLD}

# Set entrypoint
ENTRYPOINT [ "/bin/bash"]
23 changes: 20 additions & 3 deletions docker/base/Dockerfile.ubuntu20.04-2-numpy
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5
ARG VERIFICARLO_VERSION=v0.5.0
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5

RUN cat /proc/cpuinfo | grep flags | uniq
RUN cat /proc/cpuinfo | grep "model name" | uniq


# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
# and causes bug
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
ENV LD_PRELOAD=""

# Use IEEE mode for compiling with verificarlo
RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
Expand All @@ -11,22 +21,29 @@ RUN git config --global user.email "[email protected]" &&\
git config --global user.name "Anonymous Patcher"

# Build numpy from sources and link with the local BLAS and LAPACK
RUN pip3.8 install cython
RUN python3 -m pip install cython
RUN cd /opt/build &&\
git clone -b v1.19.1 --depth=1 https://github.com/numpy/numpy.git &&\
cd /opt/build/numpy &&\
git checkout v1.19.1 &&\
git am /tmp/numpy-verificarlo.patch &&\
CFLAGS="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument" \
OPT="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument --conservative" \
FOPT="--exclude-file=/tmp/numpy-vfc-exclude.txt -Wunused-command-line-argument --conservative" \
NPY_BLAS_ORDER=BLAS NPY_LAPACK_ORDER=LAPACK \
python3 setup.py config --compiler=verificarlo --fcompiler=verificarlof build_clib \
--compiler=verificarlo --fcompiler=verificarlof build_ext \
--compiler=verificarlo --fcompiler=verificarlof build -j 4 install

# Smoked test for vectorization.
# We should run the full numpy test suit in next versions
RUN python3 -c "import numpy as np; x = np.array(range(4),dtype=np.float64); z=[i**2 for i in range(4)]; assert((x**2==z).all())"

# Remove temporary files
RUN rm -rf /opt/build/*

# Restore default MCA mode
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE

ENV LD_PRELOAD=${LD_PRELOAD_OLD}

ENTRYPOINT [ "/bin/bash"]
15 changes: 13 additions & 2 deletions docker/base/Dockerfile.ubuntu20.04-3-scipy
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy
ARG VERIFICARLO_VERSION=v0.5.0
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy

RUN cat /proc/cpuinfo | grep flags | uniq
RUN cat /proc/cpuinfo | grep "model name" | uniq


# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
# and causes bug
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
ENV LD_PRELOAD=""

# Load backend IEEE
RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
Expand All @@ -10,7 +19,7 @@ RUN cd /opt/build/ &&\
git clone https://github.com/scipy/scipy.git &&\
cd /opt/build/scipy &&\
git checkout v1.5.4 &&\
CFLAGS="--disable-debug-flag" FFLAGS="--disable-debug-flag" NPY_NUM_BUILD_JOBS=4 \
CFLAGS="--conservative" FFLAGS="--conservative" NPY_NUM_BUILD_JOBS=4 \
python3 setup.py config --compiler=verificarlo --fcompiler=verificarlof build_clib \
--compiler=verificarlo --fcompiler=verificarlof build_ext \
--compiler=verificarlo --fcompiler=verificarlof build -j 4 install
Expand All @@ -22,4 +31,6 @@ RUN rm -rf /opt/build/*
ENV CC "verificarlo-c"
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE

ENV LD_PRELOAD=${LD_PRELOAD_OLD}

ENTRYPOINT [ "/bin/bash"]
16 changes: 14 additions & 2 deletions docker/base/Dockerfile.ubuntu20.04-4-sklearn
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy
ARG VERIFICARLO_VERSION=v0.5.0
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy-scipy

RUN cat /proc/cpuinfo | grep flags | uniq
RUN cat /proc/cpuinfo | grep "model name" | uniq


# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
# and causes bug
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
ENV LD_PRELOAD=""

# Load backend IEEE
RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
Expand All @@ -7,7 +17,7 @@ RUN cd /opt/build &&\
git clone https://github.com/scikit-learn/scikit-learn.git &&\
cd scikit-learn &&\
git checkout 0.23.2 &&\
python3 setup.py build -j 4 install
CFLAGS="--conservative" python3 setup.py build -j 4 install

# Remove temporary files
RUN rm -rf /opt/build/*
Expand All @@ -16,4 +26,6 @@ RUN rm -rf /opt/build/*
ENV CC "verificarlo-c"
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE

ENV LD_PRELOAD=${LD_PRELOAD_OLD}

ENTRYPOINT [ "/bin/bash"]
6 changes: 5 additions & 1 deletion docker/resources/libmath/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ SRCS = src/wrapping_script.c # source files
OBJS = $(SRCS:.c=.o)
ROOT = $(PWD)

ifdef CONSERVATIVE
CFLAGS += --conservative
endif

.PHONY: tracer

$(TARGET_LIB): $(OBJS)
$(CC) ${LDFLAGS} -ldl -o $@ $^
$(CC) ${LDFLAGS} ${CFLAGS} -ldl -o $@ $^

tracer:
$(CC) ${TRACER_FLAGS} ${CFLAGS} ${LDFLAGS} ${LIBS} -o ${TARGET_LIB} $(SRCS)
Expand Down
53 changes: 39 additions & 14 deletions docker/resources/verificarlo.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
--- verificarlo 2020-12-17 11:27:57.074070576 -0500
+++ /home/yohan/local/bin/verificarlo 2020-12-16 18:37:46.866142995 -0500
@@ -294,11 +294,17 @@
diff --git a/verificarlo.in.in b/verificarlo.in.in
index 14cd655..a9090b8 100644
--- a/verificarlo.in.in
+++ b/verificarlo.in.in
@@ -136,7 +136,8 @@ def compile_vfcwrapper(source, output, args, emit_llvm=False):

internal_options = (" -S -emit-llvm " if emit_llvm else "") + \
f" -c -Wno-varargs -I {mcalib_includes} "
- shell(f'{clang} -O3 -march=native {internal_options} {extra_args} {source} -o {output} ')
+ conservative = '-march=x86-64' if args.conservative else '-march=native'
+ shell(f'{clang} -O3 {conservative} {internal_options} {extra_args} {source} -o {output} ')


def linker_mode(sources, options, libraries, output, args):
@@ -204,9 +205,11 @@ def compiler_mode(sources, options, output, args):
compile_only([source], ' -c ' + options, basename_output, args)
continue

+ conservative = '-march=x86-64' if args.conservative else ''
+
# Compile to ir (fortran uses flang, c uses clang)
shell(
- f'{compiler} -c -S {debug} {source} {include} -emit-llvm {options} -o {ir.name}')
+ f'{compiler} -c -S {debug} {source} {include} -emit-llvm {options} -o {ir.name} {conservative}')

selectfunction = ""
if args.function:
@@ -246,7 +249,7 @@ def compiler_mode(sources, options, output, args):
basename_output = output

# Produce object file
- shell(f'{compiler} -c {basename_output} {ins.name} {options}')
+ shell(f'{compiler} -c {basename_output} {ins.name} {options} {conservative}')


if __name__ == "__main__":
@@ -282,6 +285,8 @@ if __name__ == "__main__":
parser.add_argument('--version', action='version', version=PACKAGE_STRING)
parser.add_argument('--linker', choices=linkers.keys(), default=default_linker,
help="linker to use, {dl} by default".format(dl=default_linker))
+ parser.add_argument('--disable-debug-flag', action="store_true",
+ help="Remove -g from the flag since it can cause error with flang")
+ parser.add_argument(
+ '--conservative', action='store_true', help='conservative')

args, other = parser.parse_known_args()

sources, llvm_options = parse_extra_args(other)

+ if args.disable_debug_flag:
+ if "-g" in llvm_options:
+ llvm_options = llvm_options.replace("-g", "")
+
# check input files
if (args.E or args.S or args.c) and len(sources) > 1 and args.o:
fail('cannot specify -o when generating multiple output files')
Loading

0 comments on commit 06c8059

Please sign in to comment.