Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63509 - in sandbox/numeric_bindings: boost/numeric/bindings/lapack/computational libs/numeric/bindings/tools
From: thomas.klimpel_at_[hidden]
Date: 2010-07-02 14:55:55


Author: klimpel
Date: 2010-07-01 18:52:39 EDT (Thu, 01 Jul 2010)
New Revision: 63509
URL: http://svn.boost.org/trac/boost/changeset/63509

Log:
improve detection of optimal workspace queries
Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hetrf.hpp | 10 ++++++++--
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp | 26 ++++++++++++++++++++++++--
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 10 ++++++----
   3 files changed, 38 insertions(+), 8 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hetrf.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hetrf.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hetrf.hpp 2010-07-01 18:52:39 EDT (Thu, 01 Jul 2010)
@@ -23,6 +23,7 @@
 #include <boost/numeric/bindings/remove_imaginary.hpp>
 #include <boost/numeric/bindings/size.hpp>
 #include <boost/numeric/bindings/stride.hpp>
+#include <boost/numeric/bindings/traits/detail/utils.hpp>
 #include <boost/numeric/bindings/uplo_tag.hpp>
 #include <boost/numeric/bindings/value_type.hpp>
 #include <boost/static_assert.hpp>
@@ -101,7 +102,6 @@
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixA >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixA >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_mutable< VectorIPIV >::value) );
- BOOST_ASSERT( bindings::size(work.select(value_type())) >= 1 );
         BOOST_ASSERT( bindings::size(work.select(value_type())) >=
                 min_size_work());
         BOOST_ASSERT( bindings::size_column(a) >= 0 );
@@ -144,7 +144,13 @@
             optimal_workspace ) {
         namespace bindings = ::boost::numeric::bindings;
         typedef typename result_of::uplo_tag< MatrixA >::type uplo;
- return invoke( a, ipiv, minimal_workspace() );
+ value_type opt_size_work;
+ detail::hetrf( uplo(), bindings::size_column(a),
+ bindings::begin_value(a), bindings::stride_major(a),
+ bindings::begin_value(ipiv), &opt_size_work, -1 );
+ bindings::detail::array< value_type > tmp_work(
+ traits::detail::to_int( opt_size_work ) );
+ return invoke( a, ipiv, workspace( tmp_work ) );
     }
 
     //

Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp 2010-07-01 18:52:39 EDT (Thu, 01 Jul 2010)
@@ -25,6 +25,7 @@
 #include <boost/numeric/bindings/remove_imaginary.hpp>
 #include <boost/numeric/bindings/size.hpp>
 #include <boost/numeric/bindings/stride.hpp>
+#include <boost/numeric/bindings/traits/detail/utils.hpp>
 #include <boost/numeric/bindings/value_type.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/type_traits/is_same.hpp>
@@ -165,10 +166,13 @@
         BOOST_ASSERT( bindings::size(work.select(real_type())) >=
                 min_size_work( bindings::size_column(h) ));
         BOOST_ASSERT( bindings::size(wr) >= bindings::size_column(h) );
+ BOOST_ASSERT( bindings::size_column(h) >= 0 );
         BOOST_ASSERT( bindings::size_minor(h) == 1 ||
                 bindings::stride_minor(h) == 1 );
         BOOST_ASSERT( bindings::size_minor(z) == 1 ||
                 bindings::stride_minor(z) == 1 );
+ BOOST_ASSERT( bindings::stride_major(h) >= std::max< std::ptrdiff_t >(1,
+ bindings::size_column(h)) );
         BOOST_ASSERT( compz == 'N' || compz == 'I' || compz == 'V' );
         BOOST_ASSERT( job == 'E' || job == 'S' );
         return detail::hseqr( job, compz, bindings::size_column(h), ilo, ihi,
@@ -213,8 +217,16 @@
             MatrixH& h, VectorWR& wr, VectorWI& wi, MatrixZ& z,
             optimal_workspace ) {
         namespace bindings = ::boost::numeric::bindings;
+ real_type opt_size_work;
+ detail::hseqr( job, compz, bindings::size_column(h), ilo, ihi,
+ bindings::begin_value(h), bindings::stride_major(h),
+ bindings::begin_value(wr), bindings::begin_value(wi),
+ bindings::begin_value(z), bindings::stride_major(z),
+ &opt_size_work, -1 );
+ bindings::detail::array< real_type > tmp_work(
+ traits::detail::to_int( opt_size_work ) );
         return invoke( job, compz, ilo, ihi, h, wr, wi, z,
- minimal_workspace() );
+ workspace( tmp_work ) );
     }
 
     //
