public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/auto-numerical-bench:newinterfaces commit in: btl/actions/, btl/actions/BLAS/, btl/NumericInterface/NI_internal/, samples/, ...
@ 2012-10-07 21:36 Andrea Arteaga
  0 siblings, 0 replies; only message in thread
From: Andrea Arteaga @ 2012-10-07 21:36 UTC (permalink / raw
  To: gentoo-commits

commit:     9dddb5af4eb913b6b607a773508f9ebb62c28c46
Author:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
AuthorDate: Sun Oct  7 21:36:29 2012 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Sun Oct  7 21:36:29 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=9dddb5af

Placed BLAS action under subfolder. Written first LAPACK action. Updated
samples for blas and cblas.

---
 .../NI_internal/FortranDeclarations.hpp            |   14 ++++++
 .../NI_internal/FortranInterface.hpp               |   12 +++++
 btl/actions/{ => BLAS}/action_MatrixMatrix.hpp     |    0
 btl/actions/{ => BLAS}/action_MatrixTMatrix.hpp    |    0
 btl/actions/{ => BLAS}/action_MatrixTVector.hpp    |    0
 btl/actions/{ => BLAS}/action_MatrixVector.hpp     |    0
 btl/actions/{ => BLAS}/action_Rank1Update.hpp      |    0
 btl/actions/{ => BLAS}/action_Rank2Update.hpp      |    0
 btl/actions/{ => BLAS}/action_SymMatrixVector.hpp  |    0
 btl/actions/{ => BLAS}/action_TriMatrixMatrix.hpp  |    0
 btl/actions/{ => BLAS}/action_TriSolveMatrix.hpp   |    0
 btl/actions/{ => BLAS}/action_TriSolveVector.hpp   |    0
 btl/actions/{ => BLAS}/action_axpy.hpp             |    0
 btl/actions/{ => BLAS}/action_rot.hpp              |    0
 .../GeneralSolve.hpp}                              |   43 ++++++++++----------
 btl/actions/actionsBLAS.hpp                        |   41 +++++++++++++-----
 samples/blastests.xml                              |   33 +++------------
 samples/cblastests.xml                             |   12 +++---
 18 files changed, 88 insertions(+), 67 deletions(-)

diff --git a/btl/NumericInterface/NI_internal/FortranDeclarations.hpp b/btl/NumericInterface/NI_internal/FortranDeclarations.hpp
index 35bce39..2378cf2 100644
--- a/btl/NumericInterface/NI_internal/FortranDeclarations.hpp
+++ b/btl/NumericInterface/NI_internal/FortranDeclarations.hpp
@@ -79,6 +79,20 @@ extern "C" {
     void strsm_(const char*, const char*, const char*, const char*, const int*, const int*, const float*, const float*, const int*, float*, const int*);
     void dtrsm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*, const double*, const int*, double*, const int*);
 
+
+
+
+    /******************
+     * LAPACK SOLVERS *
+     ******************/
+
+    void sgesv(const int&, const int&, float*, const int&, int*, float*, const int&, int&);
+    void dgesv(const int&, const int&, double*, const int&, int*, double*, const int&, int&);
+
+
+
+    FORTFUNC(gesv)(&N, &ONE, A, &N, ipiv, b, &N, &info);
+
 }
 
 

diff --git a/btl/NumericInterface/NI_internal/FortranInterface.hpp b/btl/NumericInterface/NI_internal/FortranInterface.hpp
index eea5898..2073e80 100644
--- a/btl/NumericInterface/NI_internal/FortranInterface.hpp
+++ b/btl/NumericInterface/NI_internal/FortranInterface.hpp
@@ -161,6 +161,18 @@ public:
     {
         FORTFUNC(trsm)("L", &uplo, "N", "N", &M, &N, &fONE, A, &M, B, &M);
     }
+
+
+
+    /******************
+     * LAPACK SOLVERS *
+     ******************/
+
+    static void GeneralSolve(const int& N, Scalar *A, Scalar *b, int *ipiv)
+    {
+        int info;
+        FORTFUNC(gesv)(&N, &ONE, A, &N, ipiv, b, &N, &info);
+    }
 };
 
 const int NumericInterface<NI_SCALAR>::ZERO = 0;

