summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiros <andyspiros@gmail.com>2011-08-02 19:53:02 +0200
committerspiros <andyspiros@gmail.com>2011-08-02 19:53:02 +0200
commitdd747ab644ad64f205cf1a2c88f47f66beb36277 (patch)
tree561fefcde6bbb6673feaa8ab99e712c98983c8ab
parentAdded SVD decomposition. Work on eigenvalues action and mat-vec (diff)
downloadauto-numerical-bench-dd747ab644ad64f205cf1a2c88f47f66beb36277.tar.gz
auto-numerical-bench-dd747ab644ad64f205cf1a2c88f47f66beb36277.tar.bz2
auto-numerical-bench-dd747ab644ad64f205cf1a2c88f47f66beb36277.zip
Merge last week's changes:
* PBLAS/ScaLAPACK tests * BTL changes * Dependency resolution
-rw-r--r--PortageUtils.py109
-rw-r--r--benchconfig.py13
-rw-r--r--btl/actions/action_parallel_cholesky.hh30
-rw-r--r--btl/actions/action_parallel_lu_decomp.hh22
-rw-r--r--btl/actions/action_parallel_qr_decomp.hh11
-rw-r--r--btl/generic_bench/init/init_matrix.hh28
-rw-r--r--btl/libs/BLACS/blacs_interface.hh5
-rw-r--r--btl/libs/BLACS/gather.h15
-rw-r--r--btl/libs/BLACS/scatter.h27
-rw-r--r--btl/libs/PBLAS/main.cpp2
-rw-r--r--btl/libs/PBLAS/pblas.h13
-rw-r--r--btl/libs/PBLAS/pblas_interface.hh1
-rw-r--r--btl/libs/PBLAS/pblas_interface_impl.hh127
-rw-r--r--btlbase.py18
-rwxr-xr-xmain.py62
15 files changed, 370 insertions, 113 deletions
diff --git a/PortageUtils.py b/PortageUtils.py
index 5bd4c1d..8280d1c 100644
--- a/PortageUtils.py
+++ b/PortageUtils.py
@@ -1,7 +1,8 @@
import commands as cmd
import subprocess as sp
-import portage
-import os
+import os, portage, shlex
+from os.path import join as pjoin
+import benchutils
class InstallException(Exception):
def __init__(self, command, logfile):
@@ -19,10 +20,47 @@ def available_packages(pattern):
for l in cmd.getoutput('equery -q list -po ' + pattern).split()]
def normalize_cpv(cpv):
+ if type(cpv) == type(''):
+ try:
+ cpv_ = portage.catpkgsplit(cpv)
+ cpv_[-1]
+ cpv = cpv_
+ except:
+ cpv = available_packages(cpv)[-1]
if cpv[-1] != 'r0':
return '%s/%s-%s-%s' % cpv
else:
return '%s/%s-%s' % cpv[:-1]
+
+
+def get_dependencies(package, env={}, split=False):
+ pkg = normalize_cpv(package)
+ cmd = ['emerge', '--ignore-default-opts', '='+pkg, '-poq']
+ proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE, env=env)
+ lines = proc.communicate()[0].strip().split('\n')
+ if not lines[0]:
+ return []
+ if split:
+ return [portage.catpkgsplit(shlex.split(l.strip())[-1]) for l in lines]
+ else:
+ return [shlex.split(l.strip())[-1] for l in lines]
+
+def install_dependencies(package, env={}, root='/',
+ pkgdir='usr/portage/packages', logdir=None):
+ if logdir is None:
+ logdir = "/var/log/benchmarks/.unordered"
+
+ # Adjust environment
+ denv = os.environ
+ for k,v in env.items():
+ denv[k] = v
+
+ # Retrieve dependencies
+ deps = get_dependencies(package, denv, False)
+
+ for i,d in enumerate(deps):
+ logfile = pjoin(logdir, 'emergedep_%i.log' % i)
+ install_package(d, env, root, pkgdir, logfile)
def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
@@ -37,44 +75,77 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
compiler flags. It is safe to use ACCEPT_KEYWORDS=* for testing purposes.
root is the directory where the packaged will be emerged. A non-root user
- can also use this function, provided he has write access to that directory.
+ can use this function, provided he has write access to that directory.
pkgdir is the directory where the binary package will be placed. The user
has to be able to write in this directory.
The function has no return value and raises an exception in case of building
or emerging failure. Note: dependencies will NOT be emerged!
- """
+ """
+
+ # Adjust environment
+ denv = os.environ.copy()
+ for k,v in env.items():
+ denv[k] = v
+ denv['PKGDIR'] = pkgdir
+ #PATH
+ denv['PATH'] = ':'.join([pjoin(root, i) for i in ('bin', 'usr/bin')])
+ if os.environ.has_key('PATH'):
+ denv['PATH'] += ':' + os.environ['PATH']
+ denv['ROOTPATH'] = denv['PATH']
+ #LIBRARY_PATH
+ denv['LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \
+ ('usr/lib', 'usr/lib64', 'usr/lib32')])
+ if os.environ.has_key('LIBRARY_PATH'):
+ denv['LIBRARY_PATH'] += ':' + os.environ['LIBRARY_PATH']
+ #LD_LIBRARY_PATH
+ denv['LD_LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \
+ ('usr/lib', 'usr/lib64', 'usr/lib32')])
+ if os.environ.has_key('LD_LIBRARY_PATH'):
+ denv['LD_LIBRARY_PATH'] += ':' + os.environ['LD_LIBRARY_PATH']
+ #INCLUDE_PATH
+ denv['INCLUDE_PATH'] = ':'.join([pjoin(root, i) for i in ('usr/include',)])
+ if os.environ.has_key('INCLUDE_PATH'):
+ denv['INCLUDE_PATH'] += ':' + os.environ['INCLUDE_PATH']
# Retrieve package string
pkg = normalize_cpv(package)
- # Setup command line
- env['PKGDIR'] = pkgdir
- envl = ""
- for i in env:
- envl += i + '="' + env[i] + '" '
- cl = envl + 'emerge --ignore-default-opts -OB "=' + pkg + '"'
-
# Execute emerge command and log the results
if logfile is not None:
fout = file(logfile, 'w')
- fout.write(cl+'\n'+80*'-'+'\n')
fout.flush()
else:
fout = sp.PIPE
- p = sp.Popen( \
- ['emerge', '--ignore-default-opts', '-OB', '=' + pkg], \
- env = env, \
- stdout = fout, stderr = sp.STDOUT \
- )
+ cmd = ['emerge', '--ignore-default-opts', '-OB', '=' + pkg]
+ p = sp.Popen(cmd, env=denv, stdout=fout, stderr=sp.STDOUT)
p.wait()
+
+ if p.returncode != 0:
+ # In case of error, print the whole emerge command
+ raise InstallException(' '.join(cmd), logfile)
+
+ # Unpack package onto root
+ benchutils.mkdir(pkgdir)
+ benchutils.mkdir(root)
+ archive = pjoin(pkgdir, pkg+'.tbz2')
+ tarcmd = ['tar', 'xjvf', archive, '-C', root]
+ cl = ' '.join(tarcmd)
if logfile is not None:
- fout.close()
+ fout.write('\n\n' + 80*'#' + '\n\n')
+ fout.write(cl + '\n' + 80*'-' + '\n')
+ p = sp.Popen(tarcmd, stdout=fout, stderr=sp.STDOUT)
+ p.wait()
if p.returncode != 0:
# In case of error, print the whole emerge command
raise InstallException(cl, logfile)
+ if logfile is not None:
+ fout.close()
+
if __name__ == '__main__':
# Just a test
- print available_packages('blas-reference')
+ from pprint import pprint
+
+ pprint(get_dependencies('sci-libs/blas-reference-3.3.1-r1'))
diff --git a/benchconfig.py b/benchconfig.py
index c5ef732..b192e0a 100644
--- a/benchconfig.py
+++ b/benchconfig.py
@@ -1,6 +1,7 @@
import sys, os, time
import subprocess as sp
-from benchutils import *
+#from benchutils import mkdir
+import benchutils as bu
try:
needsinitialization = not initialized
@@ -68,11 +69,11 @@ if needsinitialization:
del logdirb
def makedirs():
- mkdir(rootsdir)
- mkdir(testsdir)
- mkdir(pkgsdir)
- mkdir(reportdir)
- mkdir(logdir)
+ bu.mkdir(rootsdir)
+ bu.mkdir(testsdir)
+ bu.mkdir(pkgsdir)
+ bu.mkdir(reportdir)
+ bu.mkdir(logdir)
diff --git a/btl/actions/action_parallel_cholesky.hh b/btl/actions/action_parallel_cholesky.hh
index 05ef3ef..6c3a6da 100644
--- a/btl/actions/action_parallel_cholesky.hh
+++ b/btl/actions/action_parallel_cholesky.hh
@@ -9,6 +9,8 @@
#include "STL_interface.hh"
#include <string>
+#include <sstream>
+#include <fstream>
template<class Interface>
class Action_parallel_cholesky {
@@ -27,25 +29,17 @@ public :
// STL matrix and vector initialization
if (iamroot) {
- typename LapackInterface::stl_matrix temp_stl;
- init_matrix_symm<pseudo_random>(temp_stl, size);
- Global_A_stl.reserve(size*size);
- const double add = 5000./size;
- for (int r = 0; r < size; ++r)
- for (int c = 0; c < size; ++c)
- if (r==c)
- Global_A_stl.push_back((std::abs(temp_stl[r][c])+add)*size);
- else
- Global_A_stl.push_back(temp_stl[r][c]);
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_SPD_matrix(Global_A_stl, size, seed);
}
const int blocksize = std::max(std::min(size/4, 64), 2);
- Interface::scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
LocalRows = desc[8];
LocalCols = Local_A_stl.size()/desc[8];
// Generic local matrix and vectors initialization
- Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
Interface::matrix_from_stl(Local_A , Local_A_stl);
_cost = 0;
@@ -69,7 +63,6 @@ public :
MESSAGE("Action_parallel_cholesky destructor");
// Deallocation
- Interface::free_matrix(Local_A_ref, Local_A_stl.size());
Interface::free_matrix(Local_A , Local_A_stl.size());
}
@@ -86,16 +79,21 @@ public :
BTL_DONT_INLINE void initialize()
{
- Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
}
BTL_DONT_INLINE void calculate()
{
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
Interface::parallel_cholesky(Local_A, desc);
}
BTL_DONT_INLINE void check_result()
{
+ if (_size > 2) {
+ double error = Interface::test_cholesky(Global_A_stl, Local_A, desc);
+ if (iamroot)
+ cout << " {error: " << error << "} ";
+ }
}
@@ -106,8 +104,10 @@ private:
typename Interface::stl_matrix Global_A_stl;
typename Interface::stl_matrix Local_A_stl;
- typename Interface::gene_matrix Local_A_ref;
typename Interface::gene_matrix Local_A;
+
+ typename Interface::stl_matrix Glotal_Test_stl;
+ typename Interface::stl_matrix Local_Test_stl;
};
#endif /* ACTION_PARALLEL_CHOLESKY_HH_ */
diff --git a/btl/actions/action_parallel_lu_decomp.hh b/btl/actions/action_parallel_lu_decomp.hh
index d3dc620..06602fd 100644
--- a/btl/actions/action_parallel_lu_decomp.hh
+++ b/btl/actions/action_parallel_lu_decomp.hh
@@ -26,16 +26,17 @@ public :
// STL matrix and vector initialization
if (iamroot) {
- init_vector<pseudo_random>(Global_A_stl, size*size);
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_matrix(Global_A_stl, size, seed);
}
const int blocksize = std::max(std::min(size/4, 64), 2);
- Interface::scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
LocalRows = desc[8];
LocalCols = Local_A_stl.size()/desc[8];
// Generic local matrix and vectors initialization
- Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
Interface::matrix_from_stl(Local_A , Local_A_stl);
_cost = 2.0*size*size*size/3.0 + static_cast<double>(size*size);
@@ -55,7 +56,6 @@ public :
MESSAGE("Action_parallel_lu_decomp destructor");
// Deallocation
- Interface::free_matrix(Local_A_ref, Local_A_stl.size());
Interface::free_matrix(Local_A , Local_A_stl.size());
}
@@ -72,12 +72,12 @@ public :
BTL_DONT_INLINE void initialize()
{
- Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
}
BTL_DONT_INLINE void calculate()
{
- Interface::parallel_lu_decomp(Local_A, desc);
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
+ Interface::parallel_lu_decomp(Local_A, ipiv_stl, desc);
}
BTL_DONT_INLINE void check_result()
@@ -100,6 +100,13 @@ public :
//
// Interface::free_matrix(A, _size*_size);
// }
+
+
+// if (_size > 2) {
+// double error = Interface::test_LU(Global_A_stl, Local_A, desc);
+// if (iamroot)
+// cout << " {error: " << error << "} ";
+// }
}
private:
@@ -109,8 +116,9 @@ private:
typename Interface::stl_matrix Global_A_stl;
typename Interface::stl_matrix Local_A_stl;
- typename Interface::gene_matrix Local_A_ref;
typename Interface::gene_matrix Local_A;
+
+ std::vector<int> ipiv_stl;
};
diff --git a/btl/actions/action_parallel_qr_decomp.hh b/btl/actions/action_parallel_qr_decomp.hh
index a41414c..cda1ba5 100644
--- a/btl/actions/action_parallel_qr_decomp.hh
+++ b/btl/actions/action_parallel_qr_decomp.hh
@@ -27,16 +27,17 @@ public :
// STL matrix and vector initialization
if (iamroot) {
- init_vector<pseudo_random>(Global_A_stl, size*size);
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_matrix(Global_A_stl, size, seed);
}
const int blocksize = std::max(std::min(size/4, 64), 2);
- Interface::scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
LocalRows = desc[8];
LocalCols = Local_A_stl.size()/desc[8];
// Generic local matrix and vectors initialization
- Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
Interface::matrix_from_stl(Local_A , Local_A_stl);
_cost = 2.0*size*size*size;
@@ -56,7 +57,6 @@ public :
MESSAGE("Action_parallel_qr_decomp destructor");
// Deallocation
- Interface::free_matrix(Local_A_ref, Local_A_stl.size());
Interface::free_matrix(Local_A , Local_A_stl.size());
}
@@ -73,11 +73,11 @@ public :
BTL_DONT_INLINE void initialize()
{
- Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
}
BTL_DONT_INLINE void calculate()
{
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
Interface::parallel_qr_decomp(Local_A, desc);
}
@@ -92,7 +92,6 @@ private:
typename Interface::stl_matrix Global_A_stl;
typename Interface::stl_matrix Local_A_stl;
- typename Interface::gene_matrix Local_A_ref;
typename Interface::gene_matrix Local_A;
};
diff --git a/btl/generic_bench/init/init_matrix.hh b/btl/generic_bench/init/init_matrix.hh
index 67cbd20..0420c7a 100644
--- a/btl/generic_bench/init/init_matrix.hh
+++ b/btl/generic_bench/init/init_matrix.hh
@@ -20,6 +20,8 @@
#ifndef INIT_MATRIX_HH
#define INIT_MATRIX_HH
+#include "LinearCongruential.hh"
+
// The Vector class must satisfy the following part of STL vector concept :
// resize() method
// [] operator for setting element
@@ -61,4 +63,30 @@ BTL_DONT_INLINE void init_matrix_symm(Matrix& A, int size){
}
}
+template<class Matrix> BTL_DONT_INLINE
+void init_matrix(Matrix& A, const int& size, const unsigned& seed)
+{
+ typedef typename Matrix::value_type value_t;
+ A.resize(size*size);
+ LinearCongruential rng(seed);
+ for (typename Matrix::iterator i = A.begin(), end = A.end(); i != end; ++i)
+ *i = rng.get_01();
+}
+
+template<class Matrix> BTL_DONT_INLINE
+void init_SPD_matrix(Matrix& A, const int& size, const unsigned& seed)
+{
+ typedef typename Matrix::value_type value_t;
+ A.resize(size*size);
+ LinearCongruential rng(seed);
+ for (int r = 0; r < size; ++r) {
+ A[r+size*r] = rng.get_01() + size;
+ for (int c = r+1; c < size; ++c) {
+ const value_t v = rng.get_01();
+ A[r+size*c] = v;
+ A[c+size*r] = v;
+ }
+ }
+}
+
#endif
diff --git a/btl/libs/BLACS/blacs_interface.hh b/btl/libs/BLACS/blacs_interface.hh
index 6932150..eaef8a5 100644
--- a/btl/libs/BLACS/blacs_interface.hh
+++ b/btl/libs/BLACS/blacs_interface.hh
@@ -76,6 +76,11 @@ public:
blacs_get_(&ignored, &what, &ctxt);
return ctxt;
}
+ static int myid() {
+ int procnum, myid;
+ blacs_pinfo_(&myid, &procnum);
+ return myid;
+ }
static void scatter_matrix(const stl_vector& GlobalMatrix, stl_vector& LocalMatrix,
diff --git a/btl/libs/BLACS/gather.h b/btl/libs/BLACS/gather.h
index 3505233..1ee8149 100644
--- a/btl/libs/BLACS/gather.h
+++ b/btl/libs/BLACS/gather.h
@@ -13,5 +13,20 @@
#undef TYPENAME
#undef TYPEPREFIX
+template<typename T>
+static void gather_matrix(std::vector<T>& GlobalMatrix, const std::vector<T>& LocalMatrix,
+ const int* desc
+) {
+ int GlobalRows = desc[2], GlobalCols = desc[3],
+ BlockRows = desc[4], BlockCols = desc[5],
+ LocalRows = desc[8], LocalCols = LocalMatrix.size()/desc[8];
+ int ctxt;
+ {
+ int ignored, what = 0;
+ blacs_get_(&ignored, &what, &ctxt);
+ }
+ gather(ctxt, GlobalMatrix, LocalMatrix, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+}
+
#endif /* GATHER_H_ */
diff --git a/btl/libs/BLACS/scatter.h b/btl/libs/BLACS/scatter.h
index 5e6a76c..310da87 100644
--- a/btl/libs/BLACS/scatter.h
+++ b/btl/libs/BLACS/scatter.h
@@ -13,5 +13,32 @@
#undef TYPENAME
#undef TYPEPREFIX
+template<typename T>
+void scatter_matrix(const std::vector<T>& GlobalMatrix, std::vector<T>& LocalMatrix,
+ int *desc,
+ const int& GlobalRows=0, const int& GlobalCols=0,
+ const int& BlockRows=0, const int& BlockCols=0
+ )
+{
+ int GlobalRows_ = GlobalRows, GlobalCols_ = GlobalCols,
+ BlockRows_ = BlockRows, BlockCols_ = BlockCols,
+ LocalRows_, LocalCols_;
+ int ctxt;
+ {
+ int ignored, what = 0;
+ blacs_get_(&ignored, &what, &ctxt);
+ }
+ scatter(ctxt, GlobalMatrix, LocalMatrix,
+ GlobalRows_, GlobalCols_, BlockRows_, BlockCols_, LocalRows_, LocalCols_
+ );
+
+ const int iZERO = 0;
+ int info;
+ const int LLD = std::max(1, LocalRows_);
+ descinit_(desc, &GlobalRows_, &GlobalCols_, &BlockRows_, &BlockCols_,
+ &iZERO, &iZERO, &ctxt, &LLD, &info
+ );
+}
+
#endif /* SCATTER_H_ */
diff --git a/btl/libs/PBLAS/main.cpp b/btl/libs/PBLAS/main.cpp
index f1f7d69..96046e1 100644
--- a/btl/libs/PBLAS/main.cpp
+++ b/btl/libs/PBLAS/main.cpp
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
distr_bench<Action_parallel_lu_decomp<pblas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT, !iamroot);
if (cholesky)
- distr_bench<Action_parallel_cholesky<pblas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT, !iamroot);
+ distr_bench<Action_parallel_cholesky<pblas_interface<REAL_TYPE> > >(MIN_MM, MAX_MM, NB_POINT, !iamroot);
if (qr_decomp)
distr_bench<Action_parallel_qr_decomp<pblas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT, !iamroot);
diff --git a/btl/libs/PBLAS/pblas.h b/btl/libs/PBLAS/pblas.h
index e801b8b..48dd7cc 100644
--- a/btl/libs/PBLAS/pblas.h
+++ b/btl/libs/PBLAS/pblas.h
@@ -42,6 +42,19 @@ extern "C" {
);
+ /* Level 3 */
+
+ // Single
+ void pstrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const float*,
+ const float*, const int*, const int*, const int*,
+ float*, const int*, const int*, const int*);
+
+ // Double
+ void pdtrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*,
+ const double*, const int*, const int*, const int*,
+ double*, const int*, const int*, const int*);
+
+
/*************
* Scalapack *
diff --git a/btl/libs/PBLAS/pblas_interface.hh b/btl/libs/PBLAS/pblas_interface.hh
index cdfb70a..01459f5 100644
--- a/btl/libs/PBLAS/pblas_interface.hh
+++ b/btl/libs/PBLAS/pblas_interface.hh
@@ -1,3 +1,4 @@
+#include "blas.h"
#include "pblas.h"
#include "blacs_interface.hh"
diff --git a/btl/libs/PBLAS/pblas_interface_impl.hh b/btl/libs/PBLAS/pblas_interface_impl.hh
index d71d61e..d1d1c9f 100644
--- a/btl/libs/PBLAS/pblas_interface_impl.hh
+++ b/btl/libs/PBLAS/pblas_interface_impl.hh
@@ -1,6 +1,7 @@
#define PBLAS_PREFIX p
#define PBLAS_FUNC(NAME) CAT(CAT(CAT(PBLAS_PREFIX, SCALAR_PREFIX),NAME),_)
+#define BLAS_FUNC(NAME) CAT(CAT(SCALAR_PREFIX,NAME),_)
template<> class pblas_interface<SCALAR> : public blacs_interface<SCALAR>
{
@@ -45,26 +46,26 @@ public:
}
- static inline void parallel_lu_decomp(gene_matrix& X, const int* desc)
+ static inline void parallel_lu_decomp(gene_matrix& X, std::vector<int>& ipiv, const int* desc)
{
const int GlobalRows = desc[2], GlobalCols = desc[3];
const int iONE = 1;
int info;
- std::vector<int> ipiv(desc[8] + desc[4]);
+ ipiv.resize(desc[8] + desc[4]);
PBLAS_FUNC(getrf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc,
&ipiv[0], &info);
-// if (info != 0)
-// cerr << " { LU error : " << info << " } ";
+ if (info != 0 && myid() == 0)
+ cout << " { LU error : " << info << " } ";
}
static inline void parallel_cholesky(gene_matrix& X, const int* desc)
{
const int N = desc[2], iONE = 1;
- const char UPLO = 'U';
+ const char UP = 'U';
int info;
- PBLAS_FUNC(potrf)(&UPLO, &N, X, &iONE, &iONE, desc, &info);
-// if (info != 0)
-// cerr << " { cholesky error : " << info << " } ";
+ PBLAS_FUNC(potrf)(&UP, &N, X, &iONE, &iONE, desc, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { cholesky error : " << info << " } ";
}
static inline void parallel_qr_decomp(gene_matrix& X, const int* desc)
@@ -86,13 +87,13 @@ public:
// Retrieve LWORK
PBLAS_FUNC(geqpf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc, &ipiv[0], &tau[0], &lworkd, &imONE, &info);
lwork = static_cast<int>(lworkd);
-// if (info != 0)
-// cerr << " { qr_decomp lwork error } ";
+ if (info != 0 && myid() == 0)
+ cout << " { qr_decomp lwork error } ";
std::vector<SCALAR> work(lwork);
PBLAS_FUNC(geqpf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc, &ipiv[0], &tau[0], &work[0], &lwork, &info);
-// if (info != 0)
-// cerr << " { qr_decomp computation error } ";
+ if (info != 0 && myid() == 0)
+ cerr << " { qr_decomp computation error } ";
}
static inline void parallel_symm_ev(gene_matrix& A, const int* descA, gene_vector& w, gene_matrix& Z, const int* descZ)
@@ -109,13 +110,13 @@ public:
Z, &iONE, &iONE, descZ, &lworkd, &imONE, &liwork, &imONE, &info);
lwork = static_cast<int>(lworkd);
work.resize(lwork); iwork.resize(liwork);
-// if (info != 0)
-// cerr << " { symm_ev l(i)work error } ";
+ if (info != 0 && myid() == 0)
+ cout << " { symm_ev l(i)work error } ";
PBLAS_FUNC(syevd)(&jobz, &uplo, &N, A, &iONE, &iONE, descA, w,
Z, &iONE, &iONE, descZ, &work[0], &lwork, &iwork[0], &liwork, &info);
-// if (info != 0)
-// cerr << " { symm_ev computation error } ";
+ if (info != 0 && myid() == 0)
+ cout << " { symm_ev computation error } ";
}
static inline void parallel_svd_decomp(gene_matrix& A, int* descA, gene_matrix& U, int *descU, gene_matrix& V, int *descV, gene_vector& s)
@@ -129,14 +130,100 @@ public:
// Retrieve lwork
PBLAS_FUNC(gesvd)(&job, &job, &size, &size, A, &iONE, &iONE, descA, s,
U, &iONE, &iONE, descU, V, &iONE, &iONE, descV, &lworkd, &imONE, &info);
-// if (info != 0)
-// cerr << " { svd_decomp lwork error } ";
+ if (info != 0 && myid() == 0)
+ cout << " { svd_decomp lwork error } ";
lwork = static_cast<int>(lworkd);
work.resize(lwork);
PBLAS_FUNC(gesvd)(&job, &job, &size, &size, A, &iONE, &iONE, descA, s,
U, &iONE, &iONE, descU, V, &iONE, &iONE, descV, &work[0], &lwork, &info);
-// if (info != 0)
-// cerr << " { svd_decomp computation error } ";
+ if (info != 0 && myid() == 0)
+ cout << " { svd_decomp computation error } ";
+ }
+
+ static inline real_type
+ test_LU(stl_matrix& Global_A, gene_matrix& Local_LU, int *desc)
+ {
+ bool iamroot = myid() == 0;
+ int _size = desc[2];
+
+ // Create and scatter Identity
+ int Testdesc[9];
+ stl_matrix Global_Test_stl, Local_Test_stl;
+ if (iamroot)
+ {
+ stl_matrix Identity(_size * _size);
+ for (int r = 0; r < _size; ++r)
+ Identity[r + _size * r] = 1;
+ scatter_matrix(Identity, Local_Test_stl, Testdesc, _size, _size,
+ desc[4], desc[5]);
+ }
+ else
+ scatter_matrix(stl_matrix(), Local_Test_stl, Testdesc);
+
+ // Compute L * U
+ real_type alpha = 1., malpha = -1;
+ int iONE = 1;
+ PBLAS_FUNC(trmm)("L", "L", "N", "N", desc + 2, desc + 2, &alpha, Local_LU,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+ PBLAS_FUNC(trmm)("R", "U", "N", "N", desc + 2, desc + 2, &alpha, Local_LU,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+
+ // Gather result
+ gather_matrix(Global_Test_stl, Local_Test_stl, desc);
+ if (iamroot)
+ {
+ int size2 = _size*_size;
+ BLAS_FUNC(axpy)(&size2, &malpha, &Global_A[0], &iONE,
+ &Global_Test_stl[0], &iONE);
+ double error = BLAS_FUNC(nrm2)(&size2, &Global_Test_stl[0], &iONE);
+ error /= BLAS_FUNC(nrm2)(&size2, &Global_A[0], &iONE);
+ return error;
+ }
+ else
+ return 0.;
+ }
+
+ static inline real_type
+ test_cholesky(stl_matrix& Global_A, gene_matrix& Local_U, int *desc)
+ {
+ bool iamroot = myid() == 0;
+ int _size = desc[2];
+
+ // Create and scatter Identity
+ int Testdesc[9];
+ stl_matrix Global_Test_stl, Local_Test_stl;
+ if (iamroot)
+ {
+ stl_matrix Identity(_size * _size);
+ for (int r = 0; r < _size; ++r)
+ Identity[r + _size * r] = 1;
+ scatter_matrix(Identity, Local_Test_stl, Testdesc, _size, _size,
+ desc[4], desc[5]);
+ }
+ else
+ scatter_matrix(stl_matrix(), Local_Test_stl, Testdesc);
+
+ // Compute U' * U
+ real_type alpha = 1., malpha = -1;
+ int iONE = 1;
+ PBLAS_FUNC(trmm)("L", "U", "T", "N", desc + 2, desc + 2, &alpha, Local_U,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+ PBLAS_FUNC(trmm)("R", "U", "N", "N", desc + 2, desc + 2, &alpha, Local_U,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+
+ // Gather result
+ gather_matrix(Global_Test_stl, Local_Test_stl, desc);
+ if (iamroot)
+ {
+ int size2 = _size*_size;
+ BLAS_FUNC(axpy)(&size2, &malpha, &Global_A[0], &iONE,
+ &Global_Test_stl[0], &iONE);
+ double error = BLAS_FUNC(nrm2)(&size2, &Global_Test_stl[0], &iONE);
+ error /= BLAS_FUNC(nrm2)(&size2, &Global_A[0], &iONE);
+ return error;
+ }
+ else
+ return 0.;
}
};
diff --git a/btlbase.py b/btlbase.py
index 7ac0818..1914fe3 100644
--- a/btlbase.py
+++ b/btlbase.py
@@ -22,11 +22,9 @@ class BTLBase(basemodule.BaseModule):
class BTLTest(basemodule.BaseTest):
- compileenv = {}
- runenv = {}
-
def _compileTest(self):
self.compileenv = {}
+ self.runenv = {}
# Includes
includes = [pjoin(cfg.btldir, i) for i in \
@@ -64,6 +62,12 @@ class BTLTest(basemodule.BaseTest):
self.compileenv['LIBRARY_PATH'] = ':'.join(libdirs)
self.compileenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
self.runenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
+ # PATH
+ envpath = ':'.join([pjoin(root, l) for l in ('bin', 'usr/bin')])
+ if (os.environ.has_key('PATH')):
+ envpath += ':' + os.environ['PATH']
+ self.compileenv['PATH'] = envpath
+ self.runenv['PATH'] = envpath
exe = pjoin(self.testdir, "test")
@@ -105,13 +109,12 @@ class BTLTest(basemodule.BaseTest):
# Open pipe
logfile = file(pjoin(self.logdir, 'btlrun.log'), 'w')
args = preargs + [exe] + list(self.tests)
- logfile.write(' '.join([n+'='+v for n,v in self.runenv.items()]) + ' ')
+ logfile.write(' '.join( \
+ [n + '="'+v+'"' for n,v in self.runenv.items()] ) + ' ')
logfile.write(' '.join(args) + '\n')
logfile.write(80*'-' + '\n')
proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
- #env=self.runenv,
- env={'LD_LIBRARY_PATH' : self.runenv['LD_LIBRARY_PATH']},
- cwd=self.testdir)
+ env=self.runenv, cwd=self.testdir)
# Interpret output
while True:
@@ -138,4 +141,5 @@ class BTLTest(basemodule.BaseTest):
Print.up()
logfile.close()
proc.wait()
+ Print("Execution finished with return code " + str(proc.returncode))
return proc.returncode \ No newline at end of file
diff --git a/main.py b/main.py
index 561d5d9..360d055 100755
--- a/main.py
+++ b/main.py
@@ -24,10 +24,13 @@ try:
mod = tmp.Module(sys.argv[3:])
del tmp
cfg.makedirs()
-except ImportError, IndexError:
+except ImportError as e:
print e
print_usage()
exit(1)
+except IndexError:
+ print_usage()
+ exit(1)
def tests_from_input(input):
@@ -84,27 +87,6 @@ used at compile-time as dictionary (it can just be a void one).
After the tests every successful tested item will contain the item "result",
which can contain any type of data and will be used for the final report.
"""
-#tests = {
-# "reference-gfortran" : {
-# "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'),
-# "env" : {'FC' : 'gfortran'}
-# },
-#
-# "eigen-gcc" : {
-# "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'),
-# "env" : {'CXX' : 'g++', 'CXXFLAGS' : '-O2'}
-# },
-#
-# "eigen-icc" : {
-# "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'),
-# "env" : {'CXX' : 'icc', 'CXXFLAGS' : '-O3'}
-# },
-#
-# "reference-ifort" : {
-# "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'),
-# "env" : {'FC' : 'ifort'}
-# }
-#}
"""
@@ -158,27 +140,43 @@ for tn,(name,test) in enumerate(cfg.tests.items(),1):
Print.down()
package = normalize_cpv(test['package'])
archive = pjoin(pkgdir, package+".tbz2")
- Print("Emerging package %s" % package)
if os.path.exists(archive):
Print("Package already emerged - skipping")
else:
try:
+ # Emerge dependencies
+ Print("Emerging dependencies")
+ install_dependencies( \
+ test['package'], root=root, pkgdir=pkgdir, \
+ logdir=tlogdir)
+
+ # Emerge pacakge
+ Print("Emerging package %s" % package)
logfile = pjoin(tlogdir, 'emerge.log')
- Print("(Run 'tail -f " + logfile + " | less' on another terminal" \
+ Print("(Run 'tail -f " + logfile + "' on another terminal" \
+ " to see the progress)")
install_package( \
test['package'], env=test['env'], root=root, pkgdir=pkgdir, \
logfile=logfile
)
+# archives.append(archive)
+
# Unpack the archive onto the given root directory
- os.path.exists(root) or os.makedirs(root)
- tarcmd = ['tar', 'xjf', archive, '-C', root]
- logfile = file(pjoin(tlogdir, 'tar.log'), 'w')
- tarp = sp.Popen(tarcmd, stdout=logfile, stderr=sp.STDOUT)
- tarp.wait()
- logfile.close()
- if tarp.returncode != 0:
- raise InstallException(tarcmd, logfile.name)
+# Print("Unpacking packages")
+# logfile = pjoin(tlogdir, 'tar.log')
+# Print("(Run 'tail -f " + logfile + "' on another terminal" \
+# + " to see the progress)")
+# logfile = file(logfile, 'w')
+# tarcmds = [['tar', 'xvjf', a, '-C', root] for a in archives]
+# os.path.exists(root) or os.makedirs(root)
+# tarcmd = ['tar', 'xjf', archive, '-C', root]
+# for c in tarcmds:
+# logfile.write(' '.join(c) + '\n' + 80*'-' + '\n')
+# tarp = sp.Popen(c, stdout=sp.PIPE, stderr=sp.STDOUT)
+# logfile.write(tarp.communicate()[0])
+# logfile.write('\n\n' + 80*'#' + '\n\n')
+# if tarp.returncode != 0:
+# raise InstallException(tarcmd, logfile.name)
except InstallException as e:
Print("Package %s failed to emerge" % package)