From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qizrh-0003R6-9W for garchives@archives.gentoo.org; Tue, 19 Jul 2011 02:16:53 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B9BF221C0E3; Tue, 19 Jul 2011 02:16:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6505A21C0E3 for ; Tue, 19 Jul 2011 02:16:44 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9997B1BC013 for ; Tue, 19 Jul 2011 02:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E690B8003D for ; Tue, 19 Jul 2011 02:16:42 +0000 (UTC) From: "Andrea Arteaga" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrea Arteaga" Message-ID: <75c943fd4c2d2ce6454732cc90df910f3e73b182.spiros@gentoo> Subject: [gentoo-commits] proj/auto-numerical-bench:unstable commit in: /, btl/actions/, btl/generic_bench/timers/, btl/libs/PBLAS/, btl/libs/BLAS/, ... X-VCS-Repository: proj/auto-numerical-bench X-VCS-Files: btl/actions/action_parallel_axpy.hh btl/actions/action_parallel_matrix_vector_product.hh btl/generic_bench/timers/distributed_perf_analyzer_root.hh btl/libs/BLACS/gather.h btl/libs/BLACS/gather_impl.h btl/libs/BLACS/scatter_impl.h btl/libs/BLAS/blas.h btl/libs/PBLAS/main.cpp btl/libs/PBLAS/pblas.h btl/libs/PBLAS/pblas_interface_impl.hh btl/libs/STL/STL_interface.hh btlbase.py pblas.py X-VCS-Directories: / btl/actions/ btl/generic_bench/timers/ btl/libs/PBLAS/ btl/libs/BLAS/ btl/libs/BLACS/ btl/libs/STL/ X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: 75c943fd4c2d2ce6454732cc90df910f3e73b182 Date: Tue, 19 Jul 2011 02:16:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 191fdbe104c70e614018f27a9ee6fa38 commit: 75c943fd4c2d2ce6454732cc90df910f3e73b182 Author: spiros gmail com> AuthorDate: Tue Jul 19 02:12:01 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Tue Jul 19 02:12:01 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3D75c943fd Updated much of the parallel BTL. Added first version of (almost working) pblas/scalapck python module. --- btl/actions/action_parallel_axpy.hh | 141 ++++++++++++++= ++++++ .../action_parallel_matrix_vector_product.hh | 62 ++------- .../timers/distributed_perf_analyzer_root.hh | 2 +- btl/libs/BLACS/gather.h | 10 +- btl/libs/BLACS/gather_impl.h | 9 +- btl/libs/BLACS/scatter_impl.h | 5 - btl/libs/BLAS/blas.h | 6 + btl/libs/PBLAS/main.cpp | 6 +- btl/libs/PBLAS/pblas.h | 49 +++++-- btl/libs/PBLAS/pblas_interface_impl.hh | 13 ++ btl/libs/STL/STL_interface.hh | 11 ++ btlbase.py | 8 +- pblas.py | 67 +++++++++ 13 files changed, 307 insertions(+), 82 deletions(-) diff --git a/btl/actions/action_parallel_axpy.hh b/btl/actions/action_par= allel_axpy.hh new file mode 100644 index 0000000..905909d --- /dev/null +++ b/btl/actions/action_parallel_axpy.hh @@ -0,0 +1,141 @@ +#ifndef ACTION_PARALLEL_AXPY +#define ACTION_PARALLEL_AXPY +#include "utilities.h" +#include "STL_interface.hh" +#include +#include +#include "init/init_function.hh" +#include "init/init_vector.hh" +#include "init/init_matrix.hh" + +#include "blas.h" + +using namespace std; + +template +class Action_parallel_axpy { +public: + BTL_DONT_INLINE Action_parallel_axpy( int size ):_size(size), _coef(1.= ) + { + MESSAGE("Action_parallel_axpy Ctor"); + int iZERO =3D 0, iONE =3D 1; + + GlobalRows =3D _size; + GlobalCols =3D 1; + BlockRows =3D 2; + BlockCols=3D 1; + + int myid, procnum; + blacs_pinfo_(&myid, &procnum); + iamroot =3D (myid =3D=3D 0); + + // STL matrix and vector initialization + if (iamroot) { + init_vector(Global_x_stl, _size); + init_vector(Global_y_stl, _size); + } + + Interface::scatter_matrix(Global_x_stl, Local_x_stl, GlobalRows, Glo= balCols, BlockRows, BlockCols, LocalRows, LocalCols); + Interface::scatter_matrix(Global_y_stl, Local_y_stl, GlobalRows, Glo= balCols, BlockRows, BlockCols, LocalRows, LocalCols); + + Interface::vector_from_stl(Local_x_ref, Local_x_stl); + Interface::vector_from_stl(Local_x , Local_x_stl); + Interface::vector_from_stl(Local_y_ref, Local_y_stl); + Interface::vector_from_stl(Local_y , Local_y_stl); + + // Descinit + int context =3D Interface::context(); + int info; + int LD =3D std::max(1, LocalRows); + descinit_(descX, &_size, &iONE, &BlockRows, &BlockCols, &iZERO, &iZE= RO, &context, &LD, &info); + descinit_(descY, &_size, &iONE, &BlockRows, &BlockCols, &iZERO, &iZE= RO, &context, &LD, &info); + + // Copy Y to Test_y + Test_y_stl =3D Global_y_stl; + } + + // Invalidate copy constructor + Action_parallel_axpy (const Action_parallel_axpy&) + { + INFOS("illegal call to Action_parallel_axpy Copy Ctor"); + exit(1); + } + + // Destructor + BTL_DONT_INLINE ~Action_parallel_axpy(){ + + MESSAGE("Action_parallel_axpy Dtor"); + + // deallocation + + Interface::free_vector(Local_x_ref); + Interface::free_vector(Local_y_ref); + + Interface::free_vector(Local_x); + Interface::free_vector(Local_y); + } + + // action name + static inline std::string name() + { + return "axpy_" + Interface::name(); + } + + double nb_op_base( void ){ + return 2.0*_size; + } + + BTL_DONT_INLINE void initialize(){ + Interface::copy_vector(Local_x_ref, Local_x, LocalRows*LocalCols); + Interface::copy_vector(Local_y_ref, Local_y, LocalRows*LocalCols); + } + + BTL_DONT_INLINE void calculate( void ) { + BTL_ASM_COMMENT("#begin axpy"); + Interface::parallel_axpy(_coef, Local_x, descX, Local_y, descY, _s= ize); + BTL_ASM_COMMENT("end axpy"); + } + + void check_result( void ){ + int iONE =3D 1; + Interface::vector_to_stl(Local_y, Local_y_stl); + Interface::gather_matrix(Global_y_stl, Local_y_stl, GlobalRows, Glob= alCols, BlockRows, BlockCols, LocalRows, LocalCols); + + // calculation check + if (iamroot) { + + // Compute YTest + STL_interface::axpy(_coef, Global_x= _stl, Test_y_stl, _size); + + typename Interface::real_type error =3D + STL_interface::norm_diff(Glob= al_y_stl, Test_y_stl); + + if (error > 1e-5) + std::cerr << "Error: " << error << std::endl; + } + + } + +private: + int _size; + int GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols= ; + typename Interface::real_type _coef; + bool iamroot; + + typename Interface::stl_vector Global_x_stl; + typename Interface::stl_vector Global_y_stl; + typename Interface::stl_vector Test_y_stl; + + typename Interface::stl_vector Local_x_stl; + typename Interface::stl_vector Local_y_stl; + + typename Interface::gene_vector Local_x_ref; + typename Interface::gene_vector Local_y_ref; + + typename Interface::gene_vector Local_x; + typename Interface::gene_vector Local_y; + + int descX[9], descY[9]; +}; + +#endif diff --git a/btl/actions/action_parallel_matrix_vector_product.hh b/btl/a= ctions/action_parallel_matrix_vector_product.hh index bac8bc3..5c97b1d 100644 --- a/btl/actions/action_parallel_matrix_vector_product.hh +++ b/btl/actions/action_parallel_matrix_vector_product.hh @@ -1,24 +1,5 @@ -//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D -// File : action_matrix_vector_product.hh -// Author : L. Plagne -// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002 -//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307= , USA. -// -#ifndef ACTION_MATRIX_VECTOR_PRODUCT -#define ACTION_MATRIX_VECTOR_PRODUCT +#ifndef ACTION_PARALLEL_MATRIX_VECTOR_PRODUCT +#define ACTION_PARALLEL_MATRIX_VECTOR_PRODUCT #include "utilities.h" #include "STL_interface.hh" #include @@ -27,10 +8,7 @@ #include "init/init_vector.hh" #include "init/init_matrix.hh" =20 -#include -extern "C" { #include "blas.h" -} =20 using namespace std; =20 @@ -62,16 +40,6 @@ public : init_vector(Global_A_stl, GlobalRows*GlobalCols); init_vector(Global_x_stl, GlobalCols); init_vector(Global_y_stl, GlobalRows); - - // Compute YTest (?) - Test_y_stl.resize(GlobalRows); - double alpha =3D 1., beta =3D 0.; - char notrans =3D 'N'; - dgemv_(¬rans, &GlobalRows, &GlobalCols, - &alpha, &Global_A_stl[0], &GlobalRows, - &Global_x_stl[0], &iONE, - &beta, &Test_y_stl[0], &iONE - ); } =20 Interface::scatter_matrix(Global_A_stl, Local_A_stl, GlobalRows, Glo= balCols, BlockRows, BlockCols, LocalRows, LocalCols); @@ -113,11 +81,11 @@ public : =20 // deallocation =20 - Interface::free_matrix(Local_A_ref, GlobalRows*GlobalCols);; + Interface::free_matrix(Local_A_ref, GlobalRows*GlobalCols); Interface::free_vector(Local_x_ref); Interface::free_vector(Local_y_ref); =20 - Interface::free_matrix(Local_A, GlobalRows*GlobalCols);; + Interface::free_matrix(Local_A, GlobalRows*GlobalCols); Interface::free_vector(Local_x); Interface::free_vector(Local_y); =20 @@ -126,7 +94,7 @@ public : // action name static inline std::string name( void ) { - return "parallel_matrix_vector_" + Interface::name(); + return "matrix_vector_" + Interface::name(); } =20 double nb_op_base( void ){ @@ -134,11 +102,9 @@ public : } =20 BTL_DONT_INLINE void initialize( void ){ - Interface::copy_matrix(Local_A_ref,Local_A,LocalRows*LocalCols); Interface::copy_vector(Local_x_ref,Local_x,LocalXRows*LocalXCols); Interface::copy_vector(Local_y_ref,Local_y,LocalYRows*LocalYCols); - } =20 BTL_DONT_INLINE void calculate( void ) { @@ -148,8 +114,6 @@ public : } =20 BTL_DONT_INLINE void check_result( void ){ - int iONE =3D 1; - double dmONE =3D -1.; int GlobalYCols; Interface::vector_to_stl(Local_y, Local_y_stl); =20 @@ -157,11 +121,16 @@ public : =20 // calculation check if (iamroot) { - daxpy_(&GlobalRows, &dmONE, &Global_y_stl[0], &iONE, &Test_y_stl[0= ], &iONE); - double nrm =3D dnrm2_(&GlobalRows, &Test_y_stl[0], &iONE); =20 - if (nrm > 1e-5) - std::cerr << "Error: " << nrm << std::endl; + // Compute YTest + Test_y_stl.resize(GlobalRows); + STL_interface::matrix_vector_produc= t(Global_A_stl, Global_x_stl, Test_y_stl, _size); + + typename Interface::real_type error =3D + STL_interface::norm_diff(Glob= al_y_stl, Test_y_stl); + + if (error > 1e-5) + std::cerr << "Error: " << error << std::endl; } =20 } @@ -194,6 +163,3 @@ private : =20 =20 #endif - - - diff --git a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh b= /btl/generic_bench/timers/distributed_perf_analyzer_root.hh index ca59738..98a08ef 100644 --- a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh +++ b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh @@ -52,7 +52,7 @@ public: double time_action =3D m_time_action / (double(_nb_calc)); =20 /* Check */ - int do_check =3D (BtlConfig::Instance.checkResults && size<128) ? 1 = : 0; + int do_check =3D (BtlConfig::Instance.checkResults && size<128) ? 1 = : 1; igebs2d_(&context, "A", " ", &iONE, &iONE, &do_check, &iONE); if (do_check > 0) { action.initialize(); diff --git a/btl/libs/BLACS/gather.h b/btl/libs/BLACS/gather.h index 101d975..3505233 100644 --- a/btl/libs/BLACS/gather.h +++ b/btl/libs/BLACS/gather.h @@ -1,13 +1,17 @@ #ifndef GATHER_H_ #define GATHER_H_ =20 -//#define TYPENAME float -//#define TYPEPREFIX s -//#include "gather_impl.h" +#define TYPENAME float +#define TYPEPREFIX s +#include "gather_impl.h" +#undef TYPENAME +#undef TYPEPREFIX =20 #define TYPENAME double #define TYPEPREFIX d #include "gather_impl.h" +#undef TYPENAME +#undef TYPEPREFIX =20 =20 #endif /* GATHER_H_ */ diff --git a/btl/libs/BLACS/gather_impl.h b/btl/libs/BLACS/gather_impl.h index 92a52f3..e9b5c6c 100644 --- a/btl/libs/BLACS/gather_impl.h +++ b/btl/libs/BLACS/gather_impl.h @@ -2,11 +2,6 @@ #define CAT_(x,y) x##y #define CAT(x,y) CAT_(x,y) =20 -#ifndef TYPENAME -# define TYPENAME double -# define TYPEPREFIX d -#endif - #define FUNCNAME(name) CAT(CAT(TYPEPREFIX, name),_) #define vector_t std::vector =20 @@ -33,8 +28,8 @@ inline void gather( blacs_pinfo_(&myid, &procnum); blacs_gridinfo_(&context, &procrows, &proccols, &myrow, &mycol); bool iamroot =3D (myrow =3D=3D rootrow && mycol =3D=3D rootcol); - double *GlobalMatrix; - const double *LocalMatrix =3D &LocalMatrixVector[0]; + TYPENAME *GlobalMatrix; + const TYPENAME *LocalMatrix =3D &LocalMatrixVector[0]; =20 /* Broadcast matrix info */ int binfo[2]; diff --git a/btl/libs/BLACS/scatter_impl.h b/btl/libs/BLACS/scatter_impl.= h index 5c82ea5..7ff633f 100644 --- a/btl/libs/BLACS/scatter_impl.h +++ b/btl/libs/BLACS/scatter_impl.h @@ -1,11 +1,6 @@ #define CAT_(x,y) x##y #define CAT(x,y) CAT_(x,y) =20 -//#ifndef TYPENAME -//# define TYPENAME double -//# define TYPEPREFIX d -//#endif - #define FUNCNAME(name) CAT(CAT(TYPEPREFIX, name),_) #define vector_t std::vector =20 diff --git a/btl/libs/BLAS/blas.h b/btl/libs/BLAS/blas.h index 28f3a4e..67e02e4 100644 --- a/btl/libs/BLAS/blas.h +++ b/btl/libs/BLAS/blas.h @@ -11,6 +11,10 @@ typedef long BLASLONG; typedef unsigned long BLASULONG; #endif =20 +#include + +extern "C" { + int BLASFUNC(xerbla)(const char *, int *info, int); =20 float BLASFUNC(sdot) (int *, float *, int *, float *, int *); @@ -672,4 +676,6 @@ int BLASFUNC(cpotri)(char *, int *, float *, int *, = int *); int BLASFUNC(zpotri)(char *, int *, double *, int *, int *); int BLASFUNC(xpotri)(char *, int *, double *, int *, int *); =20 +} + #endif diff --git a/btl/libs/PBLAS/main.cpp b/btl/libs/PBLAS/main.cpp index 33a4f96..4b64f12 100644 --- a/btl/libs/PBLAS/main.cpp +++ b/btl/libs/PBLAS/main.cpp @@ -8,6 +8,7 @@ #include "blacsinit.hh" #include "pblas_interface.hh" #include "action_parallel_matrix_vector_product.hh" +#include "action_parallel_axpy.hh" =20 #include =20 @@ -17,8 +18,9 @@ int main(int argc, char **argv) { bool iamroot =3D blacsinit(&argc, &argv); =20 - distr_bench > >(10,MAX_MV,NB_POINT,!iamroot); -// Action_parallel_matrix_vector_product > acti= on(3000); +// distr_bench > >(10,MAX_MV,NB_POINT,!iamroot); + distr_bench > >(10,MAX= _MV,NB_POINT,!iamroot); +// Action_parallel_axpy > action(8); // action.initialize(); // action.calculate(); // action.check_result(); diff --git a/btl/libs/PBLAS/pblas.h b/btl/libs/PBLAS/pblas.h index 4144292..adc6c91 100644 --- a/btl/libs/PBLAS/pblas.h +++ b/btl/libs/PBLAS/pblas.h @@ -5,19 +5,42 @@ extern "C" { #endif =20 - /* PBLAS declarations */ - void pdgemv_(const char*, const int*, const int*, - const double*, const double*, const int*, const int*, const int*= , - const double*, const int*, const int*, const int*= , const int*, - const double*, double*, const int*, const int*, const int*= , const int*); - void psgemv_(const char*, const int*, const int*, - const float*, const float*, const int*, const int*, const int*, - const float*, const int*, const int*, const int*, = const int*, - const float*, float*, const int*, const int*, const int*, = const int*); - - - int numroc_(const int*, const int*, const int*, const int*, const = int*); - int descinit_(const int*, const int*, const int*, const int*, cons= t int*, const int*, const int*, const int*, const int*, int*); + int numroc_(const int*, const int*, const int*, const int*, const int*= ); + int descinit_(const int*, const int*, const int*, const int*, const in= t*, const int*, const int*, const int*, const int*, int*); + + + /* Level 1 */ + + // Single + void psaxpy_(const int*, const float*, + const float*, const int*, const int*, const int*, const int*, + const float*, const int*, const int*, const int*, const int* + ); + + // Double + void pdaxpy_(const int*, const double*, + const double*, const int*, const int*, const int*, const int*, + const double*, const int*, const int*, const int*, const int* + ); + + + + /* Level 2 */ + + // Single + void psgemv_(const char*, const int*, const int*, + const float*, const float*, const int*, const int*, const int*, + const float*, const int*, const int*, const int*, cons= t int*, + const float*, float*, const int*, const int*, const int*, cons= t int* + ); + + // Double + void pdgemv_(const char*, const int*, const int*, + const double*, const double*, const int*, const int*, const int*, + const double*, const int*, const int*, const int*, co= nst int*, + const double*, double*, const int*, const int*, const int*, co= nst int* + ); + =20 #ifdef __cplusplus } diff --git a/btl/libs/PBLAS/pblas_interface_impl.hh b/btl/libs/PBLAS/pbla= s_interface_impl.hh index 14b27df..b534a4e 100644 --- a/btl/libs/PBLAS/pblas_interface_impl.hh +++ b/btl/libs/PBLAS/pblas_interface_impl.hh @@ -10,6 +10,19 @@ public: return MAKE_STRING(PBLASNAME); } =20 + static inline void parallel_axpy(const SCALAR& coef, + gene_vector& x, int *descX, + gene_vector& y, int *descY, + const int& size + ) + { + int iZERO =3D 0, iONE =3D 1; + PBLAS_FUNC(axpy)(&size, &coef, + x, &iONE, &iONE, descX, &iONE, + y, &iONE, &iONE, descY, &iONE + ); + } + static inline void parallel_matrix_vector_product( int GlobalRows, int GlobalCols, gene_matrix& A, int *descA, diff --git a/btl/libs/STL/STL_interface.hh b/btl/libs/STL/STL_interface.h= h index 93e76bd..060cb69 100644 --- a/btl/libs/STL/STL_interface.hh +++ b/btl/libs/STL/STL_interface.hh @@ -133,6 +133,17 @@ public : } } =20 + static inline void matrix_vector_product(gene_vector& A, gene_vector &= B, gene_vector & X, int N) + { + real somme; + for (int i=3D0;i