Commit 3b9e7f23 authored by MIJIEUX Thomas's avatar MIJIEUX Thomas

send all output formatted for human to stderr

parent 225d97fd
......@@ -7,41 +7,41 @@
** With SPACK
*** Install SPACK
If you dont have spack, download it:
If you do not have spack, download it:
#+begin_src bash
cd ${HOME}
git clone https://github.com/solverstack/spack.git
#+end_src
Set SPACK_ROOT variable to the directory where spack is installed:
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent :tangle-mode (identity #o755)
#!/bin/bash
export SPACK_ROOT=/home/tmijieux/spack
#+end_src
Load spack to into your terminal environment:
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent
source ${SPACK_ROOT}/share/spack/setup-env.sh
export MODULEPATH=$SPACK_ROOT/share/spack/modules/linux-x86_64:$MODULEPATH
spack compiler find
#+end_src
*** Install Fabulous
On plafrim, you need to load the required modules:
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent
module purge
module load compiler/gcc/6.1.0
module load build/cmake/3.2.1
module load intel/mkl/64/11.2/2016.0.0
spack compiler find
#+end_src
Set shell variables for spack to find the dependencies
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent
export CMAKE_DIR=/cm/shared/dev/apps/build/cmake/3.2.1
#+end_src
Check the specification with:
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent
SPEC="fabulous@develop+chameleon%gcc@6.1.0 ^chameleon@master ^mkl@exist ^cmake@exist"
spack spec ${SPEC}
#+end_src
......@@ -62,7 +62,7 @@
#+end_src
If everything looks good, you can proceed the installation with:
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh
#+begin_src bash :session *INSTALLFABULOUS* :tangle install-fabulous.sh :results silent
spack install -v ${SPEC}
#+end_src
......@@ -75,7 +75,7 @@
#+end_src
then:
#+begin_src bash
#+begin_src bash :results silent
chmod +x ./install-fabulous.sh
./install-fabulous.sh
#+end_src
This diff is collapsed.
......@@ -29,7 +29,7 @@
Eventually, anyone must be able to gather all interesting results into RESULTS.org
just by evaluating code blocks from RESULTS.org and/or tangling RESULTS.org
* DONE Implement IB+DR
* TODO Implement IB+DR+QR
* DONE Implement IB+DR+QR
** tpqrt and tpmqrt kernels
* TODO iterated orthogonalization stop criterion
* TODO find out how to link fabulous with parallel mkl with spack
......
......@@ -37,7 +37,7 @@ private:
private:
template<class Matrix>
void print_precond(const Matrix &A, std::ostream &o = std::cout)
void print_precond(const Matrix &A, std::ostream &o = std::cerr)
{
using fabulous::Color;
o << "Right Pre Conditionner : [";
......@@ -48,13 +48,15 @@ private:
o<<Color::reset<<"]\n";
}
void print_iteration_start_info(int size_to_span, std::ostream &o = std::cout)
void print_iteration_start_info(
int size_to_span, std::ostream &o = std::cerr)
{
o << "################## Restart number: " <<_nb_restart <<" #################\n";
o << "################## SizeToSpan : " <<size_to_span <<" ##############\n";
}
void print_iteration_end_info(int size_krylov_space, std::ostream &o = std::cout)
void print_iteration_end_info(
int size_krylov_space, std::ostream &o = std::cerr)
{
o <<"######################################################\n";
o <<" Restart Done : "<< _nb_restart <<"\n";
......@@ -69,7 +71,8 @@ private:
void print_start_info(
int dim, int nbRHS, int maxMVP, int max_krylov_space_size,
const OrthoParam &ortho, const RestartParam &restart_param,
const std::vector<P> &epsilon, Matrix &A, Algo &algo, std::ostream &o = std::cout)
const std::vector<P> &epsilon, Matrix &A, Algo &algo,
std::ostream &o = std::cerr)
{
Arithmetik<S> arith;
......
......@@ -36,14 +36,14 @@ public:
using P = primary_type;
private:
void print_header(int nb_mvp, std::ostream &o = std::cout)
void print_header(int nb_mvp, std::ostream &o = std::cerr)
{
o << "#######################################################\n";
o << "#################### Arnoldi ##########################\n";
o << "######## Mat Vect product scheduled "<< nb_mvp <<"###########\n";
}
void print_footer(std::ostream &o = std::cout)
void print_footer(std::ostream &o = std::cerr)
{
o << "################# Iterations done: "<<_iteration_count<<"(+1)\n";
o << "#######################################################\n";
......
......@@ -38,14 +38,14 @@ public:
using P = primary_type;
private:
void print_header(int nb_mvp, std::ostream &o = std::cout)
void print_header(int nb_mvp, std::ostream &o = std::cerr)
{
o << "#######################################################\n";
o << "#################### Arnoldi ##########################\n";
o << "######### Mat Vect product scheduled: "<< nb_mvp <<" ###########\n";
}
void print_footer(std::ostream &o = std::cout)
void print_footer(std::ostream &o = std::cerr)
{
o << "################# Iterations done: "<<_iteration_count<<"(+1)\n";
o << "#######################################################\n";
......@@ -202,10 +202,10 @@ private:
void handle_IB_on_R0(Block<S> &U, const Block<S> &Q0, const Block<S> &Lambda0)
{
std::cout<<Color::yellow<<Color::bold;
std::cout<<"\t\tINEXACT BREAKDOWN on R0\n";
std::cout<<"\t\tNb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS;
std::cout<<Color::reset<<std::endl;
std::cerr<<Color::yellow<<Color::bold;
std::cerr<<"\t\tINEXACT BREAKDOWN on R0\n";
std::cerr<<"\t\tNb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS;
std::cerr<<Color::reset<<std::endl;
int M = U.get_nb_row();
Block<S> U1 = U.sub_block(0, 0, M, _nb_direction_kept);
......@@ -260,15 +260,15 @@ private:
// Test if algorithm need to be launched again
if (_nb_direction_kept == 0) {
std::cout << "\t\tTOTAL INEXACT BREAKDOWN on R0\n";
std::cout << "\t\tNb direction kept: 0 / " << _nbRHS << std::endl;
std::cerr << "\t\tTOTAL INEXACT BREAKDOWN on R0\n";
std::cerr << "\t\tNb direction kept: 0 / " << _nbRHS << std::endl;
return Lambda0.check_precision(epsilon);
}
if (_nb_direction_discarded > 0) {
handle_IB_on_R0(U, Q0, Lambda0);
} else {
std::cout<<"\t\tNo INEXACT BREAKDOWN on R0\n";
std::cerr<<"\t\tNo INEXACT BREAKDOWN on R0\n";
Block<S> W = _base.get_W(_nbRHS);
W.copy(Q0);
_base.increase(_nbRHS);
......@@ -281,8 +281,8 @@ private:
void print_ib_occured()
{
std::cout<<Color::warning<<"### Inexact Breakdown Occured!! ###\n"<<Color::reset;
std::cout<<"Nb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS<<"\n";
std::cerr<<Color::warning<<"### Inexact Breakdown Occured!! ###\n"<<Color::reset;
std::cerr<<"Nb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS<<"\n";
}
/**
......
......@@ -36,14 +36,14 @@ public:
private:
void print_header(int nb_mvp, std::ostream &o = std::cout)
void print_header(int nb_mvp, std::ostream &o = std::cerr)
{
o << "#######################################################\n";
o << "#################### Arnoldi ##########################\n";
o << "######### Mat Vect product scheduled: "<< nb_mvp <<" ###########\n";
}
void print_footer(std::ostream &o = std::cout)
void print_footer(std::ostream &o = std::cerr)
{
o << "################# Iterations done: "<<_iteration_count<<"(+1)\n";
o << "#######################################################\n";
......@@ -215,10 +215,10 @@ private:
void handle_IB_on_R0(Block<S> &U, const Block<S> &Q0, const Block<S> &Lambda0)
{
std::cout<<Color::yellow<<Color::bold;
std::cout<<"\t\tINEXACT BREAKDOWN on R0\n";
std::cout<<"\t\tNb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS;
std::cout<<Color::reset<<std::endl;
std::cerr<<Color::yellow<<Color::bold;
std::cerr<<"\t\tINEXACT BREAKDOWN on R0\n";
std::cerr<<"\t\tNb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS;
std::cerr<<Color::reset<<std::endl;
int M = U.get_nb_row();
Block<S> U1 = U.sub_block(0, 0, M, _nb_direction_kept);
......@@ -274,15 +274,15 @@ private:
// Test if algorithm need to be launched again
if (_nb_direction_kept == 0) {
std::cout << "\t\tTOTAL INEXACT BREAKDOWN on R0\n";
std::cout << "\t\tNb direction kept: 0 / " << _nbRHS << std::endl;
std::cerr << "\t\tTOTAL INEXACT BREAKDOWN on R0\n";
std::cerr << "\t\tNb direction kept: 0 / " << _nbRHS << std::endl;
return Lambda0.check_precision(epsilon);
}
if (_nb_direction_discarded > 0) {
handle_IB_on_R0(U, Q0, Lambda0);
} else {
std::cout<<"\t\tNo INEXACT BREAKDOWN on R0\n";
std::cerr<<"\t\tNo INEXACT BREAKDOWN on R0\n";
Block<S> W = _base.get_W(_nbRHS);
W.copy(Q0);
_base.increase(_nbRHS);
......@@ -295,8 +295,8 @@ private:
void print_ib_occured()
{
std::cout<<Color::warning<<"### Inexact Breakdown Occured!! ###\n"<<Color::reset;
std::cout<<"Nb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS<<"\n";
std::cerr<<Color::warning<<"### Inexact Breakdown Occured!! ###\n"<<Color::reset;
std::cerr<<"Nb direction kept: "<<_nb_direction_kept<<"/"<<_nbRHS<<"\n";
}
/**
......
......@@ -33,19 +33,19 @@ public:
P max; /*!< Arnoldi Maximum norm reached at this iteration*/
P minReal; /*!< Real Minimal norm reached at this iteration*/
P maxReal; /*!< Real Maximum norm reached at this iteration*/
double time_spent; /*!< Time spent for this iteration */
double least_square_spent; /*!< Time spent for this iteration in least_square */
double mvp_spent; /*!< Time spent for this iteration in mvp */
double ortho_spent; /*!< Time spent for this iteration in orthogonalization */
double total_time; /*!< Time time for this iteration */
double least_square_time; /*!< Time time for this iteration in least_square */
double mvp_time; /*!< Time time for this iteration in mvp */
double ortho_time; /*!< Time time for this iteration in orthogonalization */
static void print_header(std::ostream &o = std::cout)
static void print_header(std::ostream &o = std::cerr)
{
o <<"global_iteration\tlocal_iteration\tkrylov_space_size\tnb_mvp\t"
"current_block_size\tminRes\tmaxRes\tminRealRes\tmaxRealRes\ttime\t"
"least_square_time\tmvp_spent\tortho_spent\tname\n";
"least_square_time\tmvp_time\tortho_time\tname\n";
}
void print(std::string name, std::ostream &o = std::cout)
void print(std::string name, std::ostream &o = std::cerr)
{
o << glob_iteration<<"\t"
<< loc_iteration<<"\t"
......@@ -56,10 +56,10 @@ public:
<< max<<"\t"
<< minReal<<"\t"
<< maxReal<<"\t"
<< time_spent<<"\t"
<< least_square_spent<<"\t"
<< mvp_spent<<"\t"
<< ortho_spent<<"\t"
<< total_time<<"\t"
<< least_square_time<<"\t"
<< mvp_time<<"\t"
<< ortho_time<<"\t"
<< name << "\n";
}
};
......@@ -134,7 +134,7 @@ public:
_mvp_timer.reset();
_ortho_timer.reset();
std::cout<<"\nStart of Iteration ["
std::cerr<<"\nStart of Iteration ["
<<Color::note<<iteration_count<<" :: "
<<size_krylov_space<<Color::reset<<"]\n";
if (iteration_count == 0) {
......@@ -202,14 +202,15 @@ public:
_iterations.push_back(
Entry{ _global_iteration, id, size_krylov_space,
_total_mvp, mvp_diff, min, max, 0, 0,
elapsed, least_square_elapsed, mvp_elapsed, ortho_elapsed }
elapsed, least_square_elapsed,
mvp_elapsed, ortho_elapsed }
);
FABULOUS_NOTE("\t\t "<<Color::red<<"MIN="<<Color::reset<<std::scientific<<min
<<"\t"<<Color::red<<"MAX="<<Color::reset<<std::scientific<<max);
if (std::isnan(min) || std::isnan(max))
FABULOUS_FATAL_ERROR("nan encoutered");
std::cout<< "End of Iteration ["<<Color::note<<id<<" :: "
std::cerr<< "End of Iteration ["<<Color::note<<id<<" :: "
<< size_krylov_space<<Color::reset<<"]\n\n";
}
......@@ -263,7 +264,7 @@ public:
it.current_block_size,
it.min, it.max,
it.minReal, it.maxReal,
it.time_spent);
it.total_time);
}
}
......@@ -278,7 +279,7 @@ public:
it.current_block_size,
it.min, it.max,
it.minReal, it.maxReal,
it.time_spent,
it.total_time,
it.loc_iteration,
it.krylov_space_size);
}
......@@ -295,7 +296,7 @@ public:
it.current_block_size,
it.min,
it.max,
it.time_spent);
it.total_time);
}
}
......@@ -310,12 +311,12 @@ public:
for (int i = 0; i < size; ++i) {
_array[3*i + 0] = _iterations[i].min;
_array[3*i + 1] = _iterations[i].max;
_array[3*i + 2] = _iterations[i].time_spent;
_array[3*i + 2] = _iterations[i].total_time;
}
return _array.data();
}
void print(std::string name="log", std::ostream& o = std::cout)
void print(std::string name="log", std::ostream& o = std::cerr)
{
LogEntry<P>::print_header(o);
for (auto&&it : _iterations)
......
......@@ -46,7 +46,7 @@ public:
fabulous::fatal_error(ss.str());
return;
}
std::cout<<"Loading IW matrix: '"<<filename<<"'\n";
std::cerr<<"Loading IW matrix: '"<<filename<<"'\n";
LoadMatrix(A, file, check_square);
file.close();
}
......@@ -71,11 +71,11 @@ public:
"Check what you are doing. Exiting ...\n"
);
}
std::cout << "Type: '" << IW_matrix_type<V>::name
std::cerr << "Type: '" << IW_matrix_type<V>::name
<< "' sizes=("<<M<<", "<<N<<")\n";
if (check_square && N != M) {
std::cout<< "N != M :: "<<N<<" != "<<M<<"\n"
std::cerr<< "N != M :: "<<N<<" != "<<M<<"\n"
<< "Matrix is not square !\n"
<< "Exiting\n";
exit(EXIT_FAILURE);
......
......@@ -84,10 +84,10 @@ private:
do {
getline(file,line);
std::cout << line << "\n";
std::cerr << line << "\n";
commentLine = ( line.length() == 0 || line[0] == '%' );
} while (commentLine);
std::cout << std::flush;
std::cerr << std::flush;
auto size = split(line);
int N = std::stoi(size[0]);
......@@ -96,7 +96,7 @@ private:
//Check square ?
if (N != M) {
std::cout<<"N != M :: "<< N <<" != "<<M<<"\n"
std::cerr<<"N != M :: "<< N <<" != "<<M<<"\n"
<<"Matrix is not square !\nExiting\n";
exit(EXIT_FAILURE);
}
......
......@@ -40,20 +40,20 @@ static void check_solution(Matrix &mat, const Block &RHS,
//Then display for each vect
for (int j=0; j<nbRHS; ++j) {
std::cout<<"Metrics on "<<j<<"\n";
std::cerr<<"Metrics on "<<j<<"\n";
P ForwardError = X_Diff.get_norm(j);
std::cout <<"["<<j<<"]\tForward Error (on X) \t" << ForwardError <<"\n";
std::cerr <<"["<<j<<"]\tForward Error (on X) \t" << ForwardError <<"\n";
P SecondMemberError = MatxSolMinusB.get_norm(j);
std::cout <<"["<<j<<"]\tSecond Member Error \t" << SecondMemberError <<"\n";
std::cerr <<"["<<j<<"]\tSecond Member Error \t" << SecondMemberError <<"\n";
P ForwardErrorNormalized = ForwardError / (X_Exact.get_norm(j));
std::cout <<"["<<j<<"]\tForward Error Norm. \t" << ForwardErrorNormalized <<"\n";
std::cerr <<"["<<j<<"]\tForward Error Norm. \t" << ForwardErrorNormalized <<"\n";
P normB = RHS.get_norm(j);
P NormwiseBackwardError = SecondMemberError / normB;
std::cout <<"["<<j<<"]\tNormwise Backward Error\t"<<NormwiseBackwardError<<"\n\n";
std::cerr <<"["<<j<<"]\tNormwise Backward Error\t"<<NormwiseBackwardError<<"\n\n";
}
}
......@@ -83,11 +83,11 @@ static Logger<P> run_test_BGMRES( Matrix &mat, Block &RHS, Block &XExact,
template<class P>
static void print_logs(Logger<P> &logger, const std::string &test_name)
{
std::cout << "Logs for "<< test_name << "\n";
std::cerr << "Logs for "<< test_name << "\n";
logger.for_each_iteration(
[&](int ite, int nbMatVect, int /*currSize*/, P min, P max, double /*time*/)
{
std::cout<<ite<<"\t"<<nbMatVect<<"\t"
std::cerr<<ite<<"\t"<<nbMatVect<<"\t"
<<min<<"\t"<<max<<"\t"<<"\n";
}
);
......@@ -103,11 +103,56 @@ template<class P> struct TestRet
int maxMVP; /**< max matrix vector product scheduled */
};
template<class Algo, class Restart>
std::string get_formatted_filename(
std::string label, Orthogonalizer ortho,
Algo algo, Restart restart, bool append_suffix)
{
std::stringstream name;
name << label;
if (append_suffix) {
name <<"_" <<ortho.get_scheme()<<"_"<<ortho.get_type()<<"_"
<< algo <<"BGMRES"<< get_type(restart);
}
return name.str();
}
template<class Logger, class Algo, class Restart>
void print_logger_to_file(
Logger logger, std::string label, Orthogonalizer ortho,
Algo algo, Restart restart, bool append_suffix)
{
std::stringstream filepath;
std::string name;
name = get_formatted_filename(label, ortho, algo, restart, append_suffix);
filepath << "../data/res/" << name << ".res";
std::ofstream file{filepath.str(), std::ios::out};
if (file.is_open()) {
logger.print(name, file);
file.close();
} else {
std::stringstream errorsstr;
errorsstr << "Cannot open '" << filepath.str()
<<"': '" <<strerror(errno)<<"'";
error(errorsstr.str());
}
}
template<class Logger, class Algo, class Restart>
void print_logger_to_stdout(
Logger logger, std::string label, Orthogonalizer ortho,
Algo algo, Restart restart, bool append_suffix)
{
std::string name;
name = get_formatted_filename(label, ortho, algo, restart, append_suffix);
logger.print(name, ::std::cout);
}
template<class Algo, class Restart, class Matrix, class Block,
class S = typename Block::value_type,
class P = typename Block::primary_type >
TestRet<P> run_test_BGMRES_filelog(
const std::string &filename,
const std::string &label,
Matrix &mat, Block &RHS, Block &XExact, std::vector<P> &epsilon,
Algo algo, int maxMVP, int maxKrylovSpaceSize,
OrthoParam ortho, Restart restart, bool append_suffix=true )
......@@ -119,7 +164,6 @@ TestRet<P> run_test_BGMRES_filelog(
const int nbRHS = RHS.get_nb_col();
const int dim = RHS.get_nb_row();
Block X{dim, nbRHS};
Timer time;
time.start();
auto eq = equation(mat, X, RHS, epsilon);
......@@ -129,25 +173,10 @@ TestRet<P> run_test_BGMRES_filelog(
time.stop();
double elapsed = time.get_length();
int nb = logger.get_nb_mvp();
std::cout<<"Return value / max_mvp : " << nb << "/" << maxMVP << std::endl;
std::cerr<<"Return value / max_mvp : " << nb << "/" << maxMVP << std::endl;
std::stringstream name, filepath;
name << filename;
if (append_suffix) {
name <<"_" <<ortho.get_scheme()<<"_"<<ortho.get_type()<<"_"
<< algo <<"BGMRES"<< get_type(restart);
}
filepath << "../data/res/" << name.str() << ".res";
print_logger_to_file(logger, label, ortho, algo, restart, append_suffix);
std::ofstream file{filepath.str(), std::ios::out};
if (file.is_open()) {
logger.print(name.str(), file);
file.close();
} else {
std::stringstream errorsstr;
errorsstr << "Cannot open '" << filepath.str() <<"': '" <<strerror(errno)<<"'";
error(errorsstr.str());
}
auto minmax = compare_blocks(X, XExact);
return TestRet<P>{elapsed, nb, minmax, maxMVP};
}
......@@ -155,7 +184,7 @@ TestRet<P> run_test_BGMRES_filelog(
template<class P>
static void print_elapsed_time(const TestRet<P> &r, const std::string &test_name)
{
std::cout << test_name<<":\n"
std::cerr << test_name<<":\n"
<< "\tElapsed time:\t"<<r.elapsed << " seconds for "
<< r.nb_mvp<<"/"<<r.maxMVP<<" iterations\n"
<< "\tForward error:\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment