forked from verificarlo/verificarlo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2258a6d
commit 3f6b9b1
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export SAMPLES=100 | ||
|
||
check_status() { | ||
if [[ $? != 0 ]]; then | ||
echo "Fail" | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_executable() { | ||
if [[ ! -f $1 ]]; then | ||
echo "Executable $1 not found" | ||
exit 1 | ||
fi | ||
} | ||
|
||
optimizations=('-O0' '-O1' '-O2' '-O3' '-Ofast') | ||
|
||
export VFC_BACKENDS_LOGGER=False | ||
|
||
parallel --header : "make --silent type={type} optimization={optimization} operator={operator}" ::: type float double ::: optimization "${optimizations[@]}" ::: operator add sub mul div | ||
|
||
run_test() { | ||
declare -A operation_name=(["+"]="add" ["-"]="sub" ["x"]="mul" ["/"]="div") | ||
|
||
local type="$1" | ||
local optimization="$2" | ||
local op="$3" | ||
local op_name=${operation_name[$op]} | ||
|
||
local bin=test_${type}_${optimization}_${op_name} | ||
local file=tmp.$type.$op_name.$optimization.txt | ||
|
||
echo "Running test $type $op $optimization $op_name" | ||
|
||
rm -f $file | ||
|
||
for i in $(seq 1 $SAMPLES); do | ||
./$bin $op 0.1 0.2 >>$file | ||
done | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Failed!" | ||
exit 1 | ||
fi | ||
|
||
# Check if we have variabilities | ||
if [[ $(sort -u $file | wc -l) == 1 ]]; then | ||
echo "Failed!" | ||
echo "File $file failed" | ||
sort -u $file | ||
exit 1 | ||
fi | ||
} | ||
|
||
export -f run_test | ||
|
||
parallel --halt now,fail=1 --header : "run_test {type} {optimization} {op} " \ | ||
::: type float double \ | ||
::: op "+" "-" "x" "/" \ | ||
::: optimization "${optimizations[@]}" | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Failed!" | ||
exit 1 | ||
else | ||
echo "Success!" | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export SAMPLES=100 | ||
|
||
check_status() { | ||
if [[ $? != 0 ]]; then | ||
echo "Fail" | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_executable() { | ||
if [[ ! -f $1 ]]; then | ||
echo "Executable $1 not found" | ||
exit 1 | ||
fi | ||
} | ||
|
||
optimizations=('-O0' '-O1' '-O2' '-O3' '-Ofast') | ||
|
||
export VFC_BACKENDS_LOGGER=False | ||
|
||
parallel --header : "make --silent type={type} optimization={optimization} operator={operator}" ::: type float double ::: optimization "${optimizations[@]}" ::: operator add sub mul div | ||
|
||
run_test() { | ||
declare -A operation_name=(["+"]="add" ["-"]="sub" ["x"]="mul" ["/"]="div") | ||
|
||
declare -A args | ||
args["float+"]="0.1 0.01" | ||
args["float-"]="0.1 0.001" | ||
args["floatx"]="0.1 0.001" | ||
args["float/"]="1 313" | ||
args["floats"]="0.1" | ||
args["double+"]="0.1 0.01" | ||
args["double-"]="0.1 0.001" | ||
args["doublex"]="0.1 0.01" | ||
args["double/"]="1 3" | ||
args["doubles"]="0.1" | ||
|
||
local type="$1" | ||
local optimization="$2" | ||
local op="$3" | ||
local op_name=${operation_name[$op]} | ||
|
||
local bin=test_${type}_${optimization}_${op_name} | ||
local file=tmp.$type.$op_name.$optimization.txt | ||
|
||
echo "Running test $type $op $optimization $op_name on ${args["$type$op"]}..." | ||
|
||
rm -f $file | ||
|
||
for i in $(seq 1 $SAMPLES); do | ||
./$bin $op ${args["$type$op"]} >>$file | ||
done | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Failed!" | ||
exit 1 | ||
fi | ||
|
||
# Check if we have variabilities | ||
if [[ $(sort -u $file | wc -l) == 1 ]]; then | ||
echo "Failed!" | ||
echo "File $file failed" | ||
sort -u $file | ||
exit 1 | ||
fi | ||
} | ||
|
||
export -f run_test | ||
|
||
parallel --halt now,fail=1 --header : "run_test {type} {optimization} {op} " \ | ||
::: type double float \ | ||
::: op "+" "-" "x" "/" \ | ||
::: optimization "${optimizations[@]}" | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Failed!" | ||
exit 1 | ||
else | ||
echo "Success!" | ||
exit 0 | ||
fi |