Skip to content

Commit 06c8059

Browse files
New release v0.5.0 (#37)
* 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
1 parent 4484855 commit 06c8059

10 files changed

+157
-105
lines changed

.github/workflows/build-fuzzy.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Build Fuzzy Environments
23

34
on:
@@ -17,32 +18,32 @@ jobs:
1718
include:
1819
- NAME: Lapack + Libmath
1920
DOCKER_FROM: ""
20-
DOCKER_TO: fuzzy_v0.4.1-lapack
21-
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack
21+
DOCKER_TO: fuzzy_v0.5.0-lapack
22+
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack
2223
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-0-lapack-libmath
2324

2425
- NAME: Python
25-
DOCKER_FROM: fuzzy_v0.4.1-lapack
26-
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5
27-
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5
26+
DOCKER_FROM: fuzzy_v0.5.0-lapack
27+
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5
28+
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5
2829
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-1-python
2930

3031
- NAME: Numpy
31-
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5
32-
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy
33-
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy
32+
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5
33+
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy
34+
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy
3435
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-2-numpy
3536

3637
- NAME: Scipy
37-
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy
38-
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy
39-
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy
38+
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy
39+
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy
40+
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy-scipy
4041
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-3-scipy
4142

4243
- NAME: Scikit-Learn
43-
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy
44-
DOCKER_TO: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
45-
DOCKER_IMAGE: verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
44+
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy
45+
DOCKER_TO: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
46+
DOCKER_IMAGE: verificarlo/fuzzy:v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
4647
DOCKER_FILE: ./docker/base/Dockerfile.ubuntu20.04-4-sklearn
4748

4849
name: ${{ matrix.NAME }}
@@ -94,7 +95,8 @@ jobs:
9495
fi
9596
9697
docker build ./ -t ${{ matrix.DOCKER_IMAGE }} \
97-
-f ${{ matrix.DOCKER_FILE }}
98+
-f ${{ matrix.DOCKER_FILE }} \
99+
--build-arg VERIFICARLO_VERSION=v0.5.0
98100
99101
docker save ${{ matrix.DOCKER_IMAGE }} -o /tmp/${{ matrix.DOCKER_TO }}.tar
100102
@@ -115,9 +117,9 @@ jobs:
115117
runs-on: ubuntu-20.04
116118
env:
117119
RUN_IF_CHANGED: docker
118-
DOCKER_FROM: fuzzy_v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
120+
DOCKER_FROM: fuzzy_v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
119121
DOCKER_IMAGE: verificarlo/fuzzy
120-
DOCKER_FROM_TAG: v0.4.1-lapack-python3.8.5-numpy-scipy-sklearn
122+
DOCKER_FROM_TAG: v0.5.0-lapack-python3.8.5-numpy-scipy-sklearn
121123

122124
steps:
123125
- name: Checkout repository

CHANGELOG

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# [v0.5.0] 2021/06/18
2+
3+
## Changed
4+
* Changed verificarlo version to compile fuzzy images [v0.4.1 -> v0.5.0]
5+
6+
## Deprecated
7+
* Version v0.4.1 should not be used anymore because it contains a bug
8+
on vectorized instructions.
9+
10+
# [v0.4.1] 2021/06/18
11+
12+
## Added
13+
* Add build script to wrap an existing docker image with the fuzzy-libmath
14+
* Add dockerfile for base3 + sklearn:0.23.2 (base 4)
15+
* Add dockerfile for base2 + scipy:1.5.4 (base 3)
16+
* Add dockerfile for base1 + numpy:1.19.1 (base 2)
17+
* Add dockerfile for base0 + python:3.8.5 (base 1)
18+
* Add dockerfile for fuzzy lapack:3.9.0 + libmath (base 0)
19+
* Add fuzzy libmath project from https://github.com/big-data-lab-team/MCA-libmath
20+
21+
# [v0] 2021/05/12
22+
23+
This release is merely being issued such that the project can begin indexing on Zenodo, and a DOI can be referenced for this project.

docker/base/Dockerfile.ubuntu20.04-0-lapack-libmath

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM verificarlo/verificarlo:v0.4.1
1+
ARG VERIFICARLO_VERSION=v0.5.0
2+
FROM verificarlo/verificarlo:${VERIFICARLO_VERSION}
3+
4+
RUN cat /proc/cpuinfo | grep flags | uniq
5+
RUN cat /proc/cpuinfo | grep "model name" | uniq
26

37
# Setup build dependencies
48
RUN apt-get update -qqq &&\
@@ -12,13 +16,8 @@ RUN apt-get update -qqq &&\
1216

1317
# Copy verificarlo's exclusion file for Python 3
1418
COPY docker/resources/python-vfc-exclude.txt /tmp/python-vfc-exclude.txt
15-
16-
# Copy and apply verificarlo patch for adding VFC_BACKENDS_FROM_FILE option
17-
# Could be removed when verificarlo-v0.4.2 will be available
1819
COPY docker/resources/verificarlo.patch /tmp/verificarlo.patch
19-
COPY docker/resources/vfcwrapper.patch /tmp/vfcwrapper.patch
2020
RUN patch $(which verificarlo) /tmp/verificarlo.patch
21-
RUN patch /usr/local/include/vfcwrapper.c /tmp/vfcwrapper.patch
2221

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

3938

@@ -52,20 +51,20 @@ RUN cd /opt/build/ &&\
5251
mkdir build &&\
5352
cd /opt/build/lapack-3.9.0/build &&\
5453
cmake FC=verificarlo-f -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=verificarlo-c -DCMAKE_Fortran_COMPILER=verificarlo-f \
55-
-DCBLAS=ON -DBUILD_SHARED_LIBS=ON .. &&\
54+
-DCBLAS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="--conservative" -DCMAKE_Fortran_FLAGS="--conservative" .. &&\
5655
make &&\
5756
make install
5857

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

62-
# Preloading the instrumented shared library
63-
ENV LD_PRELOAD="/opt/mca-libmath/libmath.so:/usr/local/lib/libblas.so:/usr/local/lib/libcblas.so"
64-
6561
# Restore default behavior for verificarlo's CC
6662
ENV CC "verificarlo-c"
6763
ENV VFC_BACKENDS_SILENT_LOAD="True"
6864
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE
6965

66+
# Preloading the instrumented shared library
67+
ENV LD_PRELOAD="/opt/mca-libmath/libmath.so:/usr/local/lib/libblas.so:/usr/local/lib/libcblas.so"
68+
7069
# Set bash shell as entrypoint
7170
ENTRYPOINT [ "/bin/bash"]

docker/base/Dockerfile.ubuntu20.04-1-python

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
FROM verificarlo/fuzzy:v0.4.1-lapack
1+
ARG VERIFICARLO_VERSION=v0.5.0
2+
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack
3+
4+
RUN cat /proc/cpuinfo | grep flags | uniq
5+
RUN cat /proc/cpuinfo | grep "model name" | uniq
6+
7+
8+
# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
9+
# and causes bug
10+
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
11+
ENV LD_PRELOAD=""
212

313
# Use IEEE mode for compiling with verificarlo
414
RUN echo "libinterflop_ieee.so" > $VFC_BACKENDS_FROM_FILE
@@ -11,7 +21,7 @@ RUN cd /opt/build/ && \
1121
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz && \
1222
tar xvf Python-3.8.5.tgz && \
1323
cd Python-3.8.5 && \
14-
CFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt" ./configure --enable-optimizations --with-ensurepip=install &&\
24+
CFLAGS="--exclude-file=/tmp/python-vfc-exclude.txt --conservative" ./configure --enable-optimizations --with-ensurepip=install &&\
1525
make -j &&\
1626
make install &&\
1727
wget https://bootstrap.pypa.io/get-pip.py &&\
@@ -23,5 +33,7 @@ RUN rm -rf /opt/build/*
2333
# Restore default MCA mode
2434
RUN echo "libinterflop_mca.so -m rr" > $VFC_BACKENDS_FROM_FILE
2535

36+
ENV LD_PRELOAD=${LD_PRELOAD_OLD}
37+
2638
# Set entrypoint
2739
ENTRYPOINT [ "/bin/bash"]

docker/base/Dockerfile.ubuntu20.04-2-numpy

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5
1+
ARG VERIFICARLO_VERSION=v0.5.0
2+
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5
3+
4+
RUN cat /proc/cpuinfo | grep flags | uniq
5+
RUN cat /proc/cpuinfo | grep "model name" | uniq
6+
7+
8+
# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
9+
# and causes bug
10+
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
11+
ENV LD_PRELOAD=""
212

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

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

37+
# Smoked test for vectorization.
38+
# We should run the full numpy test suit in next versions
39+
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())"
40+
2641
# Remove temporary files
2742
RUN rm -rf /opt/build/*
2843

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

47+
ENV LD_PRELOAD=${LD_PRELOAD_OLD}
48+
3249
ENTRYPOINT [ "/bin/bash"]

docker/base/Dockerfile.ubuntu20.04-3-scipy

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy
1+
ARG VERIFICARLO_VERSION=v0.5.0
2+
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy
23

4+
RUN cat /proc/cpuinfo | grep flags | uniq
5+
RUN cat /proc/cpuinfo | grep "model name" | uniq
6+
7+
8+
# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
9+
# and causes bug
10+
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
11+
ENV LD_PRELOAD=""
312

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

34+
ENV LD_PRELOAD=${LD_PRELOAD_OLD}
35+
2536
ENTRYPOINT [ "/bin/bash"]
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
FROM verificarlo/fuzzy:v0.4.1-lapack-python3.8.5-numpy-scipy
1+
ARG VERIFICARLO_VERSION=v0.5.0
2+
FROM verificarlo/fuzzy:${VERIFICARLO_VERSION}-lapack-python3.8.5-numpy-scipy
3+
4+
RUN cat /proc/cpuinfo | grep flags | uniq
5+
RUN cat /proc/cpuinfo | grep "model name" | uniq
6+
7+
8+
# Unset LD_PRELOAD because it will open VFC_BACKENDS_FROM_FILE
9+
# and causes bug
10+
RUN LD_PRELOAD_OLD=${LD_PRELOAD}
11+
ENV LD_PRELOAD=""
212

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

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

29+
ENV LD_PRELOAD=${LD_PRELOAD_OLD}
30+
1931
ENTRYPOINT [ "/bin/bash"]

docker/resources/libmath/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ SRCS = src/wrapping_script.c # source files
1313
OBJS = $(SRCS:.c=.o)
1414
ROOT = $(PWD)
1515

16+
ifdef CONSERVATIVE
17+
CFLAGS += --conservative
18+
endif
19+
1620
.PHONY: tracer
1721

1822
$(TARGET_LIB): $(OBJS)
19-
$(CC) ${LDFLAGS} -ldl -o $@ $^
23+
$(CC) ${LDFLAGS} ${CFLAGS} -ldl -o $@ $^
2024

2125
tracer:
2226
$(CC) ${TRACER_FLAGS} ${CFLAGS} ${LDFLAGS} ${LIBS} -o ${TARGET_LIB} $(SRCS)

docker/resources/verificarlo.patch

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
1-
--- verificarlo 2020-12-17 11:27:57.074070576 -0500
2-
+++ /home/yohan/local/bin/verificarlo 2020-12-16 18:37:46.866142995 -0500
3-
@@ -294,11 +294,17 @@
1+
diff --git a/verificarlo.in.in b/verificarlo.in.in
2+
index 14cd655..a9090b8 100644
3+
--- a/verificarlo.in.in
4+
+++ b/verificarlo.in.in
5+
@@ -136,7 +136,8 @@ def compile_vfcwrapper(source, output, args, emit_llvm=False):
6+
7+
internal_options = (" -S -emit-llvm " if emit_llvm else "") + \
8+
f" -c -Wno-varargs -I {mcalib_includes} "
9+
- shell(f'{clang} -O3 -march=native {internal_options} {extra_args} {source} -o {output} ')
10+
+ conservative = '-march=x86-64' if args.conservative else '-march=native'
11+
+ shell(f'{clang} -O3 {conservative} {internal_options} {extra_args} {source} -o {output} ')
12+
13+
14+
def linker_mode(sources, options, libraries, output, args):
15+
@@ -204,9 +205,11 @@ def compiler_mode(sources, options, output, args):
16+
compile_only([source], ' -c ' + options, basename_output, args)
17+
continue
18+
19+
+ conservative = '-march=x86-64' if args.conservative else ''
20+
+
21+
# Compile to ir (fortran uses flang, c uses clang)
22+
shell(
23+
- f'{compiler} -c -S {debug} {source} {include} -emit-llvm {options} -o {ir.name}')
24+
+ f'{compiler} -c -S {debug} {source} {include} -emit-llvm {options} -o {ir.name} {conservative}')
25+
26+
selectfunction = ""
27+
if args.function:
28+
@@ -246,7 +249,7 @@ def compiler_mode(sources, options, output, args):
29+
basename_output = output
30+
31+
# Produce object file
32+
- shell(f'{compiler} -c {basename_output} {ins.name} {options}')
33+
+ shell(f'{compiler} -c {basename_output} {ins.name} {options} {conservative}')
34+
35+
36+
if __name__ == "__main__":
37+
@@ -282,6 +285,8 @@ if __name__ == "__main__":
438
parser.add_argument('--version', action='version', version=PACKAGE_STRING)
539
parser.add_argument('--linker', choices=linkers.keys(), default=default_linker,
640
help="linker to use, {dl} by default".format(dl=default_linker))
7-
+ parser.add_argument('--disable-debug-flag', action="store_true",
8-
+ help="Remove -g from the flag since it can cause error with flang")
41+
+ parser.add_argument(
42+
+ '--conservative', action='store_true', help='conservative')
943

1044
args, other = parser.parse_known_args()
1145

12-
sources, llvm_options = parse_extra_args(other)
13-
14-
+ if args.disable_debug_flag:
15-
+ if "-g" in llvm_options:
16-
+ llvm_options = llvm_options.replace("-g", "")
17-
+
18-
# check input files
19-
if (args.E or args.S or args.c) and len(sources) > 1 and args.o:
20-
fail('cannot specify -o when generating multiple output files')

0 commit comments

Comments
 (0)