diff --git a/btl/actions/action_MatrixMatrix.hpp b/btl/actions/BLAS/action_MatrixMatrix.hpp
similarity index 100%
rename from btl/actions/action_MatrixMatrix.hpp
rename to btl/actions/BLAS/action_MatrixMatrix.hpp

diff --git a/btl/actions/action_MatrixTMatrix.hpp b/btl/actions/BLAS/action_MatrixTMatrix.hpp
similarity index 100%
rename from btl/actions/action_MatrixTMatrix.hpp
rename to btl/actions/BLAS/action_MatrixTMatrix.hpp

diff --git a/btl/actions/action_MatrixTVector.hpp b/btl/actions/BLAS/action_MatrixTVector.hpp
similarity index 100%
rename from btl/actions/action_MatrixTVector.hpp
rename to btl/actions/BLAS/action_MatrixTVector.hpp

diff --git a/btl/actions/action_MatrixVector.hpp b/btl/actions/BLAS/action_MatrixVector.hpp
similarity index 100%
rename from btl/actions/action_MatrixVector.hpp
rename to btl/actions/BLAS/action_MatrixVector.hpp

diff --git a/btl/actions/action_Rank1Update.hpp b/btl/actions/BLAS/action_Rank1Update.hpp
similarity index 100%
rename from btl/actions/action_Rank1Update.hpp
rename to btl/actions/BLAS/action_Rank1Update.hpp

diff --git a/btl/actions/action_Rank2Update.hpp b/btl/actions/BLAS/action_Rank2Update.hpp
similarity index 100%
rename from btl/actions/action_Rank2Update.hpp
rename to btl/actions/BLAS/action_Rank2Update.hpp

diff --git a/btl/actions/action_SymMatrixVector.hpp b/btl/actions/BLAS/action_SymMatrixVector.hpp
similarity index 100%
rename from btl/actions/action_SymMatrixVector.hpp
rename to btl/actions/BLAS/action_SymMatrixVector.hpp

diff --git a/btl/actions/action_TriMatrixMatrix.hpp b/btl/actions/BLAS/action_TriMatrixMatrix.hpp
similarity index 100%
rename from btl/actions/action_TriMatrixMatrix.hpp
rename to btl/actions/BLAS/action_TriMatrixMatrix.hpp

diff --git a/btl/actions/action_TriSolveMatrix.hpp b/btl/actions/BLAS/action_TriSolveMatrix.hpp
similarity index 100%
rename from btl/actions/action_TriSolveMatrix.hpp
rename to btl/actions/BLAS/action_TriSolveMatrix.hpp

diff --git a/btl/actions/action_TriSolveVector.hpp b/btl/actions/BLAS/action_TriSolveVector.hpp
similarity index 100%
copy from btl/actions/action_TriSolveVector.hpp
copy to btl/actions/BLAS/action_TriSolveVector.hpp

diff --git a/btl/actions/action_axpy.hpp b/btl/actions/BLAS/action_axpy.hpp
similarity index 100%
rename from btl/actions/action_axpy.hpp
rename to btl/actions/BLAS/action_axpy.hpp

diff --git a/btl/actions/action_rot.hpp b/btl/actions/BLAS/action_rot.hpp
similarity index 100%
rename from btl/actions/action_rot.hpp
rename to btl/actions/BLAS/action_rot.hpp

diff --git a/btl/actions/action_TriSolveVector.hpp b/btl/actions/LAPACK/GeneralSolve.hpp
similarity index 62%
rename from btl/actions/action_TriSolveVector.hpp
rename to btl/actions/LAPACK/GeneralSolve.hpp
index 6cac6f1..7fb98ba 100644
--- a/btl/actions/action_TriSolveVector.hpp
+++ b/btl/actions/LAPACK/GeneralSolve.hpp
@@ -15,71 +15,70 @@
 // 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_TRISOLVEVECTOR
-#define ACTION_TRISOLVEVECTOR
+#ifndef ACTION_GENERALSOLVE
+#define ACTION_GENERALSOLVE
 
 #include "LinearCongruential.hpp"
 #include <vector>
 #include <algorithm>
 
 template<class Interface>