@@ -262,10 +274,13 @@
         BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixZ >::value) );
         BOOST_ASSERT( bindings::size(work.select(value_type())) >=
                 min_size_work( bindings::size_column(h) ));
+ BOOST_ASSERT( bindings::size_column(h) >= 0 );
         BOOST_ASSERT( bindings::size_minor(h) == 1 ||
                 bindings::stride_minor(h) == 1 );
         BOOST_ASSERT( bindings::size_minor(z) == 1 ||
                 bindings::stride_minor(z) == 1 );
+ BOOST_ASSERT( bindings::stride_major(h) >= std::max< std::ptrdiff_t >(1,
+ bindings::size_column(h)) );
         BOOST_ASSERT( compz == 'N' || compz == 'I' || compz == 'V' );
         BOOST_ASSERT( job == 'E' || job == 'S' );
         return detail::hseqr( job, compz, bindings::size_column(h), ilo, ihi,
@@ -305,7 +320,14 @@
             const fortran_int_t ilo, const fortran_int_t ihi,
             MatrixH& h, VectorW& w, MatrixZ& z, optimal_workspace ) {
         namespace bindings = ::boost::numeric::bindings;
- return invoke( job, compz, ilo, ihi, h, w, z, minimal_workspace() );
+ value_type opt_size_work;
+ detail::hseqr( job, compz, bindings::size_column(h), ilo, ihi,
+ bindings::begin_value(h), bindings::stride_major(h),
+ bindings::begin_value(w), bindings::begin_value(z),
+ bindings::stride_major(z), &opt_size_work, -1 );
+ bindings::detail::array< value_type > tmp_work(
+ traits::detail::to_int( opt_size_work ) );
+ return invoke( job, compz, ilo, ihi, h, w, z, workspace( tmp_work ) );
     }
 
     //

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py 2010-07-01 18:52:39 EDT (Thu, 01 Jul 2010)
@@ -373,7 +373,7 @@
     return None
   if type( arg ) == StringType:
     if re.compile( '^[A-Z]+$' ).match( arg ) == None:
- return [ None ]
+ return []
     else:
       return [ arg.upper() ]
   
@@ -384,7 +384,7 @@
   if re.compile( '^[A-Z]+$' ).match( arg[0] ) == None:
     for a in arg[1]:
       sub_result = nested_list_args( a )
- if sub_result != [ None ] and sub_result != None:
+ if sub_result != [] and sub_result != None:
         for r in sub_result:
           if r not in result:
             result.append( r )
@@ -788,7 +788,7 @@
 #
 def match_assert_ge( argument_map, text_field ):
   #print "Match assert GE..."
- match_it = re.compile( ' +[A-Z]+[ ]{0,3}(>=|must be at least)[ ]{0,3}((min|max|MIN|MAX|[0-9A-Z]| ?[\(\)\,\+\*\-] ?)+)' ).findall( text_field )
+ match_it = re.compile( ' +[A-Z]+[ ]{0,3}(>=|\.GE\.|must be at least)[ ]{0,3}((min|max|MIN|MAX|[0-9A-Z]| ?[\(\)\,\+\*\-] ?)+)' ).findall( text_field )
   if len( match_it ) == 1 or \
      (len( match_it ) == 2 and re.compile( 'For (optimum|optimal|best) (performance|efficiency)' ).search( text_field ) != None):
     print "Match assert GE:", match_it
@@ -1410,7 +1410,7 @@
       # And, try to detect for which work arrays the query will run.
       # Keep the same order of workspace names as used in the grouped arguments map
       if 'WORK' in argument_name:
- match_query = re.compile( 'If ' + argument_name + ' \= \-1(\,|then|a|workspace|\s)+query', re.M ).search( comment_block )
+ match_query = re.compile( 'If ' + argument_name + ' \= \-1(\,|then|'+subroutine_name+'|does|a|workspace|\s)+query', re.M ).search( comment_block )
         if match_query != None:
           work_query_block = comment_block[ match_query.start(0): ]
           any_workspace = "(" + "|".join( grouped_arguments[ 'by_io' ][ 'workspace' ] ) + ")"
@@ -1435,6 +1435,8 @@
               else:
                  print "Not relying on backend to return minimum size of " + name + " with a " + \
                        "workspace query."
+ if argument_name[0] == 'L' and 'where NB is the block size returned by ILAENV' in comment_block:
+ argument_properties[ 'workspace_query_for' ] = [ argument_name[1:] ]
 
     #
     # Handle CHARACTER comment blocks.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk