Skip to content

Commit

Permalink
Merge branch 'ppushv'
Browse files Browse the repository at this point in the history
  • Loading branch information
jgdumas committed Jul 10, 2024
2 parents 892299a + 9044278 commit bd89ed4
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 65 deletions.
9 changes: 9 additions & 0 deletions bin/3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# ==========================================================================
# PLinOpt: C++ routines handling linear, bilinear & trilinear programs
# Authors: J-G. Dumas, B. Grenet, C. Pernet, A. Sedoglavic
# ==========================================================================
# Script: finds 3 files with starting letters L, R and P
# ==========================================================================

basename $1 | awk -v dir=`dirname $1` '{ c=substr($1, 2); print dir"/L"c,dir"/R"c,dir"/P"c }'
8 changes: 8 additions & 0 deletions bin/FDT.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/bash
# ==========================================================================
# PLinOpt: C++ routines handling linear, bilinear & trilinear programs
# Authors: J-G. Dumas, B. Grenet, C. Pernet, A. Sedoglavic
# ==========================================================================
# ==========================================================================
# Tests: optimizer, compacter, transpozer, factorizer, sparsifier, inplacer
# ==========================================================================

tmpfile=/tmp/fdt_plinopt.$$
numopt=10
modulus=7
Expand Down
83 changes: 83 additions & 0 deletions bin/TTP.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
# ==========================================================================
# PLinOpt: C++ routines handling linear, bilinear & trilinear programs
# Authors: J-G. Dumas, B. Grenet, C. Pernet, A. Sedoglavic
# ==========================================================================
# Tests: trilinear in-placer
# Requires: maple from maplesoft to certify results
# ==========================================================================

MAPLEPROG=maple
MAPLEHERE=true
if ! command -v maple &> /dev/null
then
echo "maple could not be found."
MAPLEHERE=false
else
if ! echo "1234+5678;" | maple | grep 6912 &> /dev/null
then
echo "`command -v maple` is here but not running"
MAPLEHERE=false
else
echo "maple is up and running"
fi
fi
if [ "${MAPLEHERE}" != true ] ; then
MAPLEPROG=tee > /dev/null
fi


tmpfile=/tmp/fdt_plinopt.$$
numopt=100


if [ "$#" -ge 1 ]; then
fics=("$@")
else
fics=(data/L*sms)
fi

BINDRS=(./ ./bin)

for dir in ${BINDRS[@]}
do
if [ -x ${dir}/trilplacer ]; then
echo "Found executables in ${dir}"
BINDIR=${dir}
fi
done

TRIPL=${BINDIR}/trilplacer

for fic in ${fics[@]}
do
if [ -e ${fic} ]; then
threefics=`./bin/3.sh ${fic}`
mdims=(`fgrep -v '#' ${threefics} | egrep '( M| R)' | cut -d':' -f2 | tr '\n' ' '`)
Lm=${mdims[0]}; let Ldm=1+${Lm}
Ln=${mdims[1]}; let Ldn=2*${Ln}
Rm=${mdims[3]}; let Rdm=1+${Rm}
Rn=${mdims[4]}; let Rdn=2*${Rn}
Pm=${mdims[6]}; let Pdm=2*${Pm}
Pn=${mdims[7]}; let Pdn=1+${Pn}
echo -n "${fic} ${Lm}x${Ln} ${Rm}x${Rn} ${Pm}x${Pn} :"
(${TRIPL} -O ${numopt} `./bin/3.sh $fic` >& /dev/stdout) | ${MAPLEPROG} | egrep '(errors :=|ADD|SCA|[0-9][^#]*AXPY)' | tr '\n' '\t'| tee -a ${tmpfile}
echo | tee -a ${tmpfile}
echo -n "${fic} ${Ldm}x${Ldn} ${Rdm}x${Rdn} ${Pdm}x${Pdn} :"
(${TRIPL} -e -O ${numopt} `./bin/3.sh $fic` >& /dev/stdout) | ${MAPLEPROG} | egrep '(errors :=|ADD|SCA|[0-9][^#]*AXPY)' | tr '\n' '\t'| tee -a ${tmpfile}
echo | tee -a ${tmpfile}
fi
done

if [ "${MAPLEHERE}" = true ] ; then
let tries=2*${#fics[@]}
success=`grep 'errors := \[0, 0, 0\]' ${tmpfile} | wc -l`

echo -ne "\033[1;93mSUCCESS: "
if [ ${success} -ne ${tries} ]; then
echo -ne "\033[1;91m"
fi
echo -e "${success} \033[1;93m/ ${tries}\033[0m"
fi

\rm -rf ${tmpfile}
19 changes: 17 additions & 2 deletions include/plinopt_inplace.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ Matrix::Row::const_iterator nextindex(const size_t preci,

// ===============================================================

auto isAdd { [](const char c) { return ( (c=='+') || (c=='-') ); } };
auto isSca { [](const char c) { return ( (c=='*') || (c=='/') ); } };
auto isAddSub { [](const char c) { return ( (c=='+') || (c=='-') ); } };
auto isMulDiv { [](const char c) { return ( (c=='*') || (c=='/') ); } };

// ===============================================================
// Definition of ADD, SCA, MUL atomic operations
Expand Down Expand Up @@ -119,6 +119,21 @@ std::string rmnl(const std::string& str) {
return s;
}

// ===============================================================
// Enables checking a matrix multiplication with Maple
#ifdef INPLACE_CHECKER
// Compare program with a matrix multiplication
void CheckMatrixMultiplication(const char L, const Matrix& A,
const char H, const Matrix& B,
const char F, const Matrix& C);

// Compare program with direct linear applications
void CheckTriLinearProgram(const char L, const Matrix& AA,
const char H, const Matrix& BB,
const char F, const Matrix& CC,
bool expanded = false);
#endif


#include "plinopt_inplace.inl"

Expand Down
Loading

0 comments on commit bd89ed4

Please sign in to comment.