-class Action_TriSolveVector {
+class Action_GeneralSolve {
 
     typedef typename Interface::Scalar Scalar;
     typedef std::vector<Scalar> vector_t;
 
 private:
     // Invalidate copy constructor
-    Action_TriSolveVector(const Action_TriSolveVector&);
+    Action_GeneralSolve(const Action_GeneralSolve&);
 
 public:
 
     // Constructor
-    Action_TriSolveVector(int size)
+    Action_GeneralSolve(int size)
     : _size(size), lc(10),
       A(lc.fillVector<Scalar>(size*size)), b(lc.fillVector<Scalar>(size)),
-      x_work(size)
+      A_work(size*size), x_work(size), b_res(size), ipiv(size)
     {
-        MESSAGE("Action_TriSolveVector Constructor");
-
-        // Adding size to the diagonal of A to ensure it is invertible
-        for (int i = 0; i < size; ++i)
-            A[i+size*i] += size;
+        MESSAGE("Action_GeneralSolve Constructor");
     }
 
     // Action name
     static std::string name()
     {
-        return "TriSolveVector_" + Interface::name();
+        return "GeneralSolve_" + Interface::name();
     }
 
     double fpo() {
-        return double(_size)*double(_size) - 2*double(_size);
+        return double(_size)*double(_size)*double(_size);
     }
 
     inline void initialize(){
-          std::copy(b.begin(), b.end(), x_work.begin());
+        std::copy(A.begin(), A.end(), A_work.begin());
+        std::copy(b.begin(), b.end(), x_work.begin());
     }
 
     inline void calculate() {
-        Interface::TriSolveVector('U', _size, &A[0], &x_work[0]);
+        Interface::GeneralSolve(_size, &A_work[0], &x_work[0], &ipiv[0]);
     }
 
     Scalar getResidual() {
         initialize();
         calculate();
-        Interface::TriMatrixVector('U', _size, &A[0], &x_work[0]);
-        Interface::axpy(_size, -1., &b[0], &x_work[0]);
-        return Interface::norm(_size, &x_work[0]);
+        std::copy(b.begin(), b.end(), b_res.begin());
+        Interface::MatrixVector(false, _size, _size, -1., &A[0], &x_work[0],
+                                1., &b_res[0]);
+        return Interface::norm(_size, &b_res[0]);
     }
 
-//private:
+private:
     const int _size;
     LinearCongruential<> lc;
 
-    vector_t A, b;
-    vector_t x_work;
+    const vector_t A, b;
+    vector_t A_work, x_work, b_res;
+    std::vector<int> ipiv;
 
 };
 
-#endif // ACTION_TRISOLVEVECTOR
+#endif // ACTION_GENERALSOLVE

diff --git a/btl/actions/actionsBLAS.hpp b/btl/actions/actionsBLAS.hpp
index 1ac4b12..9d8aed8 100644
--- a/btl/actions/actionsBLAS.hpp
+++ b/btl/actions/actionsBLAS.hpp
@@ -1,14 +1,31 @@
-#include "action_axpy.hpp"
-#include "action_rot.hpp"
+//=====================================================
+// Copyright (C) 2012 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// 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.
+//
+#include "BLAS/action_axpy.hpp"
+#include "BLAS/action_rot.hpp"
 
-#include "action_MatrixVector.hpp"
-#include "action_MatrixTVector.hpp"
-#include "action_SymMatrixVector.hpp"
-#include "action_TriSolveVector.hpp"
-#include "action_Rank1Update.hpp"
-#include "action_Rank2Update.hpp"
+#include "BLAS/action_MatrixVector.hpp"
+#include "BLAS/action_MatrixTVector.hpp"
+#include "BLAS/action_SymMatrixVector.hpp"
+#include "BLAS/action_TriSolveVector.hpp"
+#include "BLAS/action_Rank1Update.hpp"
+#include "BLAS/action_Rank2Update.hpp"
 
-#include "action_MatrixMatrix.hpp"
-#include "action_MatrixTMatrix.hpp"
-#include "action_TriMatrixMatrix.hpp"
-#include "action_TriSolveMatrix.hpp"
+#include "BLAS/action_MatrixMatrix.hpp"
+#include "BLAS/action_MatrixTMatrix.hpp"
+#include "BLAS/action_TriMatrixMatrix.hpp"
+#include "BLAS/action_TriSolveMatrix.hpp"

diff --git a/samples/blastests.xml b/samples/blastests.xml
index c9f45c2..fba38f2 100644
--- a/samples/blastests.xml
+++ b/samples/blastests.xml
@@ -1,44 +1,23 @@
 <numbench>
 
-    <operations module="blas">axpy matrix_vector matrix_matrix aat</operations>
+    <operations module="blas">axpy MatrixVector MatrixTVector MatrixMatrix MatrixTMatrix TriSolveVector TriSolveMatrix</operations>
 
     <testcases>
 
-        <case id="reference">
+        <case id="reference-Os">
             <pkg>sci-libs/blas-reference-20120423</pkg>
             <emergeenv>
-                <var name="FFLAGS">-O3</var>
+                <var name="FFLAGS">-Os</var>
             </emergeenv>
         </case>
 
-        <case id="atlas">
-            <pkg>sci-libs/atlas-3.10.0</pkg>
-            <emergeenv>
-                <var name="USE">threads</var>
-            </emergeenv>
-        </case>
-
-        <case id="eigen">
-            <pkg>dev-cpp/eigen-3.1.1-r1</pkg>
-            <emergeenv>
-                <var name="CXXFLAGS">-O3</var>
-            </emergeenv>
-        </case>
-
-        <case id="openblas">
-            <pkg>sci-libs/openblas-0.2.3</pkg>
+        <case id="reference-Ofast">
+            <pkg>sci-libs/blas-reference-20120423</pkg>
             <emergeenv>
-                <var name="FFLAGS">-O3</var>
-                <var name="CFLAGS">-O3</var>
-                <var name="USE">-openmp threads</var>
+                <var name="FFLAGS">-Ofast</var>
             </emergeenv>
         </case>
 
-        <case id="mkl">
-            <pkg>sci-libs/mkl-10.3.7.256</pkg>
-            <skip>mkl32*</skip>
-        </case>
-
     </testcases>
 
 </numbench>

diff --git a/samples/cblastests.xml b/samples/cblastests.xml
index 9a08eef..00c6644 100644
--- a/samples/cblastests.xml
+++ b/samples/cblastests.xml
@@ -1,13 +1,13 @@
 <numbench>
 
-    <operations module="cblas">axpy matrix_vector matrix_matrix aat</operations>
+    <operations module="cblas">axpy MatrixVector MatrixTVector MatrixMatrix MatrixTMatrix TriSolveVector TriSolveMatrix</operations>
 
     <testcases>
 
         <case id="reference">
             <pkg>sci-libs/cblas-reference-20110218</pkg>
             <emergeenv>
-                <var name="FFLAGS">-O3</var>
+                <var name="FFLAGS">-Ofast</var>
             </emergeenv>
         </case>
 
@@ -18,22 +18,22 @@
             </emergeenv>
         </case>
 
-        <case id="openblas1">
+        <case id="openblas">
             <pkg>sci-libs/openblas-0.2.3</pkg>
             <emergeenv>
                 <var name="FFLAGS">-O3</var>
                 <var name="CFLAGS">-O3</var>
                 <var name="USE">incblas</var>
             </emergeenv>
-            <runenv>
-                <var name="OPENBLAS_NUM_THREADS">1</var>
-            </runenv>
         </case>
 
         <case id="mkl">
             <pkg>sci-libs/mkl-10.3.7.256</pkg>
             <skip>mkl32*</skip>
             <skip>*int64*</skip>
+            <skip>mkl64-dynamic</skip>
+            <skip>mkl64-gfortran</skip>
+            <skip>mkl64-intel</skip>
         </case>
 
     </testcases>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-07 21:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-07 21:36 [gentoo-commits] proj/auto-numerical-bench:newinterfaces commit in: btl/actions/, btl/actions/BLAS/, btl/NumericInterface/NI_internal/, samples/, Andrea Arteaga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox