Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from yohanchatelain/master
Browse files Browse the repository at this point in the history
Pre-release:
  • Loading branch information
ali4006 authored Mar 3, 2021
2 parents f15ca2a + e2ca624 commit 6510d47
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for the instrumented shared library

CC = verificarlo-c --save-temps --verbose
CC = verificarlo-c --save-temps --verbose -g
TRACER_FLAGS = --tracer --tracer-debug-mode --tracer-level=temporary
CFLAGS = -fPIC --verbose # C flags
LDFLAGS = -shared # linking flags
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ across the operating systems.
git clone https://github.com/big-data-lab-team/MCA-libmath.git /tmp/mca-libmath/
cd /tmp/mca-libmath/src/
make
make test
```

3) Export Linux `LD_PRELOAD` environment variable by running:
```
export LD_PRELOAD=/tmp/mca-libmath/src/libpreload.so
export LD_PRELOAD=/tmp/mca-libmath/src/libmath.so
```

4) Set the virtual precision and instrumentation mode of Verificarlo by running:
Expand Down
2 changes: 1 addition & 1 deletion src/wrapping_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static float (*real_erfcf)(float dbl);
static double (*real_lgamma)(double dbl);
static float (*real_lgammaf)(float dbl);
static double (*real_tgamma)(double dbl);
static double (*real_tgammaf)(float dbl);
static float (*real_tgammaf)(float dbl);

static double (*real_lgamma_r)(double dbl, int *signgamp);
static float (*real_lgammaf_r)(float dbl, int *signgamp);
Expand Down
2 changes: 1 addition & 1 deletion tests/check_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def load_value(filename):
value = np.loadtxt(filename)
value = np.loadtxt(filename, dtype=np.float64)
return value


Expand Down
1 change: 1 addition & 0 deletions tests/data/math-functions-binary32-lgamma_r.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lgammaf_r 3.5
1 change: 1 addition & 0 deletions tests/data/math-functions-binary32-sincos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sincosf 1
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ y1f 6
erff 1
erfcf 1
lgammaf .5
tgammaf .5
tgammaf .5
1 change: 1 addition & 0 deletions tests/data/math-functions-binary64-lgamma_r.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lgamma_r 3.5
1 change: 1 addition & 0 deletions tests/data/math-functions-binary64-sincos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sincos 1
2 changes: 0 additions & 2 deletions tests/math-functions-binary32-special.txt

This file was deleted.

Empty file removed tests/math-functions-binary32.txt
Empty file.
1 change: 0 additions & 1 deletion tests/math-functions-binary64-lgamma_r.txt

This file was deleted.

1 change: 0 additions & 1 deletion tests/math-functions-binary64-special.txt

This file was deleted.

66 changes: 0 additions & 66 deletions tests/math-functions.txt

This file was deleted.

18 changes: 10 additions & 8 deletions tests/test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _GNU_SOURCE
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -25,7 +26,8 @@ void eval(char *argv[]) {
printf(FMT(x), res);
}
}
#elif BIVAR
#endif
#ifdef BIVAR
void eval(char *argv[]) {
REAL x = atof(argv[1]);
REAL y = atof(argv[2]);
Expand All @@ -34,7 +36,8 @@ void eval(char *argv[]) {
printf(FMT(x), res);
}
}
#elif LGAMMA_R
#endif
#ifdef LGAMMA_R
void eval(char *argv[]) {
REAL x = atof(argv[1]);
int *sign;
Expand All @@ -43,17 +46,16 @@ void eval(char *argv[]) {
printf(FMT(x), res);
}
}
#elif SINCOS
#endif
#ifdef SINCOS
void eval(char *argv[]) {
REAL x = atof(argv[1]);
REAL *cos, *sin;
REAL cosx, sinx;
for (int i = 0; i < N; i++) {
FUNCTION(x, cos, sin);
printf(FMT2(x), *cos, *sin);
FUNCTION(x, &cosx, &sinx);
printf(FMT2(x), cosx, sinx);
}
}
#else
#error "No signature provided"
#endif

int main(int argc, char *argv[]) {
Expand Down
51 changes: 37 additions & 14 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export VFC_BACKENDS="libinterflop_mca.so --mode=pb --precision-binary64=52 --precision-binary32=23"
export VFC_BACKENDS="libinterflop_mca.so --mode=mca --precision-binary64=53 --precision-binary32=24"
export LD_PRELOAD=$PWD/../libmath.so

declare -A signature_a
Expand Down Expand Up @@ -28,11 +28,19 @@ function check_compilation() {
fi
}

function check_file_exist() {
if [[ ! -f $1 ]]; then
echo "File ${1} does not exist"
exit 1
fi
}

function compile() {
TYPE=$1
SIG=$2
FUNCTION=$3
gcc test.c -lm -DREAL=$TYPE -D$SIG -DFUNCTION=$FUNCTION -o test
echo "gcc test.c -lm -DREAL=$TYPE -D$SIG -DFUNCTION=$FUNCTION -o test"
gcc -g test.c -lm -DREAL=$TYPE -D$SIG -DFUNCTION=$FUNCTION -o test
check_compilation
}

Expand All @@ -42,31 +50,46 @@ function run() {

IFS=" "
for TYPE in "${!type_a[@]}"; do
FILE=data/"math-functions-${type_a[$TYPE]}-${signature_a[univar]}.txt"
while read -r FUNCTION POINT ; do
echo "Evalue $FUNCTION on ${POINT}"
compile $TYPE UNIVAR $FUNCTION
run $POINT
assert_noise
done < math-functions-${type_a[$TYPE]}-${signature_a[univar]}.txt
done < $FILE
done

IFS=" "
for TYPE in "${!type_a[@]}"; do
FILE=data/"math-functions-${type_a[$TYPE]}-${signature_a[bivar]}.txt"
while read -r FUNCTION POINT1 POINT2 ; do
echo "Evalue $FUNCTION on ${POINT}"
compile $TYPE BIVAR $FUNCTION
run $POINT1 $POINT2
assert_noise
done < math-functions-${type_a[$TYPE]}-${signature_a[bivar]}.txt
done < $FILE
done

IFS=" "
for TYPE in "${!type_a[@]}"; do
FILE=data/"math-functions-${type_a[$TYPE]}-${signature_a[sincos]}.txt"
while read -r FUNCTION POINT ; do
echo "Evalue $FUNCTION on ${POINT}"
compile $TYPE SINCOS $FUNCTION
run $POINT
assert_noise
done < $FILE
done

IFS=" "
for TYPE in "${!type_a[@]}"; do
FILE=data/"math-functions-${type_a[$TYPE]}-${signature_a[lgamma_r]}.txt"
check_file_exist $FILE
while read -r FUNCTION POINT ; do
echo "Evalue $FUNCTION on ${POINT}"
compile $TYPE LGAMMA_R $FUNCTION
run $POINT
assert_noise
done < $FILE
done

# for TYPE in "${!type_a[@]}"; do
# while read -r FUNCTION ; do
# gcc test.c -DREAL=$TYPE -DBIVAR -DFUNCTION=$FUNCTION -o test
# ./test 0.1 0.1 > outputs
# res=$(std_1)
# assert_noise $res
# res=$(std_2)
# assert_noise $res
# done < math-functions-${type_a[$TYPE]}-${signature[BIVAR]}.txt
# done

0 comments on commit 6510d47

Please sign in to comment.